jenkins-bot has submitted this change and it was merged.

Change subject: Remove upload methods other than local file from 
Special:ImportTranslations
......................................................................


Remove upload methods other than local file from Special:ImportTranslations

Bug: 47823
Change-Id: I30f280d6e4fad5442bc3766f19aba5451dbe4d17
---
M Translate.i18n.php
M Translate.php
M resources/js/ext.translate.special.importtranslations.js
M specials/SpecialImportTranslations.php
4 files changed, 29 insertions(+), 114 deletions(-)

Approvals:
  Siebrand: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Translate.i18n.php b/Translate.i18n.php
index c3558ec..5247285 100644
--- a/Translate.i18n.php
+++ b/Translate.i18n.php
@@ -309,13 +309,9 @@
        'translate-manage-fuzzy-summary' => 'The message definition has 
changed',
 
        'importtranslations' => 'Import translations',
-       'translate-import-from-url' => 'URL to the file:',
-       'translate-import-from-wiki' => 'File in this wiki:',
        'translate-import-from-local' => 'Local file upload:',
        'translate-import-load' => 'Load file',
 
-       'translate-import-err-type-not-supported' => 'Unable to load the file:
-Method <code>$1</code> is not supported.',
        'translate-import-err-dl-failed' => 'Unable to fetch the file:
 $1',
        'translate-import-err-ul-failed' => 'File upload was not successful',
diff --git a/Translate.php b/Translate.php
index 4150ae2..56fd9e3 100644
--- a/Translate.php
+++ b/Translate.php
@@ -608,13 +608,6 @@
  */
 $wgTranslateUseTux = true;
 
-/**
- * Whether to allow uploading gettext files through URLs on
- * Special:ImportTranslations. Default is false.
- * @since 2013-04-26
- */
-$wgTranslateAllowImportFromUrl = false;
-
 # </source>
 
 /** @cond cli_support */
diff --git a/resources/js/ext.translate.special.importtranslations.js 
b/resources/js/ext.translate.special.importtranslations.js
index e037a13..99a34ba 100644
--- a/resources/js/ext.translate.special.importtranslations.js
+++ b/resources/js/ext.translate.special.importtranslations.js
@@ -1,27 +1,20 @@
-( function ( $, mw ) {
+( function ( $ ) {
        'use strict';
-       $( function () {
 
-               $( '.mw-translate-import-inputs' ).change( function () {
-                       var id = $( this ).attr( 'id' ).replace( /-input/, '' );
+       function buttoner ( $input ) {
+               if ( $input.val ) {
+                       $( 'input[type=submit]' ).prop( 'disabled', false );
+               } else {
+                       $( 'input[type=submit]' ).prop( 'disabled', true );
+               }
+       }
 
-                       $( 'input[name=upload-type]:checked' ).attr( 'checked', 
false );
-                       $( '#' + id ).attr( 'checked', 'checked' );
+       $( document ).ready( function ( ) {
+               var $input = $( '#mw-translate-up-local-input' );
+               $input.on( 'change', function () {
+                       buttoner( $input );
                } );
 
-               $( '#mw-translate-up-wiki-input' ).autocomplete( {
-                       source: function ( request, response ) {
-                               var api, data, success;
-
-                               api = mw.util.wikiScript( 'api' );
-                               data = { action: 'opensearch', format: 'json', 
namespace: 6, search: request.term };
-
-                               success = function ( res ) {
-                                       response( res[1] );
-                               };
-
-                               $.get( api, data, success );
-                       }
-               } );
+               buttoner( $input );
        } );
-} ( jQuery, mediaWiki ) );
+} ( jQuery ) );
diff --git a/specials/SpecialImportTranslations.php 
b/specials/SpecialImportTranslations.php
index 21396ef..9926b6a 100644
--- a/specials/SpecialImportTranslations.php
+++ b/specials/SpecialImportTranslations.php
@@ -5,8 +5,7 @@
  * @file
  * @author Niklas Laxström
  * @author Siebrand Mazeland
- * @copyright Copyright © 2009-2013, Niklas Laxström, Siebrand Mazeland
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 
2.0 or later
+ * @license GPL2+
  */
 
 /**
@@ -141,46 +140,14 @@
                        ) ) .
                                Html::hidden( 'token', 
$this->getUser()->getEditToken() ) .
                                Html::hidden( 'title', 
$this->getTitle()->getPrefixedText() ) .
-                               Xml::openElement( 'table' ) .
-                               Xml::openElement( 'tr' ) .
-                               Xml::openElement( 'td' )
-               );
-
-               $class = array( 'class' => 'mw-translate-import-inputs' );
-
-               if ( $wgTranslateAllowImportFromUrl === true ) {
-                       $this->getOutput()->addHTML(
-                               Xml::radioLabel( $this->msg( 
'translate-import-from-url' )->text(),
-                                       'upload-type', 'url', 
'mw-translate-up-url',
-                                       $this->getRequest()->getText( 
'upload-type' ) === 'url' ) .
-                                       "\n" . Xml::closeElement( 'td' ) . 
Xml::openElement( 'td' ) . "\n" .
-                                       Xml::input( 'upload-url', 50,
-                                               $this->getRequest()->getText( 
'upload-url' ),
-                                               array( 'id' => 
'mw-translate-up-url-input' ) + $class ) .
-                                       "\n" . Xml::closeElement( 'td' ) . 
Xml::closeElement( 'tr' ) .
-                                       Xml::openElement( 'tr' ) . 
Xml::openElement( 'td' ) . "\n"
-                       );
-               }
-
-               $this->getOutput()->addHTML(
-                       Xml::radioLabel( $this->msg( 
'translate-import-from-wiki' )->text(),
-                               'upload-type', 'wiki', 'mw-translate-up-wiki',
-                               $this->getRequest()->getText( 'upload-type' ) 
=== 'wiki' ) .
-                               "\n" . Xml::closeElement( 'td' ) . 
Xml::openElement( 'td' ) . "\n" .
-                               Xml::input( 'upload-wiki', 50,
-                                       $this->getRequest()->getText( 
'upload-wiki', 'File:' ),
-                                       array( 'id' => 
'mw-translate-up-wiki-input' ) + $class ) .
-                               "\n" . Xml::closeElement( 'td' ) . 
Xml::closeElement( 'tr' ) .
-                               Xml::openElement( 'tr' ) . Xml::openElement( 
'td' ) . "\n" .
-                               Xml::radioLabel( $this->msg( 
'translate-import-from-local' )->text(),
-                                       'upload-type', 'local', 
'mw-translate-up-local',
-                                       $this->getRequest()->getText( 
'upload-type' ) === 'local' ) .
-                               "\n" . Xml::closeElement( 'td' ) . 
Xml::openElement( 'td' ) . "\n" .
-                               Xml::input( 'upload-local', 50,
+                               Xml::inputLabel(
+                                       $this->msg( 
'translate-import-from-local' )->text(),
+                                       'upload-local', // name
+                                       'mw-translate-up-local-input', // id
+                                       50, // size
                                        $this->getRequest()->getText( 
'upload-local' ),
-                                       array( 'type' => 'file', 'id' => 
'mw-translate-up-local-input' ) + $class ) .
-                               "\n" . Xml::closeElement( 'td' ) . 
Xml::closeElement( 'tr' ) .
-                               Xml::closeElement( 'table' ) .
+                                       array( 'type' => 'file' )
+                               ) .
                                Xml::submitButton( $this->msg( 
'translate-import-load' )->text() ) .
                                Xml::closeElement( 'form' )
                );
@@ -192,49 +159,15 @@
         * @return array
         */
        protected function loadFile( &$filedata ) {
-               global $wgTranslateAllowImportFromUrl;
+               $filename = $this->getRequest()->getFileTempname( 
'upload-local' );
 
-               $source = $this->getRequest()->getText( 'upload-type' );
-
-               if ( $source === 'url' && $wgTranslateAllowImportFromUrl === 
true ) {
-                       $url = $this->getRequest()->getText( 'upload-url' );
-                       $filedata = Http::get( $url );
-                       if ( $filedata ) {
-                               return array( 'ok' );
-                       } else {
-                               return array( 'dl-failed', 'Unknown reason' );
-                       }
-               } elseif ( $source === 'local' ) {
-                       $filename = $this->getRequest()->getFileTempname( 
'upload-local' );
-
-                       if ( !is_uploaded_file( $filename ) ) {
-                               return array( 'ul-failed' );
-                       }
-
-                       $filedata = file_get_contents( $filename );
-
-                       return array( 'ok' );
-               } elseif ( $source === 'wiki' ) {
-                       $filetitle = $this->getRequest()->getText( 
'upload-wiki' );
-                       $title = Title::newFromText( $filetitle, NS_FILE );
-
-                       if ( !$title ) {
-                               return array( 'invalid-title', $filetitle );
-                       }
-
-                       $file = wfLocalFile( $title );
-
-                       if ( !$file || !$file->exists() ) {
-                               return array( 'no-such-file', 
$title->getPrefixedText() );
-                       }
-
-                       $filename = $file->getPath();
-                       $filedata = file_get_contents( $filename );
-
-                       return array( 'ok' );
-               } else {
-                       return array( 'type-not-supported', $source );
+               if ( !is_uploaded_file( $filename ) ) {
+                       return array( 'ul-failed' );
                }
+
+               $filedata = file_get_contents( $filename );
+
+               return array( 'ok' );
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/65567
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I30f280d6e4fad5442bc3766f19aba5451dbe4d17
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to