For MediaWiki (recent comments | status changes | tags | authors | states | release notes | statistics)
Index: trunk/phase3/includes/SpecialUpload.php =================================================================== --- trunk/phase3/includes/SpecialUpload.php (revision 35608) +++ trunk/phase3/includes/SpecialUpload.php (revision 35609) @@ -539,6 +539,9 @@ 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 @@ -739,6 +742,31 @@ 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]] Index: trunk/phase3/languages/messages/MessagesEn.php =================================================================== --- trunk/phase3/languages/messages/MessagesEn.php (revision 35608) +++ trunk/phase3/languages/messages/MessagesEn.php (revision 35609) @@ -1631,6 +1631,7 @@ 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',