Debian Codegraph @

includes/specials/SpecialUnusedCategories.php

raw symbols SCIP
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 */
20
21 namespace MediaWiki\Specials;
22
23 use MediaWiki\Cache\LinkBatchFactory;
24 use MediaWiki\SpecialPage\QueryPage;
25 use MediaWiki\Title\Title;
26 use Skin;
27 use stdClass;
28 use Wikimedia\Rdbms\IConnectionProvider;
29
30 /**
31 * Implements Special:Unusedcategories
32 *
33 * @ingroup SpecialPage
34 */
35 class SpecialUnusedCategories extends QueryPage {
36
37 /**
38 * @param IConnectionProvider $dbProvider
39 * @param LinkBatchFactory $linkBatchFactory
40 */
41 public function __construct(
42 IConnectionProvider $dbProvider,
43 LinkBatchFactory $linkBatchFactory
44 ) {
45 parent::__construct( 'Unusedcategories' );
46 $this->setDatabaseProvider( $dbProvider );
47 $this->setLinkBatchFactory( $linkBatchFactory );
48 }
49
50 public function isExpensive() {
51 return true;
52 }
53
54 protected function getPageHeader() {
55 return $this->msg( 'unusedcategoriestext' )->parseAsBlock();
56 }
57
58 protected function getOrderFields() {
59 return [ 'title' ];
60 }
61
62 public function getQueryInfo() {
63 return [
64 'tables' => [ 'page', 'categorylinks', 'page_props' ],
65 'fields' => [
66 'namespace' => 'page_namespace',
67 'title' => 'page_title',
68 ],
69 'conds' => [
70 'cl_from' => null,
71 'page_namespace' => NS_CATEGORY,
72 'page_is_redirect' => 0,
73 'pp_page' => null,
74 ],
75 'join_conds' => [
76 'categorylinks' => [ 'LEFT JOIN', 'cl_to = page_title' ],
77 'page_props' => [ 'LEFT JOIN', [
78 'page_id = pp_page',
79 'pp_propname' => 'expectunusedcategory'
80 ] ]
81 ]
82 ];
83 }
84
85 /**
86 * A should come before Z (T32907)
87 * @return bool
88 */
89 protected function sortDescending() {
90 return false;
91 }
92
93 /**
94 * @param Skin $skin
95 * @param stdClass $result Result row
96 * @return string
97 */
98 public function formatResult( $skin, $result ) {
99 $title = Title::makeTitle( NS_CATEGORY, $result->title );
100
101 return $this->getLinkRenderer()->makeLink( $title, $title->getText() );
102 }
103
104 protected function getGroupName() {
105 return 'maintenance';
106 }
107
108 public function preprocessResults( $db, $res ) {
109 $this->executeLBFromResultWrapper( $res );
110 }
111 }
112
113 /**
114 * Retain the old class name for backwards compatibility.
115 * @deprecated since 1.41
116 */
117 class_alias( SpecialUnusedCategories::class, 'SpecialUnusedCategories' );