MediaWiki  REL1_22
SpecialShortpages.php
Go to the documentation of this file.
00001 <?php
00030 class ShortPagesPage extends QueryPage {
00031 
00032     function __construct( $name = 'Shortpages' ) {
00033         parent::__construct( $name );
00034     }
00035 
00036     function isSyndicated() {
00037         return false;
00038     }
00039 
00040     function getQueryInfo() {
00041         return array(
00042             'tables' => array( 'page' ),
00043             'fields' => array( 'namespace' => 'page_namespace',
00044                     'title' => 'page_title',
00045                     'value' => 'page_len' ),
00046             'conds' => array( 'page_namespace' =>
00047                     MWNamespace::getContentNamespaces(),
00048                     'page_is_redirect' => 0 ),
00049             'options' => array( 'USE INDEX' => 'page_redirect_namespace_len' )
00050         );
00051     }
00052 
00053     function getOrderFields() {
00054         return array( 'page_len' );
00055     }
00056 
00061     function preprocessResults( $db, $res ) {
00062         # There's no point doing a batch check if we aren't caching results;
00063         # the page must exist for it to have been pulled out of the table
00064         if ( !$this->isCached() || !$res->numRows() ) {
00065             return;
00066         }
00067 
00068         $batch = new LinkBatch();
00069         foreach ( $res as $row ) {
00070             $batch->add( $row->namespace, $row->title );
00071         }
00072         $batch->execute();
00073 
00074         $res->seek( 0 );
00075     }
00076 
00077     function sortDescending() {
00078         return false;
00079     }
00080 
00086     function formatResult( $skin, $result ) {
00087         $dm = $this->getLanguage()->getDirMark();
00088 
00089         $title = Title::makeTitleSafe( $result->namespace, $result->title );
00090         if ( !$title ) {
00091             return Html::element( 'span', array( 'class' => 'mw-invalidtitle' ),
00092                 Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) );
00093         }
00094 
00095         $hlink = Linker::linkKnown(
00096             $title,
00097             $this->msg( 'hist' )->escaped(),
00098             array(),
00099             array( 'action' => 'history' )
00100         );
00101         $hlinkInParentheses = $this->msg( 'parentheses' )->rawParams( $hlink )->escaped();
00102 
00103         if ( $this->isCached() ) {
00104             $plink = Linker::link( $title );
00105             $exists = $title->exists();
00106         } else {
00107             $plink = Linker::linkKnown( $title );
00108             $exists = true;
00109         }
00110 
00111         $size = $this->msg( 'nbytes' )->numParams( $result->value )->escaped();
00112 
00113         return $exists
00114                 ? "${hlinkInParentheses} {$dm}{$plink} {$dm}[{$size}]"
00115                 : "<del>${hlinkInParentheses} {$dm}{$plink} {$dm}[{$size}]</del>";
00116     }
00117 
00118     protected function getGroupName() {
00119         return 'maintenance';
00120     }
00121 }