Parse 'upload_source_url' message on SpecialUpload
[lhc/web/wiklou.git] / includes / specials / SpecialUpload.php
index 5c5026c..77ad9aa 100644 (file)
@@ -485,6 +485,7 @@ class SpecialUpload extends SpecialPage {
         * @param string $copyStatus
         * @param string $source
         * @return string
+        * @todo Use Config obj instead of globals
         */
        public static function getInitialPageText( $comment = '', $license = '',
                $copyStatus = '', $source = ''
@@ -568,8 +569,6 @@ class SpecialUpload extends SpecialPage {
         * @throws MWException
         */
        protected function processVerificationError( $details ) {
-               global $wgFileExtensions;
-
                switch ( $details['status'] ) {
 
                        /** Statuses that only require name changing **/
@@ -604,7 +603,7 @@ class SpecialUpload extends SpecialPage {
                                } else {
                                        $msg->params( $details['finalExt'] );
                                }
-                               $extensions = array_unique( $wgFileExtensions );
+                               $extensions = array_unique( $this->getConfig()->get( 'FileExtensions' ) );
                                $msg->params( $this->getLanguage()->commaList( $extensions ),
                                        count( $extensions ) );
 
@@ -739,6 +738,18 @@ class SpecialUpload extends SpecialPage {
        protected function getGroupName() {
                return 'media';
        }
+
+       /**
+        * Should we rotate images in the preview on Special:Upload.
+        *
+        * This controls js: mw.config.get( 'wgFileCanRotate' )
+        *
+        * @todo What about non-BitmapHandler handled files?
+        */
+       public static function rotationEnabled() {
+               $bitmapHandler = new BitmapHandler();
+               return $bitmapHandler->autoRotateEnabled();
+       }
 }
 
 /**
@@ -822,8 +833,6 @@ class UploadForm extends HTMLForm {
         * @return array Descriptor array
         */
        protected function getSourceSection() {
-               global $wgCopyUploadsFromSpecialUpload;
-
                if ( $this->mSessionKey ) {
                        return array(
                                'SessionKey' => array(
@@ -839,7 +848,7 @@ class UploadForm extends HTMLForm {
 
                $canUploadByUrl = UploadFromUrl::isEnabled()
                        && ( UploadFromUrl::isAllowed( $this->getUser() ) === true )
-                       && $wgCopyUploadsFromSpecialUpload;
+                       && $this->getConfig()->get( 'CopyUploadsFromSpecialUpload' );
                $radio = $canUploadByUrl;
                $selectedSourceType = strtolower( $this->getRequest()->getText( 'wpSourceType', 'File' ) );
 
@@ -894,7 +903,7 @@ class UploadForm extends HTMLForm {
                                        $this->getContext()->getLanguage()->formatSize( $this->mMaxUploadSize['url'] )
                                )->parse() .
                                        $this->msg( 'word-separator' )->escaped() .
-                                       $this->msg( 'upload_source_url' )->escaped(),
+                                       $this->msg( 'upload_source_url' )->parse(),
                                'checked' => $selectedSourceType == 'url',
                        );
                }
@@ -918,17 +927,18 @@ class UploadForm extends HTMLForm {
        protected function getExtensionsMessage() {
                # Print a list of allowed file extensions, if so configured.  We ignore
                # MIME type here, it's incomprehensible to most people and too long.
-               global $wgCheckFileExtensions, $wgStrictFileExtensions,
-                       $wgFileExtensions, $wgFileBlacklist;
+               $config = $this->getConfig();
 
-               if ( $wgCheckFileExtensions ) {
-                       if ( $wgStrictFileExtensions ) {
+               if ( $config->get( 'CheckFileExtensions' ) ) {
+                       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( $wgFileExtensions ) )
+                                               $this->getContext()->getLanguage()->commaList(
+                                                       array_unique( $config->get( 'FileExtensions' ) )
+                                               )
                                        )->parseAsBlock() .
                                        "</div>\n";
                        } else {
@@ -937,13 +947,17 @@ class UploadForm extends HTMLForm {
                                        '<div id="mw-upload-preferred">' .
                                                $this->msg(
                                                        'upload-preferred',
-                                                       $this->getContext()->getLanguage()->commaList( array_unique( $wgFileExtensions ) )
+                                                       $this->getContext()->getLanguage()->commaList(
+                                                               array_unique( $config->get( 'FileExtensions' ) )
+                                                       )
                                                )->parseAsBlock() .
                                        "</div>\n" .
                                        '<div id="mw-upload-prohibited">' .
                                                $this->msg(
                                                        'upload-prohibited',
-                                                       $this->getContext()->getLanguage()->commaList( array_unique( $wgFileBlacklist ) )
+                                                       $this->getContext()->getLanguage()->commaList(
+                                                               array_unique( $config->get( 'FileBlacklist' ) )
+                                                       )
                                                )->parseAsBlock() .
                                        "</div>\n";
                        }
@@ -962,6 +976,7 @@ class UploadForm extends HTMLForm {
         * @return array Descriptor array
         */
        protected function getDescriptionSection() {
+               $config = $this->getConfig();
                if ( $this->mSessionKey ) {
                        $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash();
                        try {
@@ -1034,8 +1049,7 @@ class UploadForm extends HTMLForm {
                        );
                }
 
-               global $wgUseCopyrightUpload;
-               if ( $wgUseCopyrightUpload ) {
+               if ( $config->get( 'UseCopyrightUpload' ) ) {
                        $descriptor['UploadCopyStatus'] = array(
                                'type' => 'text',
                                'section' => 'description',
@@ -1110,11 +1124,11 @@ class UploadForm extends HTMLForm {
         * Add upload JS to the OutputPage
         */
        protected function addUploadJS() {
-               global $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview,
-                       $wgEnableAPI, $wgStrictFileExtensions;
+               $config = $this->getConfig();
 
-               $useAjaxDestCheck = $wgUseAjax && $wgAjaxUploadDestCheck;
-               $useAjaxLicensePreview = $wgUseAjax && $wgAjaxLicensePreview && $wgEnableAPI;
+               $useAjaxDestCheck = $config->get( 'UseAjax' ) && $config->get( 'AjaxUploadDestCheck' );
+               $useAjaxLicensePreview = $config->get( 'UseAjax' ) &&
+                       $config->get( 'AjaxLicensePreview' ) && $config->get( 'EnableAPI' );
                $this->mMaxUploadSize['*'] = UploadBase::getMaxUploadSize();
 
                $scriptVars = array(
@@ -1125,9 +1139,10 @@ class UploadForm extends HTMLForm {
                                // the wpDestFile textbox
                                $this->mDestFile === '',
                        'wgUploadSourceIds' => $this->mSourceIds,
-                       'wgStrictFileExtensions' => $wgStrictFileExtensions,
+                       'wgStrictFileExtensions' => $config->get( 'StrictFileExtensions' ),
                        'wgCapitalizeUploads' => MWNamespace::isCapitalized( NS_FILE ),
                        'wgMaxUploadSize' => $this->mMaxUploadSize,
+                       'wgFileCanRotate' => SpecialUpload::rotationEnabled(),
                );
 
                $out = $this->getOutput();
@@ -1135,8 +1150,7 @@ class UploadForm extends HTMLForm {
 
                $out->addModules( array(
                        'mediawiki.action.edit', // For <charinsert> support
-                       'mediawiki.legacy.upload', // Old form stuff...
-                       'mediawiki.special.upload', // Newer extras for thumbnail preview.
+                       'mediawiki.special.upload', // Extras for thumbnail and license preview.
                ) );
        }