ShortPages and LongPages are almsot identical; remove some duplication.
[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
29 function getSQL() {
30 $dbr =& wfGetDB( DB_SLAVE );
31 $cur = $dbr->tableName( 'cur' );
32 $name = $dbr->addQuotes( $this->getName() );
33
34 return
35 "SELECT $name as type,
36 cur_namespace as namespace,
37 cur_title as title,
38 LENGTH(cur_text) AS value
39 FROM $cur
40 WHERE cur_namespace=0 AND cur_is_redirect=0";
41 }
42
43 function sortDescending() {
44 return false;
45 }
46
47 function formatResult( $skin, $result ) {
48 global $wgLang;
49 $nb = wfMsg( "nbytes", $wgLang->formatNum( $result->value ) );
50 $link = $skin->makeKnownLink( $result->title, "" );
51 return "{$link} ({$nb})";
52 }
53 }
54
55 /**
56 * constructor
57 */
58 function wfSpecialShortpages() {
59 list( $limit, $offset ) = wfCheckLimits();
60
61 $spp = new ShortPagesPage();
62
63 return $spp->doQuery( $offset, $limit );
64 }
65
66 ?>