API * Better log events info * Added RAW debugging format
[mediawiki.git] / includes / SpecialShortpages.php
blob34b3505bbd4714908aec02e107481192d450875f
1 <?php
2 /**
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
8 /**
9 * SpecialShortpages extends QueryPage. It is used to return the shortest
10 * pages in the database.
11 * @package MediaWiki
12 * @subpackage SpecialPage
14 class ShortPagesPage extends QueryPage {
16 function getName() {
17 return "Shortpages";
20 /**
21 * This query is indexed as of 1.5
23 function isExpensive() {
24 return true;
27 function isSyndicated() {
28 return false;
31 function getSQL() {
32 $dbr =& wfGetDB( DB_SLAVE );
33 $page = $dbr->tableName( 'page' );
34 $name = $dbr->addQuotes( $this->getName() );
36 $forceindex = $dbr->useIndexClause("page_len");
37 return
38 "SELECT $name as type,
39 page_namespace as namespace,
40 page_title as title,
41 page_len AS value
42 FROM $page $forceindex
43 WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0";
46 function preprocessResults( &$dbo, $res ) {
47 # There's no point doing a batch check if we aren't caching results;
48 # the page must exist for it to have been pulled out of the table
49 if( $this->isCached() ) {
50 $batch = new LinkBatch();
51 while( $row = $dbo->fetchObject( $res ) )
52 $batch->addObj( Title::makeTitleSafe( $row->namespace, $row->title ) );
53 $batch->execute();
54 if( $dbo->numRows( $res ) > 0 )
55 $dbo->dataSeek( $res, 0 );
59 function sortDescending() {
60 return false;
63 function formatResult( $skin, $result ) {
64 global $wgLang, $wgContLang;
65 $dm = $wgContLang->getDirMark();
67 $title = Title::makeTitleSafe( $result->namespace, $result->title );
68 if ( !$title ) {
69 return '<!-- Invalid title ' . htmlspecialchars( "{$result->namespace}:{$result->title}" ). '-->';
71 $hlink = $skin->makeKnownLinkObj( $title, wfMsgHtml( 'hist' ), 'action=history' );
72 $plink = $this->isCached()
73 ? $skin->makeLinkObj( $title )
74 : $skin->makeKnownLinkObj( $title );
75 $size = wfMsgHtml( 'nbytes', $wgLang->formatNum( htmlspecialchars( $result->value ) ) );
77 return $title->exists()
78 ? "({$hlink}) {$dm}{$plink} {$dm}[{$size}]"
79 : "<s>({$hlink}) {$dm}{$plink} {$dm}[{$size}]</s>";
83 /**
84 * constructor
86 function wfSpecialShortpages() {
87 list( $limit, $offset ) = wfCheckLimits();
89 $spp = new ShortPagesPage();
91 return $spp->doQuery( $offset, $limit );