MediaWiki REL1_37
SpecialMostLinkedTemplates.php
Go to the documentation of this file.
1<?php
29
37
42 public function __construct(
45 ) {
46 parent::__construct( 'Mostlinkedtemplates' );
47 $this->setDBLoadBalancer( $loadBalancer );
48 $this->setLinkBatchFactory( $linkBatchFactory );
49 }
50
56 public function isExpensive() {
57 return true;
58 }
59
65 public function isSyndicated() {
66 return false;
67 }
68
74 public function sortDescending() {
75 return true;
76 }
77
78 public function getQueryInfo() {
79 return [
80 'tables' => [ 'templatelinks' ],
81 'fields' => [
82 'namespace' => 'tl_namespace',
83 'title' => 'tl_title',
84 'value' => 'COUNT(*)'
85 ],
86 'options' => [ 'GROUP BY' => [ 'tl_namespace', 'tl_title' ] ]
87 ];
88 }
89
96 public function preprocessResults( $db, $res ) {
98 }
99
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' ],
114 $this->getContext(),
115 $result->namespace,
116 $result->title
117 )
118 );
119 }
120
121 return $this->getLanguage()->specialList(
122 $this->getLinkRenderer()->makeLink( $title ),
123 $this->makeWlhLink( $title, $result )
124 );
125 }
126
134 private function makeWlhLink( $title, $result ) {
135 $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() );
136 $label = $this->msg( 'ntransclusions' )->numParams( $result->value )->text();
137
138 return $this->getLinkRenderer()->makeLink( $wlh, $label );
139 }
140
141 protected function getGroupName() {
142 return 'highuse';
143 }
144}
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition Linker.php:185
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
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)
LinkBatchFactory null $linkBatchFactory
Definition QueryPage.php:74
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
ILoadBalancer null $loadBalancer
Definition QueryPage.php:71
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.
makeWlhLink( $title, $result)
Make a "what links here" link for a given title.
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
isSyndicated()
Is there a feed available?
isExpensive()
Is this report expensive, i.e should it be cached?
__construct(ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory)
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:38
Database cluster connection, tracking, load balancing, and transaction manager interface.
Result wrapper for grabbing data queried from an IDatabase object.