8 * SpecialShortpages extends QueryPage. It is used to return the shortest
9 * pages in the database.
10 * @ingroup SpecialPage
12 class ShortPagesPage
extends QueryPage
{
19 * This query is indexed as of 1.5
21 function isExpensive() {
25 function isSyndicated() {
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) . ")";
41 $nsclause = "page_namespace = " . NS_MAIN
;
44 "SELECT $name as type,
45 page_namespace as namespace,
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
);
60 if( $db->numRows( $res ) > 0 )
61 $db->dataSeek( $res, 0 );
65 function sortDescending() {
69 function formatResult( $skin, $result ) {
70 global $wgLang, $wgContLang;
71 $dm = $wgContLang->getDirMark();
73 $title = Title
::makeTitleSafe( $result->namespace, $result->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>";
92 function wfSpecialShortpages() {
93 list( $limit, $offset ) = wfCheckLimits();
95 $spp = new ShortPagesPage();
97 return $spp->doQuery( $offset, $limit );