2005-08-15 02:57:19 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
2005-09-16 15:07:07 +00:00
|
|
|
* A special page to show pages ordered by the number of pages linking to them
|
2005-08-15 02:57:19 +00:00
|
|
|
*
|
|
|
|
|
* @package MediaWiki
|
|
|
|
|
* @subpackage SpecialPage
|
2005-09-16 15:07:07 +00:00
|
|
|
*
|
|
|
|
|
* @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
|
2005-09-27 19:50:49 +00:00
|
|
|
* @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
|
2005-09-16 15:07:07 +00:00
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
|
2005-08-15 02:57:19 +00:00
|
|
|
*/
|
|
|
|
|
|
2005-09-16 15:07:07 +00:00
|
|
|
/* */
|
|
|
|
|
require_once 'QueryPage.php';
|
2005-08-15 02:57:19 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @package MediaWiki
|
|
|
|
|
* @subpackage SpecialPage
|
|
|
|
|
*/
|
|
|
|
|
class MostlinkedPage extends QueryPage {
|
|
|
|
|
|
2005-09-13 17:33:33 +00:00
|
|
|
function getName() { return 'Mostlinked'; }
|
|
|
|
|
function isExpensive() { return true; }
|
2005-08-15 02:57:19 +00:00
|
|
|
function isSyndicated() { return false; }
|
|
|
|
|
|
2005-09-16 15:07:07 +00:00
|
|
|
/**
|
|
|
|
|
* Note: Getting page_namespace only works if $this->isCached() is false
|
|
|
|
|
*/
|
2005-08-15 02:57:19 +00:00
|
|
|
function getSQL() {
|
|
|
|
|
$dbr =& wfGetDB( DB_SLAVE );
|
|
|
|
|
extract( $dbr->tableNames( 'pagelinks', 'page' ) );
|
|
|
|
|
return
|
|
|
|
|
"SELECT 'Mostlinked' AS type,
|
|
|
|
|
pl_namespace AS namespace,
|
|
|
|
|
pl_title AS title,
|
|
|
|
|
COUNT(*) AS value,
|
2005-09-16 15:07:07 +00:00
|
|
|
|
2005-08-15 02:57:19 +00:00
|
|
|
page_namespace
|
|
|
|
|
FROM $pagelinks
|
|
|
|
|
LEFT JOIN $page ON pl_namespace=page_namespace AND pl_title=page_title
|
|
|
|
|
GROUP BY pl_namespace,pl_title
|
|
|
|
|
HAVING COUNT(*) > 1";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatResult( $skin, $result ) {
|
|
|
|
|
global $wgContLang;
|
|
|
|
|
|
|
|
|
|
$nt = Title::makeTitle( $result->namespace, $result->title );
|
|
|
|
|
$text = $wgContLang->convert( $nt->getPrefixedText() );
|
2005-09-16 15:07:07 +00:00
|
|
|
|
|
|
|
|
if ( $this->isCached() )
|
2005-08-15 02:57:19 +00:00
|
|
|
$plink = $skin->makeKnownLink( $nt->getPrefixedText(), $text );
|
2005-09-16 15:07:07 +00:00
|
|
|
else {
|
|
|
|
|
$plink = is_null( $result->page_namespace )
|
|
|
|
|
? $skin->makeBrokenLink( $nt->getPrefixedText(), $text )
|
|
|
|
|
: $skin->makeKnownLink( $nt->getPrefixedText(), $text );
|
|
|
|
|
}
|
2005-08-15 02:57:19 +00:00
|
|
|
|
2005-09-16 15:07:07 +00:00
|
|
|
$nl = wfMsg( 'nlinks', $result->value );
|
|
|
|
|
$nlink = $skin->makeKnownLink( $wgContLang->specialPage( 'Whatlinkshere' ), $nl, 'target=' . $nt->getPrefixedURL() );
|
2005-08-15 02:57:19 +00:00
|
|
|
|
|
|
|
|
return "{$plink} ({$nlink})";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* constructor
|
|
|
|
|
*/
|
|
|
|
|
function wfSpecialMostlinked() {
|
|
|
|
|
list( $limit, $offset ) = wfCheckLimits();
|
|
|
|
|
|
|
|
|
|
$wpp = new MostlinkedPage();
|
|
|
|
|
|
|
|
|
|
$wpp->doQuery( $offset, $limit );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|