* (bug 5338) Reject extra initial colons in title
[mediawiki.git] / includes / SpecialMostlinked.php
blob6b518606bb5657d50ec6449db184c661b307e458
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,
37 page_namespace
38 FROM $pagelinks
39 LEFT JOIN $page ON pl_namespace=page_namespace AND pl_title=page_title
40 GROUP BY pl_namespace,pl_title
41 HAVING COUNT(*) > 1";
44 function formatResult( $skin, $result ) {
45 global $wgContLang;
47 $nt = Title::makeTitle( $result->namespace, $result->title );
48 $text = $wgContLang->convert( $nt->getPrefixedText() );
50 if ( $this->isCached() )
51 $plink = $skin->makeKnownLink( $nt->getPrefixedText(), $text );
52 else {
53 $plink = is_null( $result->page_namespace )
54 ? $skin->makeBrokenLink( $nt->getPrefixedText(), $text )
55 : $skin->makeKnownLink( $nt->getPrefixedText(), $text );
58 $nl = wfMsg( 'nlinks', $result->value );
59 $nlink = $skin->makeKnownLink( $wgContLang->specialPage( 'Whatlinkshere' ), $nl, 'target=' . $nt->getPrefixedURL() );
61 return "{$plink} ({$nlink})";
65 /**
66 * constructor
68 function wfSpecialMostlinked() {
69 list( $limit, $offset ) = wfCheckLimits();
71 $wpp = new MostlinkedPage();
73 $wpp->doQuery( $offset, $limit );