3 * Implements Special:Mostcategories
5 * Copyright © 2005 Ævar Arnfjörð Bjarmason
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * http://www.gnu.org/copyleft/gpl.html
23 * @ingroup SpecialPage
24 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
27 use MediaWiki\MediaWikiServices
;
28 use Wikimedia\Rdbms\IResultWrapper
;
29 use Wikimedia\Rdbms\IDatabase
;
32 * A special page that list pages that have highest category count
34 * @ingroup SpecialPage
36 class MostcategoriesPage
extends QueryPage
{
37 function __construct( $name = 'Mostcategories' ) {
38 parent
::__construct( $name );
41 public function isExpensive() {
45 function isSyndicated() {
49 public function getQueryInfo() {
51 'tables' => [ 'categorylinks', 'page' ],
53 'namespace' => 'page_namespace',
54 'title' => 'page_title',
57 'conds' => [ 'page_namespace' =>
58 MediaWikiServices
::getInstance()->getNamespaceInfo()->getContentNamespaces() ],
60 'HAVING' => 'COUNT(*) > 1',
61 'GROUP BY' => [ 'page_namespace', 'page_title' ]
73 * @param IDatabase $db
74 * @param IResultWrapper $res
76 function preprocessResults( $db, $res ) {
77 $this->executeLBFromResultWrapper( $res );
82 * @param object $result Result row
85 function formatResult( $skin, $result ) {
86 $title = Title
::makeTitleSafe( $result->namespace, $result->title
);
90 [ 'class' => 'mw-invalidtitle' ],
91 Linker
::getInvalidTitleDescription(
99 $linkRenderer = $this->getLinkRenderer();
100 if ( $this->isCached() ) {
101 $link = $linkRenderer->makeLink( $title );
103 $link = $linkRenderer->makeKnownLink( $title );
106 $count = $this->msg( 'ncategories' )->numParams( $result->value
)->escaped();
108 return $this->getLanguage()->specialList( $link, $count );
111 protected function getGroupName() {