MediaWiki
REL1_24
|
00001 <?php 00032 class ListDuplicatedFilesPage extends QueryPage { 00033 function __construct( $name = 'ListDuplicatedFiles' ) { 00034 parent::__construct( $name ); 00035 } 00036 00037 function isExpensive() { 00038 return true; 00039 } 00040 00041 function isSyndicated() { 00042 return false; 00043 } 00044 00056 function getQueryInfo() { 00057 return array( 00058 'tables' => array( 'image' ), 00059 'fields' => array( 00060 'namespace' => NS_FILE, 00061 'title' => 'MIN(img_name)', 00062 'value' => 'count(*)' 00063 ), 00064 'options' => array( 00065 'GROUP BY' => 'img_sha1', 00066 'HAVING' => 'count(*) > 1', 00067 ), 00068 ); 00069 } 00070 00077 function preprocessResults( $db, $res ) { 00078 if ( $res->numRows() > 0 ) { 00079 $linkBatch = new LinkBatch(); 00080 00081 foreach ( $res as $row ) { 00082 $linkBatch->add( $row->namespace, $row->title ); 00083 } 00084 00085 $res->seek( 0 ); 00086 $linkBatch->execute(); 00087 } 00088 } 00089 00090 00096 function formatResult( $skin, $result ) { 00097 // Future version might include a list of the first 5 duplicates 00098 // perhaps separated by an "↔". 00099 $image1 = Title::makeTitle( $result->namespace, $result->title ); 00100 $dupeSearch = SpecialPage::getTitleFor( 'FileDuplicateSearch', $image1->getDBKey() ); 00101 00102 $msg = $this->msg( 'listduplicatedfiles-entry' ) 00103 ->params( $image1->getText() ) 00104 ->numParams( $result->value - 1 ) 00105 ->params( $dupeSearch->getPrefixedDBKey() ); 00106 00107 return $msg->parse(); 00108 } 00109 00110 protected function getGroupName() { 00111 return 'media'; 00112 } 00113 }