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