MediaWiki
REL1_20
|
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 00062 function preprocessResults( $db, $res ) { 00063 # There's no point doing a batch check if we aren't caching results; 00064 # the page must exist for it to have been pulled out of the table 00065 if ( !$this->isCached() || !$res->numRows() ) { 00066 return; 00067 } 00068 00069 $batch = new LinkBatch(); 00070 foreach ( $res as $row ) { 00071 $batch->add( $row->namespace, $row->title ); 00072 } 00073 $batch->execute(); 00074 00075 $res->seek( 0 ); 00076 } 00077 00078 function sortDescending() { 00079 return false; 00080 } 00081 00082 function formatResult( $skin, $result ) { 00083 $dm = $this->getLanguage()->getDirMark(); 00084 00085 $title = Title::makeTitleSafe( $result->namespace, $result->title ); 00086 if ( !$title ) { 00087 return Html::element( 'span', array( 'class' => 'mw-invalidtitle' ), 00088 Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) ); 00089 } 00090 00091 $hlink = Linker::linkKnown( 00092 $title, 00093 $this->msg( 'hist' )->escaped(), 00094 array(), 00095 array( 'action' => 'history' ) 00096 ); 00097 $hlinkInParentheses = $this->msg( 'parentheses' )->rawParams( $hlink )->escaped(); 00098 00099 if ( $this->isCached() ) { 00100 $plink = Linker::link( $title ); 00101 $exists = $title->exists(); 00102 } else { 00103 $plink = Linker::linkKnown( $title ); 00104 $exists = true; 00105 } 00106 00107 $size = $this->msg( 'nbytes' )->numParams( $result->value )->escaped(); 00108 00109 return $exists 00110 ? "${hlinkInParentheses} {$dm}{$plink} {$dm}[{$size}]" 00111 : "<del>${hlinkInParentheses} {$dm}{$plink} {$dm}[{$size}]</del>"; 00112 } 00113 }