MediaWiki REL1_37
SpecialUnusedTemplates.php
Go to the documentation of this file.
1<?php
28
35
40 parent::__construct( 'Unusedtemplates' );
41 $this->setDBLoadBalancer( $loadBalancer );
42 }
43
44 public function isExpensive() {
45 return true;
46 }
47
48 public function isSyndicated() {
49 return false;
50 }
51
52 protected function sortDescending() {
53 return false;
54 }
55
56 protected function getOrderFields() {
57 return [ 'title' ];
58 }
59
60 public function getQueryInfo() {
61 return [
62 'tables' => [ 'page', 'templatelinks' ],
63 'fields' => [
64 'namespace' => 'page_namespace',
65 'title' => 'page_title',
66 ],
67 'conds' => [
68 'page_namespace' => NS_TEMPLATE,
69 'tl_from IS NULL',
70 'page_is_redirect' => 0
71 ],
72 'join_conds' => [ 'templatelinks' => [
73 'LEFT JOIN', [ 'tl_title = page_title',
74 'tl_namespace = page_namespace' ] ] ]
75 ];
76 }
77
78 public function preprocessResults( $db, $res ) {
80 }
81
87 public function formatResult( $skin, $result ) {
89 $title = Title::makeTitle( NS_TEMPLATE, $result->title );
90 $pageLink = $linkRenderer->makeKnownLink(
91 $title,
92 null,
93 [],
94 [ 'redirect' => 'no' ]
95 );
96 $wlhLink = $linkRenderer->makeKnownLink(
97 SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() ),
98 $this->msg( 'unusedtemplateswlh' )->text()
99 );
100
101 return $this->getLanguage()->specialList( $pageLink, $wlhLink );
102 }
103
104 protected function getPageHeader() {
105 return $this->msg( 'unusedtemplatestext' )->parseAsBlock();
106 }
107
108 protected function getGroupName() {
109 return 'maintenance';
110 }
111}
const NS_TEMPLATE
Definition Defines.php:74
makeKnownLink( $target, $text=null, array $extraAttribs=[], array $query=[])
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)
ILoadBalancer null $loadBalancer
Definition QueryPage.php:71
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,...
LinkRenderer null $linkRenderer
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getLanguage()
Shortcut to get user's language.
A special page that lists unused templates.
sortDescending()
Override to sort by increasing values.
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
isSyndicated()
Sometime we don't want to build rss / atom feeds.
getPageHeader()
The content returned by this function will be output before any result.
preprocessResults( $db, $res)
Do any necessary preprocessing of the result object.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
__construct(ILoadBalancer $loadBalancer)
getOrderFields()
Subclasses return an array of fields to order by here.
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
Database cluster connection, tracking, load balancing, and transaction manager interface.