MediaWiki  master
SpecialUnusedImages.php
Go to the documentation of this file.
1 <?php
25 
32 
37  parent::__construct( 'Unusedimages' );
38  $this->setDBLoadBalancer( $loadBalancer );
39  }
40 
41  public function isExpensive() {
42  return true;
43  }
44 
45  protected function sortDescending() {
46  return false;
47  }
48 
49  public function isSyndicated() {
50  return false;
51  }
52 
53  public function getQueryInfo() {
54  $retval = [
55  'tables' => [ 'image', 'imagelinks' ],
56  'fields' => [
57  'namespace' => NS_FILE,
58  'title' => 'img_name',
59  'value' => 'img_timestamp',
60  ],
61  'conds' => [ 'il_to IS NULL' ],
62  'join_conds' => [ 'imagelinks' => [ 'LEFT JOIN', 'il_to = img_name' ] ]
63  ];
64 
65  if ( $this->getConfig()->get( 'CountCategorizedImagesAsUsed' ) ) {
66  // Order is significant
67  $retval['tables'] = [ 'image', 'page', 'categorylinks',
68  'imagelinks' ];
69  $retval['conds']['page_namespace'] = NS_FILE;
70  $retval['conds'][] = 'cl_from IS NULL';
71  $retval['conds'][] = 'img_name = page_title';
72  $retval['join_conds']['categorylinks'] = [
73  'LEFT JOIN', 'cl_from = page_id' ];
74  $retval['join_conds']['imagelinks'] = [
75  'LEFT JOIN', 'il_to = page_title' ];
76  }
77 
78  return $retval;
79  }
80 
81  public function usesTimestamps() {
82  return true;
83  }
84 
85  protected function getPageHeader() {
86  if ( $this->getConfig()->get( 'CountCategorizedImagesAsUsed' ) ) {
87  return $this->msg(
88  'unusedimagestext-categorizedimgisused'
89  )->parseAsBlock();
90  }
91  return $this->msg( 'unusedimagestext' )->parseAsBlock();
92  }
93 
94  protected function getGroupName() {
95  return 'maintenance';
96  }
97 }
SpecialUnusedImages\getQueryInfo
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: SpecialUnusedImages.php:53
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:911
SpecialUnusedImages\isSyndicated
isSyndicated()
Sometime we don't want to build rss / atom feeds.
Definition: SpecialUnusedImages.php:49
SpecialUnusedImages\__construct
__construct(ILoadBalancer $loadBalancer)
Definition: SpecialUnusedImages.php:36
SpecialUnusedImages\isExpensive
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
Definition: SpecialUnusedImages.php:41
SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
Definition: SpecialPage.php:877
SpecialUnusedImages\sortDescending
sortDescending()
Override to sort by increasing values.
Definition: SpecialUnusedImages.php:45
SpecialUnusedImages\getPageHeader
getPageHeader()
The content returned by this function will be output before any result.
Definition: SpecialUnusedImages.php:85
SpecialUnusedImages
A special page that lists unused images.
Definition: SpecialUnusedImages.php:31
QueryPage\setDBLoadBalancer
setDBLoadBalancer(ILoadBalancer $loadBalancer)
Definition: QueryPage.php:873
SpecialUnusedImages\usesTimestamps
usesTimestamps()
Does this query return timestamps rather than integers in its 'value' field? If true,...
Definition: SpecialUnusedImages.php:81
QueryPage\$loadBalancer
ILoadBalancer null $loadBalancer
Definition: QueryPage.php:71
NS_FILE
const NS_FILE
Definition: Defines.php:70
ImageQueryPage
Variant of QueryPage which uses a gallery to output results, thus suited for reports generating image...
Definition: ImageQueryPage.php:36
Wikimedia\Rdbms\ILoadBalancer
Database cluster connection, tracking, load balancing, and transaction manager interface.
Definition: ILoadBalancer.php:81
SpecialUnusedImages\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialUnusedImages.php:94