* Added a FIXME
[mediawiki.git] / includes / SpecialMostlinked.php
blobc7926380bb872c57d0309cb1b4b1f020530c1e03
1 <?php
2 /**
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
8 require_once ( 'QueryPage.php' ) ;
10 /**
12 * @package MediaWiki
13 * @subpackage SpecialPage
15 class MostlinkedPage extends QueryPage {
17 function getName() { return 'Mostlinked'; }
18 function isExpensive() { return true; }
19 function isSyndicated() { return false; }
21 function getSQL() {
22 $dbr =& wfGetDB( DB_SLAVE );
23 extract( $dbr->tableNames( 'pagelinks', 'page' ) );
24 return
25 "SELECT 'Mostlinked' AS type,
26 pl_namespace AS namespace,
27 pl_title AS title,
28 COUNT(*) AS value,
29 -- FIXME: The presence of this is a bug
30 page_namespace
31 FROM $pagelinks
32 LEFT JOIN $page ON pl_namespace=page_namespace AND pl_title=page_title
33 GROUP BY pl_namespace,pl_title
34 HAVING COUNT(*) > 1";
37 function formatResult( $skin, $result ) {
38 global $wgContLang;
40 $nt = Title::makeTitle( $result->namespace, $result->title );
41 $text = $wgContLang->convert( $nt->getPrefixedText() );
42 if ( is_null( $result->page_namespace ) )
43 $plink = $skin->makeBrokenLink( $nt->getPrefixedText(), $text );
44 else
45 $plink = $skin->makeKnownLink( $nt->getPrefixedText(), $text );
47 $nl = wfMsg( "nlinks", $result->value );
48 $nlink = $skin->makeKnownLink( $wgContLang->specialPage( "Whatlinkshere" ), $nl, "target=" . $nt->getPrefixedURL() );
50 return "{$plink} ({$nlink})";
54 /**
55 * constructor
57 function wfSpecialMostlinked() {
58 list( $limit, $offset ) = wfCheckLimits();
60 $wpp = new MostlinkedPage();
62 $wpp->doQuery( $offset, $limit );