From e573db3d766ba60bf9f3a77851232a2f37606330 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Fri, 24 Aug 2012 12:20:27 +0200 Subject: [PATCH] Use ImageGallery directly in SpecialUpload::getDupeWarning() There is no need to go through a complete parse operation to show the image gallery of duplicate files, instead the class can be used directly. Also refactored the code to do an early return if there are no duplicated to not nest the code unnecessarily. Change-Id: I459e539cf8140ef978388b3a65c644a0eb6c9a46 --- includes/specials/SpecialUpload.php | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index d1a9b160c9..43ea345b74 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -702,21 +702,18 @@ class SpecialUpload extends SpecialPage { * @return string */ public static function getDupeWarning( $dupes ) { - global $wgOut; - if( $dupes ) { - $msg = ''; - foreach( $dupes as $file ) { - $title = $file->getTitle(); - $msg .= $title->getPrefixedText() . - '|' . $title->getText() . "\n"; - } - $msg .= ''; - return '
  • ' . - wfMessage( 'file-exists-duplicate' )->numParams( count( $dupes ) )->parse() . - $wgOut->parse( $msg ) . "
  • \n"; - } else { + if ( !$dupes ) { return ''; } + + $gallery = new ImageGallery; + $gallery->setShowBytes( false ); + foreach( $dupes as $file ) { + $gallery->add( $file->getTitle() ); + } + return '
  • ' . + wfMessage( 'file-exists-duplicate' )->numParams( count( $dupes ) )->parse() . + $gallery->toHtml() . "
  • \n"; } } -- 2.20.1