MediaWiki  master
SpecialUnusedImages.php
Go to the documentation of this file.
1 <?php
30  function __construct( $name = 'Unusedimages' ) {
31  parent::__construct( $name );
32  }
33 
34  function isExpensive() {
35  return true;
36  }
37 
38  function sortDescending() {
39  return false;
40  }
41 
42  function isSyndicated() {
43  return false;
44  }
45 
46  function getQueryInfo() {
47  $retval = [
48  'tables' => [ 'image', 'imagelinks' ],
49  'fields' => [
50  'namespace' => NS_FILE,
51  'title' => 'img_name',
52  'value' => 'img_timestamp',
53  ],
54  'conds' => [ 'il_to IS NULL' ],
55  'join_conds' => [ 'imagelinks' => [ 'LEFT JOIN', 'il_to = img_name' ] ]
56  ];
57 
58  if ( $this->getConfig()->get( 'CountCategorizedImagesAsUsed' ) ) {
59  // Order is significant
60  $retval['tables'] = [ 'image', 'page', 'categorylinks',
61  'imagelinks' ];
62  $retval['conds']['page_namespace'] = NS_FILE;
63  $retval['conds'][] = 'cl_from IS NULL';
64  $retval['conds'][] = 'img_name = page_title';
65  $retval['join_conds']['categorylinks'] = [
66  'LEFT JOIN', 'cl_from = page_id' ];
67  $retval['join_conds']['imagelinks'] = [
68  'LEFT JOIN', 'il_to = page_title' ];
69  }
70 
71  return $retval;
72  }
73 
74  function usesTimestamps() {
75  return true;
76  }
77 
78  function getPageHeader() {
79  if ( $this->getConfig()->get( 'CountCategorizedImagesAsUsed' ) ) {
80  return $this->msg(
81  'unusedimagestext-categorizedimgisused'
82  )->parseAsBlock();
83  }
84  return $this->msg( 'unusedimagestext' )->parseAsBlock();
85  }
86 
87  protected function getGroupName() {
88  return 'maintenance';
89  }
90 }
Variant of QueryPage which uses a gallery to output results, thus suited for reports generating image...
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
const NS_FILE
Definition: Defines.php:66
getConfig()
Shortcut to get main config object.
__construct( $name='Unusedimages')
A special page that lists unused images.