MediaWiki  REL1_22
SpecialMostinterwikis.php
Go to the documentation of this file.
00001 <?php
00032 class MostinterwikisPage extends QueryPage {
00033     function __construct( $name = 'Mostinterwikis' ) {
00034         parent::__construct( $name );
00035     }
00036 
00037     function isExpensive() {
00038         return true;
00039     }
00040 
00041     function isSyndicated() {
00042         return false;
00043     }
00044 
00045     function getQueryInfo() {
00046         return array(
00047             'tables' => array(
00048                 'langlinks',
00049                 'page'
00050             ), 'fields' => array(
00051                 'namespace' => 'page_namespace',
00052                 'title' => 'page_title',
00053                 'value' => 'COUNT(*)'
00054             ), 'conds' => array(
00055                 'page_namespace' => MWNamespace::getContentNamespaces()
00056             ), 'options' => array(
00057                 'HAVING' => 'COUNT(*) > 1',
00058                 'GROUP BY' => array(
00059                     'page_namespace',
00060                     'page_title'
00061                 )
00062             ), 'join_conds' => array(
00063                 'page' => array(
00064                     'LEFT JOIN',
00065                     'page_id = ll_from'
00066                 )
00067             )
00068         );
00069     }
00070 
00077     function preprocessResults( $db, $res ) {
00078         # There's no point doing a batch check if we aren't caching results;
00079         # the page must exist for it to have been pulled out of the table
00080         if ( !$this->isCached() || !$res->numRows() ) {
00081             return;
00082         }
00083 
00084         $batch = new LinkBatch;
00085         foreach ( $res as $row ) {
00086             $batch->add( $row->namespace, $row->title );
00087         }
00088         $batch->execute();
00089 
00090         // Back to start for display
00091         $res->seek( 0 );
00092     }
00093 
00099     function formatResult( $skin, $result ) {
00100         $title = Title::makeTitleSafe( $result->namespace, $result->title );
00101         if ( !$title ) {
00102             return Html::element(
00103                 'span',
00104                 array( 'class' => 'mw-invalidtitle' ),
00105                 Linker::getInvalidTitleDescription(
00106                     $this->getContext(),
00107                     $result->namespace,
00108                     $result->title
00109                 )
00110             );
00111         }
00112 
00113         if ( $this->isCached() ) {
00114             $link = Linker::link( $title );
00115         } else {
00116             $link = Linker::linkKnown( $title );
00117         }
00118 
00119         $count = $this->msg( 'ninterwikis' )->numParams( $result->value )->escaped();
00120 
00121         return $this->getLanguage()->specialList( $link, $count );
00122     }
00123 
00124     protected function getGroupName() {
00125         return 'highuse';
00126     }
00127 }