MediaWiki master
SpecialUnusedTemplates.php
Go to the documentation of this file.
1<?php
9namespace MediaWiki\Specials;
10
16use stdClass;
18
27
28 public function __construct(
29 IConnectionProvider $dbProvider,
30 ) {
31 parent::__construct( 'Unusedtemplates' );
32 $this->setDatabaseProvider( $dbProvider );
33 }
34
36 public function isExpensive() {
37 return true;
38 }
39
41 public function isSyndicated() {
42 return false;
43 }
44
46 protected function sortDescending() {
47 return false;
48 }
49
51 protected function getOrderFields() {
52 return [ 'title' ];
53 }
54
56 public function getQueryInfo() {
57 return [
58 'tables' => [ 'linktarget', 'templatelinks', 'page', 'page_props' ],
59 'fields' => [
60 'namespace' => 'page_namespace',
61 'title' => 'page_title',
62 ],
63 'conds' => [
64 'page_namespace' => NS_TEMPLATE,
65 'tl_from' => null,
66 'page_is_redirect' => 0,
67 'pp_page' => null
68 ],
69 'join_conds' => [
70 'linktarget' => [ 'LEFT JOIN', [ 'lt_title = page_title', 'lt_namespace = page_namespace' ] ],
71 'templatelinks' => [ 'LEFT JOIN', [ 'tl_target_id = lt_id' ] ],
72 'page_props' => [ 'LEFT JOIN', [ 'page_id = pp_page', 'pp_propname' => 'expectunusedtemplate' ] ]
73 ]
74 ];
75 }
76
78 public function preprocessResults( $db, $res ) {
79 $this->executeLBFromResultWrapper( $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( $title );
91 $wlhLink = $linkRenderer->makeKnownLink(
92 SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() ),
93 $this->msg( 'unusedtemplateswlh' )->text()
94 );
95
96 return $this->getLanguage()->specialList( $pageLink, $wlhLink );
97 }
98
100 protected function getPageHeader() {
101 return $this->msg( 'unusedtemplatestext' )->parseAsBlock();
102 }
103
105 protected function getGroupName() {
106 return 'maintenance';
107 }
108
110 protected function getRecacheDB() {
111 return $this->getDatabaseProvider()->getReplicaDatabase(
112 TemplateLinksTable::VIRTUAL_DOMAIN,
113 'vslow'
114 );
115 }
116}
117
122class_alias( SpecialUnusedTemplates::class, 'SpecialUnusedTemplates' );
const NS_TEMPLATE
Definition Defines.php:61
makeTitle( $linkId)
Convert a link ID to a Title.to override Title
The base class for all skins.
Definition Skin.php:54
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:77
setDatabaseProvider(IConnectionProvider $databaseProvider)
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
Parent class for all special pages.
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.
isSyndicated()
Sometimes we don't want to build rss / atom feeds.to override bool
getOrderFields()
Subclasses return an array of fields to order by here.Don't append DESC to the field names,...
isExpensive()
Should this query page only be updated offline on large wikis?If the query for this page is considere...
sortDescending()
Override to sort by increasing values.to override bool
getRecacheDB()
Get a DB connection to be used for slow recache queries.to override IReadableDatabase
preprocessResults( $db, $res)
Do any necessary preprocessing of the result object.to override
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
__construct(IConnectionProvider $dbProvider,)
getPageHeader()
The content returned by this function will be output before any result.to override string
Represents a title within MediaWiki.
Definition Title.php:69
Provide primary and replica IDatabase connections.