wfMsgForContentNoTrans() was removed
[mediawiki.git] / includes / specials / SpecialMostlinked.php
blob019df4937af49cbece50dd61db4baabd51879456
1 <?php
2 /**
3 * Implements Special:Mostlinked
5 * Copyright © 2005 Ævar Arnfjörð Bjarmason, 2006 Rob Church
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * http://www.gnu.org/copyleft/gpl.html
22 * @file
23 * @ingroup SpecialPage
24 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
25 * @author Rob Church <robchur@gmail.com>
28 /**
29 * A special page to show pages ordered by the number of pages linking to them.
31 * @ingroup SpecialPage
33 class MostlinkedPage extends QueryPage {
34 function __construct( $name = 'Mostlinked' ) {
35 parent::__construct( $name );
38 public function isExpensive() {
39 return true;
42 function isSyndicated() {
43 return false;
46 public function getQueryInfo() {
47 return array(
48 'tables' => array( 'pagelinks', 'page' ),
49 'fields' => array(
50 'namespace' => 'pl_namespace',
51 'title' => 'pl_title',
52 'value' => 'COUNT(*)',
53 'page_namespace'
55 'options' => array(
56 'HAVING' => 'COUNT(*) > 1',
57 'GROUP BY' => array(
58 'pl_namespace', 'pl_title',
59 'page_namespace'
62 'join_conds' => array(
63 'page' => array(
64 'LEFT JOIN',
65 array(
66 'page_namespace = pl_namespace',
67 'page_title = pl_title'
74 /**
75 * Pre-fill the link cache
77 * @param IDatabase $db
78 * @param ResultWrapper $res
80 function preprocessResults( $db, $res ) {
81 if ( $res->numRows() > 0 ) {
82 $linkBatch = new LinkBatch();
84 foreach ( $res as $row ) {
85 $linkBatch->add( $row->namespace, $row->title );
88 $res->seek( 0 );
89 $linkBatch->execute();
93 /**
94 * Make a link to "what links here" for the specified title
96 * @param Title $title Title being queried
97 * @param string $caption Text to display on the link
98 * @return string
100 function makeWlhLink( $title, $caption ) {
101 $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedDBkey() );
103 return Linker::linkKnown( $wlh, $caption );
107 * Make links to the page corresponding to the item,
108 * and the "what links here" page for it
110 * @param Skin $skin Skin to be used
111 * @param object $result Result row
112 * @return string
114 function formatResult( $skin, $result ) {
115 $title = Title::makeTitleSafe( $result->namespace, $result->title );
116 if ( !$title ) {
117 return Html::element(
118 'span',
119 array( 'class' => 'mw-invalidtitle' ),
120 Linker::getInvalidTitleDescription(
121 $this->getContext(),
122 $result->namespace,
123 $result->title )
127 $link = Linker::link( $title );
128 $wlh = $this->makeWlhLink(
129 $title,
130 $this->msg( 'nlinks' )->numParams( $result->value )->escaped()
133 return $this->getLanguage()->specialList( $link, $wlh );
136 protected function getGroupName() {
137 return 'highuse';