MediaWiki  1.34.0
SpecialListDuplicatedFiles.php
Go to the documentation of this file.
1 <?php
29 
36  function __construct( $name = 'ListDuplicatedFiles' ) {
37  parent::__construct( $name );
38  }
39 
40  public function isExpensive() {
41  return true;
42  }
43 
44  function isSyndicated() {
45  return false;
46  }
47 
59  public function getQueryInfo() {
60  return [
61  'tables' => [ 'image' ],
62  'fields' => [
63  'namespace' => NS_FILE,
64  'title' => 'MIN(img_name)',
65  'value' => 'count(*)'
66  ],
67  'options' => [
68  'GROUP BY' => 'img_sha1',
69  'HAVING' => 'count(*) > 1',
70  ],
71  ];
72  }
73 
80  function preprocessResults( $db, $res ) {
82  }
83 
89  function formatResult( $skin, $result ) {
90  // Future version might include a list of the first 5 duplicates
91  // perhaps separated by an "↔".
92  $image1 = Title::makeTitle( $result->namespace, $result->title );
93  $dupeSearch = SpecialPage::getTitleFor( 'FileDuplicateSearch', $image1->getDBkey() );
94 
95  $msg = $this->msg( 'listduplicatedfiles-entry' )
96  ->params( $image1->getText() )
97  ->numParams( $result->value - 1 )
98  ->params( $dupeSearch->getPrefixedDBkey() );
99 
100  return $msg->parse();
101  }
102 
103  public function execute( $par ) {
104  $this->addHelpLink( 'Help:Managing_files' );
105  parent::execute( $par );
106  }
107 
108  protected function getGroupName() {
109  return 'media';
110  }
111 }
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:792
SpecialListDuplicatedFiles\getQueryInfo
getQueryInfo()
Get all the duplicates by grouping on sha1s.
Definition: SpecialListDuplicatedFiles.php:59
NS_FILE
const NS_FILE
Definition: Defines.php:66
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Definition: SpecialPage.php:83
$res
$res
Definition: testCompression.php:52
SpecialListDuplicatedFiles\execute
execute( $par)
This is the actual workhorse.
Definition: SpecialListDuplicatedFiles.php:103
QueryPage
This is a class for doing query pages; since they're almost all the same, we factor out some of the f...
Definition: QueryPage.php:36
QueryPage\executeLBFromResultWrapper
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
Definition: QueryPage.php:800
SpecialListDuplicatedFiles\preprocessResults
preprocessResults( $db, $res)
Pre-fill the link cache.
Definition: SpecialListDuplicatedFiles.php:80
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:828
SpecialListDuplicatedFiles\formatResult
formatResult( $skin, $result)
Definition: SpecialListDuplicatedFiles.php:89
SpecialListDuplicatedFiles\isSyndicated
isSyndicated()
Sometime we don't want to build rss / atom feeds.
Definition: SpecialListDuplicatedFiles.php:44
SpecialListDuplicatedFiles
Special:ListDuplicatedFiles Lists all files where the current version is a duplicate of the current v...
Definition: SpecialListDuplicatedFiles.php:35
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:24
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:586
SpecialListDuplicatedFiles\isExpensive
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
Definition: SpecialListDuplicatedFiles.php:40
SpecialListDuplicatedFiles\__construct
__construct( $name='ListDuplicatedFiles')
Definition: SpecialListDuplicatedFiles.php:36
SpecialListDuplicatedFiles\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialListDuplicatedFiles.php:108