Index: trunk/extensions/WikiLove/WikiLove.php |
— | — | @@ -129,6 +129,8 @@ |
130 | 130 | 'wikilove-commons-text', |
131 | 131 | 'wikilove-commons-link', |
132 | 132 | 'wikilove-commons-url', |
| 133 | + 'wikilove-err-preview-api', |
| 134 | + 'wikilove-err-send-api', |
133 | 135 | ), |
134 | 136 | 'dependencies' => array( |
135 | 137 | 'jquery.ui.dialog', |
Index: trunk/extensions/WikiLove/WikiLove.api.php |
— | — | @@ -31,14 +31,12 @@ |
32 | 32 | 'notminor' => true, |
33 | 33 | ), false, array( 'wsEditToken' => $wgRequest->getSessionData( 'wsEditToken' ) ) ), true ); |
34 | 34 | |
| 35 | + $api->execute(); |
| 36 | + |
35 | 37 | if ( isset( $params['email'] ) ) { |
36 | 38 | $this->emailUser( $talk, $params['subject'], $params['email'], $params['token'] ); |
37 | 39 | } |
38 | 40 | |
39 | | - $api->execute(); |
40 | | - |
41 | | - $result = $api->getResult(); |
42 | | - |
43 | 41 | $this->getResult()->addValue( 'redirect', 'pageName', $talk->getPrefixedDBkey() ); |
44 | 42 | $this->getResult()->addValue( 'redirect', 'fragment', Title::escapeFragmentForURL( $params['subject'] ) ); |
45 | 43 | // note that we cannot use Title::makeTitle here as it doesn't sanitize the fragment |
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js |
— | — | @@ -328,7 +328,7 @@ |
329 | 329 | |
330 | 330 | // Check for a header if it is required |
331 | 331 | if( $.inArray( 'header', currentTypeOrSubtype.fields ) >= 0 && $( '#mw-wikilove-header' ).val().length <= 0 ) { |
332 | | - $.wikiLove.showError( 'wikilove-err-header' ); return false; |
| 332 | + $.wikiLove.showAddDetailsError( 'wikilove-err-header' ); return false; |
333 | 333 | } |
334 | 334 | |
335 | 335 | // Check for a title if it is required, and otherwise use the header text |
— | — | @@ -339,12 +339,12 @@ |
340 | 340 | if( $.inArray( 'message', currentTypeOrSubtype.fields ) >= 0 ) { |
341 | 341 | // Check for a message if it is required |
342 | 342 | if ( $( '#mw-wikilove-message' ).val().length <= 0 ) { |
343 | | - $.wikiLove.showError( 'wikilove-err-msg' ); return false; |
| 343 | + $.wikiLove.showAddDetailsError( 'wikilove-err-msg' ); return false; |
344 | 344 | } |
345 | 345 | |
346 | 346 | // If there isn't a signature already in the message, throw an error |
347 | 347 | if ( $( '#mw-wikilove-message' ).val().indexOf( '~~~' ) >= 0 ) { |
348 | | - $.wikiLove.showError( 'wikilove-err-sig' ); return false; |
| 348 | + $.wikiLove.showAddDetailsError( 'wikilove-err-sig' ); return false; |
349 | 349 | } |
350 | 350 | } |
351 | 351 | |
— | — | @@ -371,7 +371,7 @@ |
372 | 372 | success: function( data ) { |
373 | 373 | if ( !data.query.pages[-1].imageinfo ) { |
374 | 374 | // Image does not exist |
375 | | - $.wikiLove.showError( 'wikilove-err-image-bad' ); |
| 375 | + $.wikiLove.showAddDetailsError( 'wikilove-err-image-bad' ); |
376 | 376 | $( '#mw-wikilove-preview-spinner' ).fadeOut( 200 ); |
377 | 377 | } else { |
378 | 378 | // Image exists. Proceed with preview. |
— | — | @@ -379,7 +379,7 @@ |
380 | 380 | } |
381 | 381 | }, |
382 | 382 | error: function() { |
383 | | - $.wikiLove.showError( 'wikilove-err-image-api' ); |
| 383 | + $.wikiLove.showAddDetailsError( 'wikilove-err-image-api' ); |
384 | 384 | $( '#mw-wikilove-preview-spinner' ).fadeOut( 200 ); |
385 | 385 | } |
386 | 386 | } ); |
— | — | @@ -387,7 +387,7 @@ |
388 | 388 | } else { // a gallery |
389 | 389 | if ( $( '#mw-wikilove-image' ).val().length <= 0 ) { |
390 | 390 | // Display an error telling them to select an image. |
391 | | - $.wikiLove.showError( 'wikilove-err-image' ); return false; |
| 391 | + $.wikiLove.showAddDetailsError( 'wikilove-err-image' ); return false; |
392 | 392 | } else { |
393 | 393 | // Proceed with preview. |
394 | 394 | $.wikiLove.submitPreview(); |
— | — | @@ -417,10 +417,14 @@ |
418 | 418 | } |
419 | 419 | }, |
420 | 420 | |
421 | | - showError: function( errmsg ) { |
| 421 | + showAddDetailsError: function( errmsg ) { |
422 | 422 | $( '#mw-wikilove-add-details' ).append( $( '<div class="mw-wikilove-error"></div>' ).text( mw.msg( errmsg ) ) ); |
423 | 423 | }, |
424 | 424 | |
| 425 | + showPreviewError: function( errmsg ) { |
| 426 | + $( '#mw-wikilove-preview' ).append( $( '<div class="mw-wikilove-error"></div>' ).text( mw.msg( errmsg ) ) ); |
| 427 | + }, |
| 428 | + |
425 | 429 | /* |
426 | 430 | * Prepares a message or e-mail body by replacing placeholders. |
427 | 431 | * $1: message entered by the user |
— | — | @@ -475,6 +479,10 @@ |
476 | 480 | success: function( data ) { |
477 | 481 | $.wikiLove.showPreview( data.parse.text['*'] ); |
478 | 482 | $( '#mw-wikilove-preview-spinner' ).fadeOut( 200 ); |
| 483 | + }, |
| 484 | + error: function() { |
| 485 | + $.wikiLove.showAddDetailsError( 'wikilove-err-preview-api' ); |
| 486 | + $( '#mw-wikilove-preview-spinner' ).fadeOut( 200 ); |
479 | 487 | } |
480 | 488 | }); |
481 | 489 | }, |
— | — | @@ -548,7 +556,7 @@ |
549 | 557 | $( '#mw-wikilove-send-spinner' ).fadeOut( 200 ); |
550 | 558 | |
551 | 559 | if ( typeof data.error !== 'undefined' ) { |
552 | | - $( '#mw-wikilove-preview' ).append( '<div class="mw-wikilove-error">' + mw.html.escape( data.error.info ) + '<div>' ); |
| 560 | + $.wikiLove.showPreviewError( data.error.info ); |
553 | 561 | return; |
554 | 562 | } |
555 | 563 | |
— | — | @@ -563,6 +571,10 @@ |
564 | 572 | mw.config.get( 'wgArticlePath' ).replace( '$1', mw.util.wikiUrlencode( data.redirect.pageName ) ) |
565 | 573 | + '#' + data.redirect.fragment ); |
566 | 574 | } |
| 575 | + }, |
| 576 | + error: function() { |
| 577 | + $.wikiLove.showPreviewError( 'wikilove-err-send-api' ); |
| 578 | + $( '#mw-wikilove-send-spinner' ).fadeOut( 200 ); |
567 | 579 | } |
568 | 580 | }); |
569 | 581 | }, |
Index: trunk/extensions/WikiLove/WikiLove.i18n.php |
— | — | @@ -41,10 +41,12 @@ |
42 | 42 | 'wikilove-err-msg' => 'Please enter a message.', |
43 | 43 | 'wikilove-err-image' => 'Please select an image.', |
44 | 44 | 'wikilove-err-image-bad' => 'Image does not exist.', |
45 | | - 'wikilove-err-image-api' => 'Image check failed.', |
| 45 | + 'wikilove-err-image-api' => 'Something went wrong when retrieving the image. Please try again.', |
46 | 46 | 'wikilove-err-sig' => 'Please do not include a signature in the message.', |
47 | | - 'wikilove-err-gallery' => 'Something went wrong when loading the images!', |
| 47 | + 'wikilove-err-gallery' => 'Something went wrong when loading the images.', |
48 | 48 | 'wikilove-err-gallery-again' => 'Try again', |
| 49 | + 'wikilove-err-preview-api' => 'Something went wrong during previewing. Please try again.', |
| 50 | + 'wikilove-err-send-api' => 'Something went wrong when sending the message. Please try again.', |
49 | 51 | 'wikilove-summary' => '/* $1 */ new WikiLove message', |
50 | 52 | 'wikilove-what-is-this' => "What is this?", |
51 | 53 | 'wikilove-anon-warning' => 'Note: This user is not registered, he or she many not notice this message.', |