MediaWiki  master
SpecialMostCategories.php
Go to the documentation of this file.
1 <?php
34 
41 
43  private $namespaceInfo;
44 
50  public function __construct(
51  NamespaceInfo $namespaceInfo,
52  ILoadBalancer $loadBalancer,
53  LinkBatchFactory $linkBatchFactory
54  ) {
55  parent::__construct( 'Mostcategories' );
56  $this->namespaceInfo = $namespaceInfo;
57  $this->setDBLoadBalancer( $loadBalancer );
58  $this->setLinkBatchFactory( $linkBatchFactory );
59  }
60 
61  public function isExpensive() {
62  return true;
63  }
64 
65  public function isSyndicated() {
66  return false;
67  }
68 
69  public function getQueryInfo() {
70  return [
71  'tables' => [ 'categorylinks', 'page' ],
72  'fields' => [
73  'namespace' => 'page_namespace',
74  'title' => 'page_title',
75  'value' => 'COUNT(*)'
76  ],
77  'conds' => [
78  'page_namespace' => $this->namespaceInfo->getContentNamespaces()
79  ],
80  'options' => [
81  'HAVING' => 'COUNT(*) > 1',
82  'GROUP BY' => [ 'page_namespace', 'page_title' ]
83  ],
84  'join_conds' => [
85  'page' => [
86  'LEFT JOIN',
87  'page_id = cl_from'
88  ]
89  ]
90  ];
91  }
92 
97  public function preprocessResults( $db, $res ) {
99  }
100 
106  public function formatResult( $skin, $result ) {
107  $title = Title::makeTitleSafe( $result->namespace, $result->title );
108  if ( !$title ) {
109  return Html::element(
110  'span',
111  [ 'class' => 'mw-invalidtitle' ],
112  Linker::getInvalidTitleDescription(
113  $this->getContext(),
114  $result->namespace,
115  $result->title
116  )
117  );
118  }
119 
120  $linkRenderer = $this->getLinkRenderer();
121  if ( $this->isCached() ) {
122  $link = $linkRenderer->makeLink( $title );
123  } else {
124  $link = $linkRenderer->makeKnownLink( $title );
125  }
126 
127  $count = $this->msg( 'ncategories' )->numParams( $result->value )->escaped();
128 
129  return $this->getLanguage()->specialList( $link, $count );
130  }
131 
132  protected function getGroupName() {
133  return 'highuse';
134  }
135 }
This class is a collection of static functions that serve two purposes:
Definition: Html.php:55
Some internal bits split of from Skin.php.
Definition: Linker.php:65
Represents a title within MediaWiki.
Definition: Title.php:82
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
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:46
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:902
setDBLoadBalancer(ILoadBalancer $loadBalancer)
Definition: QueryPage.php:920
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
Definition: QueryPage.php:315
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
Definition: QueryPage.php:140
A special page that list pages that have highest category count.
isExpensive()
Should this query page only be updated offline on large wikis?
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...
isSyndicated()
Sometimes we don't want to build rss / atom feeds.
__construct(NamespaceInfo $namespaceInfo, ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory)
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.
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:36
This class is a delegate to ILBFactory for a given database cluster.
Result wrapper for grabbing data queried from an IDatabase object.