Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php |
— | — | @@ -23,6 +23,7 @@ |
24 | 24 | 'articlefeedbackv5-error-unknown' => 'Unknown error', |
25 | 25 | 'articlefeedbackv5-error-submit' => 'Form submission error.', |
26 | 26 | 'articlefeedbackv5-error-nofeedback' => 'Please enter your feedback.', |
| 27 | + 'articlefeedbackv5-error-flagging' => 'Error flagging feedback.', |
27 | 28 | |
28 | 29 | // Article Feedback special page. |
29 | 30 | 'articlefeedbackv5-form-optionid' => 'Option $1', |
Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js |
— | — | @@ -53,18 +53,27 @@ |
54 | 54 | 'type' : 'POST', |
55 | 55 | 'dataType': 'json', |
56 | 56 | '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' |
61 | 61 | }, |
62 | 62 | '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' ) ); |
67 | 77 | } |
68 | | - // TODO have a callback for failures. |
69 | 78 | } ); |
70 | 79 | return false; |
71 | 80 | } |
Index: trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php |
— | — | @@ -15,7 +15,7 @@ |
16 | 16 | */ |
17 | 17 | class ApiFlagFeedbackArticleFeedbackv5 extends ApiBase { |
18 | 18 | public function __construct( $query, $moduleName ) { |
19 | | - parent::__construct( $query, $moduleName, 'af' ); |
| 19 | + parent::__construct( $query, $moduleName, '' ); |
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | |
30 | 30 | if ( !isset( $params['feedbackid'] ) |
31 | 31 | || !preg_match( '/^\d+$/', $params['feedbackid'] ) ) { |
32 | | - $error = wfMsg( 'articlefeedbackv5-invalid-feedback-id' ); |
| 32 | + $error = 'articlefeedbackv5-invalid-feedback-id'; |
33 | 33 | } |
34 | 34 | |
35 | 35 | # load feedback record, bail if we don't have one |
— | — | @@ -40,13 +40,13 @@ |
41 | 41 | |
42 | 42 | if ( !$record->af_id ) { |
43 | 43 | // no-op, because this is already broken |
44 | | - $error = wfMsg( 'articlefeedbackv5-invalid-feedback-id' ); |
| 44 | + $error = 'articlefeedbackv5-invalid-feedback-id'; |
45 | 45 | } elseif ( $params['flagtype'] == 'abuse' ) { |
46 | 46 | $update['af_abuse_count'] = $record->af_abuse_count + 1; |
47 | 47 | } elseif ( $params['flagtype'] == 'hide' ) { |
48 | 48 | $update['af_hide_count'] = $record->af_hide_count + 1; |
49 | 49 | } else { |
50 | | - $error = wfMsg( 'articlefeedbackv5-invalid-feedback-flag' ); |
| 50 | + $error = 'articlefeedbackv5-invalid-feedback-flag'; |
51 | 51 | } |
52 | 52 | |
53 | 53 | if ( !$error ) { |
— | — | @@ -63,7 +63,7 @@ |
64 | 64 | $reason = $error; |
65 | 65 | } else { |
66 | 66 | $result = 'Success'; |
67 | | - $reason = 'Feedback saved.'; |
| 67 | + $reason = null; |
68 | 68 | } |
69 | 69 | |
70 | 70 | $this->getResult()->addValue( |
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php |
— | — | @@ -132,6 +132,13 @@ |
133 | 133 | 'jquery.articleFeedbackv5.special' => array( |
134 | 134 | 'scripts ' => 'jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js', |
135 | 135 | '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 | + ), |
136 | 143 | ), |
137 | 144 | ); |
138 | 145 | |