MediaWiki REL1_39
SpecialUnusedTemplates.php
Go to the documentation of this file.
1<?php
29
36
38 private $linksMigration;
39
44 public function __construct(
45 ILoadBalancer $loadBalancer,
46 LinksMigration $linksMigration
47 ) {
48 parent::__construct( 'Unusedtemplates' );
49 $this->setDBLoadBalancer( $loadBalancer );
50 $this->linksMigration = $linksMigration;
51 }
52
53 public function isExpensive() {
54 return true;
55 }
56
57 public function isSyndicated() {
58 return false;
59 }
60
61 protected function sortDescending() {
62 return false;
63 }
64
65 protected function getOrderFields() {
66 return [ 'title' ];
67 }
68
69 public function getQueryInfo() {
70 $queryInfo = $this->linksMigration->getQueryInfo(
71 'templatelinks',
72 'templatelinks',
73 'LEFT JOIN'
74 );
75 list( $ns, $title ) = $this->linksMigration->getTitleFields( 'templatelinks' );
76 $joinConds = [];
77 $templatelinksJoin = [
78 'LEFT JOIN', [ "$title = page_title",
79 "$ns = page_namespace" ] ];
80 if ( in_array( 'linktarget', $queryInfo['tables'] ) ) {
81 $joinConds['linktarget'] = $templatelinksJoin;
82 } else {
83 $joinConds['templatelinks'] = $templatelinksJoin;
84 }
85 return [
86 'tables' => array_merge( $queryInfo['tables'], [ 'page' ] ),
87 'fields' => [
88 'namespace' => 'page_namespace',
89 'title' => 'page_title',
90 ],
91 'conds' => [
92 'page_namespace' => NS_TEMPLATE,
93 'tl_from IS NULL',
94 'page_is_redirect' => 0
95 ],
96 'join_conds' => array_merge( $joinConds, $queryInfo['joins'] )
97 ];
98 }
99
100 public function preprocessResults( $db, $res ) {
102 }
103
109 public function formatResult( $skin, $result ) {
110 $linkRenderer = $this->getLinkRenderer();
111 $title = Title::makeTitle( NS_TEMPLATE, $result->title );
112 $pageLink = $linkRenderer->makeKnownLink(
113 $title,
114 null,
115 [],
116 [ 'redirect' => 'no' ]
117 );
118 $wlhLink = $linkRenderer->makeKnownLink(
119 SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() ),
120 $this->msg( 'unusedtemplateswlh' )->text()
121 );
122
123 return $this->getLanguage()->specialList( $pageLink, $wlhLink );
124 }
125
126 protected function getPageHeader() {
127 return $this->msg( 'unusedtemplatestext' )->parseAsBlock();
128 }
129
130 protected function getGroupName() {
131 return 'maintenance';
132 }
133}
const NS_TEMPLATE
Definition Defines.php:74
Service for compat reading of links tables.
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:42
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)
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,...
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.
__construct(ILoadBalancer $loadBalancer, LinksMigration $linksMigration)
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
isSyndicated()
Sometimes 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...
getOrderFields()
Subclasses return an array of fields to order by here.
isExpensive()
Should this query page only be updated offline on large wikis?
Create and track the database connections and transactions for a given database cluster.