Fix bug http://bugzilla.wikipedia.org/show_bug.cgi?id=705
[lhc/web/wiklou.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 function isExpensive() {
26 return true;
27 }
28 function isSyndicated() { return false; }
29
30 function getSQL() {
31 $dbr =& wfGetDB( DB_SLAVE );
32 $cur = $dbr->tableName( 'cur' );
33 $name = $dbr->addQuotes( $this->getName() );
34
35 return
36 "SELECT $name as type,
37 cur_namespace as namespace,
38 cur_title as title,
39 LENGTH(cur_text) AS value
40 FROM $cur
41 WHERE cur_namespace=0 AND cur_is_redirect=0";
42 }
43
44 function sortDescending() {
45 return false;
46 }
47
48 function formatResult( $skin, $result ) {
49 global $wgLang, $wgContLang;
50 $nb = wfMsg( "nbytes", $wgLang->formatNum( $result->value ) );
51 $link = $skin->makeKnownLink( $result->title, $wgContLang->convert( $result->title ) );
52 return "{$link} ({$nb})";
53 }
54 }
55
56 /**
57 * constructor
58 */
59 function wfSpecialShortpages() {
60 list( $limit, $offset ) = wfCheckLimits();
61
62 $spp = new ShortPagesPage();
63
64 return $spp->doQuery( $offset, $limit );
65 }
66
67 ?>