From: Alexandre Emsenhuber Date: Fri, 24 Aug 2012 10:20:27 +0000 (+0200) Subject: Use ImageGallery directly in SpecialUpload::getDupeWarning() X-Git-Tag: 1.31.0-rc.0~22553^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=commitdiff_plain;h=e573db3d766ba60bf9f3a77851232a2f37606330;p=lhc%2Fweb%2Fwiklou.git 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 --- 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"; } }