r23390 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23389‎ | r23390 | r23391 >
Date:15:15, 25 June 2007
Author:robchurch
Status:old
Tags:
Comment:
Port "most revisions" and "fewest revisions"
Modified paths:
  • /branches/robchurch/reports/includes/AutoLoader.php (modified) (history)
  • /branches/robchurch/reports/includes/QueryPage.php (modified) (history)
  • /branches/robchurch/reports/includes/SpecialFewestrevisions.php (deleted) (history)
  • /branches/robchurch/reports/includes/SpecialMostrevisions.php (deleted) (history)
  • /branches/robchurch/reports/includes/SpecialPage.php (modified) (history)
  • /branches/robchurch/reports/includes/reports/FewestRevisionsReport.php (added) (history)
  • /branches/robchurch/reports/includes/reports/MostRevisionsReport.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/messages.inc (modified) (history)

Diff [purge]

Index: branches/robchurch/reports/maintenance/language/messages.inc
@@ -919,7 +919,7 @@
920920 ),
921921 'fewestrevisions' => array(
922922 'fewestrevisions',
923 - 'fewestrevisions-summary',
 923+ 'fewestrevisions-header',
924924 ),
925925 'uncategorizedpages' => array(
926926 'uncategorizedpages',
Index: branches/robchurch/reports/includes/SpecialMostrevisions.php
@@ -1,66 +0,0 @@
2 -<?php
3 -/**
4 - * A special page to show pages in the
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 -
13 -/**
14 - * @addtogroup SpecialPage
15 - */
16 -class MostrevisionsPage extends QueryPage {
17 -
18 - function getName() { return 'Mostrevisions'; }
19 - function isExpensive() { return true; }
20 - function isSyndicated() { return false; }
21 -
22 - function getSQL() {
23 - $dbr = wfGetDB( DB_SLAVE );
24 - list( $revision, $page ) = $dbr->tableNamesN( 'revision', 'page' );
25 - return
26 - "
27 - SELECT
28 - 'Mostrevisions' as type,
29 - page_namespace as namespace,
30 - page_title as title,
31 - COUNT(*) as value
32 - FROM $revision
33 - JOIN $page ON page_id = rev_page
34 - WHERE page_namespace = " . NS_MAIN . "
35 - GROUP BY 1,2,3
36 - HAVING COUNT(*) > 1
37 - ";
38 - }
39 -
40 - function formatResult( $skin, $result ) {
41 - global $wgLang, $wgContLang;
42 -
43 - $nt = Title::makeTitle( $result->namespace, $result->title );
44 - $text = $wgContLang->convert( $nt->getPrefixedText() );
45 -
46 - $plink = $skin->makeKnownLinkObj( $nt, $text );
47 -
48 - $nl = wfMsgExt( 'nrevisions', array( 'parsemag', 'escape'),
49 - $wgLang->formatNum( $result->value ) );
50 - $nlink = $skin->makeKnownLinkObj( $nt, $nl, 'action=history' );
51 -
52 - return wfSpecialList($plink, $nlink);
53 - }
54 -}
55 -
56 -/**
57 - * constructor
58 - */
59 -function wfSpecialMostrevisions() {
60 - list( $limit, $offset ) = wfCheckLimits();
61 -
62 - $wpp = new MostrevisionsPage();
63 -
64 - $wpp->doQuery( $offset, $limit );
65 -}
66 -
67 -?>
Index: branches/robchurch/reports/includes/SpecialFewestrevisions.php
@@ -1,65 +0,0 @@
2 -<?php
3 -
4 -/**
5 - * Special page for listing the articles with the fewest revisions.
6 - *
7 - * @package MediaWiki
8 - * @addtogroup SpecialPage
9 - * @author Martin Drashkov
10 - */
11 -class FewestrevisionsPage extends QueryPage {
12 -
13 - function getName() {
14 - return 'Fewestrevisions';
15 - }
16 -
17 - function isExpensive() {
18 - return true;
19 - }
20 -
21 - function isSyndicated() {
22 - return false;
23 - }
24 -
25 - function getSql() {
26 - $dbr = wfGetDB( DB_SLAVE );
27 - list( $revision, $page ) = $dbr->tableNamesN( 'revision', 'page' );
28 -
29 - return "SELECT 'Fewestrevisions' as type,
30 - page_namespace as namespace,
31 - page_title as title,
32 - COUNT(*) as value
33 - FROM $revision
34 - JOIN $page ON page_id = rev_page
35 - WHERE page_namespace = " . NS_MAIN . "
36 - GROUP BY 1,2,3
37 - HAVING COUNT(*) > 1";
38 - }
39 -
40 - function sortDescending() {
41 - return false;
42 - }
43 -
44 - function formatResult( $skin, $result ) {
45 - global $wgLang, $wgContLang;
46 -
47 - $nt = Title::makeTitleSafe( $result->namespace, $result->title );
48 - $text = $wgContLang->convert( $nt->getPrefixedText() );
49 -
50 - $plink = $skin->makeKnownLinkObj( $nt, $text );
51 -
52 - $nl = wfMsgExt( 'nrevisions', array( 'parsemag', 'escape'),
53 - $wgLang->formatNum( $result->value ) );
54 - $nlink = $skin->makeKnownLinkObj( $nt, $nl, 'action=history' );
55 -
56 - return wfSpecialList( $plink, $nlink );
57 - }
58 -}
59 -
60 -function wfSpecialFewestrevisions() {
61 - list( $limit, $offset ) = wfCheckLimits();
62 - $frp = new FewestrevisionsPage();
63 - $frp->doQuery( $offset, $limit );
64 -}
65 -
66 -?>
Index: branches/robchurch/reports/includes/reports/FewestRevisionsReport.php
@@ -0,0 +1,151 @@
 2+<?php
 3+
 4+/**
 5+ * Report lists pages with the fewest revisions
 6+ *
 7+ * @addtogroup Reports
 8+ * @author Rob Church <robchur@gmail.com>
 9+ */
 10+class FewestRevisionsReport 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 'Fewestrevisions';
 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+ * Should redirects be filtered from results?
 39+ *
 40+ * @return bool
 41+ */
 42+ public function excludeRedirects() {
 43+ return true;
 44+ }
 45+
 46+ /**
 47+ * Is it appropriate to allow filtering namespaces?
 48+ *
 49+ * @return bool
 50+ */
 51+ public function allowNamespaceFilter() {
 52+ return true;
 53+ }
 54+
 55+ /**
 56+ * Get a list of namespaces this report can be run
 57+ * against - false indicates *all* namespaces
 58+ *
 59+ * @return mixed
 60+ */
 61+ public function getApplicableNamespaces() {
 62+ return array(
 63+ NS_MAIN,
 64+ ) + $GLOBALS['wgContentNamespaces'];
 65+ }
 66+
 67+ /**
 68+ * Return base SQL for the report
 69+ *
 70+ * @param Database $dbr Database object being queried
 71+ * @return string
 72+ */
 73+ public function getBaseSql( $dbr ) {
 74+ list( $page, $revision ) = $dbr->tableNamesN( 'page', 'revision' );
 75+ return
 76+ "SELECT
 77+ page_id AS rp_id,
 78+ page_namespace AS rp_namespace,
 79+ page_title AS rp_title,
 80+ page_is_redirect AS rp_redirect,
 81+ COUNT(*) AS count
 82+ FROM {$revision}
 83+ LEFT JOIN {$page} ON rev_page = page_id";
 84+ }
 85+
 86+ /**
 87+ * Return additional WHERE clauses and other conditions
 88+ * to which the paging clauses will be appened when
 89+ * the report runs live
 90+ *
 91+ * @param Database $dbr Database object being queried
 92+ * @return array
 93+ */
 94+ public function getExtraConditions( $dbr ) {
 95+ return array();
 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 ASC',
 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+ $revs = wfMsgExt( 'nrevisions', array( 'parsemag', 'escape' ),
 146+ $wgLang->formatNum( $params['count'] ) );
 147+ return "<li>" . $skin->makeLinkObj( $title ) . " ({$revs})</li>\n";
 148+ }
 149+
 150+}
 151+
 152+?>
\ No newline at end of file
Property changes on: branches/robchurch/reports/includes/reports/FewestRevisionsReport.php
___________________________________________________________________
Added: svn:eol-style
1153 + native
Index: branches/robchurch/reports/includes/reports/Report.php
@@ -380,10 +380,12 @@
381381 'BrokenRedirectsReport',
382382 'DeadEndPagesReport',
383383 'DoubleRedirectsReport',
 384+ 'FewestRevisionsReport',
384385 'LargestCategoriesReport',
385386 'LongPagesReport',
386387 'MostCategoriesReport',
387388 'MostLinkedPagesReport',
 389+ 'MostRevisionsReport',
388390 'MostUsedImagesReport',
389391 'MostUsedTemplatesReport',
390392 'OrphanedPagesReport',
Index: branches/robchurch/reports/includes/reports/MostRevisionsReport.php
@@ -0,0 +1,151 @@
 2+<?php
 3+
 4+/**
 5+ * Report lists pages with the most revisions
 6+ *
 7+ * @addtogroup Reports
 8+ * @author Rob Church <robchur@gmail.com>
 9+ */
 10+class MostRevisionsReport 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 'Mostrevisions';
 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+ * Should redirects be filtered from results?
 39+ *
 40+ * @return bool
 41+ */
 42+ public function excludeRedirects() {
 43+ return true;
 44+ }
 45+
 46+ /**
 47+ * Is it appropriate to allow filtering namespaces?
 48+ *
 49+ * @return bool
 50+ */
 51+ public function allowNamespaceFilter() {
 52+ return true;
 53+ }
 54+
 55+ /**
 56+ * Get a list of namespaces this report can be run
 57+ * against - false indicates *all* namespaces
 58+ *
 59+ * @return mixed
 60+ */
 61+ public function getApplicableNamespaces() {
 62+ return array(
 63+ NS_MAIN,
 64+ ) + $GLOBALS['wgContentNamespaces'];
 65+ }
 66+
 67+ /**
 68+ * Return base SQL for the report
 69+ *
 70+ * @param Database $dbr Database object being queried
 71+ * @return string
 72+ */
 73+ public function getBaseSql( $dbr ) {
 74+ list( $page, $revision ) = $dbr->tableNamesN( 'page', 'revision' );
 75+ return
 76+ "SELECT
 77+ page_id AS rp_id,
 78+ page_namespace AS rp_namespace,
 79+ page_title AS rp_title,
 80+ page_is_redirect AS rp_redirect,
 81+ COUNT(*) AS count
 82+ FROM {$revision}
 83+ LEFT JOIN {$page} ON rev_page = page_id";
 84+ }
 85+
 86+ /**
 87+ * Return additional WHERE clauses and other conditions
 88+ * to which the paging clauses will be appened when
 89+ * the report runs live
 90+ *
 91+ * @param Database $dbr Database object being queried
 92+ * @return array
 93+ */
 94+ public function getExtraConditions( $dbr ) {
 95+ return array();
 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+ $revs = wfMsgExt( 'nrevisions', array( 'parsemag', 'escape' ),
 146+ $wgLang->formatNum( $params['count'] ) );
 147+ return "<li>" . $skin->makeLinkObj( $title ) . " ({$revs})</li>\n";
 148+ }
 149+
 150+}
 151+
 152+?>
\ No newline at end of file
Property changes on: branches/robchurch/reports/includes/reports/MostRevisionsReport.php
___________________________________________________________________
Added: svn:eol-style
1153 + native
Index: branches/robchurch/reports/includes/AutoLoader.php
@@ -182,8 +182,6 @@
183183 'LogReader' => 'includes/SpecialLog.php',
184184 'LogViewer' => 'includes/SpecialLog.php',
185185 'MIMEsearchPage' => 'includes/SpecialMIMEsearch.php',
186 - 'MostrevisionsPage' => 'includes/SpecialMostrevisions.php',
187 - 'FewestrevisionsPage' => 'includes/SpecialFewestrevisions.php',
188186 'MovePageForm' => 'includes/SpecialMovepage.php',
189187 'NewbieContributionsPage' => 'includes/SpecialNewbieContributions.php',
190188 'SpecialNewPages' => 'includes/SpecialNewpages.php',
@@ -278,10 +276,12 @@
279277 'BrokenRedirectsReport' => 'includes/reports/BrokenRedirectsReport.php',
280278 'DeadEndPagesReport' => 'includes/reports/DeadEndPagesReport.php',
281279 'DoubleRedirectsReport' => 'includes/reports/DoubleRedirectsReport.php',
 280+ 'FewestRevisionsReport' => 'includes/reports/FewestRevisionsReport.php',
282281 'LargestCategoriesReport' => 'includes/reports/LargestCategoriesReport.php',
283282 'LongPagesReport' => 'includes/reports/LongPagesReport.php',
284283 'MostCategoriesReport' => 'includes/reports/MostCategoriesReport.php',
285284 'MostLinkedPagesReport' => 'includes/reports/MostLinkedPagesReport.php',
 285+ 'MostRevisionsReport' => 'includes/reports/MostRevisionsReport.php',
286286 'MostUsedImagesReport' => 'includes/reports/MostUsedImagesReport.php',
287287 'MostUsedTemplatesReport' => 'includes/reports/MostUsedTemplatesReport.php',
288288 'OrphanedPagesReport' => 'includes/reports/OrphanedPagesReport.php',
Index: branches/robchurch/reports/includes/QueryPage.php
@@ -16,8 +16,6 @@
1717 //----------------------------------------------------------------------------
1818 array( 'DisambiguationsPage', 'Disambiguations' ),
1919 array( 'MostimagesPage', 'Mostimages' ),
20 - array( 'MostrevisionsPage', 'Mostrevisions' ),
21 - array( 'FewestrevisionsPage', 'Fewestrevisions' ),
2220 array( 'UnusedCategoriesPage', 'Unusedcategories' ),
2321 array( 'UnusedimagesPage', 'Unusedimages' ),
2422 array( 'UnusedtemplatesPage', 'Unusedtemplates' ),
Index: branches/robchurch/reports/includes/SpecialPage.php
@@ -104,8 +104,8 @@
105105 'Mostlinkedtemplates' => 'MostUsedTemplatesReport',
106106 'Mostcategories' => 'MostCategoriesReport',
107107 'Mostusedimages' => 'MostUsedImagesReport',
108 - 'Mostrevisions' => array( 'SpecialPage', 'Mostrevisions' ),
109 - 'Fewestrevisions' => array( 'SpecialPage', 'Fewestrevisions' ),
 108+ 'Mostrevisions' => 'MostRevisionsReport',
 109+ 'Fewestrevisions' => 'FewestRevisionsReport',
110110 'Shortpages' => 'ShortPagesReport',
111111 'Longpages' => 'LongPagesReport',
112112 'Newpages' => 'SpecialNewPages',//array( 'IncludableSpecialPage', 'Newpages' ),
Index: branches/robchurch/reports/languages/messages/MessagesEn.php
@@ -1528,8 +1528,8 @@
15291529 'withoutinterwiki-header' => 'This report lists pages which do not link to other language editions.',
15301530
15311531 # Fewest revisions report
1532 -'fewestrevisions' => 'Articles with the fewest revisions',
1533 -'fewestrevisions-summary' => '', # only translate this message to other languages if you have to change it
 1532+'fewestrevisions' => 'Pages with the fewest revisions',
 1533+'fewestrevisions-header' => 'This report lists pages with the fewest number of revisions on the wiki.',
15341534
15351535 # Uncategorised pages report
15361536 'uncategorizedpages' => 'Uncategorized pages',
@@ -1586,8 +1586,8 @@
15871587 'mostcategories-header' => 'This report lists pages belonging to the largest number of categories.',
15881588 'mostusedimages' => 'Most used images',
15891589 'mostusedimages-header' => 'This report lists the most-used images on the wiki.',
1590 -'mostrevisions' => 'Articles with the most revisions',
1591 -'mostrevisions-summary' => '', # only translate this message to other languages if you have to change it
 1590+'mostrevisions' => 'Pages with the most revisions',
 1591+'mostrevisions-header' => 'This report lists pages with the greatest number of revisions on the wiki.',
15921592 'allpages' => 'All pages',
15931593 'allpages-summary' => '', # only translate this message to other languages if you have to change it
15941594 'prefixindex' => 'Prefix index',

Status & tagging log