MediaWiki  master
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 }
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:912
SpecialMostLinkedTemplates\preprocessResults
preprocessResults( $db, $res)
Pre-cache page existence to speed up link generation.
Definition: SpecialMostLinkedTemplates.php:96
SpecialPage\getTitleFor
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,...
Definition: SpecialPage.php:107
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
SpecialMostLinkedTemplates\isExpensive
isExpensive()
Is this report expensive, i.e should it be cached?
Definition: SpecialMostLinkedTemplates.php:56
SpecialMostLinkedTemplates\makeWlhLink
makeWlhLink( $title, $result)
Make a "what links here" link for a given title.
Definition: SpecialMostLinkedTemplates.php:134
SpecialMostLinkedTemplates\formatResult
formatResult( $skin, $result)
Format a result row.
Definition: SpecialMostLinkedTemplates.php:107
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:26
SpecialMostLinkedTemplates\sortDescending
sortDescending()
Sort the results in descending order?
Definition: SpecialMostLinkedTemplates.php:74
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
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:689
QueryPage\setDBLoadBalancer
setDBLoadBalancer(ILoadBalancer $loadBalancer)
Definition: QueryPage.php:892
QueryPage\$linkBatchFactory
LinkBatchFactory null $linkBatchFactory
Definition: QueryPage.php:74
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:1028
SpecialMostLinkedTemplates
Special page lists templates with a large number of transclusion links, i.e.
Definition: SpecialMostLinkedTemplates.php:36
SpecialMostLinkedTemplates\isSyndicated
isSyndicated()
Is there a feed available?
Definition: SpecialMostLinkedTemplates.php:65
SpecialMostLinkedTemplates\__construct
__construct(ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory)
Definition: SpecialMostLinkedTemplates.php:42
QueryPage\$loadBalancer
ILoadBalancer null $loadBalancer
Definition: QueryPage.php:71
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:232
SpecialMostLinkedTemplates\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialMostLinkedTemplates.php:141
Wikimedia\Rdbms\ILoadBalancer
Database cluster connection, tracking, load balancing, and transaction manager interface.
Definition: ILoadBalancer.php:81
SpecialMostLinkedTemplates\getQueryInfo
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: SpecialMostLinkedTemplates.php:78