Index: trunk/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js |
— | — | @@ -204,7 +204,7 @@ |
205 | 205 | // Build data from form values for 'action=articlefeedback' |
206 | 206 | var data = {}; |
207 | 207 | for ( var key in context.options.ratings ) { |
208 | | - var id = context.options.ratings[key].id; |
| 208 | + var id = context.options.ratings[key]; |
209 | 209 | data['r' + id] = context.$ui.find( 'input[name="r' + id + '"]' ).val(); |
210 | 210 | } |
211 | 211 | var expertise = []; |
— | — | @@ -410,8 +410,8 @@ |
411 | 411 | context.$ui.find( '.articleFeedback-rating' ).each( function() { |
412 | 412 | var name = $(this).attr( 'rel' ); |
413 | 413 | var rating = name in context.options.ratings |
414 | | - && context.options.ratings[name].id in ratings ? |
415 | | - ratings[context.options.ratings[name].id] : null; |
| 414 | + && context.options.ratings[name] in ratings ? |
| 415 | + ratings[context.options.ratings[name]] : null; |
416 | 416 | // Report |
417 | 417 | if ( |
418 | 418 | rating !== null |
— | — | @@ -489,12 +489,13 @@ |
490 | 490 | .find( '.articleFeedback-ratings' ) |
491 | 491 | .each( function() { |
492 | 492 | for ( var key in context.options.ratings ) { |
493 | | - var rating = context.options.ratings[key]; |
| 493 | + var tipMsg = 'articlefeedback-field-' + key + '-tip', |
| 494 | + labelMsg = 'articlefeedback-field-' + key + '-label'; |
494 | 495 | $( $.articleFeedback.tpl.rating ) |
495 | 496 | .attr( 'rel', key ) |
496 | 497 | .find( '.articleFeedback-label' ) |
497 | | - .attr( 'title', mw.msg( rating.tip ) ) |
498 | | - .text( mw.msg( rating.label ) ) |
| 498 | + .attr( 'title', mw.msg( tipMsg ) ) |
| 499 | + .text( mw.msg( labelMsg ) ) |
499 | 500 | .end() |
500 | 501 | .find( '.articleFeedback-rating-clear' ) |
501 | 502 | .attr( 'title', mw.msg( 'articlefeedback-form-panel-clear' ) ) |
— | — | @@ -709,8 +710,8 @@ |
710 | 711 | .end() |
711 | 712 | // Name the hidden fields |
712 | 713 | .find( '.articleFeedback-rating' ) |
713 | | - .each( function( rating ) { |
714 | | - $(this).find( 'input:hidden' ) .attr( 'name', 'r' + ( rating + 1 ) ); |
| 714 | + .each( function() { |
| 715 | + $(this).find( 'input:hidden' ) .attr( 'name', 'r' + context.options.ratings[$(this).attr( 'rel' )] ); |
715 | 716 | } ) |
716 | 717 | .end() |
717 | 718 | // Setup switch behavior |
— | — | @@ -838,9 +839,7 @@ |
839 | 840 | * } |
840 | 841 | * } ); |
841 | 842 | * |
842 | | - * Rating IDs need to match up to the contents of your article_feedback_ratings table, which is a |
843 | | - * lookup table containing rating IDs and message keys used for translating rating IDs into string; |
844 | | - * and be included in $wgArticleFeedbackRatings, which is an array of allowed IDs. |
| 843 | + * Rating IDs need to be included in $wgArticleFeedbackRatingTypes, which is an array mapping allowed IDs to rating names. |
845 | 844 | */ |
846 | 845 | $.fn.articleFeedback = function() { |
847 | 846 | var args = arguments; |
Index: trunk/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.js |
— | — | @@ -199,28 +199,7 @@ |
200 | 200 | } )(); |
201 | 201 | |
202 | 202 | var config = { |
203 | | - 'ratings': { |
204 | | - 'trustworthy': { |
205 | | - 'id': '1', |
206 | | - 'label': 'articlefeedback-field-trustworthy-label', |
207 | | - 'tip': 'articlefeedback-field-trustworthy-tip' |
208 | | - }, |
209 | | - 'objective': { |
210 | | - 'id': '2', |
211 | | - 'label': 'articlefeedback-field-objective-label', |
212 | | - 'tip': 'articlefeedback-field-objective-tip' |
213 | | - }, |
214 | | - 'complete': { |
215 | | - 'id': '3', |
216 | | - 'label': 'articlefeedback-field-complete-label', |
217 | | - 'tip': 'articlefeedback-field-complete-tip' |
218 | | - }, |
219 | | - 'wellwritten': { |
220 | | - 'id': '4', |
221 | | - 'label': 'articlefeedback-field-wellwritten-label', |
222 | | - 'tip': 'articlefeedback-field-wellwritten-tip' |
223 | | - } |
224 | | - }, |
| 203 | + 'ratings': mw.config.get( 'wgArticleFeedbackRatingTypesFlipped' ), |
225 | 204 | 'pitches': { |
226 | 205 | 'survey': { |
227 | 206 | 'weight': 1, |
Index: trunk/extensions/ArticleFeedback/populateAFRevisions.php |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | } |
30 | 30 | |
31 | 31 | public function execute() { |
32 | | - global $wgArticleFeedbackRatings; |
| 32 | + global $wgArticleFeedbackRatingTypes; |
33 | 33 | |
34 | 34 | $this->output( "Populating article_feedback_revisions table ...\n" ); |
35 | 35 | |
— | — | @@ -63,10 +63,10 @@ |
64 | 64 | ); |
65 | 65 | |
66 | 66 | // Initialize counts and sums for each rating |
67 | | - // If $wgArticleFeedbackRatings = array( 1, 2, 3, 4 ) this initializes them |
| 67 | + // If array_keys( $wgArticleFeedbackRatingTypes ) = array( 1, 2, 3, 4 ) this initializes them |
68 | 68 | // to array( 1 => 0, 2 => 0, 3 => 0, 4 => 0 ) |
69 | | - $counts = $sums = array_combine( $wgArticleFeedbackRatings, |
70 | | - array_fill( 0, count( $wgArticleFeedbackRatings ), 0 ) |
| 69 | + $counts = $sums = array_combine( array_keys( $wgArticleFeedbackRatingTypes ), |
| 70 | + array_fill( 0, count( $wgArticleFeedbackRatingTypes ), 0 ) |
71 | 71 | ); |
72 | 72 | |
73 | 73 | // Process each of the queried rows and update $data |
Index: trunk/extensions/ArticleFeedback/api/ApiQueryArticleFeedback.php |
— | — | @@ -5,31 +5,24 @@ |
6 | 6 | } |
7 | 7 | |
8 | 8 | public function execute() { |
9 | | - global $wgArticleFeedbackRatings; |
| 9 | + global $wgArticleFeedbackRatingTypes; |
10 | 10 | |
11 | 11 | $params = $this->extractRequestParams(); |
12 | 12 | $result = $this->getResult(); |
13 | 13 | $revisionLimit = $this->getRevisionLimit( $params['pageid'] ); |
14 | 14 | |
15 | | - $this->addTables( array( 'article_feedback_revisions', 'article_feedback_ratings' ) ); |
| 15 | + $this->addTables( array( 'article_feedback_revisions' ) ); |
16 | 16 | $this->addFields( array( |
17 | 17 | 'MAX(afr_revision) as afr_revision', |
18 | 18 | 'SUM(afr_total) as afr_total', |
19 | 19 | 'SUM(afr_count) as afr_count', |
20 | 20 | 'afr_rating_id', |
21 | | - 'aar_rating', |
22 | 21 | ) ); |
23 | | - $this->addJoinConds( array( |
24 | | - 'article_feedback_ratings' => array( 'LEFT JOIN', array( |
25 | | - 'aar_id=afr_rating_id', |
26 | | - 'afr_rating_id' => $wgArticleFeedbackRatings, |
27 | | - ) |
28 | | - ), |
29 | | - ) ); |
30 | 22 | $this->addWhereFld( 'afr_page_id', $params['pageid'] ); |
31 | 23 | $this->addWhere( 'afr_revision >= ' . $revisionLimit ); |
| 24 | + $this->addWhereFld( 'afr_rating_id', array_keys( $wgArticleFeedbackRatingTypes ) ); |
32 | 25 | $this->addOption( 'GROUP BY', 'afr_rating_id' ); |
33 | | - $this->addOption( 'LIMIT', count( $wgArticleFeedbackRatings ) ); |
| 26 | + $this->addOption( 'LIMIT', count( $wgArticleFeedbackRatingTypes ) ); |
34 | 27 | |
35 | 28 | // Rating counts and totals |
36 | 29 | $res = $this->select( __METHOD__ ); |
— | — | @@ -44,7 +37,7 @@ |
45 | 38 | } |
46 | 39 | $ratings[$params['pageid']]['ratings'][] = array( |
47 | 40 | 'ratingid' => (int) $row->afr_rating_id, |
48 | | - 'ratingdesc' => $row->aar_rating, |
| 41 | + 'ratingdesc' => $wgArticleFeedbackRatingTypes[$row->afr_rating_id], |
49 | 42 | 'total' => (int) $row->afr_total, |
50 | 43 | 'count' => (int) $row->afr_count, |
51 | 44 | 'countall' => isset( $historicCounts[$row->afr_rating_id] ) |
— | — | @@ -122,7 +115,7 @@ |
123 | 116 | } |
124 | 117 | |
125 | 118 | protected function getHistoricCounts( $params ) { |
126 | | - global $wgArticleFeedbackRatings; |
| 119 | + global $wgArticleFeedbackRatingTypes; |
127 | 120 | |
128 | 121 | $res = $this->getDB()->select( |
129 | 122 | 'article_feedback_pages', |
— | — | @@ -132,7 +125,7 @@ |
133 | 126 | ), |
134 | 127 | array( |
135 | 128 | 'aap_page_id' => $params['pageid'], |
136 | | - 'aap_rating_id' => $wgArticleFeedbackRatings, |
| 129 | + 'aap_rating_id' => array_keys( $wgArticleFeedbackRatingTypes ), |
137 | 130 | ), |
138 | 131 | __METHOD__ |
139 | 132 | ); |
— | — | @@ -174,29 +167,25 @@ |
175 | 168 | } |
176 | 169 | |
177 | 170 | protected function getUserRatings( $params ) { |
178 | | - global $wgUser, $wgArticleFeedbackRatings; |
| 171 | + global $wgUser, $wgArticleFeedbackRatingTypes; |
179 | 172 | |
180 | 173 | $res = $this->getDB()->select( |
181 | | - array( 'article_feedback', 'article_feedback_ratings' ), |
| 174 | + array( 'article_feedback' ), |
182 | 175 | array( |
183 | 176 | 'aa_rating_id', |
184 | | - 'aar_rating', |
185 | 177 | 'aa_revision', |
186 | 178 | 'aa_rating_value', |
187 | 179 | ), |
188 | 180 | array( |
189 | 181 | 'aa_page_id' => $params['pageid'], |
190 | | - 'aa_rating_id' => $wgArticleFeedbackRatings, |
| 182 | + 'aa_rating_id' => array_keys( $wgArticleFeedbackRatingTypes ), |
191 | 183 | 'aa_user_text' => $wgUser->getName(), |
192 | 184 | 'aa_user_anon_token' => $this->getAnonToken( $params ), |
193 | 185 | ), |
194 | 186 | __METHOD__, |
195 | 187 | array( |
196 | | - 'LIMIT' => count( $wgArticleFeedbackRatings ), |
| 188 | + 'LIMIT' => count( $wgArticleFeedbackRatingTypes ), |
197 | 189 | 'ORDER BY' => 'aa_id DESC', |
198 | | - ), |
199 | | - array( |
200 | | - 'article_feedback_ratings' => array( 'LEFT JOIN', array( 'aar_id=aa_rating_id' ) ) |
201 | 190 | ) |
202 | 191 | ); |
203 | 192 | $ratings = array(); |
— | — | @@ -210,7 +199,7 @@ |
211 | 200 | $ratings[$row->aa_rating_id] = array( |
212 | 201 | 'value' => $row->aa_rating_value, |
213 | 202 | 'revision' => $row->aa_revision, |
214 | | - 'text' => $row->aar_rating, |
| 203 | + 'text' => $wgArticleFeedbackRatingTypes[$row->aa_rating_id], |
215 | 204 | ); |
216 | 205 | } |
217 | 206 | } |
Index: trunk/extensions/ArticleFeedback/api/ApiArticleFeedback.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | } |
7 | 7 | |
8 | 8 | public function execute() { |
9 | | - global $wgUser, $wgArticleFeedbackRatings, $wgArticleFeedbackSMaxage, |
| 9 | + global $wgUser, $wgArticleFeedbackRatingTypes, $wgArticleFeedbackSMaxage, |
10 | 10 | $wgArticleFeedbackNamespaces; |
11 | 11 | $params = $this->extractRequestParams(); |
12 | 12 | |
— | — | @@ -44,7 +44,7 @@ |
45 | 45 | |
46 | 46 | // Build array( rating ID => rating value ) |
47 | 47 | $ratings = array(); |
48 | | - foreach ( $wgArticleFeedbackRatings as $ratingID ) { |
| 48 | + foreach ( $wgArticleFeedbackRatingTypes as $ratingID => $unused ) { |
49 | 49 | $ratings[$ratingID] = intval( $params["r{$ratingID}"] ); |
50 | 50 | } |
51 | 51 | // Insert the new ratings |
— | — | @@ -60,14 +60,14 @@ |
61 | 61 | array( |
62 | 62 | 'aa_user_text' => $wgUser->getName(), |
63 | 63 | 'aa_page_id' => $params['pageid'], |
64 | | - 'aa_rating_id' => $wgArticleFeedbackRatings, |
| 64 | + 'aa_rating_id' => array_keys( $wgArticleFeedbackRatingTypes ), |
65 | 65 | 'aa_user_anon_token' => $token, |
66 | 66 | 'aa_id < ' . intval( $id ) |
67 | 67 | ), |
68 | 68 | __METHOD__, |
69 | 69 | array( |
70 | 70 | 'ORDER BY' => 'aa_id DESC', |
71 | | - 'LIMIT' => count( $wgArticleFeedbackRatings ), |
| 71 | + 'LIMIT' => count( $wgArticleFeedbackRatingTypes ), |
72 | 72 | ) |
73 | 73 | ); |
74 | 74 | $lastRatings = array(); |
— | — | @@ -76,22 +76,22 @@ |
77 | 77 | $lastRatings[$row->aa_rating_id]['revision'] = $row->aa_revision; |
78 | 78 | } |
79 | 79 | |
80 | | - foreach ( $wgArticleFeedbackRatings as $rating ) { |
| 80 | + foreach ( $wgArticleFeedbackRatingTypes as $ratingID => $unused ) { |
81 | 81 | $lastPageRating = false; |
82 | 82 | $lastRevRating = false; |
83 | | - if ( isset( $lastRatings[$rating] ) ) { |
84 | | - $lastPageRating = intval( $lastRatings[$rating]['value'] ); |
85 | | - if ( intval( $lastRatings[$rating]['revision'] ) == $revisionId ) { |
| 83 | + if ( isset( $lastRatings[$ratingID] ) ) { |
| 84 | + $lastPageRating = intval( $lastRatings[$ratingID]['value'] ); |
| 85 | + if ( intval( $lastRatings[$ratingID]['revision'] ) == $revisionId ) { |
86 | 86 | $lastRevRating = $lastPageRating; |
87 | 87 | } |
88 | 88 | } |
89 | | - $thisRating = intval( $params["r{$rating}"] ); |
| 89 | + $thisRating = intval( $params["r{$ratingID}"] ); |
90 | 90 | |
91 | 91 | // Update counter tables |
92 | | - $this->insertRevisionRating( $pageId, $revisionId, $rating, $thisRating - $lastRevRating, |
| 92 | + $this->insertRevisionRating( $pageId, $revisionId, $ratingID, $thisRating - $lastRevRating, |
93 | 93 | $thisRating, $lastRevRating |
94 | 94 | ); |
95 | | - $this->insertPageRating( $pageId, $rating, $thisRating - $lastPageRating, $thisRating, $lastPageRating ); |
| 95 | + $this->insertPageRating( $pageId, $ratingID, $thisRating - $lastPageRating, $thisRating, $lastPageRating ); |
96 | 96 | } |
97 | 97 | |
98 | 98 | $this->insertProperties( $revisionId, $wgUser, $token, $params ); |
— | — | @@ -328,7 +328,7 @@ |
329 | 329 | } |
330 | 330 | |
331 | 331 | public function getAllowedParams() { |
332 | | - global $wgArticleFeedbackRatings; |
| 332 | + global $wgArticleFeedbackRatingTypes; |
333 | 333 | $ret = array( |
334 | 334 | 'pageid' => array( |
335 | 335 | ApiBase::PARAM_TYPE => 'integer', |
— | — | @@ -352,8 +352,8 @@ |
353 | 353 | ), |
354 | 354 | ); |
355 | 355 | |
356 | | - foreach( $wgArticleFeedbackRatings as $rating ) { |
357 | | - $ret["r{$rating}"] = array( |
| 356 | + foreach( $wgArticleFeedbackRatingTypes as $ratingID => $unused ) { |
| 357 | + $ret["r{$ratingID}"] = array( |
358 | 358 | ApiBase::PARAM_TYPE => 'integer', |
359 | 359 | ApiBase::PARAM_REQUIRED => true, |
360 | 360 | ApiBase::PARAM_ISMULTI => false, |
— | — | @@ -366,7 +366,7 @@ |
367 | 367 | } |
368 | 368 | |
369 | 369 | public function getParamDescription() { |
370 | | - global $wgArticleFeedbackRatings; |
| 370 | + global $wgArticleFeedbackRatingTypes; |
371 | 371 | $ret = array( |
372 | 372 | 'pageid' => 'Page ID to submit feedback for', |
373 | 373 | 'revid' => 'Revision ID to submit feedback for', |
— | — | @@ -374,7 +374,7 @@ |
375 | 375 | 'bucket' => 'Which rating widget was shown to the user', |
376 | 376 | 'expertise' => 'What kinds of expertise does the user claim to have', |
377 | 377 | ); |
378 | | - foreach( $wgArticleFeedbackRatings as $rating ) { |
| 378 | + foreach( $wgArticleFeedbackRatingTypes as $rating => $unused ) { |
379 | 379 | $ret["r{$rating}"] = "Rating {$rating}"; |
380 | 380 | } |
381 | 381 | return $ret; |
Index: trunk/extensions/ArticleFeedback/ArticleFeedback.php |
— | — | @@ -24,8 +24,8 @@ |
25 | 25 | // Number of revisions to keep a rating alive for |
26 | 26 | $wgArticleFeedbackRatingLifetime = 30; |
27 | 27 | |
28 | | -// Array of the "ratings" id's to store. Allows it to be a bit more dynamic |
29 | | -$wgArticleFeedbackRatings = array( 1, 2, 3, 4 ); |
| 28 | +// Array of rating types |
| 29 | +$wgArticleFeedbackRatingTypes = array( 1 => 'trustworthy', 2 => 'objective', 3 => 'complete', 4 => 'wellwritten' ); |
30 | 30 | |
31 | 31 | // Which categories the pages must belong to have the rating widget added (with _ in text) |
32 | 32 | // Extension is "disabled" if this field is an empty array (as per default configuration) |
Index: trunk/extensions/ArticleFeedback/SpecialArticleFeedback.php |
— | — | @@ -536,19 +536,11 @@ |
537 | 537 | } |
538 | 538 | |
539 | 539 | protected static function getCategories() { |
540 | | - global $wgArticleFeedbackRatings; |
| 540 | + global $wgArticleFeedbackRatingTypes; |
541 | 541 | |
542 | 542 | if ( !isset( self::$categories ) ) { |
543 | | - $dbr = wfGetDB( DB_SLAVE ); |
544 | | - $res = $dbr->select( |
545 | | - 'article_feedback_ratings', |
546 | | - array( 'aar_id', 'aar_rating' ), |
547 | | - array( 'aar_id' => $wgArticleFeedbackRatings ), |
548 | | - __METHOD__ |
549 | | - ); |
550 | | - self::$categories = array(); |
551 | | - foreach ( $res as $row ) { |
552 | | - self::$categories[$row->aar_id] = wfMsg( $row->aar_rating ); |
| 543 | + foreach ( $wgArticleFeedbackRatingTypes as $id => $rating ) { |
| 544 | + self::$categories[$id] = wfMsg( $rating ); |
553 | 545 | } |
554 | 546 | } |
555 | 547 | return self::$categories; |
Index: trunk/extensions/ArticleFeedback/sql/AddRevisionsTable.sql |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | afr_page_id integer unsigned NOT NULL, |
6 | 6 | -- Revision that totals are relevant to |
7 | 7 | afr_revision integer unsigned NOT NULL, |
8 | | - -- Foreign key to article_feedback_ratings.aar_rating |
| 8 | + -- Rating ID, mapped to a name in $wgArticleFeedbackRatingTypes |
9 | 9 | afr_rating_id integer unsigned NOT NULL, |
10 | 10 | -- Sum (total) of all the ratings for this article revision |
11 | 11 | afr_total integer unsigned NOT NULL, |
Index: trunk/extensions/ArticleFeedback/sql/ArticleFeedback.sql |
— | — | @@ -1,17 +1,3 @@ |
2 | | -CREATE TABLE IF NOT EXISTS /*_*/article_feedback_ratings ( |
3 | | - -- Rating Id |
4 | | - aar_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, |
5 | | - -- Text (i18n key) for rating description |
6 | | - aar_rating varbinary(255) NOT NULL |
7 | | -) /*$wgDBTableOptions*/; |
8 | | - |
9 | | -INSERT INTO /*_*/article_feedback_ratings (aar_rating) VALUES ('articlefeedback-field-trustworthy-label'); |
10 | | -INSERT INTO /*_*/article_feedback_ratings (aar_rating) VALUES ('articlefeedback-field-objective-label'); |
11 | | -INSERT INTO /*_*/article_feedback_ratings (aar_rating) VALUES ('articlefeedback-field-complete-label'); |
12 | | -INSERT INTO /*_*/article_feedback_ratings (aar_rating) VALUES ('articlefeedback-field-wellwritten-label'); |
13 | | - |
14 | 2 | -- Store article feedbacks (user rating per revision) |
15 | 3 | CREATE TABLE IF NOT EXISTS /*_*/article_feedback ( |
16 | 4 | -- Row ID (primary key) |
— | — | @@ -28,7 +14,7 @@ |
29 | 15 | aa_revision integer unsigned NOT NULL, |
30 | 16 | -- MW Timestamp |
31 | 17 | aa_timestamp binary(14) NOT NULL DEFAULT '', |
32 | | - -- Foreign key to article_feedback_ratings.aar_rating |
| 18 | + -- Rating ID, mapped to a name in $wgArticleFeedbackRatingTypes |
33 | 19 | aa_rating_id int unsigned NOT NULL, |
34 | 20 | -- Value of the rating (0 is "unrated", else 1-5) |
35 | 21 | aa_rating_value int unsigned NOT NULL, |
— | — | @@ -45,7 +31,7 @@ |
46 | 32 | CREATE TABLE IF NOT EXISTS /*_*/article_feedback_pages ( |
47 | 33 | -- Foreign key to page.page_id |
48 | 34 | aap_page_id integer unsigned NOT NULL, |
49 | | - -- Foreign key to article_feedback_ratings.aar_rating |
| 35 | + -- Rating ID, mapped to a name in $wgArticleFeedbackRatingTypes |
50 | 36 | aap_rating_id integer unsigned NOT NULL, |
51 | 37 | -- Sum (total) of all the ratings for this article revision |
52 | 38 | aap_total integer unsigned NOT NULL, |
— | — | @@ -61,7 +47,7 @@ |
62 | 48 | afr_page_id integer unsigned NOT NULL, |
63 | 49 | -- Revision that totals are relevant to |
64 | 50 | afr_revision integer unsigned NOT NULL, |
65 | | - -- Foreign key to article_feedback_ratings.aar_rating |
| 51 | + -- Rating ID, mapped to a name in $wgArticleFeedbackRatingTypes |
66 | 52 | afr_rating_id integer unsigned NOT NULL, |
67 | 53 | -- Sum (total) of all the ratings for this article revision |
68 | 54 | afr_total integer unsigned NOT NULL, |
Index: trunk/extensions/ArticleFeedback/ArticleFeedback.hooks.php |
— | — | @@ -19,34 +19,6 @@ |
20 | 20 | 'scripts' => 'ext.articleFeedback/ext.articleFeedback.js', |
21 | 21 | 'styles' => 'ext.articleFeedback/ext.articleFeedback.css', |
22 | 22 | 'messages' => array( |
23 | | - 'articlefeedback-field-trustworthy-label', |
24 | | - 'articlefeedback-field-trustworthy-tip', |
25 | | - 'articlefeedback-field-trustworthy-tooltip-1', |
26 | | - 'articlefeedback-field-trustworthy-tooltip-2', |
27 | | - 'articlefeedback-field-trustworthy-tooltip-3', |
28 | | - 'articlefeedback-field-trustworthy-tooltip-4', |
29 | | - 'articlefeedback-field-trustworthy-tooltip-5', |
30 | | - 'articlefeedback-field-complete-label', |
31 | | - 'articlefeedback-field-complete-tip', |
32 | | - 'articlefeedback-field-complete-tooltip-1', |
33 | | - 'articlefeedback-field-complete-tooltip-2', |
34 | | - 'articlefeedback-field-complete-tooltip-3', |
35 | | - 'articlefeedback-field-complete-tooltip-4', |
36 | | - 'articlefeedback-field-complete-tooltip-5', |
37 | | - 'articlefeedback-field-objective-label', |
38 | | - 'articlefeedback-field-objective-tip', |
39 | | - 'articlefeedback-field-objective-tooltip-1', |
40 | | - 'articlefeedback-field-objective-tooltip-2', |
41 | | - 'articlefeedback-field-objective-tooltip-3', |
42 | | - 'articlefeedback-field-objective-tooltip-4', |
43 | | - 'articlefeedback-field-objective-tooltip-5', |
44 | | - 'articlefeedback-field-wellwritten-label', |
45 | | - 'articlefeedback-field-wellwritten-tip', |
46 | | - 'articlefeedback-field-wellwritten-tooltip-1', |
47 | | - 'articlefeedback-field-wellwritten-tooltip-2', |
48 | | - 'articlefeedback-field-wellwritten-tooltip-3', |
49 | | - 'articlefeedback-field-wellwritten-tooltip-4', |
50 | | - 'articlefeedback-field-wellwritten-tooltip-5', |
51 | 23 | 'articlefeedback-pitch-reject', |
52 | 24 | 'articlefeedback-pitch-or', |
53 | 25 | 'articlefeedback-pitch-thanks', |
— | — | @@ -71,8 +43,12 @@ |
72 | 44 | 'jquery.articleFeedback', |
73 | 45 | 'jquery.cookie', |
74 | 46 | 'jquery.clickTracking', |
| 47 | + 'ext.articleFeedback.ratingi18n', |
75 | 48 | ), |
76 | 49 | ), |
| 50 | + 'ext.articleFeedback.ratingi18n' => array( |
| 51 | + 'messages' => null, // Filled in by the resourceLoaderRegisterModules() hook function later |
| 52 | + ), |
77 | 53 | 'ext.articleFeedback.dashboard' => array( |
78 | 54 | 'scripts' => 'ext.articleFeedback/ext.articleFeedback.dashboard.js', |
79 | 55 | 'styles' => 'ext.articleFeedback/ext.articleFeedback.dashboard.css', |
— | — | @@ -260,7 +236,6 @@ |
261 | 237 | $tables[] = 'article_feedback'; |
262 | 238 | $tables[] = 'article_feedback_pages'; |
263 | 239 | $tables[] = 'article_feedback_revisions'; |
264 | | - $tables[] = 'article_feedback_ratings'; |
265 | 240 | $tables[] = 'article_feedback_properties'; |
266 | 241 | return true; |
267 | 242 | } |
— | — | @@ -280,6 +255,11 @@ |
281 | 256 | global $wgExtensionAssetsPath; |
282 | 257 | $localpath = dirname( __FILE__ ) . '/modules'; |
283 | 258 | $remotepath = "$wgExtensionAssetsPath/ArticleFeedback/modules"; |
| 259 | + |
| 260 | + if ( self::$modules['ext.articleFeedback.ratingi18n']['messages'] === null ) { |
| 261 | + self::$modules['ext.articleFeedback.ratingi18n']['messages'] = self::buildRatingMessagesArray(); |
| 262 | + } |
| 263 | + |
284 | 264 | foreach ( self::$modules as $name => $resources ) { |
285 | 265 | $resourceLoader->register( |
286 | 266 | $name, new ResourceLoaderFileModule( $resources, $localpath, $remotepath ) |
— | — | @@ -298,7 +278,8 @@ |
299 | 279 | $wgArticleFeedbackLotteryOdds, |
300 | 280 | $wgArticleFeedbackTracking, |
301 | 281 | $wgArticleFeedbackOptions, |
302 | | - $wgArticleFeedbackNamespaces; |
| 282 | + $wgArticleFeedbackNamespaces, |
| 283 | + $wgArticleFeedbackRatingTypes; |
303 | 284 | $vars['wgArticleFeedbackSMaxage'] = $wgArticleFeedbackSMaxage; |
304 | 285 | $vars['wgArticleFeedbackCategories'] = $wgArticleFeedbackCategories; |
305 | 286 | $vars['wgArticleFeedbackBlacklistCategories'] = $wgArticleFeedbackBlacklistCategories; |
— | — | @@ -307,6 +288,7 @@ |
308 | 289 | $vars['wgArticleFeedbackOptions'] = $wgArticleFeedbackOptions; |
309 | 290 | $vars['wgArticleFeedbackNamespaces'] = $wgArticleFeedbackNamespaces; |
310 | 291 | $vars['wgArticleFeedbackWhatsThisPage'] = wfMsgForContent( 'articlefeedback-form-panel-explanation-link' ); |
| 292 | + $vars['wgArticleFeedbackRatingTypesFlipped'] = array_flip( $wgArticleFeedbackRatingTypes ); |
311 | 293 | return true; |
312 | 294 | } |
313 | 295 | |
— | — | @@ -323,4 +305,15 @@ |
324 | 306 | ); |
325 | 307 | return true; |
326 | 308 | } |
| 309 | + |
| 310 | + protected static function buildRatingMessagesArray() { |
| 311 | + global $wgArticleFeedbackRatingTypes; |
| 312 | + $messages = array(); |
| 313 | + foreach ( $wgArticleFeedbackRatingTypes as $key ) { |
| 314 | + foreach ( array( 'label', 'tip', 'tooltip-1', 'tooltip-2', 'tooltip-3', 'tooltip-4', 'tooltip-5' ) as $suffix ) { |
| 315 | + $messages[] = "articlefeedback-field-$key-$suffix"; |
| 316 | + } |
| 317 | + } |
| 318 | + return $messages; |
| 319 | + } |
327 | 320 | } |