MediaWiki
REL1_20
|
00001 <?php 00033 class MostlinkedPage extends QueryPage { 00034 00035 function __construct( $name = 'Mostlinked' ) { 00036 parent::__construct( $name ); 00037 } 00038 00039 function isExpensive() { return true; } 00040 function isSyndicated() { return false; } 00041 00042 function getQueryInfo() { 00043 return array ( 00044 'tables' => array ( 'pagelinks', 'page' ), 00045 'fields' => array ( 'namespace' => 'pl_namespace', 00046 'title' => 'pl_title', 00047 'value' => 'COUNT(*)', 00048 'page_namespace' ), 00049 'options' => array ( 'HAVING' => 'COUNT(*) > 1', 00050 'GROUP BY' => array( 'pl_namespace', 'pl_title', 00051 'page_namespace' ) ), 00052 'join_conds' => array ( 'page' => array ( 'LEFT JOIN', 00053 array ( 'page_namespace = pl_namespace', 00054 'page_title = pl_title' ) ) ) 00055 ); 00056 } 00057 00064 function preprocessResults( $db, $res ) { 00065 if ( $res->numRows() > 0 ) { 00066 $linkBatch = new LinkBatch(); 00067 foreach ( $res as $row ) { 00068 $linkBatch->add( $row->namespace, $row->title ); 00069 } 00070 $res->seek( 0 ); 00071 $linkBatch->execute(); 00072 } 00073 } 00074 00082 function makeWlhLink( $title, $caption ) { 00083 $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedDBkey() ); 00084 return Linker::linkKnown( $wlh, $caption ); 00085 } 00086 00094 function formatResult( $skin, $result ) { 00095 $title = Title::makeTitleSafe( $result->namespace, $result->title ); 00096 if ( !$title ) { 00097 return Html::element( 'span', array( 'class' => 'mw-invalidtitle' ), 00098 Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) ); 00099 } 00100 $link = Linker::link( $title ); 00101 $wlh = $this->makeWlhLink( $title, 00102 $this->msg( 'nlinks' )->numParams( $result->value )->escaped() ); 00103 return $this->getLanguage()->specialList( $link, $wlh ); 00104 } 00105 }