Index: branches/robchurch/reports/maintenance/language/messages.inc |
— | — | @@ -1008,7 +1008,7 @@ |
1009 | 1009 | 'newpages-summary', |
1010 | 1010 | 'newpages-username', |
1011 | 1011 | 'ancientpages', |
1012 | | - 'ancientpages-summary', |
| 1012 | + 'ancientpages-header', |
1013 | 1013 | 'intl', |
1014 | 1014 | 'move', |
1015 | 1015 | 'movethispage', |
Index: branches/robchurch/reports/maintenance/language/messageTypes.inc |
— | — | @@ -129,7 +129,6 @@ |
130 | 130 | 'mostrevisions-summary', |
131 | 131 | 'prefixindex-summary', |
132 | 132 | 'newpages-summary', |
133 | | - 'ancientpages-summary', |
134 | 133 | 'newimages-summary', |
135 | 134 | 'userrights-summary', |
136 | 135 | 'protectedpages-summary', |
Index: branches/robchurch/reports/includes/SpecialAncientpages.php |
— | — | @@ -1,63 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * |
5 | | - * @addtogroup SpecialPage |
6 | | - */ |
7 | | - |
8 | | -/** |
9 | | - * Implements Special:Ancientpages |
10 | | - * @addtogroup SpecialPage |
11 | | - */ |
12 | | -class AncientPagesPage extends QueryPage { |
13 | | - |
14 | | - function getName() { |
15 | | - return "Ancientpages"; |
16 | | - } |
17 | | - |
18 | | - function isExpensive() { |
19 | | - return true; |
20 | | - } |
21 | | - |
22 | | - function isSyndicated() { return false; } |
23 | | - |
24 | | - function getSQL() { |
25 | | - global $wgDBtype; |
26 | | - $db = wfGetDB( DB_SLAVE ); |
27 | | - $page = $db->tableName( 'page' ); |
28 | | - $revision = $db->tableName( 'revision' ); |
29 | | - #$use_index = $db->useIndexClause( 'cur_timestamp' ); # FIXME! this is gone |
30 | | - $epoch = $wgDBtype == 'mysql' ? 'UNIX_TIMESTAMP(rev_timestamp)' : |
31 | | - 'EXTRACT(epoch FROM rev_timestamp)'; |
32 | | - return |
33 | | - "SELECT 'Ancientpages' as type, |
34 | | - page_namespace as namespace, |
35 | | - page_title as title, |
36 | | - $epoch as value |
37 | | - FROM $page, $revision |
38 | | - WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0 |
39 | | - AND page_latest=rev_id"; |
40 | | - } |
41 | | - |
42 | | - function sortDescending() { |
43 | | - return false; |
44 | | - } |
45 | | - |
46 | | - function formatResult( $skin, $result ) { |
47 | | - global $wgLang, $wgContLang; |
48 | | - |
49 | | - $d = $wgLang->timeanddate( wfTimestamp( TS_MW, $result->value ), true ); |
50 | | - $title = Title::makeTitle( $result->namespace, $result->title ); |
51 | | - $link = $skin->makeKnownLinkObj( $title, htmlspecialchars( $wgContLang->convert( $title->getPrefixedText() ) ) ); |
52 | | - return wfSpecialList($link, $d); |
53 | | - } |
54 | | -} |
55 | | - |
56 | | -function wfSpecialAncientpages() { |
57 | | - list( $limit, $offset ) = wfCheckLimits(); |
58 | | - |
59 | | - $app = new AncientPagesPage(); |
60 | | - |
61 | | - $app->doQuery( $offset, $limit ); |
62 | | -} |
63 | | - |
64 | | -?> |
Index: branches/robchurch/reports/includes/reports/Report.php |
— | — | @@ -361,6 +361,7 @@ |
362 | 362 | */ |
363 | 363 | public static function getReports() { |
364 | 364 | return array( |
| 365 | + 'AncientPagesReport', |
365 | 366 | 'BrokenRedirectsReport', |
366 | 367 | 'DeadEndPagesReport', |
367 | 368 | 'DoubleRedirectsReport', |
Index: branches/robchurch/reports/includes/reports/AncientPagesReport.php |
— | — | @@ -0,0 +1,142 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Report lists pages on the wiki which haven't been |
| 6 | + * updated in a while |
| 7 | + * |
| 8 | + * @addtogroup Reports |
| 9 | + * @author Rob Church <robchur@gmail.com> |
| 10 | + */ |
| 11 | +class AncientPagesReport extends Report { |
| 12 | + |
| 13 | + /** |
| 14 | + * Constructor |
| 15 | + */ |
| 16 | + public function __construct() { |
| 17 | + parent::__construct(); |
| 18 | + } |
| 19 | + |
| 20 | + /** |
| 21 | + * Get the name of the report |
| 22 | + * |
| 23 | + * @return string |
| 24 | + */ |
| 25 | + public function getName() { |
| 26 | + return 'Ancientpages'; |
| 27 | + } |
| 28 | + |
| 29 | + /** |
| 30 | + * Get a HTML header for the top of the page |
| 31 | + * |
| 32 | + * @return string |
| 33 | + */ |
| 34 | + public function getHeader() { |
| 35 | + global $wgLang, $wgAncientPagesThreshold; |
| 36 | + return wfMsgExt( 'ancientpages-header', 'parse', |
| 37 | + $wgLang->formatNum( $wgAncientPagesThreshold ) ); |
| 38 | + } |
| 39 | + |
| 40 | + /** |
| 41 | + * Is it appropriate to allow filtering redirects? |
| 42 | + * |
| 43 | + * @return bool |
| 44 | + */ |
| 45 | + public function allowRedirectFilter() { |
| 46 | + return false; |
| 47 | + } |
| 48 | + |
| 49 | + /** |
| 50 | + * Should redirects be filtered from results? |
| 51 | + * |
| 52 | + * @return bool |
| 53 | + */ |
| 54 | + public function excludeRedirects() { |
| 55 | + return true; |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * Is it appropriate to allow filtering namespaces? |
| 60 | + * |
| 61 | + * @return bool |
| 62 | + */ |
| 63 | + public function allowNamespaceFilter() { |
| 64 | + return true; |
| 65 | + } |
| 66 | + |
| 67 | + /** |
| 68 | + * Get a list of namespaces this report can be run |
| 69 | + * against - false indicates *all* namespaces |
| 70 | + * |
| 71 | + * @return mixed |
| 72 | + */ |
| 73 | + public function getApplicableNamespaces() { |
| 74 | + return array( |
| 75 | + NS_MAIN, |
| 76 | + ) + $GLOBALS['wgContentNamespaces']; |
| 77 | + } |
| 78 | + |
| 79 | + /** |
| 80 | + * Return base SQL for the report |
| 81 | + * |
| 82 | + * @param Database $dbr Database object being queried |
| 83 | + * @return string |
| 84 | + */ |
| 85 | + public function getBaseSql( $dbr ) { |
| 86 | + list( $page, $revision ) = $dbr->tableNamesN( 'page', 'revision' ); |
| 87 | + return |
| 88 | + "SELECT |
| 89 | + page_id AS rp_id, |
| 90 | + page_namespace AS rp_namespace, |
| 91 | + page_title AS rp_title, |
| 92 | + page_is_redirect AS rp_redirect, |
| 93 | + rev_timestamp |
| 94 | + FROM {$page} |
| 95 | + LEFT JOIN {$revision} ON page_id = rev_page"; |
| 96 | + } |
| 97 | + |
| 98 | + /** |
| 99 | + * Return additional WHERE clauses and other conditions |
| 100 | + * to which the paging clauses will be appened when |
| 101 | + * the report runs live |
| 102 | + * |
| 103 | + * @param Database $dbr Database object being queried |
| 104 | + * @return array |
| 105 | + */ |
| 106 | + public function getExtraConditions( $dbr ) { |
| 107 | + return array( |
| 108 | + 'rev_id = page_latest', |
| 109 | + 'rev_timestamp < ' . $dbr->timestamp( time() - ( $GLOBALS['wgAncientPagesThreshold'] * 86400 ) ), |
| 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 | + 'rev_timestamp' => $row->rev_timestamp, |
| 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 | + global $wgLang; |
| 137 | + $time = $wgLang->timeAndDate( $params['rev_timestamp'], true ); |
| 138 | + return "<li>" . $skin->makeLinkObj( $title ) . " [{$time}]</li>\n"; |
| 139 | + } |
| 140 | + |
| 141 | +} |
| 142 | + |
| 143 | +?> |
\ No newline at end of file |
Property changes on: branches/robchurch/reports/includes/reports/AncientPagesReport.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 144 | + native |
Index: branches/robchurch/reports/includes/AutoLoader.php |
— | — | @@ -167,7 +167,6 @@ |
168 | 168 | 'SkinTemplate' => 'includes/SkinTemplate.php', |
169 | 169 | 'QuickTemplate' => 'includes/SkinTemplate.php', |
170 | 170 | 'SpecialAllpages' => 'includes/SpecialAllpages.php', |
171 | | - 'AncientPagesPage' => 'includes/SpecialAncientpages.php', |
172 | 171 | 'IPBlockForm' => 'includes/SpecialBlockip.php', |
173 | 172 | 'SpecialBookSources' => 'includes/SpecialBooksources.php', |
174 | 173 | 'EmailConfirmation' => 'includes/SpecialConfirmemail.php', |
— | — | @@ -283,6 +282,7 @@ |
284 | 283 | 'ReportPager' => 'includes/reports/ReportPager.php', |
285 | 284 | 'CachedReportPager' => 'includes/reports/CachedReportPager.php', |
286 | 285 | |
| 286 | + 'AncientPagesReport' => 'includes/reports/AncientPagesReport.php', |
287 | 287 | 'BrokenRedirectsReport' => 'includes/reports/BrokenRedirectsReport.php', |
288 | 288 | 'DeadEndPagesReport' => 'includes/reports/DeadEndPagesReport.php', |
289 | 289 | 'DoubleRedirectsReport' => 'includes/reports/DoubleRedirectsReport.php', |
Index: branches/robchurch/reports/includes/DefaultSettings.php |
— | — | @@ -1389,6 +1389,13 @@ |
1390 | 1390 | $wgLongPagesThreshold = 80 * 1024; |
1391 | 1391 | |
1392 | 1392 | /** |
| 1393 | + * Pages which haven't been edited for at least this |
| 1394 | + * number of days will be considered "ancient" |
| 1395 | + * for the purposes of Special:Ancientpages |
| 1396 | + */ |
| 1397 | +$wgAncientPagesThreshold = 100; |
| 1398 | + |
| 1399 | +/** |
1393 | 1400 | * Maps jobs to their handling classes; extensions |
1394 | 1401 | * can add to this to provide custom jobs |
1395 | 1402 | */ |
Index: branches/robchurch/reports/includes/QueryPage.php |
— | — | @@ -14,7 +14,6 @@ |
15 | 15 | $wgQueryPages = array( |
16 | 16 | // QueryPage subclass Special page name Limit (false for none, none for the default) |
17 | 17 | //---------------------------------------------------------------------------- |
18 | | - array( 'AncientPagesPage', 'Ancientpages' ), |
19 | 18 | array( 'DisambiguationsPage', 'Disambiguations' ), |
20 | 19 | array( 'LonelyPagesPage', 'Lonelypages' ), |
21 | 20 | array( 'MostcategoriesPage', 'Mostcategories' ), |
Index: branches/robchurch/reports/includes/SpecialPage.php |
— | — | @@ -109,7 +109,7 @@ |
110 | 110 | 'Shortpages' => 'ShortPagesReport', |
111 | 111 | 'Longpages' => 'LongPagesReport', |
112 | 112 | 'Newpages' => 'SpecialNewPages',//array( 'IncludableSpecialPage', 'Newpages' ), |
113 | | - 'Ancientpages' => array( 'SpecialPage', 'Ancientpages' ), |
| 113 | + 'Ancientpages' => 'AncientPagesReport', |
114 | 114 | 'Deadendpages' => 'DeadEndPagesReport', |
115 | 115 | 'Protectedpages' => array( 'SpecialPage', 'Protectedpages' ), |
116 | 116 | 'Allpages' => array( 'IncludableSpecialPage', 'Allpages' ), |
Index: branches/robchurch/reports/languages/messages/MessagesEn.php |
— | — | @@ -1617,7 +1617,7 @@ |
1618 | 1618 | 'newpages-summary' => '', # only translate this message to other languages if you have to change it |
1619 | 1619 | 'newpages-username' => 'Username:', |
1620 | 1620 | 'ancientpages' => 'Oldest pages', |
1621 | | -'ancientpages-summary' => '', # only translate this message to other languages if you have to change it |
| 1621 | +'ancientpages-header' => 'This report lists pages which haven\'t been edited in at least $1 days.', |
1622 | 1622 | 'intl' => 'Interlanguage links', |
1623 | 1623 | 'move' => 'Move', |
1624 | 1624 | 'movethispage' => 'Move this page', |