]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - includes/specials/SpecialFewestrevisions.php
MediaWiki 1.16.0
[autoinstalls/mediawiki.git] / includes / specials / SpecialFewestrevisions.php
1 <?php
2 /**
3  * @file
4  * @ingroup SpecialPage
5  */
6
7 /**
8  * Special page for listing the articles with the fewest revisions.
9  *
10  * @ingroup SpecialPage
11  * @author Martin Drashkov
12  */
13 class FewestrevisionsPage extends QueryPage {
14
15         function getName() {
16                 return 'Fewestrevisions';
17         }
18
19         function isExpensive() {
20                 return true;
21         }
22
23         function isSyndicated() {
24                 return false;
25         }
26
27         function getSql() {
28                 $dbr = wfGetDB( DB_SLAVE );
29                 list( $revision, $page ) = $dbr->tableNamesN( 'revision', 'page' );
30
31                 return "SELECT 'Fewestrevisions' as type,
32                                 page_namespace as namespace,
33                                 page_title as title,
34                                 page_is_redirect as redirect,
35                                 COUNT(*) as value
36                         FROM $revision
37                         JOIN $page ON page_id = rev_page
38                         WHERE page_namespace = " . NS_MAIN . "
39                         GROUP BY page_namespace, page_title, page_is_redirect
40                         HAVING COUNT(*) > 1";
41                         // ^^^ This was probably here to weed out redirects.
42                         // Since we mark them as such now, it might be
43                         // useful to remove this. People _do_ create pages
44                         // and never revise them, they aren't necessarily
45                         // redirects.
46         }
47
48         function sortDescending() {
49                 return false;
50         }
51
52         function formatResult( $skin, $result ) {
53                 global $wgLang, $wgContLang;
54
55                 $nt = Title::makeTitleSafe( $result->namespace, $result->title );
56                 if( !$nt ) {
57                         return '<!-- bad title -->';
58                 }
59
60                 $text = $wgContLang->convert( $nt->getPrefixedText() );
61
62                 $plink = $skin->linkKnown(
63                         $nt,
64                         $text
65                 );
66
67                 $nl = wfMsgExt( 'nrevisions', array( 'parsemag', 'escape' ),
68                         $wgLang->formatNum( $result->value ) );
69                 $redirect = $result->redirect ? ' - ' . wfMsgHtml( 'isredirect' ) : '';
70                 $nlink = $skin->linkKnown(
71                         $nt,
72                         $nl,
73                         array(),
74                         array( 'action' => 'history' )
75                 ) . $redirect;
76
77                 return wfSpecialList( $plink, $nlink );
78         }
79 }
80
81 function wfSpecialFewestrevisions() {
82         list( $limit, $offset ) = wfCheckLimits();
83         $frp = new FewestrevisionsPage();
84         $frp->doQuery( $offset, $limit );
85 }