f50120c7c50a838893375ba4575a13800a1f7dd9
4 * A special page to show pages ordered by the number of pages linking to them
7 * @subpackage SpecialPage
9 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
10 * @author Rob Church <robchur@gmail.com>
11 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
12 * @copyright © 2006 Rob Church
13 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
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,
39 LEFT JOIN $page ON pl_namespace=page_namespace AND pl_title=page_title
45 * Pre-fill the link cache
47 function preprocessResults( &$dbr, $res ) {
48 if( $dbr->numRows( $res ) > 0 ) {
49 $linkBatch = new LinkBatch();
50 while( $row = $dbr->fetchObject( $res ) )
51 $linkBatch->addObj( Title
::makeTitleSafe( $row->namespace, $row->title
) );
52 $dbr->dataSeek( $res, 0 );
53 $linkBatch->execute();
58 * Make a link to "what links here" for the specified title
60 * @param $title Title being queried
63 function makeWlhLink( &$title, $caption ) {
64 $wlh = SpecialPage
::getTitleFor( 'Whatlinkshere', $title->getPrefixedDBkey() );
65 return Linker
::makeKnownLinkObj( $wlh, $caption );
69 * Make links to the page corresponding to the item, and the "what links here" page for it
71 * @param $result Result row
74 function formatResult( $result ) {
76 $title = Title
::makeTitleSafe( $result->namespace, $result->title
);
77 $link = Linker
::makeLinkObj( $title );
78 $wlh = $this->makeWlhLink( $title,
79 wfMsgExt( 'nlinks', array( 'parsemag', 'escape'),
80 $wgLang->formatNum( $result->value
) ) );
81 return wfSpecialList( $link, $wlh );
88 function wfSpecialMostlinked() {
89 list( $limit, $offset ) = wfCheckLimits();
91 $wpp = new MostlinkedPage();
93 $wpp->doQuery( $offset, $limit );