r105487 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105486‎ | r105487 | r105488 >
Date:23:32, 7 December 2011
Author:gregchiasson
Status:resolved (Comments)
Tags:
Comment:
Translation of AFTv5 feedback page error messages, including moving error messages out of the PHP and into the JS. Eventually I suspect all the bucket display logic will wind up there as well.
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php
@@ -23,6 +23,7 @@
2424 'articlefeedbackv5-error-unknown' => 'Unknown error',
2525 'articlefeedbackv5-error-submit' => 'Form submission error.',
2626 'articlefeedbackv5-error-nofeedback' => 'Please enter your feedback.',
 27+ 'articlefeedbackv5-error-flagging' => 'Error flagging feedback.',
2728
2829 // Article Feedback special page.
2930 'articlefeedbackv5-form-optionid' => 'Option $1',
Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js
@@ -53,18 +53,27 @@
5454 'type' : 'POST',
5555 'dataType': 'json',
5656 'data' : {
57 - 'affeedbackid': id,
58 - 'afflagtype' : type,
59 - 'format' : 'json',
60 - 'action' : 'articlefeedbackv5-flag-feedback'
 57+ 'feedbackid': id,
 58+ 'flagtype' : type,
 59+ 'format' : 'json',
 60+ 'action' : 'articlefeedbackv5-flag-feedback'
6161 },
6262 'success': function ( data ) {
63 - // TODO check output and error if needed
64 - $( '#aft5-' + type + '-link-' + id ).text(
65 - mw.msg( 'articlefeedbackv5-' + type + '-saved' )
66 - );
 63+ var msg = 'articlefeedbackv5-error-flagging';
 64+ if ( 'articlefeedbackv5-flag-feedback' in data ) {
 65+ if ( 'result' in data['articlefeedbackv5-flag-feedback'] ) {
 66+ if( data['articlefeedbackv5-flag-feedback'].result == 'Success' ) {
 67+ msg = 'articlefeedbackv5-' + type + '-saved';
 68+ } else if (data['articlefeedbackv5-flag-feedback'].result == 'Error' ) {
 69+ msg = data['articlefeedbackv5-flag-feedback'].reason;
 70+ }
 71+ }
 72+ }
 73+ $( '#aft5-' + type + '-link-' + id ).text( mw.msg( msg ) );
 74+ },
 75+ 'failure': function ( data ) {
 76+ $( '#aft5-' + type + '-link-' + id ).text( mw.msg( 'articlefeedbackv5-error-flagging' ) );
6777 }
68 - // TODO have a callback for failures.
6978 } );
7079 return false;
7180 }
Index: trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php
@@ -15,7 +15,7 @@
1616 */
1717 class ApiFlagFeedbackArticleFeedbackv5 extends ApiBase {
1818 public function __construct( $query, $moduleName ) {
19 - parent::__construct( $query, $moduleName, 'af' );
 19+ parent::__construct( $query, $moduleName, '' );
2020 }
2121
2222 /**
@@ -28,7 +28,7 @@
2929
3030 if ( !isset( $params['feedbackid'] )
3131 || !preg_match( '/^\d+$/', $params['feedbackid'] ) ) {
32 - $error = wfMsg( 'articlefeedbackv5-invalid-feedback-id' );
 32+ $error = 'articlefeedbackv5-invalid-feedback-id';
3333 }
3434
3535 # load feedback record, bail if we don't have one
@@ -40,13 +40,13 @@
4141
4242 if ( !$record->af_id ) {
4343 // no-op, because this is already broken
44 - $error = wfMsg( 'articlefeedbackv5-invalid-feedback-id' );
 44+ $error = 'articlefeedbackv5-invalid-feedback-id';
4545 } elseif ( $params['flagtype'] == 'abuse' ) {
4646 $update['af_abuse_count'] = $record->af_abuse_count + 1;
4747 } elseif ( $params['flagtype'] == 'hide' ) {
4848 $update['af_hide_count'] = $record->af_hide_count + 1;
4949 } else {
50 - $error = wfMsg( 'articlefeedbackv5-invalid-feedback-flag' );
 50+ $error = 'articlefeedbackv5-invalid-feedback-flag';
5151 }
5252
5353 if ( !$error ) {
@@ -63,7 +63,7 @@
6464 $reason = $error;
6565 } else {
6666 $result = 'Success';
67 - $reason = 'Feedback saved.';
 67+ $reason = null;
6868 }
6969
7070 $this->getResult()->addValue(
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php
@@ -132,6 +132,13 @@
133133 'jquery.articleFeedbackv5.special' => array(
134134 'scripts ' => 'jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js',
135135 'styles' => 'jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.css',
 136+ 'messages' => array(
 137+ 'articlefeedbackv5-error-flagging',
 138+ 'articlefeedbackv5-invalid-feedback-id',
 139+ 'articlefeedbackv5-invalid-feedback-flag',
 140+ 'articlefeedbackv5-abuse-saved',
 141+ 'articlefeedbackv5-hide-saved',
 142+ ),
136143 ),
137144 );
138145

Follow-up revisions

RevisionCommit summaryAuthorDate
r106067AFTv5 - fix error introduced in r105487, where I had the wrong callback keys ...gregchiasson19:21, 13 December 2011

Comments

#Comment by Catrope (talk | contribs)   16:57, 12 December 2011
+			'failure': function ( data ) {

The name of the failure callback key is 'error', not 'failure'. See the jQuery documentation.

Otherwise OK, marking fixme for the above.

Status & tagging log