Re-commit r34072 with some modifications:
[lhc/web/wiklou.git] / includes / SpecialFewestrevisions.php
1 <?php
2
3 /**
4 * Special page for listing the articles with the fewest revisions.
5 *
6 * @addtogroup SpecialPage
7 * @author Martin Drashkov
8 */
9 class FewestrevisionsPage extends QueryPage {
10
11 function getName() {
12 return 'Fewestrevisions';
13 }
14
15 function isExpensive() {
16 return true;
17 }
18
19 function isSyndicated() {
20 return false;
21 }
22
23 function getSql() {
24 $dbr = wfGetDB( DB_SLAVE );
25 list( $revision, $page ) = $dbr->tableNamesN( 'revision', 'page' );
26
27 return "SELECT 'Fewestrevisions' as type,
28 page_namespace as namespace,
29 page_title as title,
30 COUNT(*) as value
31 FROM $revision
32 JOIN $page ON page_id = rev_page
33 WHERE page_namespace = " . NS_MAIN . "
34 GROUP BY 1,2,3
35 HAVING COUNT(*) > 1";
36 }
37
38 function sortDescending() {
39 return false;
40 }
41
42 function formatResult( $skin, $result ) {
43 global $wgLang, $wgContLang;
44
45 $nt = Title::makeTitleSafe( $result->namespace, $result->title );
46 $text = $wgContLang->convert( $nt->getPrefixedText() );
47
48 $plink = $skin->makeKnownLinkObj( $nt, $text );
49
50 $nl = wfMsgExt( 'nrevisions', array( 'parsemag', 'escape'),
51 $wgLang->formatNum( $result->value ) );
52 $nlink = $skin->makeKnownLinkObj( $nt, $nl, 'action=history' );
53
54 return wfSpecialList( $plink, $nlink );
55 }
56 }
57
58 function wfSpecialFewestrevisions() {
59 list( $limit, $offset ) = wfCheckLimits();
60 $frp = new FewestrevisionsPage();
61 $frp->doQuery( $offset, $limit );
62 }