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
|
|
|
|
2017-02-10 18:09:05 +00:00
|
|
|
use Wikimedia\Rdbms\IDatabase;
|
2020-01-10 00:00:51 +00:00
|
|
|
use Wikimedia\Rdbms\IResultWrapper;
|
2017-02-19 05:03:13 +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
|
|
|
*/
|
2019-04-14 15:14:22 +00:00
|
|
|
class SpecialMostLinked extends QueryPage {
|
2020-05-16 21:42:24 +00:00
|
|
|
public function __construct( $name = 'Mostlinked' ) {
|
2010-12-22 14:16:25 +00:00
|
|
|
parent::__construct( $name );
|
|
|
|
|
}
|
2011-03-18 20:37:11 +00:00
|
|
|
|
2015-08-20 13:02:54 +00:00
|
|
|
public function isExpensive() {
|
2012-09-24 17:44:57 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-18 00:17:37 +00:00
|
|
|
public function isSyndicated() {
|
2012-09-24 17:44:57 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2005-08-15 02:57:19 +00:00
|
|
|
|
2015-08-20 13:02:54 +00:00
|
|
|
public function getQueryInfo() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
|
|
|
|
'tables' => [ 'pagelinks', 'page' ],
|
|
|
|
|
'fields' => [
|
2013-05-09 14:51:30 +00:00
|
|
|
'namespace' => 'pl_namespace',
|
|
|
|
|
'title' => 'pl_title',
|
|
|
|
|
'value' => 'COUNT(*)',
|
|
|
|
|
'page_namespace'
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'options' => [
|
2013-05-09 14:51:30 +00:00
|
|
|
'HAVING' => 'COUNT(*) > 1',
|
2016-02-17 09:09:32 +00:00
|
|
|
'GROUP BY' => [
|
2013-05-09 14:51:30 +00:00
|
|
|
'pl_namespace', 'pl_title',
|
|
|
|
|
'page_namespace'
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
'join_conds' => [
|
|
|
|
|
'page' => [
|
2013-05-09 14:51:30 +00:00
|
|
|
'LEFT JOIN',
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2013-05-09 14:51:30 +00:00
|
|
|
'page_namespace = pl_namespace',
|
|
|
|
|
'page_title = pl_title'
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
];
|
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
|
|
|
*
|
2014-12-02 18:44:26 +00:00
|
|
|
* @param IDatabase $db
|
2018-04-04 12:52:10 +00:00
|
|
|
* @param IResultWrapper $res
|
2006-05-03 14:50:16 +00:00
|
|
|
*/
|
2020-05-18 00:17:37 +00:00
|
|
|
public function preprocessResults( $db, $res ) {
|
2016-10-29 20:46:17 +00:00
|
|
|
$this->executeLBFromResultWrapper( $res );
|
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
|
|
|
|
|
*
|
2014-04-19 08:16:52 +00:00
|
|
|
* @param Title $title Title being queried
|
|
|
|
|
* @param string $caption Text to display on the link
|
|
|
|
|
* @return string
|
2006-05-03 14:50:16 +00:00
|
|
|
*/
|
2020-05-18 01:16:17 +00:00
|
|
|
private function makeWlhLink( $title, $caption ) {
|
2006-10-30 06:25:31 +00:00
|
|
|
$wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedDBkey() );
|
2013-05-09 14:51:30 +00:00
|
|
|
|
2016-11-30 22:56:33 +00:00
|
|
|
$linkRenderer = $this->getLinkRenderer();
|
|
|
|
|
return $linkRenderer->makeKnownLink( $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
|
|
|
/**
|
2013-05-09 14:51:30 +00:00
|
|
|
* Make links to the page corresponding to the item,
|
|
|
|
|
* and the "what links here" page for it
|
2006-05-03 14:50:16 +00:00
|
|
|
*
|
2013-04-14 19:18:38 +00:00
|
|
|
* @param Skin $skin Skin to be used
|
|
|
|
|
* @param object $result Result row
|
2006-05-03 14:50:16 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2020-05-18 00:17:37 +00:00
|
|
|
public 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 ) {
|
2013-05-09 14:51:30 +00:00
|
|
|
return Html::element(
|
|
|
|
|
'span',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'class' => 'mw-invalidtitle' ],
|
2013-05-09 14:51:30 +00:00
|
|
|
Linker::getInvalidTitleDescription(
|
|
|
|
|
$this->getContext(),
|
|
|
|
|
$result->namespace,
|
|
|
|
|
$result->title )
|
|
|
|
|
);
|
2009-05-27 19:07:27 +00:00
|
|
|
}
|
2013-05-09 14:51:30 +00:00
|
|
|
|
2016-11-30 22:56:33 +00:00
|
|
|
$linkRenderer = $this->getLinkRenderer();
|
|
|
|
|
$link = $linkRenderer->makeLink( $title );
|
2013-05-09 14:51:30 +00:00
|
|
|
$wlh = $this->makeWlhLink(
|
|
|
|
|
$title,
|
2016-11-30 22:56:33 +00:00
|
|
|
$this->msg( 'nlinks' )->numParams( $result->value )->text()
|
2013-05-09 14:51:30 +00:00
|
|
|
);
|
|
|
|
|
|
2011-11-21 16:13:21 +00:00
|
|
|
return $this->getLanguage()->specialList( $link, $wlh );
|
2005-08-15 02:57:19 +00:00
|
|
|
}
|
2013-03-07 20:15:54 +00:00
|
|
|
|
|
|
|
|
protected function getGroupName() {
|
|
|
|
|
return 'highuse';
|
|
|
|
|
}
|
2005-08-15 02:57:19 +00:00
|
|
|
}
|