MediaWiki  1.34.0
SpecialUnusedTemplates.php
Go to the documentation of this file.
1 <?php
33  function __construct( $name = 'Unusedtemplates' ) {
34  parent::__construct( $name );
35  }
36 
37  public function isExpensive() {
38  return true;
39  }
40 
41  function isSyndicated() {
42  return false;
43  }
44 
45  function sortDescending() {
46  return false;
47  }
48 
49  function getOrderFields() {
50  return [ 'title' ];
51  }
52 
53  public function getQueryInfo() {
54  return [
55  'tables' => [ 'page', 'templatelinks' ],
56  'fields' => [
57  'namespace' => 'page_namespace',
58  'title' => 'page_title',
59  ],
60  'conds' => [
61  'page_namespace' => NS_TEMPLATE,
62  'tl_from IS NULL',
63  'page_is_redirect' => 0
64  ],
65  'join_conds' => [ 'templatelinks' => [
66  'LEFT JOIN', [ 'tl_title = page_title',
67  'tl_namespace = page_namespace' ] ] ]
68  ];
69  }
70 
76  function formatResult( $skin, $result ) {
77  $linkRenderer = $this->getLinkRenderer();
78  $title = Title::makeTitle( NS_TEMPLATE, $result->title );
79  $pageLink = $linkRenderer->makeKnownLink(
80  $title,
81  null,
82  [],
83  [ 'redirect' => 'no' ]
84  );
85  $wlhLink = $linkRenderer->makeKnownLink(
86  SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() ),
87  $this->msg( 'unusedtemplateswlh' )->text()
88  );
89 
90  return $this->getLanguage()->specialList( $pageLink, $wlhLink );
91  }
92 
93  function getPageHeader() {
94  return $this->msg( 'unusedtemplatestext' )->parseAsBlock();
95  }
96 
97  protected function getGroupName() {
98  return 'maintenance';
99  }
100 }
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:792
SpecialUnusedTemplates\getOrderFields
getOrderFields()
Subclasses return an array of fields to order by here.
Definition: SpecialUnusedTemplates.php:49
NS_TEMPLATE
const NS_TEMPLATE
Definition: Defines.php:70
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:83
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:749
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:36
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:37
SpecialUnusedTemplates\getQueryInfo
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: SpecialUnusedTemplates.php:53
SpecialUnusedTemplates\isSyndicated
isSyndicated()
Sometime we don't want to build rss / atom feeds.
Definition: SpecialUnusedTemplates.php:41
SpecialUnusedTemplates\__construct
__construct( $name='Unusedtemplates')
Definition: SpecialUnusedTemplates.php:33
$title
$title
Definition: testCompression.php:34
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:586
SpecialUnusedTemplates\sortDescending
sortDescending()
Override to sort by increasing values.
Definition: SpecialUnusedTemplates.php:45
SpecialUnusedTemplates
A special page that lists unused templates.
Definition: SpecialUnusedTemplates.php:32
SpecialUnusedTemplates\getPageHeader
getPageHeader()
The content returned by this function will be output before any result.
Definition: SpecialUnusedTemplates.php:93
SpecialUnusedTemplates\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialUnusedTemplates.php:97
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:904
SpecialUnusedTemplates\formatResult
formatResult( $skin, $result)
Definition: SpecialUnusedTemplates.php:76
SpecialPage\$linkRenderer
MediaWiki Linker LinkRenderer null $linkRenderer
Definition: SpecialPage.php:67