Revert r39416, 39421, 39427, 39489, 39515, 39516 "Rewrite allpages to use a "tree...
[mediawiki.git] / includes / specials / SpecialShortpages.php
blob2e7d24a5a027a0ae6a1127c46e1cef285c766a4f
1 <?php
2 /**
3 * @file
4 * @ingroup SpecialPage
5 */
7 /**
8 * SpecialShortpages extends QueryPage. It is used to return the shortest
9 * pages in the database.
10 * @ingroup SpecialPage
12 class ShortPagesPage extends QueryPage {
14 function getName() {
15 return 'Shortpages';
18 /**
19 * This query is indexed as of 1.5
21 function isExpensive() {
22 return true;
25 function isSyndicated() {
26 return false;
29 function getSQL() {
30 global $wgContentNamespaces;
32 $dbr = wfGetDB( DB_SLAVE );
33 $page = $dbr->tableName( 'page' );
34 $name = $dbr->addQuotes( $this->getName() );
36 $forceindex = $dbr->useIndexClause("page_len");
38 if ($wgContentNamespaces)
39 $nsclause = "page_namespace IN (" . $dbr->makeList($wgContentNamespaces) . ")";
40 else
41 $nsclause = "page_namespace = " . NS_MAIN;
43 return
44 "SELECT $name as type,
45 page_namespace as namespace,
46 page_title as title,
47 page_len AS value
48 FROM $page $forceindex
49 WHERE $nsclause AND page_is_redirect=0";
52 function preprocessResults( $db, $res ) {
53 # There's no point doing a batch check if we aren't caching results;
54 # the page must exist for it to have been pulled out of the table
55 if( $this->isCached() ) {
56 $batch = new LinkBatch();
57 while( $row = $db->fetchObject( $res ) )
58 $batch->add( $row->namespace, $row->title );
59 $batch->execute();
60 if( $db->numRows( $res ) > 0 )
61 $db->dataSeek( $res, 0 );
65 function sortDescending() {
66 return false;
69 function formatResult( $skin, $result ) {
70 global $wgLang, $wgContLang;
71 $dm = $wgContLang->getDirMark();
73 $title = Title::makeTitleSafe( $result->namespace, $result->title );
74 if ( !$title ) {
75 return '<!-- Invalid title ' . htmlspecialchars( "{$result->namespace}:{$result->title}" ). '-->';
77 $hlink = $skin->makeKnownLinkObj( $title, wfMsgHtml( 'hist' ), 'action=history' );
78 $plink = $this->isCached()
79 ? $skin->makeLinkObj( $title )
80 : $skin->makeKnownLinkObj( $title );
81 $size = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ), $wgLang->formatNum( htmlspecialchars( $result->value ) ) );
83 return $title->exists()
84 ? "({$hlink}) {$dm}{$plink} {$dm}[{$size}]"
85 : "<s>({$hlink}) {$dm}{$plink} {$dm}[{$size}]</s>";
89 /**
90 * constructor
92 function wfSpecialShortpages() {
93 list( $limit, $offset ) = wfCheckLimits();
95 $spp = new ShortPagesPage();
97 return $spp->doQuery( $offset, $limit );