if ( !$this->mDestWarningAck ) {
$warning .= self::getExistsWarning( $this->mLocalFile );
}
+
+ $warning .= $this->getDupeWarning( $this->mTempPath );
+
if( $warning != '' ) {
/**
* Stash the file in a temporary location; the user can choose
return $output->getText();
}
+
+ /**
+ * Check for duplicate files and throw up a warning before the upload
+ * completes.
+ */
+ function getDupeWarning( $tempfile ) {
+ $hash = File::sha1Base36( $tempfile );
+ $dupes = RepoGroup::singleton()->findBySha1( $hash );
+ if( $dupes ) {
+ global $wgOut;
+ $msg = "<gallery>";
+ foreach( $dupes as $file ) {
+ $title = $file->getTitle();
+ $msg .= $title->getPrefixedText() .
+ "|" . $title->getText() . "\n";
+ }
+ $msg .= "</gallery>";
+ return "<li>" .
+ wfMsgExt( "file-exists-duplicate", array( "parse" ), count( $dupes ) ) .
+ $wgOut->parse( $msg ) .
+ "</li>\n";
+ } else {
+ return '';
+ }
+ }
/**
* Get a list of blacklisted filename prefixes from [[MediaWiki:filename-prefix-blacklist]]
please go back and upload this file under a new name. [[Image:$1|thumb|center|$1]]',
'fileexists-shared-forbidden' => 'A file with this name exists already in the shared file repository;
please go back and upload this file under a new name. [[Image:$1|thumb|center|$1]]',
+'file-exists-duplicate' => 'This file seems to be a duplicate of the following {{PLURAL:$1|file|files}}:',
'successfulupload' => 'Successful upload',
'uploadwarning' => 'Upload warning',
'savefile' => 'Save file',