MediaWiki
REL1_24
|
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( 00044 'namespace' => 'page_namespace', 00045 'title' => 'page_title', 00046 'value' => 'page_len' 00047 ), 00048 'conds' => array( 00049 'page_namespace' => MWNamespace::getContentNamespaces(), 00050 'page_is_redirect' => 0 00051 ), 00052 'options' => array( 'USE INDEX' => 'page_redirect_namespace_len' ) 00053 ); 00054 } 00055 00056 function getOrderFields() { 00057 return array( 'page_len' ); 00058 } 00059 00064 function preprocessResults( $db, $res ) { 00065 # There's no point doing a batch check if we aren't caching results; 00066 # the page must exist for it to have been pulled out of the table 00067 if ( !$this->isCached() || !$res->numRows() ) { 00068 return; 00069 } 00070 00071 $batch = new LinkBatch(); 00072 foreach ( $res as $row ) { 00073 $batch->add( $row->namespace, $row->title ); 00074 } 00075 $batch->execute(); 00076 00077 $res->seek( 0 ); 00078 } 00079 00080 function sortDescending() { 00081 return false; 00082 } 00083 00089 function formatResult( $skin, $result ) { 00090 $dm = $this->getLanguage()->getDirMark(); 00091 00092 $title = Title::makeTitleSafe( $result->namespace, $result->title ); 00093 if ( !$title ) { 00094 return Html::element( 'span', array( 'class' => 'mw-invalidtitle' ), 00095 Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) ); 00096 } 00097 00098 $hlink = Linker::linkKnown( 00099 $title, 00100 $this->msg( 'hist' )->escaped(), 00101 array(), 00102 array( 'action' => 'history' ) 00103 ); 00104 $hlinkInParentheses = $this->msg( 'parentheses' )->rawParams( $hlink )->escaped(); 00105 00106 if ( $this->isCached() ) { 00107 $plink = Linker::link( $title ); 00108 $exists = $title->exists(); 00109 } else { 00110 $plink = Linker::linkKnown( $title ); 00111 $exists = true; 00112 } 00113 00114 $size = $this->msg( 'nbytes' )->numParams( $result->value )->escaped(); 00115 00116 return $exists 00117 ? "${hlinkInParentheses} {$dm}{$plink} {$dm}[{$size}]" 00118 : "<del>${hlinkInParentheses} {$dm}{$plink} {$dm}[{$size}]</del>"; 00119 } 00120 00121 protected function getGroupName() { 00122 return 'maintenance'; 00123 } 00124 }