Index: branches/robchurch/reports/maintenance/language/messages.inc |
— | — | @@ -969,8 +969,8 @@ |
970 | 970 | 'wantedpages-header', |
971 | 971 | 'mostlinked', |
972 | 972 | 'mostlinked-summary', |
973 | | - 'mostlinkedcategories', |
974 | | - 'mostlinkedcategories-summary', |
| 973 | + 'largestcategories', |
| 974 | + 'largestcategories-header', |
975 | 975 | 'mostlinkedtemplates', |
976 | 976 | 'mostlinkedtemplates-summary', |
977 | 977 | 'mostcategories', |
Index: branches/robchurch/reports/maintenance/language/messageTypes.inc |
— | — | @@ -120,7 +120,6 @@ |
121 | 121 | 'whatlinkshere-barrow', |
122 | 122 | 'imagelist-summary', |
123 | 123 | 'mostlinked-summary', |
124 | | - 'mostlinkedcategories-summary', |
125 | 124 | 'mostlinkedtemplates-summary', |
126 | 125 | 'mostcategories-summary', |
127 | 126 | 'mostimages-summary', |
Index: branches/robchurch/reports/includes/SpecialMostlinkedcategories.php |
— | — | @@ -1,75 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * A querypage to show categories ordered in descending order by the pages in them |
5 | | - * |
6 | | - * @addtogroup SpecialPage |
7 | | - * |
8 | | - * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com> |
9 | | - * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason |
10 | | - * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
11 | | - */ |
12 | | -class MostlinkedCategoriesPage extends QueryPage { |
13 | | - |
14 | | - function getName() { return 'Mostlinkedcategories'; } |
15 | | - function isExpensive() { return true; } |
16 | | - function isSyndicated() { return false; } |
17 | | - |
18 | | - function getSQL() { |
19 | | - $dbr = wfGetDB( DB_SLAVE ); |
20 | | - $categorylinks = $dbr->tableName( 'categorylinks' ); |
21 | | - $name = $dbr->addQuotes( $this->getName() ); |
22 | | - return |
23 | | - " |
24 | | - SELECT |
25 | | - $name as type, |
26 | | - " . NS_CATEGORY . " as namespace, |
27 | | - cl_to as title, |
28 | | - COUNT(*) as value |
29 | | - FROM $categorylinks |
30 | | - GROUP BY 1,2,3 |
31 | | - "; |
32 | | - } |
33 | | - |
34 | | - function sortDescending() { return true; } |
35 | | - |
36 | | - /** |
37 | | - * Fetch user page links and cache their existence |
38 | | - */ |
39 | | - function preprocessResults( &$db, &$res ) { |
40 | | - $batch = new LinkBatch; |
41 | | - while ( $row = $db->fetchObject( $res ) ) |
42 | | - $batch->addObj( Title::makeTitleSafe( $row->namespace, $row->title ) ); |
43 | | - $batch->execute(); |
44 | | - |
45 | | - // Back to start for display |
46 | | - if ( $db->numRows( $res ) > 0 ) |
47 | | - // If there are no rows we get an error seeking. |
48 | | - $db->dataSeek( $res, 0 ); |
49 | | - } |
50 | | - |
51 | | - function formatResult( $skin, $result ) { |
52 | | - global $wgLang, $wgContLang; |
53 | | - |
54 | | - $nt = Title::makeTitle( $result->namespace, $result->title ); |
55 | | - $text = $wgContLang->convert( $nt->getText() ); |
56 | | - |
57 | | - $plink = $skin->makeLinkObj( $nt, htmlspecialchars( $text ) ); |
58 | | - |
59 | | - $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'), |
60 | | - $wgLang->formatNum( $result->value ) ); |
61 | | - return wfSpecialList($plink, $nlinks); |
62 | | - } |
63 | | -} |
64 | | - |
65 | | -/** |
66 | | - * constructor |
67 | | - */ |
68 | | -function wfSpecialMostlinkedCategories() { |
69 | | - list( $limit, $offset ) = wfCheckLimits(); |
70 | | - |
71 | | - $wpp = new MostlinkedCategoriesPage(); |
72 | | - |
73 | | - $wpp->doQuery( $offset, $limit ); |
74 | | -} |
75 | | - |
76 | | -?> |
Index: branches/robchurch/reports/includes/reports/LargestCategoriesReport.php |
— | — | @@ -0,0 +1,151 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Report lists all pages which don't exist but have |
| 6 | + * incoming links |
| 7 | + * |
| 8 | + * @addtogroup Reports |
| 9 | + * @author Rob Church <robchur@gmail.com> |
| 10 | + */ |
| 11 | +class LargestCategoriesReport 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 'Largestcategories'; |
| 27 | + } |
| 28 | + |
| 29 | + /** |
| 30 | + * Is it appropriate to allow filtering redirects? |
| 31 | + * |
| 32 | + * @return bool |
| 33 | + */ |
| 34 | + public function allowRedirectFilter() { |
| 35 | + return false; |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * Is it appropriate to allow filtering namespaces? |
| 40 | + * |
| 41 | + * @return bool |
| 42 | + */ |
| 43 | + public function allowNamespaceFilter() { |
| 44 | + return false; |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * Get a list of namespaces this report can be run |
| 49 | + * against - false indicates *all* namespaces |
| 50 | + * |
| 51 | + * @return mixed |
| 52 | + */ |
| 53 | + public function getApplicableNamespaces() { |
| 54 | + return array( |
| 55 | + NS_CATEGORY, |
| 56 | + ); |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * Return base SQL for the report |
| 61 | + * |
| 62 | + * @param Database $dbr Database object being queried |
| 63 | + * @return string |
| 64 | + */ |
| 65 | + public function getBaseSql( $dbr ) { |
| 66 | + $categorylinks = $dbr->tableName( 'categorylinks' ); |
| 67 | + return |
| 68 | + "SELECT |
| 69 | + cl_to AS rp_id, |
| 70 | + " . NS_CATEGORY . " AS rp_namespace, |
| 71 | + cl_to AS rp_title, |
| 72 | + 0 AS rp_redirect, |
| 73 | + COUNT(*) AS count |
| 74 | + FROM {$categorylinks}"; |
| 75 | + } |
| 76 | + |
| 77 | + /** |
| 78 | + * Get the column used for paging when the report is run live |
| 79 | + * |
| 80 | + * @return string |
| 81 | + */ |
| 82 | + public function getPagingColumn() { |
| 83 | + return 'cl_to'; |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * Get a partial WHERE clause to filter on namespace when |
| 88 | + * the report is run live |
| 89 | + * |
| 90 | + * @param int $namespace Namespace to limit to |
| 91 | + * @return string |
| 92 | + */ |
| 93 | + public function getNamespaceClause( $namespace ) { |
| 94 | + // Not applicable to this report |
| 95 | + return '1 = 1'; |
| 96 | + } |
| 97 | + |
| 98 | + /** |
| 99 | + * Get additional SQL to be inserted between the |
| 100 | + * conditions and ORDER clauses when the report is run live |
| 101 | + * |
| 102 | + * @param Database $dbr Database object being queried |
| 103 | + * @return string |
| 104 | + */ |
| 105 | + public function getExtraSql( $dbr ) { |
| 106 | + return ' GROUP BY 1, 2, 3'; |
| 107 | + } |
| 108 | + |
| 109 | + /** |
| 110 | + * Get ORDER BY clauses to be applied when the |
| 111 | + * report is run live |
| 112 | + * |
| 113 | + * @return array |
| 114 | + */ |
| 115 | + public function getOrderingClauses() { |
| 116 | + return array( |
| 117 | + 'count DESC', |
| 118 | + ); |
| 119 | + } |
| 120 | + |
| 121 | + /** |
| 122 | + * Given a result object, extract additional parameters |
| 123 | + * as a dictionary for later use |
| 124 | + * |
| 125 | + * @param object $row Result row |
| 126 | + * @return array |
| 127 | + */ |
| 128 | + public function extractParameters( $row ) { |
| 129 | + return array( |
| 130 | + 'count' => $row->count, |
| 131 | + ); |
| 132 | + } |
| 133 | + |
| 134 | + /** |
| 135 | + * Format an individual result row |
| 136 | + * |
| 137 | + * @param Title $title Result title |
| 138 | + * @param object $row Result row |
| 139 | + * @param array $params Result parameters |
| 140 | + * @param Skin $skin User skin |
| 141 | + * @return string |
| 142 | + */ |
| 143 | + public function formatRow( $title, $row, $params, $skin ) { |
| 144 | + global $wgLang; |
| 145 | + $members = wfMsgExt( 'nmembers', array( 'parsemag', 'escape' ), $params['count'] ); |
| 146 | + return "<li>" . $skin->makeLinkObj( $title, htmlspecialchars( $title->getText() ) ) |
| 147 | + . " ({$members})</li>\n"; |
| 148 | + } |
| 149 | + |
| 150 | +} |
| 151 | + |
| 152 | +?> |
\ No newline at end of file |
Property changes on: branches/robchurch/reports/includes/reports/LargestCategoriesReport.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 153 | + native |
Index: branches/robchurch/reports/includes/reports/Report.php |
— | — | @@ -380,6 +380,7 @@ |
381 | 381 | 'BrokenRedirectsReport', |
382 | 382 | 'DeadEndPagesReport', |
383 | 383 | 'DoubleRedirectsReport', |
| 384 | + 'LargestCategoriesReport', |
384 | 385 | 'LongPagesReport', |
385 | 386 | 'OrphanedPagesReport', |
386 | 387 | 'PopularPagesReport', |
Index: branches/robchurch/reports/includes/AutoLoader.php |
— | — | @@ -185,7 +185,6 @@ |
186 | 186 | 'MostcategoriesPage' => 'includes/SpecialMostcategories.php', |
187 | 187 | 'MostimagesPage' => 'includes/SpecialMostimages.php', |
188 | 188 | 'MostlinkedPage' => 'includes/SpecialMostlinked.php', |
189 | | - 'MostlinkedCategoriesPage' => 'includes/SpecialMostlinkedcategories.php', |
190 | 189 | 'SpecialMostlinkedtemplates' => 'includes/SpecialMostlinkedtemplates.php', |
191 | 190 | 'MostrevisionsPage' => 'includes/SpecialMostrevisions.php', |
192 | 191 | 'FewestrevisionsPage' => 'includes/SpecialFewestrevisions.php', |
— | — | @@ -283,6 +282,7 @@ |
284 | 283 | 'BrokenRedirectsReport' => 'includes/reports/BrokenRedirectsReport.php', |
285 | 284 | 'DeadEndPagesReport' => 'includes/reports/DeadEndPagesReport.php', |
286 | 285 | 'DoubleRedirectsReport' => 'includes/reports/DoubleRedirectsReport.php', |
| 286 | + 'LargestCategoriesReport' => 'includes/reports/LargestCategoriesReport.php', |
287 | 287 | 'LongPagesReport' => 'includes/reports/LongPagesReport.php', |
288 | 288 | 'OrphanedPagesReport' => 'includes/reports/OrphanedPagesReport.php', |
289 | 289 | 'PopularPagesReport' => 'includes/reports/PopularPagesReport.php', |
Index: branches/robchurch/reports/includes/QueryPage.php |
— | — | @@ -15,10 +15,8 @@ |
16 | 16 | // QueryPage subclass Special page name Limit (false for none, none for the default) |
17 | 17 | //---------------------------------------------------------------------------- |
18 | 18 | array( 'DisambiguationsPage', 'Disambiguations' ), |
19 | | - array( 'LonelyPagesPage', 'Lonelypages' ), |
20 | 19 | array( 'MostcategoriesPage', 'Mostcategories' ), |
21 | 20 | array( 'MostimagesPage', 'Mostimages' ), |
22 | | - array( 'MostlinkedCategoriesPage', 'Mostlinkedcategories' ), |
23 | 21 | array( 'SpecialMostlinkedtemplates', 'Mostlinkedtemplates' ), |
24 | 22 | array( 'MostlinkedPage', 'Mostlinked' ), |
25 | 23 | array( 'MostrevisionsPage', 'Mostrevisions' ), |
Index: branches/robchurch/reports/includes/SpecialPage.php |
— | — | @@ -100,7 +100,7 @@ |
101 | 101 | 'Wantedpages' => 'WantedPagesReport', |
102 | 102 | 'Wantedcategories' => 'WantedCategoriesReport', |
103 | 103 | 'Mostlinked' => array( 'SpecialPage', 'Mostlinked' ), |
104 | | - 'Mostlinkedcategories' => array( 'SpecialPage', 'Mostlinkedcategories' ), |
| 104 | + 'Largestcategories' => 'LargestCategoriesReport', |
105 | 105 | 'Mostlinkedtemplates' => array( 'SpecialPage', 'Mostlinkedtemplates' ), |
106 | 106 | 'Mostcategories' => array( 'SpecialPage', 'Mostcategories' ), |
107 | 107 | 'Mostimages' => array( 'SpecialPage', 'Mostimages' ), |
Index: branches/robchurch/reports/languages/messages/MessagesEn.php |
— | — | @@ -374,7 +374,7 @@ |
375 | 375 | 'Wantedpages' => array( 'Wantedpages', 'Brokenlinks' ), |
376 | 376 | 'Wantedcategories' => array( 'Wantedcategories' ), |
377 | 377 | 'Mostlinked' => array( 'Mostlinked' ), |
378 | | - 'Mostlinkedcategories' => array( 'Mostlinkedcategories' ), |
| 378 | + 'Largestcategories' => array( 'Largestcategories', 'Mostlinkedcategories' ), |
379 | 379 | 'Mostlinkedtemplates' => array( 'Mostlinkedtemplates' ), |
380 | 380 | 'Mostcategories' => array( 'Mostcategories' ), |
381 | 381 | 'Mostimages' => array( 'Mostimages' ), |
— | — | @@ -1578,8 +1578,8 @@ |
1579 | 1579 | 'wantedpages-header' => 'This report lists pages which don\'t exist, but have $1 or more incoming links.', |
1580 | 1580 | 'mostlinked' => 'Most linked to pages', |
1581 | 1581 | 'mostlinked-summary' => '', # only translate this message to other languages if you have to change it |
1582 | | -'mostlinkedcategories' => 'Most linked to categories', |
1583 | | -'mostlinkedcategories-summary' => '', # only translate this message to other languages if you have to change it |
| 1582 | +'largestcategories' => 'Largest categories', |
| 1583 | +'largestcategories-header' => 'This report lists categories with the most members.', |
1584 | 1584 | 'mostlinkedtemplates' => 'Most linked-to templates', |
1585 | 1585 | 'mostlinkedtemplates-summary' => '', # only translate this message to other languages if you have to change it |
1586 | 1586 | 'mostcategories' => 'Articles with the most categories', |