useless call
[lhc/web/wiklou.git] / includes / SpecialMostlinked.php
1 <?php
2 /**
3 * A special page to show pages ordered by the number of pages linking to them
4 *
5 * @package MediaWiki
6 * @subpackage SpecialPage
7 *
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
11 */
12
13 /* */
14 require_once 'QueryPage.php';
15
16 /**
17 * @package MediaWiki
18 * @subpackage SpecialPage
19 */
20 class MostlinkedPage extends QueryPage {
21
22 function getName() { return 'Mostlinked'; }
23 function isExpensive() { return true; }
24 function isSyndicated() { return false; }
25
26 /**
27 * Note: Getting page_namespace only works if $this->isCached() is false
28 */
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
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";
43 }
44
45 function formatResult( $skin, $result ) {
46 global $wgContLang;
47
48 $nt = Title::makeTitle( $result->namespace, $result->title );
49 $text = $wgContLang->convert( $nt->getPrefixedText() );
50
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 );
57 }
58
59 $nl = wfMsg( 'nlinks', $result->value );
60 $nlink = $skin->makeKnownLink( $wgContLang->specialPage( 'Whatlinkshere' ), $nl, 'target=' . $nt->getPrefixedURL() );
61
62 return "{$plink} ({$nlink})";
63 }
64 }
65
66 /**
67 * constructor
68 */
69 function wfSpecialMostlinked() {
70 list( $limit, $offset ) = wfCheckLimits();
71
72 $wpp = new MostlinkedPage();
73
74 $wpp->doQuery( $offset, $limit );
75 }
76
77 ?>