Merge "Copy translations of Special:MyLanguage alias from Translate"
[lhc/web/wiklou.git] / includes / specials / SpecialUpload.php
index 4fd7cd4..51dd7bd 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 ) );
 
@@ -725,8 +724,7 @@ class SpecialUpload extends SpecialPage {
                        return '';
                }
 
-               $gallery = ImageGalleryBase::factory();
-               $gallery->setContext( $this->getContext() );
+               $gallery = ImageGalleryBase::factory( false, $this->getContext() );
                $gallery->setShowBytes( false );
                foreach ( $dupes as $file ) {
                        $gallery->add( $file->getTitle() );
@@ -740,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?
+        */
+       static public function rotationEnabled() {
+               $bitmapHandler = new BitmapHandler();
+               return $bitmapHandler->autoRotateEnabled();
+       }
 }
 
 /**
@@ -823,8 +833,6 @@ class UploadForm extends HTMLForm {
         * @return array Descriptor array
         */
        protected function getSourceSection() {
-               global $wgCopyUploadsFromSpecialUpload;
-
                if ( $this->mSessionKey ) {
                        return array(
                                'SessionKey' => array(
@@ -840,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' ) );
 
@@ -919,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 {
@@ -938,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";
                        }
@@ -963,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 {
@@ -1035,8 +1049,7 @@ class UploadForm extends HTMLForm {
                        );
                }
 
-               global $wgUseCopyrightUpload;
-               if ( $wgUseCopyrightUpload ) {
+               if ( $config->get( 'UseCopyrightUpload' ) ) {
                        $descriptor['UploadCopyStatus'] = array(
                                'type' => 'text',
                                'section' => 'description',
@@ -1111,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(
@@ -1126,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();
@@ -1136,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.
                ) );
        }