Fix #2571: Duplicate anchors and missing form id tag in search form on Cologne Blue...
[mediawiki.git] / includes / SpecialMostlinked.php
blob28a209eeaf9e4a7ef5f66aba63df12a9c9fd4f4f
1 <?php
2 /**
3 * A special page to show pages ordered by the number of pages linking to them
5 * @package MediaWiki
6 * @subpackage SpecialPage
8 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
9 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
10 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
13 /* */
14 require_once 'QueryPage.php';
16 /**
17 * @package MediaWiki
18 * @subpackage SpecialPage
20 class MostlinkedPage extends QueryPage {
22 function getName() { return 'Mostlinked'; }
23 function isExpensive() { return true; }
24 function isSyndicated() { return false; }
26 /**
27 * Note: Getting page_namespace only works if $this->isCached() is false
29 function getSQL() {
30 $dbr =& wfGetDB( DB_SLAVE );
31 extract( $dbr->tableNames( 'pagelinks', 'page' ) );
32 return
33 "SELECT 'Mostlinked' AS type,
34 pl_namespace AS namespace,
35 pl_title AS title,
36 COUNT(*) AS value,
38 page_namespace
39 FROM $pagelinks
40 LEFT JOIN $page ON pl_namespace=page_namespace AND pl_title=page_title
41 GROUP BY pl_namespace,pl_title
42 HAVING COUNT(*) > 1";
45 function formatResult( $skin, $result ) {
46 global $wgContLang;
48 $nt = Title::makeTitle( $result->namespace, $result->title );
49 $text = $wgContLang->convert( $nt->getPrefixedText() );
51 if ( $this->isCached() )
52 $plink = $skin->makeKnownLink( $nt->getPrefixedText(), $text );
53 else {
54 $plink = is_null( $result->page_namespace )
55 ? $skin->makeBrokenLink( $nt->getPrefixedText(), $text )
56 : $skin->makeKnownLink( $nt->getPrefixedText(), $text );
59 $nl = wfMsg( 'nlinks', $result->value );
60 $nlink = $skin->makeKnownLink( $wgContLang->specialPage( 'Whatlinkshere' ), $nl, 'target=' . $nt->getPrefixedURL() );
62 return "{$plink} ({$nlink})";
66 /**
67 * constructor
69 function wfSpecialMostlinked() {
70 list( $limit, $offset ) = wfCheckLimits();
72 $wpp = new MostlinkedPage();
74 $wpp->doQuery( $offset, $limit );