]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - includes/specials/SpecialFewestrevisions.php
MediaWiki 1.17.0
[autoinstalls/mediawiki.git] / includes / specials / SpecialFewestrevisions.php
1 <?php
2 /**
3  * Implements Special:Fewestrevisions
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  * http://www.gnu.org/copyleft/gpl.html
19  *
20  * @file
21  * @ingroup SpecialPage
22  */
23
24 /**
25  * Special page for listing the articles with the fewest revisions.
26  *
27  * @ingroup SpecialPage
28  * @author Martin Drashkov
29  */
30 class FewestrevisionsPage extends QueryPage {
31
32         function getName() {
33                 return 'Fewestrevisions';
34         }
35
36         function isExpensive() {
37                 return true;
38         }
39
40         function isSyndicated() {
41                 return false;
42         }
43
44         function getSql() {
45                 $dbr = wfGetDB( DB_SLAVE );
46                 list( $revision, $page ) = $dbr->tableNamesN( 'revision', 'page' );
47
48                 return "SELECT 'Fewestrevisions' as type,
49                                 page_namespace as namespace,
50                                 page_title as title,
51                                 page_is_redirect as redirect,
52                                 COUNT(*) as value
53                         FROM $revision
54                         JOIN $page ON page_id = rev_page
55                         WHERE page_namespace = " . NS_MAIN . "
56                         GROUP BY page_namespace, page_title, page_is_redirect
57                         HAVING COUNT(*) > 1";
58                         // ^^^ This was probably here to weed out redirects.
59                         // Since we mark them as such now, it might be
60                         // useful to remove this. People _do_ create pages
61                         // and never revise them, they aren't necessarily
62                         // redirects.
63         }
64
65         function sortDescending() {
66                 return false;
67         }
68
69         function formatResult( $skin, $result ) {
70                 global $wgLang, $wgContLang;
71
72                 $nt = Title::makeTitleSafe( $result->namespace, $result->title );
73                 if( !$nt ) {
74                         return '<!-- bad title -->';
75                 }
76
77                 $text = $wgContLang->convert( $nt->getPrefixedText() );
78
79                 $plink = $skin->linkKnown(
80                         $nt,
81                         $text
82                 );
83
84                 $nl = wfMsgExt( 'nrevisions', array( 'parsemag', 'escape' ),
85                         $wgLang->formatNum( $result->value ) );
86                 $redirect = $result->redirect ? ' - ' . wfMsgHtml( 'isredirect' ) : '';
87                 $nlink = $skin->linkKnown(
88                         $nt,
89                         $nl,
90                         array(),
91                         array( 'action' => 'history' )
92                 ) . $redirect;
93
94                 return wfSpecialList( $plink, $nlink );
95         }
96 }
97
98 function wfSpecialFewestrevisions() {
99         list( $limit, $offset ) = wfCheckLimits();
100         $frp = new FewestrevisionsPage();
101         $frp->doQuery( $offset, $limit );
102 }