MediaWiki
REL1_19
|
00001 <?php 00031 class MostlinkedTemplatesPage extends QueryPage { 00032 00033 function __construct( $name = 'Mostlinkedtemplates' ) { 00034 parent::__construct( $name ); 00035 } 00036 00042 public function isExpensive() { 00043 return true; 00044 } 00045 00051 public function isSyndicated() { 00052 return false; 00053 } 00054 00060 public function sortDescending() { 00061 return true; 00062 } 00063 00064 public function getQueryInfo() { 00065 return array ( 00066 'tables' => array ( 'templatelinks' ), 00067 'fields' => array ( 'tl_namespace AS namespace', 00068 'tl_title AS title', 00069 'COUNT(*) AS value' ), 00070 'conds' => array ( 'tl_namespace' => NS_TEMPLATE ), 00071 'options' => array( 'GROUP BY' => 'tl_namespace, tl_title' ) 00072 ); 00073 } 00074 00081 public function preprocessResults( $db, $res ) { 00082 $batch = new LinkBatch(); 00083 foreach ( $res as $row ) { 00084 $batch->add( $row->namespace, $row->title ); 00085 } 00086 $batch->execute(); 00087 if( $db->numRows( $res ) > 0 ) 00088 $db->dataSeek( $res, 0 ); 00089 } 00090 00098 public function formatResult( $skin, $result ) { 00099 $title = Title::makeTitle( $result->namespace, $result->title ); 00100 00101 return $this->getLanguage()->specialList( 00102 Linker::link( $title ), 00103 $this->makeWlhLink( $title, $result ) 00104 ); 00105 } 00106 00114 private function makeWlhLink( $title, $result ) { 00115 $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() ); 00116 $label = $this->msg( 'ntransclusions' )->numParams( $result->value )->escaped(); 00117 return Linker::link( $wlh, $label ); 00118 } 00119 } 00120