r84304 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84303‎ | r84304 | r84305 >
Date:02:54, 19 March 2011
Author:neilk
Status:deferred
Tags:
Comment:
fix bug 25786, untranslated error for bad extension
Modified paths:
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizard.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js
@@ -216,11 +216,26 @@
217217 var _this = this;
218218 _this.clearErrors();
219219 _this.upload.extractLocalFileInfo( _this.$fileInputCtrl.val() );
220 - if ( _this.isGoodExtension( _this.upload.title.getExtension() ) ) {
 220+ var extension = _this.upload.title.getExtension();
 221+ var isGoodExtension = $j.inArray( extension.toLowerCase(), mw.UploadWizard.config[ 'fileExtensions' ] ) !== -1;
 222+ if ( isGoodExtension ) {
221223 _this.updateFilename();
222224 } else {
223 - //_this.error( 'bad-filename-extension', ext );
224 - alert("bad extension");
 225+ $( '<div>' )
 226+ .append(
 227+ $j( '<p>' ).msg( 'mwe-upwiz-upload-error-bad-filename-extension', extension ),
 228+ $j( '<p>' ).msg( 'mwe-upwiz-allowed-filename-extensions' ),
 229+ $j( '<blockquote>' ).append( $j( '<tt>' ).append(
 230+ mw.UploadWizard.config[ 'fileExtensions' ].join( " " )
 231+ ) )
 232+ )
 233+ .dialog({
 234+ width: 500,
 235+ zIndex: 200000,
 236+ autoOpen: true,
 237+ title: gM( 'mwe-upwiz-help-popup' ) + ': ' + gM( 'mwe-upwiz-help-allowed-filename-extensions' ),
 238+ modal: true
 239+ });
225240 }
226241 this.clearStatus();
227242 },
@@ -337,15 +352,6 @@
338353 // apply a error style to entire did
339354 $j( _this.div ).addClass( 'mwe-upwiz-upload-error' );
340355 $j( _this.errorDiv ).show();
341 - },
342 -
343 - /**
344 - * This is used when checking for "bad" extensions in a filename.
345 - * @param ext
346 - * @return boolean if extension was acceptable
347 - */
348 - isGoodExtension: function( ext ) {
349 - return $j.inArray( ext.toLowerCase(), mw.UploadWizard.config[ 'fileExtensions' ] ) !== -1;
350356 }
351357
352358 };
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js
@@ -62,14 +62,13 @@
6363 // we signal to the wizard to update itself, which has to delete the final vestige of
6464 // this upload (the ui.div). We have to do this silly dance because we
6565 // trigger through the div. Triggering through objects doesn't always work.
66 - // TODO fix -- this now works in jquery 1.4.2
 66+ // TODO v.1.1 fix, don't need to use the div any more -- this now works in jquery 1.4.2
6767 $j( this.ui.div ).trigger( 'removeUploadEvent' );
6868 },
6969
7070
7171 /**
7272 * Wear our current progress, for observing processes to see
73 - * XXX this is kind of a misnomer; this event is not firing except for the very first time.
7473 * @param fraction
7574 */
7675 setTransportProgress: function ( fraction ) {
@@ -188,9 +187,9 @@
189188 }
190189 }
191190
192 - // TODO this needs to be rethought.
193 - // we should already have an extension, but if we don't... ??
194191 if ( _this.title.getExtension() === null ) {
 192+ // TODO v1.1 what if we don't have an extension? Should be impossible as it is currently impossible to upload without extension, but you
 193+ // never know... theoretically there is no restriction on extensions if we are uploading to the stash, but the check is performed anyway.
195194 /*
196195 var extension = mw.UploadWizardUtil.getExtension( _this.imageinfo.url );
197196 if ( !extension ) {
@@ -409,8 +408,14 @@
410409 .click( function() {
411410 // check if there is an upload at all (should never happen)
412411 if ( _this.uploads.length === 0 ) {
413 - // XXX use standard error message
414 - alert( gM( 'mwe-upwiz-file-need-file' ) );
 412+ $( '<div>' )
 413+ .html( gM( 'mwe-upwiz-file-need-file' ) )
 414+ .dialog({
 415+ width: 500,
 416+ zIndex: 200000,
 417+ autoOpen: true,
 418+ modal: true
 419+ });
415420 return;
416421 }
417422
@@ -619,7 +624,6 @@
620625 setUploadFilled: function( upload ) {
621626 var _this = this;
622627
623 - // XXX check if it has a file?
624628 _this.uploads.push( upload );
625629
626630 /* useful for making ids unique and so on */
@@ -630,9 +634,7 @@
631635
632636 upload.deedPreview = new mw.UploadWizardDeedPreview( upload );
633637
634 - // XXX do we really need to do this now? some things will even change after step 2.
635 - // legacy.
636 - // set up details
 638+ // TODO v1.1 consider if we really have to set up details now
637639 upload.details = new mw.UploadWizardDetails( upload, $j( '#mwe-upwiz-macro-files' ) );
638640 },
639641
@@ -937,8 +939,6 @@
938940 // some details blocks cannot be submitted (for instance, identical file hash)
939941 _this.removeBlockedDetails();
940942
941 - // XXX validate all
942 -
943943 // remove ability to edit details
944944 $j.each( _this.uploads, function( i, upload ) {
945945 upload.details.div.mask();
@@ -1136,7 +1136,7 @@
11371137 * Adds a tipsy pop-up help button to the field. Can be called in two ways -- with simple string id, which identifies
11381138 * the string as 'mwe-upwiz-tooltip-' plus that id, and creates the hint with a similar id
11391139 * or with function and id -- function will be called to generate the hint every time
1140 - * XXX split into two plugins?
 1140+ * TODO v1.1 split into two plugins?
11411141 * @param key {string} -- will base the tooltip on a message found with this key
11421142 * @param fn {function} optional -- call this function every time tip is created to generate message. If present HTML element gets an id of the exact key specified
11431143 */

Status & tagging log