3 * A special page to show pages ordered by the number of pages linking to them
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
14 require_once 'QueryPage.php';
18 * @subpackage SpecialPage
20 class MostlinkedPage
extends QueryPage
{
22 function getName() { return 'Mostlinked'; }
23 function isExpensive() { return true; }
24 function isSyndicated() { return false; }
27 * Note: Getting page_namespace only works if $this->isCached() is false
30 $dbr =& wfGetDB( DB_SLAVE
);
31 extract( $dbr->tableNames( 'pagelinks', 'page' ) );
33 "SELECT 'Mostlinked' AS type,
34 pl_namespace AS namespace,
40 LEFT JOIN $page ON pl_namespace=page_namespace AND pl_title=page_title
41 GROUP BY pl_namespace,pl_title
45 function formatResult( $skin, $result ) {
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 );
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})";
69 function wfSpecialMostlinked() {
70 list( $limit, $offset ) = wfCheckLimits();
72 $wpp = new MostlinkedPage();
74 $wpp->doQuery( $offset, $limit );