MediaWiki master
SpecialUnusedCategories.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Specials;
8
9use MediaWiki\Cache\LinkBatchFactory;
13use stdClass;
15
22
23 public function __construct(
24 IConnectionProvider $dbProvider,
25 LinkBatchFactory $linkBatchFactory
26 ) {
27 parent::__construct( 'Unusedcategories' );
28 $this->setDatabaseProvider( $dbProvider );
29 $this->setLinkBatchFactory( $linkBatchFactory );
30 }
31
33 public function isExpensive() {
34 return true;
35 }
36
38 protected function getPageHeader() {
39 return $this->msg( 'unusedcategoriestext' )->parseAsBlock();
40 }
41
43 protected function getOrderFields() {
44 return [ 'title' ];
45 }
46
48 public function getQueryInfo() {
49 return [
50 'tables' => [ 'page', 'linktarget', 'categorylinks', 'page_props' ],
51 'fields' => [
52 'namespace' => 'page_namespace',
53 'title' => 'page_title',
54 ],
55 'conds' => [
56 'cl_from' => null,
57 'page_namespace' => NS_CATEGORY,
58 'page_is_redirect' => 0,
59 'pp_page' => null,
60 ],
61 'join_conds' => [
62 'linktarget' => [ 'LEFT JOIN', [
63 'lt_title = page_title',
64 'lt_namespace = page_namespace',
65 ] ],
66 'categorylinks' => [ 'LEFT JOIN', 'cl_target_id = lt_id' ],
67 'page_props' => [ 'LEFT JOIN', [
68 'page_id = pp_page',
69 'pp_propname' => 'expectunusedcategory'
70 ] ]
71 ],
72 ];
73 }
74
79 protected function sortDescending() {
80 return false;
81 }
82
88 public function formatResult( $skin, $result ) {
89 $title = Title::makeTitle( NS_CATEGORY, $result->title );
90
91 return $this->getLinkRenderer()->makeLink( $title, $title->getText() );
92 }
93
95 protected function getGroupName() {
96 return 'maintenance';
97 }
98
100 public function preprocessResults( $db, $res ) {
101 $this->executeLBFromResultWrapper( $res );
102 }
103}
104
109class_alias( SpecialUnusedCategories::class, 'SpecialUnusedCategories' );
const NS_CATEGORY
Definition Defines.php:65
makeTitle( $linkId)
Convert a link ID to a Title.to override Title
The base class for all skins.
Definition Skin.php:52
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...
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
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...
isExpensive()
Should this query page only be updated offline on large wikis?If the query for this page is considere...
sortDescending()
A should come before Z (T32907)
getPageHeader()
The content returned by this function will be output before any result.to override string
preprocessResults( $db, $res)
Do any necessary preprocessing of the result object.to override
__construct(IConnectionProvider $dbProvider, LinkBatchFactory $linkBatchFactory)
getOrderFields()
Subclasses return an array of fields to order by here.Don't append DESC to the field names,...
Represents a title within MediaWiki.
Definition Title.php:69
Provide primary and replica IDatabase connections.