MediaWiki  master
SpecialMostInterwikis.php
Go to the documentation of this file.
1 <?php
28 
35 
37  private $namespaceInfo;
38 
44  public function __construct(
48  ) {
49  parent::__construct( 'Mostinterwikis' );
50  $this->namespaceInfo = $namespaceInfo;
51  $this->setDBLoadBalancer( $loadBalancer );
52  $this->setLinkBatchFactory( $linkBatchFactory );
53  }
54 
55  public function isExpensive() {
56  return true;
57  }
58 
59  public function isSyndicated() {
60  return false;
61  }
62 
63  public function getQueryInfo() {
64  return [
65  'tables' => [
66  'langlinks',
67  'page'
68  ], 'fields' => [
69  'namespace' => 'page_namespace',
70  'title' => 'page_title',
71  'value' => 'COUNT(*)'
72  ], 'conds' => [
73  'page_namespace' => $this->namespaceInfo->getContentNamespaces()
74  ], 'options' => [
75  'HAVING' => 'COUNT(*) > 1',
76  'GROUP BY' => [
77  'page_namespace',
78  'page_title'
79  ]
80  ], 'join_conds' => [
81  'page' => [
82  'LEFT JOIN',
83  'page_id = ll_from'
84  ]
85  ]
86  ];
87  }
88 
95  public function preprocessResults( $db, $res ) {
97  }
98 
104  public function formatResult( $skin, $result ) {
105  $title = Title::makeTitleSafe( $result->namespace, $result->title );
106  if ( !$title ) {
107  return Html::element(
108  'span',
109  [ 'class' => 'mw-invalidtitle' ],
111  $this->getContext(),
112  $result->namespace,
113  $result->title
114  )
115  );
116  }
117 
118  $linkRenderer = $this->getLinkRenderer();
119  if ( $this->isCached() ) {
120  $link = $linkRenderer->makeLink( $title );
121  } else {
122  $link = $linkRenderer->makeKnownLink( $title );
123  }
124 
125  $count = $this->msg( 'ninterwikis' )->numParams( $result->value )->escaped();
126 
127  return $this->getLanguage()->specialList( $link, $count );
128  }
129 
130  protected function getGroupName() {
131  return 'highuse';
132  }
133 }
SpecialPage\$linkRenderer
LinkRenderer null $linkRenderer
Definition: SpecialPage.php:80
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:912
SpecialMostInterwikis\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialMostInterwikis.php:130
SpecialMostInterwikis\preprocessResults
preprocessResults( $db, $res)
Pre-fill the link cache.
Definition: SpecialMostInterwikis.php:95
SpecialMostInterwikis\$namespaceInfo
NamespaceInfo $namespaceInfo
Definition: SpecialMostInterwikis.php:37
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:830
Linker\getInvalidTitleDescription
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition: Linker.php:185
$res
$res
Definition: testCompression.php:57
QueryPage
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:41
QueryPage\executeLBFromResultWrapper
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
Definition: QueryPage.php:874
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
QueryPage\setLinkBatchFactory
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
Definition: QueryPage.php:135
SpecialMostInterwikis\__construct
__construct(NamespaceInfo $namespaceInfo, ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory)
Definition: SpecialMostInterwikis.php:44
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:26
QueryPage\isCached
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
Definition: QueryPage.php:297
MediaWiki\Cache\LinkBatchFactory
Definition: LinkBatchFactory.php:39
$title
$title
Definition: testCompression.php:38
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:764
SpecialMostInterwikis\isSyndicated
isSyndicated()
Sometimes we don't want to build rss / atom feeds.
Definition: SpecialMostInterwikis.php:59
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:676
SpecialMostInterwikis\getQueryInfo
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: SpecialMostInterwikis.php:63
QueryPage\setDBLoadBalancer
setDBLoadBalancer(ILoadBalancer $loadBalancer)
Definition: QueryPage.php:892
SpecialMostInterwikis\isExpensive
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
Definition: SpecialMostInterwikis.php:55
QueryPage\$linkBatchFactory
LinkBatchFactory null $linkBatchFactory
Definition: QueryPage.php:74
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:1028
QueryPage\$loadBalancer
ILoadBalancer null $loadBalancer
Definition: QueryPage.php:71
NamespaceInfo
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Definition: NamespaceInfo.php:35
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:232
SpecialMostInterwikis\formatResult
formatResult( $skin, $result)
Definition: SpecialMostInterwikis.php:104
SpecialMostInterwikis
A special page that listed pages that have highest interwiki count.
Definition: SpecialMostInterwikis.php:34
Wikimedia\Rdbms\ILoadBalancer
Database cluster connection, tracking, load balancing, and transaction manager interface.
Definition: ILoadBalancer.php:81