r23380 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23379‎ | r23380 | r23381 >
Date:10:00, 25 June 2007
Author:robchurch
Status:old
Tags:
Comment:
Port Special:MostLinkedCategories, renaming to Special:LargestCategories
Modified paths:
  • /branches/robchurch/reports/includes/AutoLoader.php (modified) (history)
  • /branches/robchurch/reports/includes/QueryPage.php (modified) (history)
  • /branches/robchurch/reports/includes/SpecialMostlinkedcategories.php (deleted) (history)
  • /branches/robchurch/reports/includes/SpecialPage.php (modified) (history)
  • /branches/robchurch/reports/includes/reports/LargestCategoriesReport.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
@@ -969,8 +969,8 @@
970970 'wantedpages-header',
971971 'mostlinked',
972972 'mostlinked-summary',
973 - 'mostlinkedcategories',
974 - 'mostlinkedcategories-summary',
 973+ 'largestcategories',
 974+ 'largestcategories-header',
975975 'mostlinkedtemplates',
976976 'mostlinkedtemplates-summary',
977977 'mostcategories',
Index: branches/robchurch/reports/maintenance/language/messageTypes.inc
@@ -120,7 +120,6 @@
121121 'whatlinkshere-barrow',
122122 'imagelist-summary',
123123 'mostlinked-summary',
124 - 'mostlinkedcategories-summary',
125124 'mostlinkedtemplates-summary',
126125 'mostcategories-summary',
127126 '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
1153 + native
Index: branches/robchurch/reports/includes/reports/Report.php
@@ -380,6 +380,7 @@
381381 'BrokenRedirectsReport',
382382 'DeadEndPagesReport',
383383 'DoubleRedirectsReport',
 384+ 'LargestCategoriesReport',
384385 'LongPagesReport',
385386 'OrphanedPagesReport',
386387 'PopularPagesReport',
Index: branches/robchurch/reports/includes/AutoLoader.php
@@ -185,7 +185,6 @@
186186 'MostcategoriesPage' => 'includes/SpecialMostcategories.php',
187187 'MostimagesPage' => 'includes/SpecialMostimages.php',
188188 'MostlinkedPage' => 'includes/SpecialMostlinked.php',
189 - 'MostlinkedCategoriesPage' => 'includes/SpecialMostlinkedcategories.php',
190189 'SpecialMostlinkedtemplates' => 'includes/SpecialMostlinkedtemplates.php',
191190 'MostrevisionsPage' => 'includes/SpecialMostrevisions.php',
192191 'FewestrevisionsPage' => 'includes/SpecialFewestrevisions.php',
@@ -283,6 +282,7 @@
284283 'BrokenRedirectsReport' => 'includes/reports/BrokenRedirectsReport.php',
285284 'DeadEndPagesReport' => 'includes/reports/DeadEndPagesReport.php',
286285 'DoubleRedirectsReport' => 'includes/reports/DoubleRedirectsReport.php',
 286+ 'LargestCategoriesReport' => 'includes/reports/LargestCategoriesReport.php',
287287 'LongPagesReport' => 'includes/reports/LongPagesReport.php',
288288 'OrphanedPagesReport' => 'includes/reports/OrphanedPagesReport.php',
289289 'PopularPagesReport' => 'includes/reports/PopularPagesReport.php',
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( 'DisambiguationsPage', 'Disambiguations' ),
19 - array( 'LonelyPagesPage', 'Lonelypages' ),
2019 array( 'MostcategoriesPage', 'Mostcategories' ),
2120 array( 'MostimagesPage', 'Mostimages' ),
22 - array( 'MostlinkedCategoriesPage', 'Mostlinkedcategories' ),
2321 array( 'SpecialMostlinkedtemplates', 'Mostlinkedtemplates' ),
2422 array( 'MostlinkedPage', 'Mostlinked' ),
2523 array( 'MostrevisionsPage', 'Mostrevisions' ),
Index: branches/robchurch/reports/includes/SpecialPage.php
@@ -100,7 +100,7 @@
101101 'Wantedpages' => 'WantedPagesReport',
102102 'Wantedcategories' => 'WantedCategoriesReport',
103103 'Mostlinked' => array( 'SpecialPage', 'Mostlinked' ),
104 - 'Mostlinkedcategories' => array( 'SpecialPage', 'Mostlinkedcategories' ),
 104+ 'Largestcategories' => 'LargestCategoriesReport',
105105 'Mostlinkedtemplates' => array( 'SpecialPage', 'Mostlinkedtemplates' ),
106106 'Mostcategories' => array( 'SpecialPage', 'Mostcategories' ),
107107 'Mostimages' => array( 'SpecialPage', 'Mostimages' ),
Index: branches/robchurch/reports/languages/messages/MessagesEn.php
@@ -374,7 +374,7 @@
375375 'Wantedpages' => array( 'Wantedpages', 'Brokenlinks' ),
376376 'Wantedcategories' => array( 'Wantedcategories' ),
377377 'Mostlinked' => array( 'Mostlinked' ),
378 - 'Mostlinkedcategories' => array( 'Mostlinkedcategories' ),
 378+ 'Largestcategories' => array( 'Largestcategories', 'Mostlinkedcategories' ),
379379 'Mostlinkedtemplates' => array( 'Mostlinkedtemplates' ),
380380 'Mostcategories' => array( 'Mostcategories' ),
381381 'Mostimages' => array( 'Mostimages' ),
@@ -1578,8 +1578,8 @@
15791579 'wantedpages-header' => 'This report lists pages which don\'t exist, but have $1 or more incoming links.',
15801580 'mostlinked' => 'Most linked to pages',
15811581 '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.',
15841584 'mostlinkedtemplates' => 'Most linked-to templates',
15851585 'mostlinkedtemplates-summary' => '', # only translate this message to other languages if you have to change it
15861586 'mostcategories' => 'Articles with the most categories',

Status & tagging log