MediaWiki  master
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 ) {
88  $linkRenderer = $this->getLinkRenderer();
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 }
SpecialPage\$linkRenderer
LinkRenderer null $linkRenderer
Definition: SpecialPage.php:80
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:912
SpecialUnusedTemplates\getOrderFields
getOrderFields()
Subclasses return an array of fields to order by here.
Definition: SpecialUnusedTemplates.php:56
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
$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
SpecialUnusedTemplates\isExpensive
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
Definition: SpecialUnusedTemplates.php:44
SpecialUnusedTemplates\getQueryInfo
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: SpecialUnusedTemplates.php:60
SpecialUnusedTemplates\isSyndicated
isSyndicated()
Sometimes we don't want to build rss / atom feeds.
Definition: SpecialUnusedTemplates.php:48
NS_TEMPLATE
const NS_TEMPLATE
Definition: Defines.php:74
$title
$title
Definition: testCompression.php:38
SpecialUnusedTemplates\preprocessResults
preprocessResults( $db, $res)
Do any necessary preprocessing of the result object.
Definition: SpecialUnusedTemplates.php:78
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:663
SpecialUnusedTemplates\sortDescending
sortDescending()
Override to sort by increasing values.
Definition: SpecialUnusedTemplates.php:52
SpecialUnusedTemplates
A special page that lists unused templates.
Definition: SpecialUnusedTemplates.php:34
SpecialUnusedTemplates\getPageHeader
getPageHeader()
The content returned by this function will be output before any result.
Definition: SpecialUnusedTemplates.php:104
SpecialUnusedTemplates\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialUnusedTemplates.php:108
QueryPage\setDBLoadBalancer
setDBLoadBalancer(ILoadBalancer $loadBalancer)
Definition: QueryPage.php:892
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:1028
SpecialUnusedTemplates\__construct
__construct(ILoadBalancer $loadBalancer)
Definition: SpecialUnusedTemplates.php:39
SpecialUnusedTemplates\formatResult
formatResult( $skin, $result)
Definition: SpecialUnusedTemplates.php:87
QueryPage\$loadBalancer
ILoadBalancer null $loadBalancer
Definition: QueryPage.php:71
Wikimedia\Rdbms\ILoadBalancer
Database cluster connection, tracking, load balancing, and transaction manager interface.
Definition: ILoadBalancer.php:81