MediaWiki master
SpecialMostInterwikis.php
Go to the documentation of this file.
1<?php
8namespace MediaWiki\Specials;
9
17use stdClass;
21
28
29 public function __construct(
30 private readonly NamespaceInfo $namespaceInfo,
31 IConnectionProvider $dbProvider,
32 LinkBatchFactory $linkBatchFactory,
33 ) {
34 parent::__construct( 'Mostinterwikis' );
35 $this->setDatabaseProvider( $dbProvider );
36 $this->setLinkBatchFactory( $linkBatchFactory );
37 }
38
40 public function isExpensive() {
41 return true;
42 }
43
45 public function isSyndicated() {
46 return false;
47 }
48
50 public function getQueryInfo() {
51 return [
52 'tables' => [
53 'langlinks',
54 'page'
55 ], 'fields' => [
56 'namespace' => 'page_namespace',
57 'title' => 'page_title',
58 'value' => 'COUNT(*)'
59 ], 'conds' => [
60 'page_namespace' => $this->namespaceInfo->getContentNamespaces()
61 ], 'options' => [
62 'HAVING' => 'COUNT(*) > 1',
63 'GROUP BY' => [
64 'page_namespace',
65 'page_title'
66 ]
67 ], 'join_conds' => [
68 'page' => [
69 'LEFT JOIN',
70 'page_id = ll_from'
71 ]
72 ]
73 ];
74 }
75
82 public function preprocessResults( $db, $res ) {
83 $this->executeLBFromResultWrapper( $res );
84 }
85
91 public function formatResult( $skin, $result ) {
92 $title = Title::makeTitleSafe( $result->namespace, $result->title );
93 if ( !$title ) {
94 return Html::element(
95 'span',
96 [ 'class' => 'mw-invalidtitle' ],
97 Linker::getInvalidTitleDescription(
98 $this->getContext(),
99 $result->namespace,
100 $result->title
101 )
102 );
103 }
104
105 $linkRenderer = $this->getLinkRenderer();
106 if ( $this->isCached() ) {
107 $link = $linkRenderer->makeLink( $title );
108 } else {
109 $link = $linkRenderer->makeKnownLink( $title );
110 }
111
112 $count = $this->msg( 'ninterwikis' )->numParams( $result->value )->escaped();
113
114 return $this->getLanguage()->specialList( $link, $count );
115 }
116
118 protected function getGroupName() {
119 return 'highuse';
120 }
121}
122
127class_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
Factory for LinkBatch objects to batch query page metadata.
The base class for all skins.
Definition Skin.php:53
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...
__construct(private readonly NamespaceInfo $namespaceInfo, IConnectionProvider $dbProvider, LinkBatchFactory $linkBatchFactory,)
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...
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:69
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)