r23363 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23362‎ | r23363 | r23364 >
Date:06:16, 25 June 2007
Author:robchurch
Status:old
Tags:
Comment:
* Port Special:LongPages, adding $wgLongPagesThreshold as a complement to "shortie"
* Port Special:DeadEndPages
Modified paths:
  • /branches/robchurch/reports/includes/AutoLoader.php (modified) (history)
  • /branches/robchurch/reports/includes/DefaultSettings.php (modified) (history)
  • /branches/robchurch/reports/includes/QueryPage.php (modified) (history)
  • /branches/robchurch/reports/includes/SpecialDeadendpages.php (deleted) (history)
  • /branches/robchurch/reports/includes/SpecialLongpages.php (deleted) (history)
  • /branches/robchurch/reports/includes/SpecialPage.php (modified) (history)
  • /branches/robchurch/reports/includes/reports/DeadEndPagesReport.php (added) (history)
  • /branches/robchurch/reports/includes/reports/LongPagesReport.php (added) (history)
  • /branches/robchurch/reports/includes/reports/Report.php (modified) (history)
  • /branches/robchurch/reports/languages/messages/MessagesEn.php (modified) (history)
  • /branches/robchurch/reports/maintenance/language/messageTypes.inc (modified) (history)
  • /branches/robchurch/reports/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: branches/robchurch/reports/maintenance/language/messages.inc
@@ -988,10 +988,9 @@
989989 'randompage-nopages',
990990 'randompage-url',
991991 'longpages',
992 - 'longpages-summary',
 992+ 'longpages-header',
993993 'deadendpages',
994 - 'deadendpages-summary',
995 - 'deadendpagestext',
 994+ 'deadendpages-header',
996995 'protectedpages',
997996 'protectedpages-summary',
998997 'protectedpagestext',
Index: branches/robchurch/reports/maintenance/language/messageTypes.inc
@@ -114,7 +114,6 @@
115115 'booksources-summary',
116116 'ipblocklist-summary',
117117 'listusers-summary',
118 - 'longpages-summary',
119118 'preferences-summary',
120119 'specialpages-summary',
121120 'whatlinkshere-summary',
@@ -133,7 +132,6 @@
134133 'ancientpages-summary',
135134 'newimages-summary',
136135 'userrights-summary',
137 - 'deadendpages-summary',
138136 'protectedpages-summary',
139137 'disambiguations-summary',
140138 'lonelypages-summary',
Index: branches/robchurch/reports/includes/SpecialLongpages.php
@@ -1,33 +0,0 @@
2 -<?php
3 -/**
4 - *
5 - * @addtogroup SpecialPage
6 - */
7 -
8 -/**
9 - *
10 - * @addtogroup SpecialPage
11 - */
12 -class LongPagesPage extends ShortPagesPage {
13 -
14 - function getName() {
15 - return "Longpages";
16 - }
17 -
18 - function sortDescending() {
19 - return true;
20 - }
21 -}
22 -
23 -/**
24 - * constructor
25 - */
26 -function wfSpecialLongpages() {
27 - list( $limit, $offset ) = wfCheckLimits();
28 -
29 - $lpp = new LongPagesPage();
30 -
31 - $lpp->doQuery( $offset, $limit );
32 -}
33 -
34 -?>
Index: branches/robchurch/reports/includes/SpecialDeadendpages.php
@@ -1,65 +0,0 @@
2 -<?php
3 -/**
4 - *
5 - * @addtogroup SpecialPage
6 - */
7 -
8 -/**
9 - *
10 - * @addtogroup SpecialPage
11 - */
12 -class DeadendPagesPage extends PageQueryPage {
13 -
14 - function getName( ) {
15 - return "Deadendpages";
16 - }
17 -
18 - function getPageHeader() {
19 - return wfMsgExt( 'deadendpagestext', array( 'parse' ) );
20 - }
21 -
22 - /**
23 - * LEFT JOIN is expensive
24 - *
25 - * @return true
26 - */
27 - function isExpensive( ) {
28 - return 1;
29 - }
30 -
31 - function isSyndicated() { return false; }
32 -
33 - /**
34 - * @return false
35 - */
36 - function sortDescending() {
37 - return false;
38 - }
39 -
40 - /**
41 - * @return string an sqlquery
42 - */
43 - function getSQL() {
44 - $dbr = wfGetDB( DB_SLAVE );
45 - list( $page, $pagelinks ) = $dbr->tableNamesN( 'page', 'pagelinks' );
46 - return "SELECT 'Deadendpages' as type, page_namespace AS namespace, page_title as title, page_title AS value " .
47 - "FROM $page LEFT JOIN $pagelinks ON page_id = pl_from " .
48 - "WHERE pl_from IS NULL " .
49 - "AND page_namespace = 0 " .
50 - "AND page_is_redirect = 0";
51 - }
52 -}
53 -
54 -/**
55 - * Constructor
56 - */
57 -function wfSpecialDeadendpages() {
58 -
59 - list( $limit, $offset ) = wfCheckLimits();
60 -
61 - $depp = new DeadendPagesPage();
62 -
63 - return $depp->doQuery( $offset, $limit );
64 -}
65 -
66 -?>
Index: branches/robchurch/reports/includes/reports/LongPagesReport.php
@@ -0,0 +1,141 @@
 2+<?php
 3+
 4+/**
 5+ * Report generates a list of long content pages
 6+ *
 7+ * @addtogroup Reports
 8+ * @author Rob Church <robchur@gmail.com>
 9+ */
 10+class LongPagesReport extends Report {
 11+
 12+ /**
 13+ * Constructor
 14+ */
 15+ public function __construct() {
 16+ parent::__construct();
 17+ }
 18+
 19+ /**
 20+ * Get the name of the report
 21+ *
 22+ * @return string
 23+ */
 24+ public function getName() {
 25+ return 'Longpages';
 26+ }
 27+
 28+ /**
 29+ * Get a HTML header for the top of the page
 30+ *
 31+ * @return string
 32+ */
 33+ public function getHeader() {
 34+ global $wgUser, $wgLongPagesThreshold;
 35+ return wfMsgExt( 'longpages-header', 'parse',
 36+ $wgUser->getSkin()->formatSize( $wgLongPagesThreshold ) );
 37+ }
 38+
 39+ /**
 40+ * Is it appropriate to allow filtering redirects?
 41+ *
 42+ * @return bool
 43+ */
 44+ public function allowRedirectFilter() {
 45+ return false;
 46+ }
 47+
 48+ /**
 49+ * Should redirects be filtered from results?
 50+ *
 51+ * @return bool
 52+ */
 53+ public function excludeRedirects() {
 54+ return true;
 55+ }
 56+
 57+ /**
 58+ * Is it appropriate to allow filtering namespaces?
 59+ *
 60+ * @return bool
 61+ */
 62+ public function allowNamespaceFilter() {
 63+ return true;
 64+ }
 65+
 66+ /**
 67+ * Get a list of namespaces this report can be run
 68+ * against - false indicates *all* namespaces
 69+ *
 70+ * @return mixed
 71+ */
 72+ public function getApplicableNamespaces() {
 73+ return array(
 74+ NS_MAIN,
 75+ ) + $GLOBALS['wgContentNamespaces'];
 76+ }
 77+
 78+ /**
 79+ * Return base SQL for the report
 80+ *
 81+ * @param Database $dbr Database object being queried
 82+ * @return string
 83+ */
 84+ public function getBaseSql( $dbr ) {
 85+ $page = $dbr->tableName( 'page' );
 86+ # Even with the improved index, MySQL still has to be
 87+ # forced to use it...
 88+ $index = $dbr->useIndexClause( 'page_len' );
 89+ return
 90+ "SELECT
 91+ page_id AS rp_id,
 92+ page_namespace AS rp_namespace,
 93+ page_title AS rp_title,
 94+ page_is_redirect AS rp_redirect,
 95+ page_len
 96+ FROM {$page} {$index}";
 97+ }
 98+
 99+ /**
 100+ * Return additional WHERE clauses and other conditions
 101+ * to which the paging clauses will be appened when
 102+ * the report runs live
 103+ *
 104+ * @param Database $dbr Database object being queried
 105+ * @return array
 106+ */
 107+ public function getExtraConditions( $dbr ) {
 108+ return array(
 109+ 'page_len > ' . intval( $GLOBALS['wgLongPagesThreshold'] )
 110+ );
 111+ }
 112+
 113+ /**
 114+ * Given a result object, extract additional parameters
 115+ * as a dictionary for later use
 116+ *
 117+ * @param object $row Result row
 118+ * @return array
 119+ */
 120+ public function extractParameters( $row ) {
 121+ return array(
 122+ 'page_len' => $row->page_len,
 123+ );
 124+ }
 125+
 126+ /**
 127+ * Format an individual result row
 128+ *
 129+ * @param Title $title Result title
 130+ * @param object $row Result row
 131+ * @param array $params Result parameters
 132+ * @param Skin $skin User skin
 133+ * @return string
 134+ */
 135+ public function formatRow( $title, $row, $params, $skin ) {
 136+ return '<li>' . $skin->makeLinkObj( $title ) . ' [' . $skin->formatSize( $params['page_len'] )
 137+ . "]</li>\n";
 138+ }
 139+
 140+}
 141+
 142+?>
\ No newline at end of file
Property changes on: branches/robchurch/reports/includes/reports/LongPagesReport.php
___________________________________________________________________
Added: svn:eol-style
1143 + native
Index: branches/robchurch/reports/includes/reports/Report.php
@@ -362,7 +362,9 @@
363363 public static function getReports() {
364364 return array(
365365 'BrokenRedirectsReport',
 366+ 'DeadEndPagesReport',
366367 'DoubleRedirectsReport',
 368+ 'LongPagesReport',
367369 'PopularPagesReport',
368370 'RedirectReport',
369371 'ShortPagesReport',
Index: branches/robchurch/reports/includes/reports/DeadEndPagesReport.php
@@ -0,0 +1,115 @@
 2+<?php
 3+
 4+/**
 5+ * Report generates a list of pages with no outgoing links
 6+ *
 7+ * @addtogroup Reports
 8+ * @author Rob Church <robchur@gmail.com>
 9+ */
 10+class DeadEndPagesReport extends Report {
 11+
 12+ /**
 13+ * Constructor
 14+ */
 15+ public function __construct() {
 16+ parent::__construct();
 17+ }
 18+
 19+ /**
 20+ * Get the name of the report
 21+ *
 22+ * @return string
 23+ */
 24+ public function getName() {
 25+ return 'Deadendpages';
 26+ }
 27+
 28+ /**
 29+ * Is it appropriate to allow filtering redirects?
 30+ *
 31+ * @return bool
 32+ */
 33+ public function allowRedirectFilter() {
 34+ return false;
 35+ }
 36+
 37+ /**
 38+ * Exclude redirects?
 39+ *
 40+ * @return bool
 41+ */
 42+ public function excludeRedirects() {
 43+ return true;
 44+ }
 45+
 46+ /**
 47+ * Get a list of namespaces this report can be run
 48+ * against - false indicates *all* namespaces
 49+ *
 50+ * @return mixed
 51+ */
 52+ public function getApplicableNamespaces() {
 53+ return array(
 54+ NS_MAIN,
 55+ ) + $GLOBALS['wgContentNamespaces'];
 56+ }
 57+
 58+ /**
 59+ * Return base SQL for the report
 60+ *
 61+ * @param Database $dbr Database object being queried
 62+ * @return string
 63+ */
 64+ public function getBaseSql( $dbr ) {
 65+ list( $page, $pagelinks ) = $dbr->tableNamesN( 'page', 'pagelinks' );
 66+ return
 67+ "SELECT
 68+ page_id AS rp_id,
 69+ page_namespace AS rp_namespace,
 70+ page_title AS rp_title,
 71+ page_is_redirect AS rp_redirect
 72+ FROM {$page}
 73+ LEFT JOIN {$pagelinks} ON page_id = pl_from";
 74+ }
 75+
 76+ /**
 77+ * Return additional WHERE clauses and other conditions
 78+ * to which the paging clauses will be appened when
 79+ * the report runs live
 80+ *
 81+ * @param Database $dbr Database object being queried
 82+ * @return array
 83+ */
 84+ public function getExtraConditions( $dbr ) {
 85+ return array(
 86+ 'pl_title IS NULL',
 87+ );
 88+ }
 89+
 90+ /**
 91+ * Given a result object, extract additional parameters
 92+ * as a dictionary for later use
 93+ *
 94+ * @param object $row Result row
 95+ * @return array
 96+ */
 97+ public function extractParameters( $row ) {
 98+ return array();
 99+ }
 100+
 101+ /**
 102+ * Format an individual result row
 103+ *
 104+ * @param Title $title Result title
 105+ * @param object $row Result row
 106+ * @param array $params Result parameters
 107+ * @param Skin $skin User skin
 108+ * @return string
 109+ */
 110+ public function formatRow( $title, $row, $params, $skin ) {
 111+ return "<li>" . $skin->makeLinkObj( $title ) . "</li>\n";
 112+ }
 113+
 114+}
 115+
 116+?>
\ No newline at end of file
Property changes on: branches/robchurch/reports/includes/reports/DeadEndPagesReport.php
___________________________________________________________________
Added: svn:eol-style
1117 + native
Index: branches/robchurch/reports/includes/AutoLoader.php
@@ -172,7 +172,6 @@
173173 'SpecialBookSources' => 'includes/SpecialBooksources.php',
174174 'EmailConfirmation' => 'includes/SpecialConfirmemail.php',
175175 'ContributionsPage' => 'includes/SpecialContributions.php',
176 - 'DeadendPagesPage' => 'includes/SpecialDeadendpages.php',
177176 'DisambiguationsPage' => 'includes/SpecialDisambiguations.php',
178177 'EmailUserForm' => 'includes/SpecialEmailuser.php',
179178 'WikiRevision' => 'includes/SpecialImport.php',
@@ -184,7 +183,6 @@
185184 'LogReader' => 'includes/SpecialLog.php',
186185 'LogViewer' => 'includes/SpecialLog.php',
187186 'LonelyPagesPage' => 'includes/SpecialLonelypages.php',
188 - 'LongPagesPage' => 'includes/SpecialLongpages.php',
189187 'MIMEsearchPage' => 'includes/SpecialMIMEsearch.php',
190188 'MostcategoriesPage' => 'includes/SpecialMostcategories.php',
191189 'MostimagesPage' => 'includes/SpecialMostimages.php',
@@ -286,7 +284,9 @@
287285 'CachedReportPager' => 'includes/reports/CachedReportPager.php',
288286
289287 'BrokenRedirectsReport' => 'includes/reports/BrokenRedirectsReport.php',
 288+ 'DeadEndPagesReport' => 'includes/reports/DeadEndPagesReport.php',
290289 'DoubleRedirectsReport' => 'includes/reports/DoubleRedirectsReport.php',
 290+ 'LongPagesReport' => 'includes/reports/LongPagesReport.php',
291291 'PopularPagesReport' => 'includes/reports/PopularPagesReport.php',
292292 'RedirectReport' => 'includes/reports/RedirectReport.php',
293293 'ShortPagesReport' => 'includes/reports/ShortPagesReport.php',
Index: branches/robchurch/reports/includes/DefaultSettings.php
@@ -1383,6 +1383,12 @@
13841384 $wgShortPagesThreshold = 250;
13851385
13861386 /**
 1387+ * Pages larger than this number of bytes will be
 1388+ * considered "long" for the purposes of Special:Longpages
 1389+ */
 1390+$wgLongPagesThreshold = 80 * 1024;
 1391+
 1392+/**
13871393 * Maps jobs to their handling classes; extensions
13881394 * can add to this to provide custom jobs
13891395 */
Index: branches/robchurch/reports/includes/QueryPage.php
@@ -15,10 +15,8 @@
1616 // QueryPage subclass Special page name Limit (false for none, none for the default)
1717 //----------------------------------------------------------------------------
1818 array( 'AncientPagesPage', 'Ancientpages' ),
19 - array( 'DeadendPagesPage', 'Deadendpages' ),
2019 array( 'DisambiguationsPage', 'Disambiguations' ),
2120 array( 'LonelyPagesPage', 'Lonelypages' ),
22 - array( 'LongPagesPage', 'Longpages' ),
2321 array( 'MostcategoriesPage', 'Mostcategories' ),
2422 array( 'MostimagesPage', 'Mostimages' ),
2523 array( 'MostlinkedCategoriesPage', 'Mostlinkedcategories' ),
Index: branches/robchurch/reports/includes/SpecialPage.php
@@ -107,10 +107,10 @@
108108 'Mostrevisions' => array( 'SpecialPage', 'Mostrevisions' ),
109109 'Fewestrevisions' => array( 'SpecialPage', 'Fewestrevisions' ),
110110 'Shortpages' => 'ShortPagesReport',
111 - 'Longpages' => array( 'SpecialPage', 'Longpages' ),
 111+ 'Longpages' => 'LongPagesReport',
112112 'Newpages' => 'SpecialNewPages',//array( 'IncludableSpecialPage', 'Newpages' ),
113113 'Ancientpages' => array( 'SpecialPage', 'Ancientpages' ),
114 - 'Deadendpages' => array( 'SpecialPage', 'Deadendpages' ),
 114+ 'Deadendpages' => 'DeadEndPagesReport',
115115 'Protectedpages' => array( 'SpecialPage', 'Protectedpages' ),
116116 'Allpages' => array( 'IncludableSpecialPage', 'Allpages' ),
117117 'Prefixindex' => array( 'IncludableSpecialPage', 'Prefixindex' ) ,
Index: branches/robchurch/reports/languages/messages/MessagesEn.php
@@ -1597,10 +1597,9 @@
15981598 'randompage-nopages' => 'There are no pages in this namespace.',
15991599 'randompage-url' => 'Special:Random', # don't translate or duplicate this message to other languages
16001600 'longpages' => 'Long pages',
1601 -'longpages-summary' => '', # only translate this message to other languages if you have to change it
 1601+'longpages-header' => 'This report lists pages which are longer than $1.',
16021602 'deadendpages' => 'Dead-end pages',
1603 -'deadendpages-summary' => '', # only translate this message to other languages if you have to change it
1604 -'deadendpagestext' => 'The following pages do not link to other pages in this wiki.',
 1603+'deadendpages-header' => 'This report lists pages which contain no outgoing links.',
16051604 'protectedpages' => 'Protected pages',
16061605 'protectedpages-summary' => '', # only translate this message to other languages if you have to change it
16071606 'protectedpagestext' => 'The following pages are protected from moving or editing',

Status & tagging log