Merge "mw.ui: button: Update focus state"
[lhc/web/wiklou.git] / includes / specials / SpecialUpload.php
index d9e3a67..72d02e0 100644 (file)
@@ -160,6 +160,8 @@ class SpecialUpload extends SpecialPage {
                        throw new ErrorPageError( 'uploaddisabled', 'uploaddisabledtext' );
                }
 
+               $this->getOutput()->addHelpLink( 'Help:Managing files' );
+
                # Check permissions
                $user = $this->getUser();
                $permissionRequired = UploadBase::isAllowed( $user );
@@ -461,7 +463,7 @@ class SpecialUpload extends SpecialPage {
                // Get the page text if this is not a reupload
                if ( !$this->mForReUpload ) {
                        $pageText = self::getInitialPageText( $this->mComment, $this->mLicense,
-                               $this->mCopyrightStatus, $this->mCopyrightSource );
+                               $this->mCopyrightStatus, $this->mCopyrightSource, $this->getConfig() );
                } else {
                        $pageText = false;
                }
@@ -491,28 +493,32 @@ class SpecialUpload extends SpecialPage {
         * @param string $license
         * @param string $copyStatus
         * @param string $source
+        * @param Config $config Configuration object to load data from
         * @return string
-        * @todo Use Config obj instead of globals
         */
        public static function getInitialPageText( $comment = '', $license = '',
-               $copyStatus = '', $source = ''
+               $copyStatus = '', $source = '', Config $config = null
        ) {
-               global $wgUseCopyrightUpload, $wgForceUIMsgAsContentMsg;
+               if ( $config === null ) {
+                       wfDebug( __METHOD__ . ' called without a Config instance passed to it' );
+                       $config = ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
+               }
 
                $msg = array();
+               $forceUIMsgAsContentMsg = (array)$config->get( 'ForceUIMsgAsContentMsg' );
                /* These messages are transcluded into the actual text of the description page.
                 * Thus, forcing them as content messages makes the upload to produce an int: template
                 * instead of hardcoding it there in the uploader language.
                 */
                foreach ( array( 'license-header', 'filedesc', 'filestatus', 'filesource' ) as $msgName ) {
-                       if ( in_array( $msgName, (array)$wgForceUIMsgAsContentMsg ) ) {
+                       if ( in_array( $msgName, $forceUIMsgAsContentMsg ) ) {
                                $msg[$msgName] = "{{int:$msgName}}";
                        } else {
                                $msg[$msgName] = wfMessage( $msgName )->inContentLanguage()->text();
                        }
                }
 
-               if ( $wgUseCopyrightUpload ) {
+               if ( $config->get( 'UseCopyrightUpload' ) ) {
                        $licensetxt = '';
                        if ( $license != '' ) {
                                $licensetxt = '== ' . $msg['license-header'] . " ==\n" . '{{' . $license . '}}' . "\n";
@@ -937,35 +943,31 @@ class UploadForm extends HTMLForm {
                $config = $this->getConfig();
 
                if ( $config->get( 'CheckFileExtensions' ) ) {
+                       $fileExtensions = array_unique( $config->get( 'FileExtensions' ) );
                        if ( $config->get( 'StrictFileExtensions' ) ) {
                                # Everything not permitted is banned
                                $extensionsList =
                                        '<div id="mw-upload-permitted">' .
-                                       $this->msg(
-                                               'upload-permitted',
-                                               $this->getContext()->getLanguage()->commaList(
-                                                       array_unique( $config->get( 'FileExtensions' ) )
-                                               )
-                                       )->parseAsBlock() .
+                                       $this->msg( 'upload-permitted' )
+                                               ->params( $this->getLanguage()->commaList( $fileExtensions ) )
+                                               ->numParams( count( $fileExtensions ) )
+                                               ->parseAsBlock() .
                                        "</div>\n";
                        } else {
                                # We have to list both preferred and prohibited
+                               $fileBlacklist = array_unique( $config->get( 'FileBlacklist' ) );
                                $extensionsList =
                                        '<div id="mw-upload-preferred">' .
-                                               $this->msg(
-                                                       'upload-preferred',
-                                                       $this->getContext()->getLanguage()->commaList(
-                                                               array_unique( $config->get( 'FileExtensions' ) )
-                                                       )
-                                               )->parseAsBlock() .
+                                               $this->msg( 'upload-preferred' )
+                                                       ->params( $this->getLanguage()->commaList( $fileExtensions ) )
+                                                       ->numParams( count( $fileExtensions ) )
+                                                       ->parseAsBlock() .
                                        "</div>\n" .
                                        '<div id="mw-upload-prohibited">' .
-                                               $this->msg(
-                                                       'upload-prohibited',
-                                                       $this->getContext()->getLanguage()->commaList(
-                                                               array_unique( $config->get( 'FileBlacklist' ) )
-                                                       )
-                                               )->parseAsBlock() .
+                                               $this->msg( 'upload-prohibited' )
+                                                       ->params( $this->getLanguage()->commaList( $fileBlacklist ) )
+                                                       ->numParams( count( $fileBlacklist ) )
+                                                       ->parseAsBlock() .
                                        "</div>\n";
                        }
                } else {
@@ -985,10 +987,10 @@ class UploadForm extends HTMLForm {
        protected function getDescriptionSection() {
                $config = $this->getConfig();
                if ( $this->mSessionKey ) {
-                       $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash();
+                       $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash( $this->getUser() );
                        try {
                                $file = $stash->getFile( $this->mSessionKey );
-                       } catch ( MWException $e ) {
+                       } catch ( Exception $e ) {
                                $file = null;
                        }
                        if ( $file ) {
@@ -1146,6 +1148,7 @@ class UploadForm extends HTMLForm {
                                // the wpDestFile textbox
                                $this->mDestFile === '',
                        'wgUploadSourceIds' => $this->mSourceIds,
+                       'wgCheckFileExtensions' => $config->get( 'CheckFileExtensions' ),
                        'wgStrictFileExtensions' => $config->get( 'StrictFileExtensions' ),
                        'wgFileExtensions' => array_values( array_unique( $config->get( 'FileExtensions' ) ) ),
                        'wgCapitalizeUploads' => MWNamespace::isCapitalized( NS_FILE ),