00001 <?php
00012 class ShortPagesPage extends QueryPage {
00013
00014 function getName() {
00015 return 'Shortpages';
00016 }
00017
00021 function isExpensive() {
00022 return true;
00023 }
00024
00025 function isSyndicated() {
00026 return false;
00027 }
00028
00029 function getSQL() {
00030 global $wgContentNamespaces;
00031
00032 $dbr = wfGetDB( DB_SLAVE );
00033 $page = $dbr->tableName( 'page' );
00034 $name = $dbr->addQuotes( $this->getName() );
00035
00036 $forceindex = $dbr->useIndexClause("page_len");
00037
00038 if ($wgContentNamespaces)
00039 $nsclause = "page_namespace IN (" . $dbr->makeList($wgContentNamespaces) . ")";
00040 else
00041 $nsclause = "page_namespace = " . NS_MAIN;
00042
00043 return
00044 "SELECT $name as type,
00045 page_namespace as namespace,
00046 page_title as title,
00047 page_len AS value
00048 FROM $page $forceindex
00049 WHERE $nsclause AND page_is_redirect=0";
00050 }
00051
00052 function preprocessResults( $db, $res ) {
00053 # There's no point doing a batch check if we aren't caching results;
00054 # the page must exist for it to have been pulled out of the table
00055 if( $this->isCached() ) {
00056 $batch = new LinkBatch();
00057 while( $row = $db->fetchObject( $res ) )
00058 $batch->add( $row->namespace, $row->title );
00059 $batch->execute();
00060 if( $db->numRows( $res ) > 0 )
00061 $db->dataSeek( $res, 0 );
00062 }
00063 }
00064
00065 function sortDescending() {
00066 return false;
00067 }
00068
00069 function formatResult( $skin, $result ) {
00070 global $wgLang, $wgContLang;
00071 $dm = $wgContLang->getDirMark();
00072
00073 $title = Title::makeTitleSafe( $result->namespace, $result->title );
00074 if ( !$title ) {
00075 return '<!-- Invalid title ' . htmlspecialchars( "{$result->namespace}:{$result->title}" ). '-->';
00076 }
00077 $hlink = $skin->makeKnownLinkObj( $title, wfMsgHtml( 'hist' ), 'action=history' );
00078 $plink = $this->isCached()
00079 ? $skin->makeLinkObj( $title )
00080 : $skin->makeKnownLinkObj( $title );
00081 $size = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ), $wgLang->formatNum( htmlspecialchars( $result->value ) ) );
00082
00083 return $title->exists()
00084 ? "({$hlink}) {$dm}{$plink} {$dm}[{$size}]"
00085 : "<s>({$hlink}) {$dm}{$plink} {$dm}[{$size}]</s>";
00086 }
00087 }
00088
00092 function wfSpecialShortpages() {
00093 list( $limit, $offset ) = wfCheckLimits();
00094
00095 $spp = new ShortPagesPage();
00096
00097 return $spp->doQuery( $offset, $limit );
00098 }