MediaWiki REL1_34
SpecialMostCategories.php
Go to the documentation of this file.
1<?php
30
37 function __construct( $name = 'Mostcategories' ) {
38 parent::__construct( $name );
39 }
40
41 public function isExpensive() {
42 return true;
43 }
44
45 function isSyndicated() {
46 return false;
47 }
48
49 public function getQueryInfo() {
50 return [
51 'tables' => [ 'categorylinks', 'page' ],
52 'fields' => [
53 'namespace' => 'page_namespace',
54 'title' => 'page_title',
55 'value' => 'COUNT(*)'
56 ],
57 'conds' => [ 'page_namespace' =>
58 MediaWikiServices::getInstance()->getNamespaceInfo()->getContentNamespaces() ],
59 'options' => [
60 'HAVING' => 'COUNT(*) > 1',
61 'GROUP BY' => [ 'page_namespace', 'page_title' ]
62 ],
63 'join_conds' => [
64 'page' => [
65 'LEFT JOIN',
66 'page_id = cl_from'
67 ]
68 ]
69 ];
70 }
71
76 function preprocessResults( $db, $res ) {
78 }
79
85 function formatResult( $skin, $result ) {
86 $title = Title::makeTitleSafe( $result->namespace, $result->title );
87 if ( !$title ) {
88 return Html::element(
89 'span',
90 [ 'class' => 'mw-invalidtitle' ],
92 $this->getContext(),
93 $result->namespace,
94 $result->title
95 )
96 );
97 }
98
100 if ( $this->isCached() ) {
101 $link = $linkRenderer->makeLink( $title );
102 } else {
103 $link = $linkRenderer->makeKnownLink( $title );
104 }
105
106 $count = $this->msg( 'ncategories' )->numParams( $result->value )->escaped();
107
108 return $this->getLanguage()->specialList( $link, $count );
109 }
110
111 protected function getGroupName() {
112 return 'highuse';
113 }
114}
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition Linker.php:187
MediaWikiServices is the service locator for the application scope of MediaWiki.
This is a class for doing query pages; since they're almost all the same, we factor out some of the f...
Definition QueryPage.php:36
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
A special page that list pages that have highest category count.
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
__construct( $name='Mostcategories')
isSyndicated()
Sometime we don't want to build rss / atom feeds.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getLanguage()
Shortcut to get user's language.
MediaWiki Linker LinkRenderer null $linkRenderer
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:38
Result wrapper for grabbing data queried from an IDatabase object.