MediaWiki REL1_40
SpecialMostInterwikis.php
Go to the documentation of this file.
1<?php
31
38
40 private $namespaceInfo;
41
47 public function __construct(
48 NamespaceInfo $namespaceInfo,
49 ILoadBalancer $loadBalancer,
50 LinkBatchFactory $linkBatchFactory
51 ) {
52 parent::__construct( 'Mostinterwikis' );
53 $this->namespaceInfo = $namespaceInfo;
54 $this->setDBLoadBalancer( $loadBalancer );
55 $this->setLinkBatchFactory( $linkBatchFactory );
56 }
57
58 public function isExpensive() {
59 return true;
60 }
61
62 public function isSyndicated() {
63 return false;
64 }
65
66 public function getQueryInfo() {
67 return [
68 'tables' => [
69 'langlinks',
70 'page'
71 ], 'fields' => [
72 'namespace' => 'page_namespace',
73 'title' => 'page_title',
74 'value' => 'COUNT(*)'
75 ], 'conds' => [
76 'page_namespace' => $this->namespaceInfo->getContentNamespaces()
77 ], 'options' => [
78 'HAVING' => 'COUNT(*) > 1',
79 'GROUP BY' => [
80 'page_namespace',
81 'page_title'
82 ]
83 ], 'join_conds' => [
84 'page' => [
85 'LEFT JOIN',
86 'page_id = ll_from'
87 ]
88 ]
89 ];
90 }
91
98 public function preprocessResults( $db, $res ) {
100 }
101
107 public function formatResult( $skin, $result ) {
108 $title = Title::makeTitleSafe( $result->namespace, $result->title );
109 if ( !$title ) {
110 return Html::element(
111 'span',
112 [ 'class' => 'mw-invalidtitle' ],
113 Linker::getInvalidTitleDescription(
114 $this->getContext(),
115 $result->namespace,
116 $result->title
117 )
118 );
119 }
120
121 $linkRenderer = $this->getLinkRenderer();
122 if ( $this->isCached() ) {
123 $link = $linkRenderer->makeLink( $title );
124 } else {
125 $link = $linkRenderer->makeKnownLink( $title );
126 }
127
128 $count = $this->msg( 'ninterwikis' )->numParams( $result->value )->escaped();
129
130 return $this->getLanguage()->specialList( $link, $count );
131 }
132
133 protected function getGroupName() {
134 return 'highuse';
135 }
136}
This class is a collection of static functions that serve two purposes:
Definition Html.php:55
Some internal bits split of from Skin.php.
Definition Linker.php:67
Represents a title within MediaWiki.
Definition Title.php:82
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
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:45
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
setDBLoadBalancer(ILoadBalancer $loadBalancer)
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
A special page that listed pages that have highest interwiki count.
isSyndicated()
Sometimes we don't want to build rss / atom feeds.
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...
isExpensive()
Should this query page only be updated offline on large wikis?
preprocessResults( $db, $res)
Pre-fill the link cache.
__construct(NamespaceInfo $namespaceInfo, ILoadBalancer $loadBalancer, 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.
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:36
This class is a delegate to ILBFactory for a given database cluster.
Result wrapper for grabbing data queried from an IDatabase object.