MediaWiki master
SpecialMostInterwikis.php
Go to the documentation of this file.
1<?php
8namespace MediaWiki\Specials;
9
10use MediaWiki\Cache\LinkBatchFactory;
17use stdClass;
21
28
29 private NamespaceInfo $namespaceInfo;
30
31 public function __construct(
32 NamespaceInfo $namespaceInfo,
33 IConnectionProvider $dbProvider,
34 LinkBatchFactory $linkBatchFactory
35 ) {
36 parent::__construct( 'Mostinterwikis' );
37 $this->namespaceInfo = $namespaceInfo;
38 $this->setDatabaseProvider( $dbProvider );
39 $this->setLinkBatchFactory( $linkBatchFactory );
40 }
41
43 public function isExpensive() {
44 return true;
45 }
46
48 public function isSyndicated() {
49 return false;
50 }
51
53 public function getQueryInfo() {
54 return [
55 'tables' => [
56 'langlinks',
57 'page'
58 ], 'fields' => [
59 'namespace' => 'page_namespace',
60 'title' => 'page_title',
61 'value' => 'COUNT(*)'
62 ], 'conds' => [
63 'page_namespace' => $this->namespaceInfo->getContentNamespaces()
64 ], 'options' => [
65 'HAVING' => 'COUNT(*) > 1',
66 'GROUP BY' => [
67 'page_namespace',
68 'page_title'
69 ]
70 ], 'join_conds' => [
71 'page' => [
72 'LEFT JOIN',
73 'page_id = ll_from'
74 ]
75 ]
76 ];
77 }
78
85 public function preprocessResults( $db, $res ) {
86 $this->executeLBFromResultWrapper( $res );
87 }
88
94 public function formatResult( $skin, $result ) {
95 $title = Title::makeTitleSafe( $result->namespace, $result->title );
96 if ( !$title ) {
97 return Html::element(
98 'span',
99 [ 'class' => 'mw-invalidtitle' ],
100 Linker::getInvalidTitleDescription(
101 $this->getContext(),
102 $result->namespace,
103 $result->title
104 )
105 );
106 }
107
108 $linkRenderer = $this->getLinkRenderer();
109 if ( $this->isCached() ) {
110 $link = $linkRenderer->makeLink( $title );
111 } else {
112 $link = $linkRenderer->makeKnownLink( $title );
113 }
114
115 $count = $this->msg( 'ninterwikis' )->numParams( $result->value )->escaped();
116
117 return $this->getLanguage()->specialList( $link, $count );
118 }
119
121 protected function getGroupName() {
122 return 'highuse';
123 }
124}
125
130class_alias( SpecialMostInterwikis::class, 'SpecialMostInterwikis' );
This class is a collection of static functions that serve two purposes:
Definition Html.php:43
Some internal bits split of from Skin.php.
Definition Linker.php:47
The base class for all skins.
Definition Skin.php:52
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:77
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.to override bool
isExpensive()
Should this query page only be updated offline on large wikis?If the query for this page is considere...
__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:70
Provide primary and replica IDatabase connections.
A database connection without write operations.
Result wrapper for grabbing data queried from an IDatabase object.
element(SerializerNode $parent, SerializerNode $node, $contents)