]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - includes/SpecialShortpages.php
MediaWiki 1.5.8 (initial commit)
[autoinstallsdev/mediawiki.git] / includes / SpecialShortpages.php
1 <?php
2 /**
3  *
4  * @package MediaWiki
5  * @subpackage SpecialPage
6  */
7
8 /**
9  *
10  */
11 require_once("QueryPage.php");
12
13 /**
14  * SpecialShortpages extends QueryPage. It is used to return the shortest
15  * pages in the database.
16  * @package MediaWiki
17  * @subpackage SpecialPage
18  */
19 class ShortPagesPage extends QueryPage {
20
21         function getName() {
22                 return "Shortpages";
23         }
24
25         /**
26          * This query is indexed as of 1.5
27          */
28         function isExpensive() {
29                 return false;
30         }
31         
32         function isSyndicated() {
33                 return false;
34         }
35
36         function getSQL() {
37                 $dbr =& wfGetDB( DB_SLAVE );
38                 $page = $dbr->tableName( 'page' );
39                 $name = $dbr->addQuotes( $this->getName() );
40                 
41                 return
42                         "SELECT $name as type,
43                                         page_namespace as namespace,
44                                 page_title as title,
45                                 page_len AS value
46                         FROM $page
47                         WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0";
48         }
49         
50         function sortDescending() {
51                 return false;
52         }
53
54         function formatResult( $skin, $result ) {
55                 global $wgLang, $wgContLang;
56                 $nb = htmlspecialchars( wfMsg( "nbytes", $wgLang->formatNum( $result->value ) ) );
57                 $title = Title::makeTitle( $result->namespace, $result->title );
58                 $link = $skin->makeKnownLinkObj( $title, $wgContLang->convert( $title->getPrefixedText() ) );
59                 return "{$link} ({$nb})";
60         }
61 }
62
63 /**
64  * constructor
65  */
66 function wfSpecialShortpages() {
67         list( $limit, $offset ) = wfCheckLimits();
68
69         $spp = new ShortPagesPage();
70
71         return $spp->doQuery( $offset, $limit );
72 }
73
74 ?>