* Reorganised the includes directory, creating subdirectories db, parser and specials
[lhc/web/wiklou.git] / includes / specials / Fewestrevisions.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 COUNT(*) as value
35 FROM $revision
36 JOIN $page ON page_id = rev_page
37 WHERE page_namespace = " . NS_MAIN . "
38 GROUP BY 1,2,3
39 HAVING COUNT(*) > 1";
40 }
41
42 function sortDescending() {
43 return false;
44 }
45
46 function formatResult( $skin, $result ) {
47 global $wgLang, $wgContLang;
48
49 $nt = Title::makeTitleSafe( $result->namespace, $result->title );
50 $text = $wgContLang->convert( $nt->getPrefixedText() );
51
52 $plink = $skin->makeKnownLinkObj( $nt, $text );
53
54 $nl = wfMsgExt( 'nrevisions', array( 'parsemag', 'escape'),
55 $wgLang->formatNum( $result->value ) );
56 $nlink = $skin->makeKnownLinkObj( $nt, $nl, 'action=history' );
57
58 return wfSpecialList( $plink, $nlink );
59 }
60 }
61
62 function wfSpecialFewestrevisions() {
63 list( $limit, $offset ) = wfCheckLimits();
64 $frp = new FewestrevisionsPage();
65 $frp->doQuery( $offset, $limit );
66 }