r85953 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85952‎ | r85953 | r85954 >
Date:15:44, 13 April 2011
Author:neilk
Status:resolved (Comments)
Tags:
Comment:
better error for same-name problem, direct users to page if they wanted to reupload
Modified paths:
  • /trunk/extensions/UploadWizard (modified) (history)
  • /trunk/extensions/UploadWizard/UploadWizard.i18n.php (modified) (history)
  • /trunk/extensions/UploadWizard/UploadWizardHooks.php (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.LanguageUpWiz.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/UploadWizardHooks.php
@@ -217,6 +217,8 @@
218218 'mwe-upwiz-change',
219219 'mwe-upwiz-fileexists-replace',
220220 'mwe-upwiz-fileexists',
 221+ 'mwe-upwiz-fileexists-replace-on-page',
 222+ 'mwe-upwiz-fileexists-replace-no-link',
221223 'mwe-upwiz-thumbnail-more',
222224 'mwe-upwiz-overwrite',
223225 'mwe-copyright-macro',
Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php
@@ -151,6 +151,8 @@
152152 'mwe-upwiz-fileexists-replace' => 'A file with the title "$1" exists already. Please change your title to something unique.',
153153 'mwe-upwiz-fileexists' => 'A file with this name exists already.
154154 Please check <b><tt>$1</tt></b> if you are not sure if you want to replace it.',
 155+ 'mwe-upwiz-fileexists-replace-on-page' => 'A file with this name exists already. If you want to replace it, go to the page for [$2 $1] and replace it there.',
 156+ 'mwe-upwiz-fileexists-replace-no-link' => 'A file with this name exists already.',
155157 'mwe-upwiz-thumbnail-more' => 'Enlarge',
156158 'mwe-upwiz-overwrite' => 'Replace the file',
157159 'mwe-copyright-macro' => 'As above',
Property changes on: trunk/extensions/UploadWizard/resources/mw.LanguageUpWiz.js
___________________________________________________________________
Modified: svn:mergeinfo
158160 Merged /trunk/phase3/extensions/UploadWizard/resources/mw.LanguageUpWiz.js:r85939
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js
@@ -330,97 +330,22 @@
331331 // result is NOT unique
332332 var title;
333333 try {
334 - title = new mw.Title( result.title ).setNamespace( 'file' ).getNameText();
 334+ title = new mw.Title( result.title ).setNamespace( 'file' );
335335 } catch ( e ) {
336336 // unparseable result from unique test?
337337 title = '[unparseable name]';
338338 }
339 -
340 - /* var img = result.img;
341 - var href = result.href; */
342 -
 339+
 340+ var errHtml;
 341+ if ( result.href ) {
 342+ errHtml = gM( 'mwe-upwiz-fileexists-replace-on-page', title.toString(), result.href );
 343+ } else {
 344+ errHtml = gM( 'mwe-upwiz-fileexists-replace-no-link', title.getNameText() );
 345+ }
 346+
343347 _this.$form.find( 'label[for=' + _this.titleId + ']' )
344 - .html( gM( 'mwe-upwiz-fileexists-replace', title ) )
 348+ .html( errHtml )
345349 .show();
346 -
347 - /* temporarily commenting out the full thumbnail etc. thing. For now, we just want the user to change
348 - to a different name
349 - _this.ignoreWarningsInput = $j("<input />").attr( { type: 'checkbox', name: 'ignorewarnings' } );
350 - var $fileAlreadyExists = $j('<div />')
351 - .append(
352 - gM( 'mwe-upwiz-fileexists',
353 - $j('<a />')
354 - .attr( { target: '_new', href: href } )
355 - .text( title )
356 - ),
357 - $j('<br />'),
358 - _this.ignoreWarningsInput,
359 - gM('mwe-upwiz-overwrite')
360 - );
361 -
362 - var $imageLink = $j('<a />')
363 - .addClass( 'image' )
364 - .attr( { target: '_new', href: href } )
365 - .append(
366 - $j( '<img />')
367 - .addClass( 'thumbimage' )
368 - .attr( {
369 - 'width' : img.thumbwidth,
370 - 'height' : img.thumbheight,
371 - 'border' : 0,
372 - 'src' : img.thumburl,
373 - 'alt' : title
374 - } )
375 - );
376 -
377 - var $imageCaption = $j( '<div />' )
378 - .addClass( 'thumbcaption' )
379 - .append(
380 - $j('<div />')
381 - .addClass( "magnify" )
382 - .append(
383 - $j('<a />' )
384 - .addClass( 'internal' )
385 - .attr( {
386 - 'title' : gM('mwe-upwiz-thumbnail-more'),
387 - 'href' : href
388 - } ),
389 -
390 - $j( '<img />' )
391 - .attr( {
392 - 'border' : 0,
393 - 'width' : 15,
394 - 'height' : 11,
395 - 'src' : mw.UploadWizard.config[ 'images_path' ] + 'magnify-clip.png'
396 - } ),
397 -
398 - $j('<span />')
399 - .html( gM( 'mwe-fileexists-thumb' ) )
400 - )
401 - );
402 -
403 - $j( _this.titleErrorDiv ).html(
404 - $j('<span />') // dummy argument since .html() only takes one arg
405 - .append(
406 - $fileAlreadyExists,
407 - $j( '<div />' )
408 - .addClass( 'thumb tright' )
409 - .append(
410 - $j( '<div />' )
411 - .addClass( 'thumbinner' )
412 - .css({
413 - 'width' : ( parseInt( img.thumbwidth ) + 2 ) + 'px;'
414 - })
415 - .append(
416 - $imageLink,
417 - $imageCaption
418 - )
419 - )
420 - )
421 - ).show();
422 - */
423 -
424 -
425350 },
426351
427352 /**
Property changes on: trunk/extensions/UploadWizard
___________________________________________________________________
Modified: svn:mergeinfo
428353 Merged /trunk/phase3/extensions/UploadWizard:r85939

Follow-up revisions

RevisionCommit summaryAuthorDate
r86033followup to r85953; title treated as string and object. Also making sure this...neilk07:26, 14 April 2011

Comments

#Comment by Catrope (talk | contribs)   07:06, 14 April 2011
-			title = new mw.Title( result.title ).setNamespace( 'file' ).getNameText();
+			title = new mw.Title( result.title ).setNamespace( 'file' );
 		} catch ( e ) {
 			// unparseable result from unique test? 
 			title = '[unparseable name]';

The code below treats title as an mw.Title object, even though the catch path sets it to a string. Calling .toString() on a string is safe though, but calling .getNameText() is not.

Status & tagging log