MediaWiki REL1_40
SpecialListDuplicatedFiles.php
Go to the documentation of this file.
1<?php
32
39
44 public function __construct(
45 ILoadBalancer $loadBalancer,
46 LinkBatchFactory $linkBatchFactory
47 ) {
48 parent::__construct( 'ListDuplicatedFiles' );
49 $this->setDBLoadBalancer( $loadBalancer );
50 $this->setLinkBatchFactory( $linkBatchFactory );
51 }
52
53 public function isExpensive() {
54 return true;
55 }
56
57 public function isSyndicated() {
58 return false;
59 }
60
72 public function getQueryInfo() {
73 return [
74 'tables' => [ 'image' ],
75 'fields' => [
76 'namespace' => NS_FILE,
77 'title' => 'MIN(img_name)',
78 'value' => 'count(*)'
79 ],
80 'options' => [
81 'GROUP BY' => 'img_sha1',
82 'HAVING' => 'count(*) > 1',
83 ],
84 ];
85 }
86
93 public function preprocessResults( $db, $res ) {
95 }
96
102 public function formatResult( $skin, $result ) {
103 // Future version might include a list of the first 5 duplicates
104 // perhaps separated by an "↔".
105 $image1 = Title::makeTitle( $result->namespace, $result->title );
106 $dupeSearch = SpecialPage::getTitleFor( 'FileDuplicateSearch', $image1->getDBkey() );
107
108 $msg = $this->msg( 'listduplicatedfiles-entry' )
109 ->params( $image1->getText() )
110 ->numParams( $result->value - 1 )
111 ->params( $dupeSearch->getPrefixedDBkey() );
112
113 return $msg->parse();
114 }
115
116 public function execute( $par ) {
117 $this->addHelpLink( 'Help:Managing_files' );
118 parent::execute( $par );
119 }
120
121 protected function getGroupName() {
122 return 'media';
123 }
124}
const NS_FILE
Definition Defines.php:70
Represents a title within MediaWiki.
Definition Title.php:82
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:45
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
setDBLoadBalancer(ILoadBalancer $loadBalancer)
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
Special:ListDuplicatedFiles Lists all files where the current version is a duplicate of the current v...
isExpensive()
Should this query page only be updated offline on large wikis?
__construct(ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory)
execute( $par)
This is the actual workhorse.
preprocessResults( $db, $res)
Pre-fill the link cache.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
isSyndicated()
Sometimes we don't want to build rss / atom feeds.
getQueryInfo()
Get all the duplicates by grouping on sha1s.
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,...
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:36
This class is a delegate to ILBFactory for a given database cluster.
Result wrapper for grabbing data queried from an IDatabase object.