Debian Codegraph @

includes/specials/SpecialUnusedImages.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\MainConfigNames;
24 use MediaWiki\SpecialPage\ImageQueryPage;
25 use Wikimedia\Rdbms\IConnectionProvider;
26
27 /**
28 * List of unused images
29 *
30 * @ingroup SpecialPage
31 */
32 class SpecialUnusedImages extends ImageQueryPage {
33
34 /**
35 * @param IConnectionProvider $dbProvider
36 */
37 public function __construct( IConnectionProvider $dbProvider ) {
38 parent::__construct( 'Unusedimages' );
39 $this->setDatabaseProvider( $dbProvider );
40 }
41
42 public function isExpensive() {
43 return true;
44 }
45
46 protected function sortDescending() {
47 return false;
48 }
49
50 public function isSyndicated() {
51 return false;
52 }
53
54 public function getQueryInfo() {
55 $retval = [
56 'tables' => [ 'image', 'imagelinks' ],
57 'fields' => [
58 'namespace' => NS_FILE,
59 'title' => 'img_name',
60 'value' => 'img_timestamp',
61 ],
62 'conds' => [ 'il_to' => null ],
63 'join_conds' => [ 'imagelinks' => [ 'LEFT JOIN', 'il_to = img_name' ] ]
64 ];
65
66 if ( $this->getConfig()->get( MainConfigNames::CountCategorizedImagesAsUsed ) ) {
67 // Order is significant
68 $retval['tables'] = [ 'image', 'page', 'categorylinks',
69 'imagelinks' ];
70 $retval['conds']['page_namespace'] = NS_FILE;
71 $retval['conds']['cl_from'] = null;
72 $retval['conds'][] = 'img_name = page_title';
73 $retval['join_conds']['categorylinks'] = [
74 'LEFT JOIN', 'cl_from = page_id' ];
75 $retval['join_conds']['imagelinks'] = [
76 'LEFT JOIN', 'il_to = page_title' ];
77 }
78
79 return $retval;
80 }
81
82 public function usesTimestamps() {
83 return true;
84 }
85
86 protected function getPageHeader() {
87 if ( $this->getConfig()->get( MainConfigNames::CountCategorizedImagesAsUsed ) ) {
88 return $this->msg(
89 'unusedimagestext-categorizedimgisused'
90 )->parseAsBlock();
91 }
92 return $this->msg( 'unusedimagestext' )->parseAsBlock();
93 }
94
95 protected function getGroupName() {
96 return 'maintenance';
97 }
98 }
99
100 /**
101 * Retain the old class name for backwards compatibility.
102 * @deprecated since 1.41
103 */
104 class_alias( SpecialUnusedImages::class, 'SpecialUnusedImages' );