MediaWiki  master
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 }
__construct( $name='ListDuplicatedFiles')
preprocessResults( $db, $res)
Pre-fill the link cache.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
This is a class for doing query pages; since they&#39;re almost all the same, we factor out some of the f...
Definition: QueryPage.php:36
const NS_FILE
Definition: Defines.php:66
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don&#39;t need a full Title object...
Definition: SpecialPage.php:83
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:586
getQueryInfo()
Get all the duplicates by grouping on sha1s.
msg( $key)
Wrapper around wfMessage that sets the current context.
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:768
Special:ListDuplicatedFiles Lists all files where the current version is a duplicate of the current v...