MediaWiki  master
SpecialMostCategories.php
Go to the documentation of this file.
1 <?php
30 
37  public function __construct( $name = 'Mostcategories' ) {
38  parent::__construct( $name );
39  }
40 
41  public function isExpensive() {
42  return true;
43  }
44 
45  public 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  public function preprocessResults( $db, $res ) {
78  }
79 
85  public 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 
99  $linkRenderer = $this->getLinkRenderer();
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 }
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:828
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:152
SpecialMostCategories\getQueryInfo
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: SpecialMostCategories.php:49
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:774
Linker\getInvalidTitleDescription
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition: Linker.php:188
$res
$res
Definition: testCompression.php:57
SpecialMostCategories
A special page that list pages that have highest category count.
Definition: SpecialMostCategories.php:36
QueryPage
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:39
QueryPage\executeLBFromResultWrapper
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
Definition: QueryPage.php:823
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
SpecialMostCategories\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialMostCategories.php:111
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:24
QueryPage\isCached
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
Definition: QueryPage.php:268
SpecialMostCategories\formatResult
formatResult( $skin, $result)
Definition: SpecialMostCategories.php:85
SpecialMostCategories\isSyndicated
isSyndicated()
Sometime we don't want to build rss / atom feeds.
Definition: SpecialMostCategories.php:45
$title
$title
Definition: testCompression.php:38
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:717
SpecialMostCategories\__construct
__construct( $name='Mostcategories')
Definition: SpecialMostCategories.php:37
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:618
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:944
SpecialMostCategories\preprocessResults
preprocessResults( $db, $res)
Definition: SpecialMostCategories.php:76
SpecialPage\$linkRenderer
MediaWiki Linker LinkRenderer null $linkRenderer
Definition: SpecialPage.php:71
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:231
SpecialMostCategories\isExpensive
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
Definition: SpecialMostCategories.php:41