MediaWiki 1.40.4
SpecialMostLinkedTemplates.php
Go to the documentation of this file.
1<?php
33
41
43 private $linksMigration;
44
50 public function __construct(
51 ILoadBalancer $loadBalancer,
52 LinkBatchFactory $linkBatchFactory,
53 LinksMigration $linksMigration
54 ) {
55 parent::__construct( 'Mostlinkedtemplates' );
56 $this->setDBLoadBalancer( $loadBalancer );
57 $this->setLinkBatchFactory( $linkBatchFactory );
58 $this->linksMigration = $linksMigration;
59 }
60
66 public function isExpensive() {
67 return true;
68 }
69
75 public function isSyndicated() {
76 return false;
77 }
78
84 public function sortDescending() {
85 return true;
86 }
87
88 public function getQueryInfo() {
89 $queryInfo = $this->linksMigration->getQueryInfo( 'templatelinks' );
90 [ $ns, $title ] = $this->linksMigration->getTitleFields( 'templatelinks' );
91 return [
92 'tables' => $queryInfo['tables'],
93 'fields' => [
94 'namespace' => $ns,
95 'title' => $title,
96 'value' => 'COUNT(*)'
97 ],
98 'options' => [ 'GROUP BY' => [ $ns, $title ] ],
99 'join_conds' => $queryInfo['joins']
100 ];
101 }
102
109 public function preprocessResults( $db, $res ) {
111 }
112
120 public function formatResult( $skin, $result ) {
121 $title = Title::makeTitleSafe( $result->namespace, $result->title );
122 if ( !$title ) {
123 return Html::element(
124 'span',
125 [ 'class' => 'mw-invalidtitle' ],
126 Linker::getInvalidTitleDescription(
127 $this->getContext(),
128 $result->namespace,
129 $result->title
130 )
131 );
132 }
133
134 return $this->getLanguage()->specialList(
135 $this->getLinkRenderer()->makeLink( $title ),
136 $this->makeWlhLink( $title, $result )
137 );
138 }
139
147 private function makeWlhLink( $title, $result ) {
148 $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() );
149 $label = $this->msg( 'ntransclusions' )->numParams( $result->value )->text();
150
151 return $this->getLinkRenderer()->makeLink( $wlh, $label );
152 }
153
154 protected function getGroupName() {
155 return 'highuse';
156 }
157}
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
Service for compat reading of links tables.
Represents a title within MediaWiki.
Definition Title.php:82
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)
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
Special page lists templates with a large number of transclusion links, i.e.
sortDescending()
Sort the results in descending order?
preprocessResults( $db, $res)
Pre-cache page existence to speed up link generation.
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
isSyndicated()
Is there a feed available?
__construct(ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory, LinksMigration $linksMigration)
isExpensive()
Is this report expensive, i.e should it be cached?
formatResult( $skin, $result)
Format a result row.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
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.