MediaWiki  master
SpecialMostlinkedcategories.php
Go to the documentation of this file.
00001 <?php
00032 class MostlinkedCategoriesPage extends QueryPage {
00033 
00034         function __construct( $name = 'Mostlinkedcategories' ) {
00035                 parent::__construct( $name );
00036         }
00037 
00038         function isSyndicated() {
00039                 return false;
00040         }
00041 
00042         function getQueryInfo() {
00043                 return array (
00044                         'tables' => array ( 'category' ),
00045                         'fields' => array ( 'title' => 'cat_title',
00046                                         'namespace' => NS_CATEGORY,
00047                                         'value' => 'cat_pages' ),
00048                 );
00049         }
00050 
00051         function sortDescending() {
00052                 return true;
00053         }
00054 
00061         function preprocessResults( $db, $res ) {
00062                 if ( !$res->numRows() ) {
00063                         return;
00064                 }
00065 
00066                 $batch = new LinkBatch;
00067                 foreach ( $res as $row ) {
00068                         $batch->add( NS_CATEGORY, $row->title );
00069                 }
00070                 $batch->execute();
00071 
00072                 // Back to start for display
00073                 $res->seek( 0 );
00074         }
00075 
00081         function formatResult( $skin, $result ) {
00082                 global $wgContLang;
00083 
00084                 $nt = Title::makeTitleSafe( NS_CATEGORY, $result->title );
00085                 if ( !$nt ) {
00086                         return Html::element( 'span', array( 'class' => 'mw-invalidtitle' ),
00087                                 Linker::getInvalidTitleDescription( $this->getContext(), NS_CATEGORY, $result->title ) );
00088                 }
00089 
00090                 $text = $wgContLang->convert( $nt->getText() );
00091 
00092                 $plink = Linker::link( $nt, htmlspecialchars( $text ) );
00093 
00094                 $nlinks = $this->msg( 'nmembers' )->numParams( $result->value )->escaped();
00095                 return $this->getLanguage()->specialList( $plink, $nlinks );
00096         }
00097 }