Merge "Add method parameter type documentation"
[lhc/web/wiklou.git] / includes / specials / SpecialUpload.php
index 98d0c9a..51a0a86 100644 (file)
@@ -93,7 +93,6 @@ class SpecialUpload extends SpecialPage {
                if ( !$this->mDesiredDestName && $request->getFileName( 'wpUploadFile' ) !== null ) {
                        $this->mDesiredDestName = $request->getFileName( 'wpUploadFile' );
                }
-               $this->mComment = $request->getText( 'wpUploadDescription' );
                $this->mLicense = $request->getText( 'wpLicense' );
 
                $this->mDestWarningAck = $request->getText( 'wpDestFileWarningAck' );
@@ -104,6 +103,14 @@ class SpecialUpload extends SpecialPage {
                $this->mCopyrightSource = $request->getText( 'wpUploadSource' );
 
                $this->mForReUpload = $request->getBool( 'wpForReUpload' ); // updating a file
+
+               $commentDefault = '';
+               $commentMsg = wfMessage( 'upload-default-description' )->inContentLanguage();
+               if ( !$this->mForReUpload && !$commentMsg->isDisabled() ) {
+                       $commentDefault = $commentMsg->plain();
+               }
+               $this->mComment = $request->getText( 'wpUploadDescription', $commentDefault );
+
                $this->mCancelUpload = $request->getCheck( 'wpCancelUpload' )
                        || $request->getCheck( 'wpReUpload' ); // b/w compat
 
@@ -340,7 +347,7 @@ class SpecialUpload extends SpecialPage {
                        if ( $warning == 'exists' ) {
                                $msg = "\t<li>" . self::getExistsWarning( $args ) . "</li>\n";
                        } elseif ( $warning == 'duplicate' ) {
-                               $msg = self::getDupeWarning( $args );
+                               $msg = $this->getDupeWarning( $args );
                        } elseif ( $warning == 'duplicate-archive' ) {
                                $msg = "\t<li>" . $this->msg( 'file-deleted-duplicate',
                                                Title::makeTitle( NS_FILE, $args )->getPrefixedText() )->parse()
@@ -563,8 +570,9 @@ class SpecialUpload extends SpecialPage {
                                } else {
                                        $msg->params( $details['finalExt'] );
                                }
-                               $msg->params( $this->getLanguage()->commaList( $wgFileExtensions ),
-                                       count( $wgFileExtensions ) );
+                               $extensions = array_unique( $wgFileExtensions );
+                               $msg->params( $this->getLanguage()->commaList( $extensions ),
+                                       count( $extensions ) );
 
                                // Add PLURAL support for the first parameter. This results
                                // in a bit unlogical parameter sequence, but does not break
@@ -672,41 +680,18 @@ class SpecialUpload extends SpecialPage {
                return $warning;
        }
 
-       /**
-        * Get a list of warnings
-        *
-        * @param string $filename local filename, e.g. 'file exists', 'non-descriptive filename'
-        * @return Array: list of warning messages
-        */
-       public static function ajaxGetExistsWarning( $filename ) {
-               $file = wfFindFile( $filename );
-               if ( !$file ) {
-                       // Force local file so we have an object to do further checks against
-                       // if there isn't an exact match...
-                       $file = wfLocalFile( $filename );
-               }
-               $s = '&#160;';
-               if ( $file ) {
-                       $exists = UploadBase::getExistsWarning( $file );
-                       $warning = self::getExistsWarning( $exists );
-                       if ( $warning !== '' ) {
-                               $s = "<div>$warning</div>";
-                       }
-               }
-               return $s;
-       }
-
        /**
         * Construct a warning and a gallery from an array of duplicate files.
         * @param $dupes array
         * @return string
         */
-       public static function getDupeWarning( $dupes ) {
+       public function getDupeWarning( $dupes ) {
                if ( !$dupes ) {
                        return '';
                }
 
-               $gallery = new ImageGallery;
+               $gallery = ImageGalleryBase::factory();
+               $gallery->setContext( $this->getContext() );
                $gallery->setShowBytes( false );
                foreach ( $dupes as $file ) {
                        $gallery->add( $file->getTitle() );
@@ -893,16 +878,16 @@ class UploadForm extends HTMLForm {
                                # Everything not permitted is banned
                                $extensionsList =
                                        '<div id="mw-upload-permitted">' .
-                                       $this->msg( 'upload-permitted', $this->getContext()->getLanguage()->commaList( $wgFileExtensions ) )->parseAsBlock() .
+                                       $this->msg( 'upload-permitted', $this->getContext()->getLanguage()->commaList( array_unique( $wgFileExtensions ) ) )->parseAsBlock() .
                                        "</div>\n";
                        } else {
                                # We have to list both preferred and prohibited
                                $extensionsList =
                                        '<div id="mw-upload-preferred">' .
-                                               $this->msg( 'upload-preferred', $this->getContext()->getLanguage()->commaList( $wgFileExtensions ) )->parseAsBlock() .
+                                               $this->msg( 'upload-preferred', $this->getContext()->getLanguage()->commaList( array_unique( $wgFileExtensions ) ) )->parseAsBlock() .
                                        "</div>\n" .
                                        '<div id="mw-upload-prohibited">' .
-                                               $this->msg( 'upload-prohibited', $this->getContext()->getLanguage()->commaList( $wgFileBlacklist ) )->parseAsBlock() .
+                                               $this->msg( 'upload-prohibited', $this->getContext()->getLanguage()->commaList( array_unique( $wgFileBlacklist ) ) )->parseAsBlock() .
                                        "</div>\n";
                        }
                } else {