r84210 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84209‎ | r84210 | r84211 >
Date:22:26, 17 March 2011
Author:catrope
Status:ok
Tags:
Comment:
1.17wmf1: MFT r84059, r84208
Modified paths:
  • /branches/wmf/1.17wmf1/extensions/ArticleFeedback/ArticleFeedback.hooks.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/ArticleFeedback/ArticleFeedback.i18n.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/ArticleFeedback/ArticleFeedback.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/ArticleFeedback/api/ApiQueryArticleFeedback.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/ArticleFeedback/modules/jquery.articleFeedback/images.psd (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/ArticleFeedback/modules/jquery.articleFeedback/images/alert.png (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/ArticleFeedback/modules/jquery.articleFeedback/images/star-full-expired.png (added) (history)
  • /branches/wmf/1.17wmf1/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.css (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/extensions/ArticleFeedback/ArticleFeedback.hooks.php
@@ -67,6 +67,8 @@
6868 'articlefeedback-form-panel-expertise-other',
6969 'articlefeedback-form-panel-submit',
7070 'articlefeedback-form-panel-success',
 71+ 'articlefeedback-form-panel-expiry-title',
 72+ 'articlefeedback-form-panel-expiry-message',
7173 'articlefeedback-report-switch-label',
7274 'articlefeedback-report-panel-title',
7375 'articlefeedback-report-panel-description',
Index: branches/wmf/1.17wmf1/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js
@@ -33,6 +33,10 @@
3434 <button class="articleFeedback-submit articleFeedback-visibleWith-form" type="submit" disabled><html:msg key="form-panel-submit" /></button>\
3535 <div class="articleFeedback-success articleFeedback-visibleWith-form"><span><html:msg key="form-panel-success" /></span></div>\
3636 <div style="clear:both;"></div>\
 37+ <div class="articleFeedback-expiry articleFeedback-visibleWith-form">\
 38+ <div class="articleFeedback-expiry-title"><html:msg key="form-panel-expiry-title" /></div>\
 39+ <div class="articleFeedback-expiry-message"><html:msg key="form-panel-expiry-message" /></div>\
 40+ </div>\
3741 </div>\
3842 <div class="articleFeedback-error"><div class="articleFeedback-error-message"><html:msg key="error" /></div></div>\
3943 <div class="articleFeedback-pitches"></div>\
@@ -212,6 +216,7 @@
213217 .show();
214218 }
215219 }
 220+ var expired = false;
216221 context.$ui.find( '.articleFeedback-rating' ).each( function() {
217222 var ratingData;
218223 // Try to get data provided for this rating
@@ -219,13 +224,20 @@
220225 data.query.articlefeedback.length &&
221226 typeof data.query.articlefeedback[0].ratings !== 'undefined'
222227 ) {
223 - var ratingsData = data.query.articlefeedback[0].ratings;
224 - var id = context.options.ratings[$(this).attr( 'rel' )].id;
225 - for ( var i = 0; i < ratingsData.length; i++ ) {
226 - if ( ratingsData[i].ratingid == id ) {
227 - ratingData = ratingsData[i];
 228+ if ( 'status' in data.query.articlefeedback[0] ) {
 229+ if ( data.query.articlefeedback[0].status == 'expired' ) {
 230+ expired = true;
228231 }
229232 }
 233+ if ( 'ratings' in data.query.articlefeedback[0] ) {
 234+ var ratingsData = data.query.articlefeedback[0].ratings;
 235+ var id = context.options.ratings[$(this).attr( 'rel' )].id;
 236+ for ( var i = 0; i < ratingsData.length; i++ ) {
 237+ if ( ratingsData[i].ratingid == id ) {
 238+ ratingData = ratingsData[i];
 239+ }
 240+ }
 241+ }
230242 }
231243 if ( typeof ratingData === 'undefined' || ratingData.total == 0 ) {
232244 // Setup in "no ratings" mode
@@ -264,6 +276,17 @@
265277 }
266278 $.articleFeedback.fn.updateRating.call( $(this) );
267279 } );
 280+ if ( expired ) {
 281+ context.$ui
 282+ .addClass( 'articleFeedback-expired' )
 283+ .find( '.articleFeedback-expiry' )
 284+ .slideDown( 'fast' );
 285+ } else {
 286+ context.$ui
 287+ .removeClass( 'articleFeedback-expired' )
 288+ .find( '.articleFeedback-expiry' )
 289+ .slideUp( 'fast' );
 290+ }
268291 // If being called just after a submit, we need to un-new the rating controls
269292 context.$ui.find( '.articleFeedback-rating-new' )
270293 .removeClass( 'articleFeedback-rating-new' );
@@ -504,6 +527,13 @@
505528 )
506529 .mousedown( function() {
507530 $.articleFeedback.fn.enableSubmission.call( context, true );
 531+ if ( context.$ui.hasClass( 'articleFeedback-expired' ) ) {
 532+ // Changing one means the rest will get submitted too
 533+ context.$ui
 534+ .removeClass( 'articleFeedback-expired' )
 535+ .find( '.articleFeedback-rating' )
 536+ .addClass( 'articleFeedback-rating-new' );
 537+ }
508538 context.$ui
509539 .find( '.articleFeedback-expertise' )
510540 .each( function() {
Index: branches/wmf/1.17wmf1/extensions/ArticleFeedback/modules/jquery.articleFeedback/images/alert.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Index: branches/wmf/1.17wmf1/extensions/ArticleFeedback/modules/jquery.articleFeedback/images/star-full-expired.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: branches/wmf/1.17wmf1/extensions/ArticleFeedback/modules/jquery.articleFeedback/images/star-full-expired.png
___________________________________________________________________
Added: svn:mime-type
511541 + application/octet-stream
Index: branches/wmf/1.17wmf1/extensions/ArticleFeedback/modules/jquery.articleFeedback/images.psd
Cannot display: file marked as a binary type.
svn:mime-type = image/psd
Index: branches/wmf/1.17wmf1/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.css
@@ -202,6 +202,11 @@
203203 background-image: url(images/star-full.png);
204204 }
205205
 206+.articleFeedback-expired .articleFeedback-rating-labels label.articleFeedback-rating-label-full {
 207+ /* @embed */
 208+ background-image: url(images/star-full-expired.png);
 209+}
 210+
206211 .articleFeedback-rating-new .articleFeedback-rating-labels label.articleFeedback-rating-label-full,
207212 .articleFeedback-rating .articleFeedback-rating-labels label.articleFeedback-rating-label-hover-tail {
208213 /* @embed */
@@ -319,6 +324,7 @@
320325 .articleFeedback-success {
321326 float: right;
322327 }
 328+
323329 .articleFeedback-success span {
324330 display: none;
325331 /* @embed */
@@ -333,3 +339,22 @@
334340 font-size: 0.8em;
335341 line-height: 3.6em;
336342 }
 343+
 344+.articleFeedback-expiry {
 345+ display: none;
 346+ border: solid 1px orange;
 347+ background-color: white;
 348+ padding: 0.5em;
 349+}
 350+.articleFeedback-expiry-title {
 351+ font-size: 1.2em;
 352+ padding-left: 28px;
 353+ /* @embed */
 354+ background-image: url(images/alert.png);
 355+ background-repeat: no-repeat;
 356+ background-position: center left;
 357+}
 358+.articleFeedback-expiry-message {
 359+ padding-left: 28px;
 360+ color: #777777;
 361+}
Index: branches/wmf/1.17wmf1/extensions/ArticleFeedback/api/ApiQueryArticleFeedback.php
@@ -103,11 +103,12 @@
104104 $ratings[$pageId]['ratings'][] = $thisRow;
105105 }
106106
107 - //Only can actually be "stale" if the user has rated the article before
 107+ // Ratings can only be expired if the user has rated before
 108+ $ratings[$params['pageid']]['status'] = 'current';
108109 if ( $params['userrating'] && $userRatedArticle ) {
109110 $dbr = wfGetDb( DB_SLAVE );
110111
111 - global $wgArticleFeedbackStaleCount;
 112+ global $wgArticleFeedbackRatingLifetime;
112113
113114 $res = $dbr->select(
114115 'revision',
@@ -120,12 +121,12 @@
121122 array ( 'LIMIT', $wgArticleFeedbackStaleCount + 1 )
122123 );
123124
124 - if ( $res && $dbr->numRows( $res ) > $wgArticleFeedbackStaleCount ) {
125 - //it's stale!
126 - $ratings[$params['pageid']]['stale'] = '';
 125+ if ( $res && $dbr->numRows( $res ) > $wgArticleFeedbackRatingLifetime ) {
 126+ // Expired status
 127+ $ratings[$params['pageid']]['status'] = 'expired';
127128 }
128129 }
129 -
 130+
130131 foreach ( $ratings as $rat ) {
131132 $result->setIndexedTagName( $rat['ratings'], 'r' );
132133 $result->addValue( array( 'query', $this->getModuleName() ), null, $rat );
Property changes on: branches/wmf/1.17wmf1/extensions/ArticleFeedback/api/ApiQueryArticleFeedback.php
___________________________________________________________________
Modified: svn:mergeinfo
133134 Merged /trunk/extensions/ArticleFeedback/api/ApiQueryArticleFeedback.php:r84059,84208
Index: branches/wmf/1.17wmf1/extensions/ArticleFeedback/ArticleFeedback.i18n.php
@@ -37,6 +37,8 @@
3838 'articlefeedback-form-panel-expertise-other' => 'The source of my knowledge is not listed here',
3939 'articlefeedback-form-panel-submit' => 'Submit ratings',
4040 'articlefeedback-form-panel-success' => 'Saved successfully',
 41+ 'articlefeedback-form-panel-expiry-title' => 'Your ratings have expired',
 42+ 'articlefeedback-form-panel-expiry-message' => 'Please reevaluate this page and submit new ratings.',
4143 'articlefeedback-report-switch-label' => 'View page ratings',
4244 'articlefeedback-report-panel-title' => 'Page ratings',
4345 'articlefeedback-report-panel-description' => 'Current average ratings.',
Index: branches/wmf/1.17wmf1/extensions/ArticleFeedback/ArticleFeedback.php
@@ -15,9 +15,8 @@
1616
1717 /* Configuration */
1818
19 -// If the number of page revisions (since users last rating) is greater than this then consider the
20 -// last rating "stale"
21 -$wgArticleFeedbackStaleCount = 5;
 19+// Number of revisions to keep a rating alive for
 20+$wgArticleFeedbackRatingLifetime = 30;
2221
2322 // Array of the "ratings" id's to store. Allows it to be a bit more dynamic
2423 $wgArticleFeedbackRatings = array( 1, 2, 3, 4 );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84059Step 1 of 2 for implementing expirations....tparscal22:20, 15 March 2011
r84208Switched from using an expired = true in the API result to status = expired |...tparscal22:22, 17 March 2011

Status & tagging log