MediaWiki
master
|
00001 <?php 00032 class MostcategoriesPage extends QueryPage { 00033 00034 function __construct( $name = 'Mostcategories' ) { 00035 parent::__construct( $name ); 00036 } 00037 00038 function isExpensive() { 00039 return true; 00040 } 00041 00042 function isSyndicated() { 00043 return false; 00044 } 00045 00046 function getQueryInfo() { 00047 return array ( 00048 'tables' => array ( 'categorylinks', 'page' ), 00049 'fields' => array ( 'namespace' => 'page_namespace', 00050 'title' => 'page_title', 00051 'value' => 'COUNT(*)' ), 00052 'conds' => array ( 'page_namespace' => MWNamespace::getContentNamespaces() ), 00053 'options' => array ( 'HAVING' => 'COUNT(*) > 1', 00054 'GROUP BY' => array( 'page_namespace', 'page_title' ) ), 00055 'join_conds' => array ( 'page' => array ( 'LEFT JOIN', 00056 'page_id = cl_from' ) ) 00057 ); 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 00085 function formatResult( $skin, $result ) { 00086 $title = Title::makeTitleSafe( $result->namespace, $result->title ); 00087 if ( !$title ) { 00088 return Html::element( 'span', array( 'class' => 'mw-invalidtitle' ), 00089 Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) ); 00090 } 00091 00092 if ( $this->isCached() ) { 00093 $link = Linker::link( $title ); 00094 } else { 00095 $link = Linker::linkKnown( $title ); 00096 } 00097 00098 $count = $this->msg( 'ncategories' )->numParams( $result->value )->escaped(); 00099 00100 return $this->getLanguage()->specialList( $link, $count ); 00101 } 00102 }