MediaWiki
REL1_23
|
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 00055 function getQueryInfo() { 00056 return array( 00057 'tables' => array( 'image' ), 00058 'fields' => array( 00059 'namespace' => NS_FILE, 00060 'title' => 'MIN(img_name)', 00061 'value' => 'count(*)' 00062 ), 00063 'options' => array( 00064 'GROUP BY' => 'img_sha1', 00065 'HAVING' => 'count(*) > 1', 00066 ), 00067 ); 00068 } 00069 00076 function preprocessResults( $db, $res ) { 00077 if ( $res->numRows() > 0 ) { 00078 $linkBatch = new LinkBatch(); 00079 00080 foreach ( $res as $row ) { 00081 $linkBatch->add( $row->namespace, $row->title ); 00082 } 00083 00084 $res->seek( 0 ); 00085 $linkBatch->execute(); 00086 } 00087 } 00088 00089 00095 function formatResult( $skin, $result ) { 00096 // Future version might include a list of the first 5 duplicates 00097 // perhaps separated by an "↔". 00098 $image1 = Title::makeTitle( $result->namespace, $result->title ); 00099 $dupeSearch = SpecialPage::getTitleFor( 'FileDuplicateSearch', $image1->getDBKey() ); 00100 00101 $msg = $this->msg( 'listduplicatedfiles-entry' ) 00102 ->params( $image1->getText() ) 00103 ->numParams( $result->value - 1 ) 00104 ->params( $dupeSearch->getPrefixedDBKey() ); 00105 00106 return $msg->parse(); 00107 } 00108 00109 protected function getGroupName() { 00110 return 'media'; 00111 } 00112 }