2005-08-15 02:57:19 +00:00
|
|
|
<?php
|
2010-06-21 12:59:04 +00:00
|
|
|
/**
|
2010-08-14 19:19:41 +00:00
|
|
|
* Implements Special:Mostlinked
|
|
|
|
|
*
|
|
|
|
|
* Copyright © 2005 Ævar Arnfjörð Bjarmason, 2006 Rob Church
|
2010-06-21 12:59:04 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
2010-06-21 13:16:32 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2010-06-21 12:59:04 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2010-08-14 19:19:41 +00:00
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @file
|
|
|
|
|
* @ingroup SpecialPage
|
2010-08-14 19:19:41 +00:00
|
|
|
* @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
|
|
|
|
|
* @author Rob Church <robchur@gmail.com>
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
*/
|
2006-05-03 14:50:16 +00:00
|
|
|
|
2005-08-15 02:57:19 +00:00
|
|
|
/**
|
2007-04-20 08:55:14 +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
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup SpecialPage
|
2005-08-15 02:57:19 +00:00
|
|
|
*/
|
|
|
|
|
class MostlinkedPage extends QueryPage {
|
|
|
|
|
|
2010-12-22 14:16:25 +00:00
|
|
|
function __construct( $name = 'Mostlinked' ) {
|
|
|
|
|
parent::__construct( $name );
|
|
|
|
|
}
|
2011-03-18 20:37:11 +00:00
|
|
|
|
2005-09-13 17:33:33 +00:00
|
|
|
function isExpensive() { return true; }
|
2005-08-15 02:57:19 +00:00
|
|
|
function isSyndicated() { return false; }
|
|
|
|
|
|
2010-12-22 14:16:25 +00:00
|
|
|
function getQueryInfo() {
|
|
|
|
|
return array (
|
|
|
|
|
'tables' => array ( 'pagelinks', 'page' ),
|
|
|
|
|
'fields' => array ( 'pl_namespace AS namespace',
|
|
|
|
|
'pl_title AS title',
|
|
|
|
|
'COUNT(*) AS value',
|
|
|
|
|
'page_namespace' ),
|
|
|
|
|
'options' => array ( 'HAVING' => 'COUNT(*) > 1',
|
|
|
|
|
'GROUP BY' => 'pl_namespace, pl_title, '.
|
|
|
|
|
'page_namespace' ),
|
|
|
|
|
'join_conds' => array ( 'page' => array ( 'LEFT JOIN',
|
|
|
|
|
array ( 'page_namespace = pl_namespace',
|
|
|
|
|
'page_title = pl_title' ) ) )
|
|
|
|
|
);
|
2005-08-15 02:57:19 +00:00
|
|
|
}
|
|
|
|
|
|
2006-05-03 14:50:16 +00:00
|
|
|
/**
|
|
|
|
|
* Pre-fill the link cache
|
2011-05-26 19:21:50 +00:00
|
|
|
*
|
|
|
|
|
* @param $db DatabaseBase
|
|
|
|
|
* @param $res
|
2006-05-03 14:50:16 +00:00
|
|
|
*/
|
2008-02-12 02:43:25 +00:00
|
|
|
function preprocessResults( $db, $res ) {
|
2006-12-16 21:53:34 +00:00
|
|
|
if( $db->numRows( $res ) > 0 ) {
|
2006-05-03 14:50:16 +00:00
|
|
|
$linkBatch = new LinkBatch();
|
2010-10-13 23:11:40 +00:00
|
|
|
foreach ( $res as $row ) {
|
2008-03-15 10:46:28 +00:00
|
|
|
$linkBatch->add( $row->namespace, $row->title );
|
2010-10-13 23:11:40 +00:00
|
|
|
}
|
2006-12-16 21:53:34 +00:00
|
|
|
$db->dataSeek( $res, 0 );
|
2006-05-03 14:50:16 +00:00
|
|
|
$linkBatch->execute();
|
2005-09-16 15:07:07 +00:00
|
|
|
}
|
2006-05-03 14:50:16 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2006-05-03 14:50:16 +00:00
|
|
|
/**
|
|
|
|
|
* Make a link to "what links here" for the specified title
|
|
|
|
|
*
|
|
|
|
|
* @param $title Title being queried
|
2010-02-08 20:41:05 +00:00
|
|
|
* @param $caption String: text to display on the link
|
|
|
|
|
* @return String
|
2006-05-03 14:50:16 +00:00
|
|
|
*/
|
2011-09-27 15:13:37 +00:00
|
|
|
function makeWlhLink( $title, $caption ) {
|
2006-10-30 06:25:31 +00:00
|
|
|
$wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedDBkey() );
|
2011-09-27 15:13:37 +00:00
|
|
|
return Linker::linkKnown( $wlh, $caption );
|
2006-05-03 14:50:16 +00:00
|
|
|
}
|
2005-08-15 02:57:19 +00:00
|
|
|
|
2006-05-03 14:50:16 +00:00
|
|
|
/**
|
|
|
|
|
* Make links to the page corresponding to the item, and the "what links here" page for it
|
|
|
|
|
*
|
2006-11-08 07:12:03 +00:00
|
|
|
* @param $skin Skin to be used
|
2006-05-03 14:50:16 +00:00
|
|
|
* @param $result Result row
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2006-11-08 07:12:03 +00:00
|
|
|
function formatResult( $skin, $result ) {
|
2006-05-03 14:50:16 +00:00
|
|
|
$title = Title::makeTitleSafe( $result->namespace, $result->title );
|
2009-05-27 19:07:27 +00:00
|
|
|
if ( !$title ) {
|
|
|
|
|
return '<!-- ' . htmlspecialchars( "Invalid title: [[$title]]" ) . ' -->';
|
|
|
|
|
}
|
2011-09-27 15:13:37 +00:00
|
|
|
$link = Linker::link( $title );
|
2006-05-14 17:44:15 +00:00
|
|
|
$wlh = $this->makeWlhLink( $title,
|
2011-09-27 15:13:37 +00:00
|
|
|
$this->msg( 'nlinks' )->numParams( $result->value )->escaped() );
|
2011-10-13 11:46:21 +00:00
|
|
|
return $this->getLang()->specialList( $link, $wlh );
|
2005-08-15 02:57:19 +00:00
|
|
|
}
|
|
|
|
|
}
|