| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
namespace MediaWiki\Specials; |
| 22 |
|
| 23 |
use MediaWiki\MainConfigNames; |
| 24 |
use MediaWiki\SpecialPage\ImageQueryPage; |
| 25 |
use Wikimedia\Rdbms\IConnectionProvider; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
class SpecialUnusedImages extends ImageQueryPage { |
| 33 |
|
| 34 |
|
| 35 |
|
| 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 |
|
| 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 |
|
| 102 |
|
| 103 |
|
| 104 |
class_alias( SpecialUnusedImages::class, 'SpecialUnusedImages' ); |