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