MediaWiki  master
SpecialMostLinkedCategories.php
Go to the documentation of this file.
1 <?php
32 
39 
42 
48  public function __construct(
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(),
100  NS_CATEGORY,
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 }
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:911
HtmlArmor
Marks HTML that shouldn't be escaped.
Definition: HtmlArmor.php:30
SpecialMostLinkedCategories\isSyndicated
isSyndicated()
Sometime we don't want to build rss / atom feeds.
Definition: SpecialMostLinkedCategories.php:59
SpecialMostLinkedCategories\preprocessResults
preprocessResults( $db, $res)
Fetch user page links and cache their existence.
Definition: SpecialMostLinkedCategories.php:83
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:829
Linker\getInvalidTitleDescription
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition: Linker.php:189
$res
$res
Definition: testCompression.php:57
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:41
MediaWiki\Languages\LanguageConverterFactory
An interface for creating language converters.
Definition: LanguageConverterFactory.php:46
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:855
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
QueryPage\setLinkBatchFactory
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
Definition: QueryPage.php:136
MediaWiki\Languages\LanguageConverterFactory\getLanguageConverter
getLanguageConverter( $language=null)
Provide a LanguageConverter for given language.
Definition: LanguageConverterFactory.php:125
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:24
MediaWiki\Cache\LinkBatchFactory
Definition: LinkBatchFactory.php:38
SpecialMostLinkedCategories\formatResult
formatResult( $skin, $result)
Definition: SpecialMostLinkedCategories.php:92
SpecialMostLinkedCategories\__construct
__construct(ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory, LanguageConverterFactory $languageConverterFactory)
Definition: SpecialMostLinkedCategories.php:48
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:763
SpecialMostLinkedCategories\sortDescending
sortDescending()
Override to sort by increasing values.
Definition: SpecialMostLinkedCategories.php:73
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:652
ILanguageConverter
The shared interface for all language converters.
Definition: ILanguageConverter.php:28
QueryPage\setDBLoadBalancer
setDBLoadBalancer(ILoadBalancer $loadBalancer)
Definition: QueryPage.php:873
QueryPage\$linkBatchFactory
LinkBatchFactory null $linkBatchFactory
Definition: QueryPage.php:74
SpecialMostLinkedCategories\getQueryInfo
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: SpecialMostLinkedCategories.php:63
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:1027
NS_CATEGORY
const NS_CATEGORY
Definition: Defines.php:78
SpecialMostLinkedCategories\$languageConverter
ILanguageConverter $languageConverter
Definition: SpecialMostLinkedCategories.php:41
QueryPage\$loadBalancer
ILoadBalancer null $loadBalancer
Definition: QueryPage.php:71
SpecialPage\getContentLanguage
getContentLanguage()
Shortcut to get content language.
Definition: SpecialPage.php:839
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:234
SpecialMostLinkedCategories
A querypage to show categories ordered in descending order by the pages in them.
Definition: SpecialMostLinkedCategories.php:38
Wikimedia\Rdbms\ILoadBalancer
Database cluster connection, tracking, load balancing, and transaction manager interface.
Definition: ILoadBalancer.php:81
SpecialMostLinkedCategories\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialMostLinkedCategories.php:113