MediaWiki  master
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 
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 }
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:231
getContext()
Gets the context this SpecialPage is executed in.
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
Definition: QueryPage.php:258
This is a class for doing query pages; since they&#39;re almost all the same, we factor out some of the f...
Definition: QueryPage.php:36
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:612
__construct( $name='Mostcategories')
A special page that list pages that have highest category count.
getLanguage()
Shortcut to get user&#39;s language.
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition: Linker.php:187
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:800
MediaWiki Linker LinkRenderer null $linkRenderer
Definition: SpecialPage.php:67