MediaWiki REL1_39
SpecialMostLinkedCategories.php
Go to the documentation of this file.
1<?php
32
39
41 private $languageConverter;
42
48 public function __construct(
49 ILoadBalancer $loadBalancer,
50 LinkBatchFactory $linkBatchFactory,
51 LanguageConverterFactory $languageConverterFactory
52 ) {
53 parent::__construct( 'Mostlinkedcategories' );
54 $this->setDBLoadBalancer( $loadBalancer );
55 $this->setLinkBatchFactory( $linkBatchFactory );
56 $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() );
57 }
58
59 public function isSyndicated() {
60 return false;
61 }
62
63 public function getQueryInfo() {
64 return [
65 'tables' => [ 'category' ],
66 'fields' => [ 'title' => 'cat_title',
67 'namespace' => NS_CATEGORY,
68 'value' => 'cat_pages' ],
69 'conds' => [ 'cat_pages > 0' ],
70 ];
71 }
72
73 protected function sortDescending() {
74 return true;
75 }
76
83 public function preprocessResults( $db, $res ) {
85 }
86
92 public function formatResult( $skin, $result ) {
93 $nt = Title::makeTitleSafe( NS_CATEGORY, $result->title );
94 if ( !$nt ) {
95 return Html::element(
96 'span',
97 [ 'class' => 'mw-invalidtitle' ],
99 $this->getContext(),
101 $result->title )
102 );
103 }
104
105 $text = $this->languageConverter->convertHtml( $nt->getText() );
106
107 $plink = $this->getLinkRenderer()->makeLink( $nt, new HtmlArmor( $text ) );
108 $nlinks = $this->msg( 'nmembers' )->numParams( $result->value )->escaped();
109
110 return $this->getLanguage()->specialList( $plink, $nlinks );
111 }
112
113 protected function getGroupName() {
114 return 'highuse';
115 }
116}
const NS_CATEGORY
Definition Defines.php:78
Marks HTML that shouldn't be escaped.
Definition HtmlArmor.php:30
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition Linker.php:189
An interface for creating language converters.
getLanguageConverter( $language=null)
Provide a LanguageConverter for given language.
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:42
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
setDBLoadBalancer(ILoadBalancer $loadBalancer)
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
A querypage to show categories ordered in descending order by the pages in them.
sortDescending()
Override to sort by increasing values.
preprocessResults( $db, $res)
Fetch user page links and cache their existence.
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
isSyndicated()
Sometimes we don't want to build rss / atom feeds.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
__construct(ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory, LanguageConverterFactory $languageConverterFactory)
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.
getContentLanguage()
Shortcut to get content language.
The shared interface for all language converters.
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:39
Create and track the database connections and transactions for a given database cluster.
Result wrapper for grabbing data queried from an IDatabase object.