* Added a FIXME
[lhc/web/wiklou.git] / includes / SpecialMostlinked.php
1 <?php
2 /**
3 *
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
7
8 require_once ( 'QueryPage.php' ) ;
9
10 /**
11 *
12 * @package MediaWiki
13 * @subpackage SpecialPage
14 */
15 class MostlinkedPage extends QueryPage {
16
17 function getName() { return 'Mostlinked'; }
18 function isExpensive() { return true; }
19 function isSyndicated() { return false; }
20
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";
35 }
36
37 function formatResult( $skin, $result ) {
38 global $wgContLang;
39
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 );
46
47 $nl = wfMsg( "nlinks", $result->value );
48 $nlink = $skin->makeKnownLink( $wgContLang->specialPage( "Whatlinkshere" ), $nl, "target=" . $nt->getPrefixedURL() );
49
50 return "{$plink} ({$nlink})";
51 }
52 }
53
54 /**
55 * constructor
56 */
57 function wfSpecialMostlinked() {
58 list( $limit, $offset ) = wfCheckLimits();
59
60 $wpp = new MostlinkedPage();
61
62 $wpp->doQuery( $offset, $limit );
63 }
64
65 ?>