Merge "fixed timestamp validation for api"
[lhc/web/wiklou.git] / includes / specials / SpecialUpload.php
index 43ea345..73c7e2a 100644 (file)
@@ -312,12 +312,12 @@ class SpecialUpload extends SpecialPage {
                $this->showUploadForm( $form );
        }
        /**
-        * Stashes the upload, shows the main form, but adds an "continue anyway button".
+        * Stashes the upload, shows the main form, but adds a "continue anyway button".
         * Also checks whether there are actually warnings to display.
         *
         * @param $warnings Array
         * @return boolean true if warnings were displayed, false if there are no
-        *      warnings and the should continue processing like there was no warning
+        *         warnings and it should continue processing
         */
        protected function showUploadWarning( $warnings ) {
                # If there are no warnings, or warnings we can ignore, return early.
@@ -336,6 +336,9 @@ class SpecialUpload extends SpecialPage {
                $warningHtml = '<h2>' . $this->msg( 'uploadwarning' )->escaped() . "</h2>\n"
                        . '<ul class="warning">';
                foreach( $warnings as $warning => $args ) {
+                       if( $warning == 'badfilename' ) {
+                               $this->mDesiredDestName = Title::makeTitle( NS_FILE, $args )->getText();
+                       }
                        if( $warning == 'exists' ) {
                                $msg = "\t<li>" . self::getExistsWarning( $args ) . "</li>\n";
                        } elseif( $warning == 'duplicate' ) {
@@ -525,6 +528,7 @@ class SpecialUpload extends SpecialPage {
         * Provides output to the user for a result of UploadBase::verifyUpload
         *
         * @param $details Array: result of UploadBase::verifyUpload
+        * @throws MWException
         */
        protected function processVerificationError( $details ) {
                global $wgFileExtensions;
@@ -645,7 +649,7 @@ class SpecialUpload extends SpecialPage {
                                $exists['normalizedFile']->getTitle()->getPrefixedText() )->parse();
                } elseif ( $exists['warning'] == 'thumb' ) {
                        // Swapped argument order compared with other messages for backwards compatibility
-                       $warning = wfMessage( 'fileexists-thumbnail-yes', 
+                       $warning = wfMessage( 'fileexists-thumbnail-yes',
                                $exists['thumbFile']->getTitle()->getPrefixedText(), $filename )->parse();
                } elseif ( $exists['warning'] == 'thumb-name' ) {
                        // Image w/o '180px-' does not exists, but we do not like these filenames
@@ -789,6 +793,8 @@ class UploadForm extends HTMLForm {
         * @return Array: descriptor array
         */
        protected function getSourceSection() {
+               global $wgCopyUploadsFromSpecialUpload;
+
                if ( $this->mSessionKey ) {
                        return array(
                                'SessionKey' => array(
@@ -802,7 +808,9 @@ class UploadForm extends HTMLForm {
                        );
                }
 
-               $canUploadByUrl = UploadFromUrl::isEnabled() && UploadFromUrl::isAllowed( $this->getUser() );
+               $canUploadByUrl = UploadFromUrl::isEnabled()
+                       && UploadFromUrl::isAllowed( $this->getUser() )
+                       && $wgCopyUploadsFromSpecialUpload;
                $radio = $canUploadByUrl;
                $selectedSourceType = strtolower( $this->getRequest()->getText( 'wpSourceType', 'File' ) );
 
@@ -1106,7 +1114,7 @@ class UploadSourceField extends HTMLTextField {
         * @return string
         */
        function getLabelHtml( $cellAttributes = array() ) {
-               $id = "wpSourceType{$this->mParams['upload-type']}";
+               $id = $this->mParams['id'];
                $label = Html::rawElement( 'label', array( 'for' => $id ), $this->mLabel );
 
                if ( !empty( $this->mParams['radio'] ) ) {