MediaWiki master
SpecialMostInterwikis.php
Go to the documentation of this file.
1<?php
22namespace MediaWiki\Specials;
23
30use Skin;
31use stdClass;
35
42
43 private NamespaceInfo $namespaceInfo;
44
50 public function __construct(
51 NamespaceInfo $namespaceInfo,
52 IConnectionProvider $dbProvider,
53 LinkBatchFactory $linkBatchFactory
54 ) {
55 parent::__construct( 'Mostinterwikis' );
56 $this->namespaceInfo = $namespaceInfo;
57 $this->setDatabaseProvider( $dbProvider );
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' => [
72 'langlinks',
73 'page'
74 ], 'fields' => [
75 'namespace' => 'page_namespace',
76 'title' => 'page_title',
77 'value' => 'COUNT(*)'
78 ], 'conds' => [
79 'page_namespace' => $this->namespaceInfo->getContentNamespaces()
80 ], 'options' => [
81 'HAVING' => 'COUNT(*) > 1',
82 'GROUP BY' => [
83 'page_namespace',
84 'page_title'
85 ]
86 ], 'join_conds' => [
87 'page' => [
88 'LEFT JOIN',
89 'page_id = ll_from'
90 ]
91 ]
92 ];
93 }
94
101 public function preprocessResults( $db, $res ) {
102 $this->executeLBFromResultWrapper( $res );
103 }
104
110 public function formatResult( $skin, $result ) {
111 $title = Title::makeTitleSafe( $result->namespace, $result->title );
112 if ( !$title ) {
113 return Html::element(
114 'span',
115 [ 'class' => 'mw-invalidtitle' ],
116 Linker::getInvalidTitleDescription(
117 $this->getContext(),
118 $result->namespace,
119 $result->title
120 )
121 );
122 }
123
124 $linkRenderer = $this->getLinkRenderer();
125 if ( $this->isCached() ) {
126 $link = $linkRenderer->makeLink( $title );
127 } else {
128 $link = $linkRenderer->makeKnownLink( $title );
129 }
130
131 $count = $this->msg( 'ninterwikis' )->numParams( $result->value )->escaped();
132
133 return $this->getLanguage()->specialList( $link, $count );
134 }
135
136 protected function getGroupName() {
137 return 'highuse';
138 }
139}
140
145class_alias( SpecialMostInterwikis::class, 'SpecialMostInterwikis' );
This class is a collection of static functions that serve two purposes:
Definition Html.php:56
Some internal bits split of from Skin.php.
Definition Linker.php:63
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:89
setDatabaseProvider(IConnectionProvider $databaseProvider)
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
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.
getLanguage()
Shortcut to get user's language.
List of pages that have the highest interwiki count.
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.
isExpensive()
Should this query page only be updated offline on large wikis?
__construct(NamespaceInfo $namespaceInfo, IConnectionProvider $dbProvider, LinkBatchFactory $linkBatchFactory)
preprocessResults( $db, $res)
Pre-fill the link cache.
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Represents a title within MediaWiki.
Definition Title.php:78
The base class for all skins.
Definition Skin.php:59
Provide primary and replica IDatabase connections.
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:36
Result wrapper for grabbing data queried from an IDatabase object.
element(SerializerNode $parent, SerializerNode $node, $contents)