4 * @addtogroup SpecialPage
8 * SpecialShortpages extends QueryPage. It is used to return the shortest
9 * pages in the database.
10 * @addtogroup SpecialPage
12 class ShortPagesPage
extends QueryPage
{
19 * This query is indexed as of 1.5
21 function isExpensive() {
25 function isSyndicated() {
30 $dbr = wfGetDB( DB_SLAVE
);
31 $page = $dbr->tableName( 'page' );
32 $name = $dbr->addQuotes( $this->getName() );
34 $forceindex = $dbr->useIndexClause("page_len");
36 "SELECT $name as type,
37 page_namespace as namespace,
40 FROM $page $forceindex
41 WHERE page_namespace=".NS_MAIN
." AND page_is_redirect=0";
44 function preprocessResults( &$db, &$res ) {
45 # There's no point doing a batch check if we aren't caching results;
46 # the page must exist for it to have been pulled out of the table
47 if( $this->isCached() ) {
48 $batch = new LinkBatch();
49 while( $row = $db->fetchObject( $res ) )
50 $batch->addObj( Title
::makeTitleSafe( $row->namespace, $row->title
) );
52 if( $db->numRows( $res ) > 0 )
53 $db->dataSeek( $res, 0 );
57 function sortDescending() {
61 function formatResult( $skin, $result ) {
62 global $wgLang, $wgContLang;
63 $dm = $wgContLang->getDirMark();
65 $title = Title
::makeTitleSafe( $result->namespace, $result->title
);
67 return '<!-- Invalid title ' . htmlspecialchars( "{$result->namespace}:{$result->title}" ). '-->';
69 $hlink = $skin->makeKnownLinkObj( $title, wfMsgHtml( 'hist' ), 'action=history' );
70 $plink = $this->isCached()
71 ?
$skin->makeLinkObj( $title )
72 : $skin->makeKnownLinkObj( $title );
73 $size = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ), $wgLang->formatNum( htmlspecialchars( $result->value
) ) );
75 return $title->exists()
76 ?
"({$hlink}) {$dm}{$plink} {$dm}[{$size}]"
77 : "<s>({$hlink}) {$dm}{$plink} {$dm}[{$size}]</s>";
84 function wfSpecialShortpages() {
85 list( $limit, $offset ) = wfCheckLimits();
87 $spp = new ShortPagesPage();
89 return $spp->doQuery( $offset, $limit );