MediaWiki 1.44.0
SpecialMostLinkedCategories.php
Go to the documentation of this file.
1<?php
23namespace MediaWiki\Specials;
24
33use stdClass;
38
46
47 private ILanguageConverter $languageConverter;
48
49 public function __construct(
50 IConnectionProvider $dbProvider,
51 LinkBatchFactory $linkBatchFactory,
52 LanguageConverterFactory $languageConverterFactory
53 ) {
54 parent::__construct( 'Mostlinkedcategories' );
55 $this->setDatabaseProvider( $dbProvider );
56 $this->setLinkBatchFactory( $linkBatchFactory );
57 $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() );
58 }
59
60 public function isSyndicated() {
61 return false;
62 }
63
64 public function getQueryInfo() {
65 $dbr = $this->getDatabaseProvider()->getReplicaDatabase();
66 return [
67 'tables' => [ 'category' ],
68 'fields' => [ 'title' => 'cat_title',
69 'namespace' => NS_CATEGORY,
70 'value' => 'cat_pages' ],
71 'conds' => [ $dbr->expr( 'cat_pages', '>', 0 ) ],
72 ];
73 }
74
75 protected function sortDescending() {
76 return true;
77 }
78
85 public function preprocessResults( $db, $res ) {
86 $this->executeLBFromResultWrapper( $res );
87 }
88
94 public function formatResult( $skin, $result ) {
95 $nt = Title::makeTitleSafe( NS_CATEGORY, $result->title );
96 if ( !$nt ) {
97 return Html::element(
98 'span',
99 [ 'class' => 'mw-invalidtitle' ],
100 Linker::getInvalidTitleDescription(
101 $this->getContext(),
103 $result->title )
104 );
105 }
106
107 $text = $this->languageConverter->convertHtml( $nt->getText() );
108
109 $plink = $this->getLinkRenderer()->makeLink( $nt, new HtmlArmor( $text ) );
110 $nlinks = $this->msg( 'nmembers' )->numParams( $result->value )->escaped();
111
112 return $this->getLanguage()->specialList( $plink, $nlinks );
113 }
114
115 protected function getGroupName() {
116 return 'highuse';
117 }
118}
123class_alias( SpecialMostLinkedCategories::class, 'SpecialMostLinkedCategories' );
const NS_CATEGORY
Definition Defines.php:79
This class is a collection of static functions that serve two purposes:
Definition Html.php:57
An interface for creating language converters.
getLanguageConverter( $language=null)
Provide a LanguageConverter for given language.
Some internal bits split of from Skin.php.
Definition Linker.php:61
The base class for all skins.
Definition Skin.php:58
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:87
setDatabaseProvider(IConnectionProvider $databaseProvider)
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getContentLanguage()
Shortcut to get content language.
getLanguage()
Shortcut to get user's language.
List of categories with the most pages in them.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
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.
__construct(IConnectionProvider $dbProvider, LinkBatchFactory $linkBatchFactory, LanguageConverterFactory $languageConverterFactory)
preprocessResults( $db, $res)
Fetch user page links and cache their existence.
sortDescending()
Override to sort by increasing values.
Represents a title within MediaWiki.
Definition Title.php:78
Marks HTML that shouldn't be escaped.
Definition HtmlArmor.php:32
The shared interface for all language converters.
Provide primary and replica IDatabase connections.
Interface to a relational database.
Definition IDatabase.php:45
Result wrapper for grabbing data queried from an IDatabase object.
element(SerializerNode $parent, SerializerNode $node, $contents)