r100806 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100805‎ | r100806 | r100807 >
Date:14:19, 26 October 2011
Author:catrope
Status:resolved (Comments)
Tags:aft 
Comment:
Make ArticleFeedback actually support custom rating types properly. This is getting to the point where it's hacks on top of hacks, would be nice to redesign it properly some time.

* Move config.ratings in JS to $wgArticleFeedbackRatingTypes in PHP. This supersedes $wgArticleFeedbackRatings, which I removed.
* Derive the -label and -tip message keys from the rating type name. The -tooltip-$i message keys are derived this way already
* Take out the hardcoded message keys for the default rating types, and put the rating i18n in a separate module whose message keys are populated dynamically based on the config
* Kill the article_feedback_ratings table with fire, all the needed data is in $wgArticleFeedbackRatings
* Fix the numbering of the hidden inputs, was assuming rating ID numbering started at 1
* Add a WHERE clause for afr_rating_id to ApiQueryArticleFeedback to prevent weirdness in the midst of a rating type migration
* Generally change things to comply with these changes
Modified paths:
  • /trunk/extensions/ArticleFeedback/ArticleFeedback.hooks.php (modified) (history)
  • /trunk/extensions/ArticleFeedback/ArticleFeedback.php (modified) (history)
  • /trunk/extensions/ArticleFeedback/SpecialArticleFeedback.php (modified) (history)
  • /trunk/extensions/ArticleFeedback/api/ApiArticleFeedback.php (modified) (history)
  • /trunk/extensions/ArticleFeedback/api/ApiQueryArticleFeedback.php (modified) (history)
  • /trunk/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.js (modified) (history)
  • /trunk/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js (modified) (history)
  • /trunk/extensions/ArticleFeedback/populateAFRevisions.php (modified) (history)
  • /trunk/extensions/ArticleFeedback/sql/AddRevisionsTable.sql (modified) (history)
  • /trunk/extensions/ArticleFeedback/sql/ArticleFeedback.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js
@@ -204,7 +204,7 @@
205205 // Build data from form values for 'action=articlefeedback'
206206 var data = {};
207207 for ( var key in context.options.ratings ) {
208 - var id = context.options.ratings[key].id;
 208+ var id = context.options.ratings[key];
209209 data['r' + id] = context.$ui.find( 'input[name="r' + id + '"]' ).val();
210210 }
211211 var expertise = [];
@@ -410,8 +410,8 @@
411411 context.$ui.find( '.articleFeedback-rating' ).each( function() {
412412 var name = $(this).attr( 'rel' );
413413 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;
416416 // Report
417417 if (
418418 rating !== null
@@ -489,12 +489,13 @@
490490 .find( '.articleFeedback-ratings' )
491491 .each( function() {
492492 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';
494495 $( $.articleFeedback.tpl.rating )
495496 .attr( 'rel', key )
496497 .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 ) )
499500 .end()
500501 .find( '.articleFeedback-rating-clear' )
501502 .attr( 'title', mw.msg( 'articlefeedback-form-panel-clear' ) )
@@ -709,8 +710,8 @@
710711 .end()
711712 // Name the hidden fields
712713 .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' )] );
715716 } )
716717 .end()
717718 // Setup switch behavior
@@ -838,9 +839,7 @@
839840 * }
840841 * } );
841842 *
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.
845844 */
846845 $.fn.articleFeedback = function() {
847846 var args = arguments;
Index: trunk/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.js
@@ -199,28 +199,7 @@
200200 } )();
201201
202202 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' ),
225204 'pitches': {
226205 'survey': {
227206 'weight': 1,
Index: trunk/extensions/ArticleFeedback/populateAFRevisions.php
@@ -28,7 +28,7 @@
2929 }
3030
3131 public function execute() {
32 - global $wgArticleFeedbackRatings;
 32+ global $wgArticleFeedbackRatingTypes;
3333
3434 $this->output( "Populating article_feedback_revisions table ...\n" );
3535
@@ -63,10 +63,10 @@
6464 );
6565
6666 // 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
6868 // 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 )
7171 );
7272
7373 // Process each of the queried rows and update $data
Index: trunk/extensions/ArticleFeedback/api/ApiQueryArticleFeedback.php
@@ -5,31 +5,24 @@
66 }
77
88 public function execute() {
9 - global $wgArticleFeedbackRatings;
 9+ global $wgArticleFeedbackRatingTypes;
1010
1111 $params = $this->extractRequestParams();
1212 $result = $this->getResult();
1313 $revisionLimit = $this->getRevisionLimit( $params['pageid'] );
1414
15 - $this->addTables( array( 'article_feedback_revisions', 'article_feedback_ratings' ) );
 15+ $this->addTables( array( 'article_feedback_revisions' ) );
1616 $this->addFields( array(
1717 'MAX(afr_revision) as afr_revision',
1818 'SUM(afr_total) as afr_total',
1919 'SUM(afr_count) as afr_count',
2020 'afr_rating_id',
21 - 'aar_rating',
2221 ) );
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 - ) );
3022 $this->addWhereFld( 'afr_page_id', $params['pageid'] );
3123 $this->addWhere( 'afr_revision >= ' . $revisionLimit );
 24+ $this->addWhereFld( 'afr_rating_id', array_keys( $wgArticleFeedbackRatingTypes ) );
3225 $this->addOption( 'GROUP BY', 'afr_rating_id' );
33 - $this->addOption( 'LIMIT', count( $wgArticleFeedbackRatings ) );
 26+ $this->addOption( 'LIMIT', count( $wgArticleFeedbackRatingTypes ) );
3427
3528 // Rating counts and totals
3629 $res = $this->select( __METHOD__ );
@@ -44,7 +37,7 @@
4538 }
4639 $ratings[$params['pageid']]['ratings'][] = array(
4740 'ratingid' => (int) $row->afr_rating_id,
48 - 'ratingdesc' => $row->aar_rating,
 41+ 'ratingdesc' => $wgArticleFeedbackRatingTypes[$row->afr_rating_id],
4942 'total' => (int) $row->afr_total,
5043 'count' => (int) $row->afr_count,
5144 'countall' => isset( $historicCounts[$row->afr_rating_id] )
@@ -122,7 +115,7 @@
123116 }
124117
125118 protected function getHistoricCounts( $params ) {
126 - global $wgArticleFeedbackRatings;
 119+ global $wgArticleFeedbackRatingTypes;
127120
128121 $res = $this->getDB()->select(
129122 'article_feedback_pages',
@@ -132,7 +125,7 @@
133126 ),
134127 array(
135128 'aap_page_id' => $params['pageid'],
136 - 'aap_rating_id' => $wgArticleFeedbackRatings,
 129+ 'aap_rating_id' => array_keys( $wgArticleFeedbackRatingTypes ),
137130 ),
138131 __METHOD__
139132 );
@@ -174,29 +167,25 @@
175168 }
176169
177170 protected function getUserRatings( $params ) {
178 - global $wgUser, $wgArticleFeedbackRatings;
 171+ global $wgUser, $wgArticleFeedbackRatingTypes;
179172
180173 $res = $this->getDB()->select(
181 - array( 'article_feedback', 'article_feedback_ratings' ),
 174+ array( 'article_feedback' ),
182175 array(
183176 'aa_rating_id',
184 - 'aar_rating',
185177 'aa_revision',
186178 'aa_rating_value',
187179 ),
188180 array(
189181 'aa_page_id' => $params['pageid'],
190 - 'aa_rating_id' => $wgArticleFeedbackRatings,
 182+ 'aa_rating_id' => array_keys( $wgArticleFeedbackRatingTypes ),
191183 'aa_user_text' => $wgUser->getName(),
192184 'aa_user_anon_token' => $this->getAnonToken( $params ),
193185 ),
194186 __METHOD__,
195187 array(
196 - 'LIMIT' => count( $wgArticleFeedbackRatings ),
 188+ 'LIMIT' => count( $wgArticleFeedbackRatingTypes ),
197189 'ORDER BY' => 'aa_id DESC',
198 - ),
199 - array(
200 - 'article_feedback_ratings' => array( 'LEFT JOIN', array( 'aar_id=aa_rating_id' ) )
201190 )
202191 );
203192 $ratings = array();
@@ -210,7 +199,7 @@
211200 $ratings[$row->aa_rating_id] = array(
212201 'value' => $row->aa_rating_value,
213202 'revision' => $row->aa_revision,
214 - 'text' => $row->aar_rating,
 203+ 'text' => $wgArticleFeedbackRatingTypes[$row->aa_rating_id],
215204 );
216205 }
217206 }
Index: trunk/extensions/ArticleFeedback/api/ApiArticleFeedback.php
@@ -5,7 +5,7 @@
66 }
77
88 public function execute() {
9 - global $wgUser, $wgArticleFeedbackRatings, $wgArticleFeedbackSMaxage,
 9+ global $wgUser, $wgArticleFeedbackRatingTypes, $wgArticleFeedbackSMaxage,
1010 $wgArticleFeedbackNamespaces;
1111 $params = $this->extractRequestParams();
1212
@@ -44,7 +44,7 @@
4545
4646 // Build array( rating ID => rating value )
4747 $ratings = array();
48 - foreach ( $wgArticleFeedbackRatings as $ratingID ) {
 48+ foreach ( $wgArticleFeedbackRatingTypes as $ratingID => $unused ) {
4949 $ratings[$ratingID] = intval( $params["r{$ratingID}"] );
5050 }
5151 // Insert the new ratings
@@ -60,14 +60,14 @@
6161 array(
6262 'aa_user_text' => $wgUser->getName(),
6363 'aa_page_id' => $params['pageid'],
64 - 'aa_rating_id' => $wgArticleFeedbackRatings,
 64+ 'aa_rating_id' => array_keys( $wgArticleFeedbackRatingTypes ),
6565 'aa_user_anon_token' => $token,
6666 'aa_id < ' . intval( $id )
6767 ),
6868 __METHOD__,
6969 array(
7070 'ORDER BY' => 'aa_id DESC',
71 - 'LIMIT' => count( $wgArticleFeedbackRatings ),
 71+ 'LIMIT' => count( $wgArticleFeedbackRatingTypes ),
7272 )
7373 );
7474 $lastRatings = array();
@@ -76,22 +76,22 @@
7777 $lastRatings[$row->aa_rating_id]['revision'] = $row->aa_revision;
7878 }
7979
80 - foreach ( $wgArticleFeedbackRatings as $rating ) {
 80+ foreach ( $wgArticleFeedbackRatingTypes as $ratingID => $unused ) {
8181 $lastPageRating = false;
8282 $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 ) {
8686 $lastRevRating = $lastPageRating;
8787 }
8888 }
89 - $thisRating = intval( $params["r{$rating}"] );
 89+ $thisRating = intval( $params["r{$ratingID}"] );
9090
9191 // Update counter tables
92 - $this->insertRevisionRating( $pageId, $revisionId, $rating, $thisRating - $lastRevRating,
 92+ $this->insertRevisionRating( $pageId, $revisionId, $ratingID, $thisRating - $lastRevRating,
9393 $thisRating, $lastRevRating
9494 );
95 - $this->insertPageRating( $pageId, $rating, $thisRating - $lastPageRating, $thisRating, $lastPageRating );
 95+ $this->insertPageRating( $pageId, $ratingID, $thisRating - $lastPageRating, $thisRating, $lastPageRating );
9696 }
9797
9898 $this->insertProperties( $revisionId, $wgUser, $token, $params );
@@ -328,7 +328,7 @@
329329 }
330330
331331 public function getAllowedParams() {
332 - global $wgArticleFeedbackRatings;
 332+ global $wgArticleFeedbackRatingTypes;
333333 $ret = array(
334334 'pageid' => array(
335335 ApiBase::PARAM_TYPE => 'integer',
@@ -352,8 +352,8 @@
353353 ),
354354 );
355355
356 - foreach( $wgArticleFeedbackRatings as $rating ) {
357 - $ret["r{$rating}"] = array(
 356+ foreach( $wgArticleFeedbackRatingTypes as $ratingID => $unused ) {
 357+ $ret["r{$ratingID}"] = array(
358358 ApiBase::PARAM_TYPE => 'integer',
359359 ApiBase::PARAM_REQUIRED => true,
360360 ApiBase::PARAM_ISMULTI => false,
@@ -366,7 +366,7 @@
367367 }
368368
369369 public function getParamDescription() {
370 - global $wgArticleFeedbackRatings;
 370+ global $wgArticleFeedbackRatingTypes;
371371 $ret = array(
372372 'pageid' => 'Page ID to submit feedback for',
373373 'revid' => 'Revision ID to submit feedback for',
@@ -374,7 +374,7 @@
375375 'bucket' => 'Which rating widget was shown to the user',
376376 'expertise' => 'What kinds of expertise does the user claim to have',
377377 );
378 - foreach( $wgArticleFeedbackRatings as $rating ) {
 378+ foreach( $wgArticleFeedbackRatingTypes as $rating => $unused ) {
379379 $ret["r{$rating}"] = "Rating {$rating}";
380380 }
381381 return $ret;
Index: trunk/extensions/ArticleFeedback/ArticleFeedback.php
@@ -24,8 +24,8 @@
2525 // Number of revisions to keep a rating alive for
2626 $wgArticleFeedbackRatingLifetime = 30;
2727
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' );
3030
3131 // Which categories the pages must belong to have the rating widget added (with _ in text)
3232 // Extension is "disabled" if this field is an empty array (as per default configuration)
Index: trunk/extensions/ArticleFeedback/SpecialArticleFeedback.php
@@ -536,19 +536,11 @@
537537 }
538538
539539 protected static function getCategories() {
540 - global $wgArticleFeedbackRatings;
 540+ global $wgArticleFeedbackRatingTypes;
541541
542542 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 );
553545 }
554546 }
555547 return self::$categories;
Index: trunk/extensions/ArticleFeedback/sql/AddRevisionsTable.sql
@@ -4,7 +4,7 @@
55 afr_page_id integer unsigned NOT NULL,
66 -- Revision that totals are relevant to
77 afr_revision integer unsigned NOT NULL,
8 - -- Foreign key to article_feedback_ratings.aar_rating
 8+ -- Rating ID, mapped to a name in $wgArticleFeedbackRatingTypes
99 afr_rating_id integer unsigned NOT NULL,
1010 -- Sum (total) of all the ratings for this article revision
1111 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 -
142 -- Store article feedbacks (user rating per revision)
153 CREATE TABLE IF NOT EXISTS /*_*/article_feedback (
164 -- Row ID (primary key)
@@ -28,7 +14,7 @@
2915 aa_revision integer unsigned NOT NULL,
3016 -- MW Timestamp
3117 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
3319 aa_rating_id int unsigned NOT NULL,
3420 -- Value of the rating (0 is "unrated", else 1-5)
3521 aa_rating_value int unsigned NOT NULL,
@@ -45,7 +31,7 @@
4632 CREATE TABLE IF NOT EXISTS /*_*/article_feedback_pages (
4733 -- Foreign key to page.page_id
4834 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
5036 aap_rating_id integer unsigned NOT NULL,
5137 -- Sum (total) of all the ratings for this article revision
5238 aap_total integer unsigned NOT NULL,
@@ -61,7 +47,7 @@
6248 afr_page_id integer unsigned NOT NULL,
6349 -- Revision that totals are relevant to
6450 afr_revision integer unsigned NOT NULL,
65 - -- Foreign key to article_feedback_ratings.aar_rating
 51+ -- Rating ID, mapped to a name in $wgArticleFeedbackRatingTypes
6652 afr_rating_id integer unsigned NOT NULL,
6753 -- Sum (total) of all the ratings for this article revision
6854 afr_total integer unsigned NOT NULL,
Index: trunk/extensions/ArticleFeedback/ArticleFeedback.hooks.php
@@ -19,34 +19,6 @@
2020 'scripts' => 'ext.articleFeedback/ext.articleFeedback.js',
2121 'styles' => 'ext.articleFeedback/ext.articleFeedback.css',
2222 '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',
5123 'articlefeedback-pitch-reject',
5224 'articlefeedback-pitch-or',
5325 'articlefeedback-pitch-thanks',
@@ -71,8 +43,12 @@
7244 'jquery.articleFeedback',
7345 'jquery.cookie',
7446 'jquery.clickTracking',
 47+ 'ext.articleFeedback.ratingi18n',
7548 ),
7649 ),
 50+ 'ext.articleFeedback.ratingi18n' => array(
 51+ 'messages' => null, // Filled in by the resourceLoaderRegisterModules() hook function later
 52+ ),
7753 'ext.articleFeedback.dashboard' => array(
7854 'scripts' => 'ext.articleFeedback/ext.articleFeedback.dashboard.js',
7955 'styles' => 'ext.articleFeedback/ext.articleFeedback.dashboard.css',
@@ -260,7 +236,6 @@
261237 $tables[] = 'article_feedback';
262238 $tables[] = 'article_feedback_pages';
263239 $tables[] = 'article_feedback_revisions';
264 - $tables[] = 'article_feedback_ratings';
265240 $tables[] = 'article_feedback_properties';
266241 return true;
267242 }
@@ -280,6 +255,11 @@
281256 global $wgExtensionAssetsPath;
282257 $localpath = dirname( __FILE__ ) . '/modules';
283258 $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+
284264 foreach ( self::$modules as $name => $resources ) {
285265 $resourceLoader->register(
286266 $name, new ResourceLoaderFileModule( $resources, $localpath, $remotepath )
@@ -298,7 +278,8 @@
299279 $wgArticleFeedbackLotteryOdds,
300280 $wgArticleFeedbackTracking,
301281 $wgArticleFeedbackOptions,
302 - $wgArticleFeedbackNamespaces;
 282+ $wgArticleFeedbackNamespaces,
 283+ $wgArticleFeedbackRatingTypes;
303284 $vars['wgArticleFeedbackSMaxage'] = $wgArticleFeedbackSMaxage;
304285 $vars['wgArticleFeedbackCategories'] = $wgArticleFeedbackCategories;
305286 $vars['wgArticleFeedbackBlacklistCategories'] = $wgArticleFeedbackBlacklistCategories;
@@ -307,6 +288,7 @@
308289 $vars['wgArticleFeedbackOptions'] = $wgArticleFeedbackOptions;
309290 $vars['wgArticleFeedbackNamespaces'] = $wgArticleFeedbackNamespaces;
310291 $vars['wgArticleFeedbackWhatsThisPage'] = wfMsgForContent( 'articlefeedback-form-panel-explanation-link' );
 292+ $vars['wgArticleFeedbackRatingTypesFlipped'] = array_flip( $wgArticleFeedbackRatingTypes );
311293 return true;
312294 }
313295
@@ -323,4 +305,15 @@
324306 );
325307 return true;
326308 }
 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+ }
327320 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r1008081.18wmf1: MFT r100806catrope14:44, 26 October 2011
r100831Fix typo in r100806 that broke i18n for tale headers on Special:ArticleFeedbackcatrope17:46, 26 October 2011

Comments

#Comment by G.Hagedorn (talk | contribs)   21:02, 26 October 2011

applied to 1.18wmf1, please consider tagging for 1.18

Status & tagging log