r61025 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61024‎ | r61025 | r61026 >
Date:21:26, 13 January 2010
Author:aaron
Status:ok
Tags:
Comment:
* Update flag markers on diffs on AJAX review
* Hide some rating tag clutter in places
* Made wgFlaggedRevsParams JS param more useful
* Fixed broken one-rev case diff CSS
* Refactored prettyRatingBox()
* Replaced some <b> tags with CSS
* Cleaned up msg usage
* Some style cleanups
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticleView.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsXML.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/client/flaggedrevs.css (modified) (history)
  • /trunk/extensions/FlaggedRevs/client/review.js (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -286,7 +286,7 @@
287287 $wgAvailableRights[] = 'stablesettings';
288288
289289 # Bump this number every time you change flaggedrevs.css/flaggedrevs.js
290 -$wgFlaggedRevStyleVersion = 65;
 290+$wgFlaggedRevStyleVersion = 66;
291291
292292 $wgExtensionFunctions[] = 'efLoadFlaggedRevs';
293293
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -1318,11 +1318,11 @@
13191319 */
13201320 public static function getLevelTier( $flags ) {
13211321 if( self::isPristine( $flags ) )
1322 - return FR_PRISTINE;
 1322+ return FR_PRISTINE; // 2
13231323 elseif( self::isQuality( $flags ) )
1324 - return FR_QUALITY;
 1324+ return FR_QUALITY; // 1
13251325 elseif( self::isSighted( $flags ) )
1326 - return FR_SIGHTED;
 1326+ return FR_SIGHTED; // 0
13271327 else
13281328 return -1;
13291329 }
@@ -1608,7 +1608,10 @@
16091609 # Param to pass to JS function to know if tags are at quality level
16101610 $tagsJS = array();
16111611 foreach( self::$dimensions as $tag => $x ) {
1612 - $tagsJS[$tag] = self::$minQL[$tag];
 1612+ $tagsJS[$tag] = array();
 1613+ $tagsJS[$tag]['levels'] = count($x)-1;
 1614+ $tagsJS[$tag]['quality'] = self::$minQL[$tag];
 1615+ $tagsJS[$tag]['pristine'] = self::$minPL[$tag];
16131616 }
16141617 $params = array( 'tags' => (object)$tagsJS );
16151618 return (object)$params;
Index: trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php
@@ -297,9 +297,10 @@
298298 }
299299 list($approved,$status) = $form->submit();
300300 if( $status === true ) {
301 - return '<suc#>'.$form->showSuccess( $approved );
 301+ $tier = FlaggedRevs::getLevelTier($form->dims)+1; // shift to 0-3
 302+ return "<suc#><t#$tier>" . $form->showSuccess( $approved );
302303 } elseif( $approved && is_array($status) ) {
303 - return '<err#>'.$form->showSyncFailure( $status );
 304+ return '<err#>' . $form->showSyncFailure( $status );
304305 } elseif( $approved ) {
305306 return '<err#>' . wfMsg( 'revreview-revnotfound' );
306307 } else { // hmmm?
Index: trunk/extensions/FlaggedRevs/FlaggedRevsXML.php
@@ -179,17 +179,17 @@
180180 }
181181
182182 /**
183 - * @param FlaggedRevision $frev, the stable version
 183+ * @param FlaggedRevision $frev, the reviewed version
184184 * @param string $html, the short message HTML
185185 * @param int $revsSince, revisions since review
 186+ * @param string $type (stable/draft/oldstable)
186187 * @param bool $stable, are we referring to the stable revision?
187188 * @param bool $synced, does stable=current and this is one of them?
188 - * @param bool $old, is this an old stable version?
189189 * @returns string
190190 * Generates a review box using a table using FlaggedRevsXML::addTagRatings()
191191 */
192192 public static function prettyRatingBox(
193 - $frev, $shtml, $revsSince, $stable=true, $synced=false, $old=false
 193+ $frev, $shtml, $revsSince, $type='oldstable', $synced=false
194194 ) {
195195 global $wgLang;
196196 # Get quality level
@@ -206,17 +206,21 @@
207207 $color = 'flaggedrevs-color-1';
208208 }
209209 # Construct some tagging
210 - if( $synced ) {
211 - $msg = $quality ? 'revreview-quality-same' : 'revreview-basic-same';
 210+ if( $synced && ($type == 'stable' || $type == 'draft') ) {
 211+ $msg = $quality ?
 212+ 'revreview-quality-same' : 'revreview-basic-same';
212213 $html = wfMsgExt($msg, array('parseinline'), $frev->getRevId(), $time, $revsSince );
213 - } elseif( $old ) {
214 - $msg = $quality ? 'revreview-quality-old' : 'revreview-basic-old';
 214+ } elseif( $type == 'oldstable' ) {
 215+ $msg = $quality ?
 216+ 'revreview-quality-old' : 'revreview-basic-old';
215217 $html = wfMsgExt($msg, array('parseinline'), $frev->getRevId(), $time );
216218 } else {
217 - if( $stable ) {
218 - $msg = $quality ? 'revreview-quality' : 'revreview-basic';
219 - } else {
220 - $msg = $quality ? 'revreview-newest-quality' : 'revreview-newest-basic';
 219+ if( $type == 'stable' ) {
 220+ $msg = $quality ?
 221+ 'revreview-quality' : 'revreview-basic';
 222+ } else { // draft
 223+ $msg = $quality ?
 224+ 'revreview-newest-quality' : 'revreview-newest-basic';
221225 }
222226 # For searching: uses messages 'revreview-quality-i', 'revreview-basic-i',
223227 # 'revreview-newest-quality-i', 'revreview-newest-basic-i'
@@ -228,8 +232,8 @@
229233 $box .= "<tr style='white-space:nowrap;'><td>$shtml&nbsp;&nbsp;</td>";
230234 $box .= "<td style='text-align:right;'>" . self::ratingToggle() . "</td></tr>\n";
231235 $box .= "<tr><td id='mw-fr-revisionratings'>$html<br />";
232 - # Add ratings if there are any...
233 - if( $stable && !empty($flags) ) {
 236+ # Add any rating tags as needed...
 237+ if( $flags && ($type == 'stable' || $type == 'oldstable') ) {
234238 $box .= self::addTagRatings( $flags, true, $color );
235239 }
236240 $box .= "</td><td></td></tr></table>";
@@ -439,16 +443,6 @@
440444 : 'revreview-newest-basic';
441445 $msg .= ($revsSince == 0) ? '-i' : '';
442446 $tag = wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time, $revsSince );
443 - # Standard UI
444 - if( !FlaggedRevs::useSimpleUI() ) {
445 - # Hide clutter
446 - if( !empty($flags) ) {
447 - $tag .= " " . FlaggedRevsXML::ratingToggle();
448 - $tag .= '<span id="mw-fr-revisionratings" style="display:block;"><br />' .
449 - wfMsg('revreview-oldrating') . FlaggedRevsXML::addTagRatings( $flags ) .
450 - '</span>';
451 - }
452 - }
453447 return $tag;
454448 }
455449 }
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -64,7 +64,10 @@
6565 'reflagLegMsg' => wfMsgHtml('revreview-reflag'),
6666 'sendingMsg' => wfMsgHtml('revreview-submitting'),
6767 'actioncomplete' => wfMsgHtml('actioncomplete'),
68 - 'actionfailed' => wfMsgHtml('actionfailed')
 68+ 'actionfailed' => wfMsgHtml('actionfailed'),
 69+ 'draftRev' => wfMsgHtml('hist-draft'),
 70+ 'sightedRev' => wfMsgHtml('hist-stable'),
 71+ 'qualityRev' => wfMsgHtml('hist-quality'),
6972 );
7073 $globalVars['wgAjaxReview'] = $ajaxReview; // language for AJAX form
7174 }
Index: trunk/extensions/FlaggedRevs/client/flaggedrevs.css
@@ -206,6 +206,7 @@
207207
208208 .fr-diff-ratings {
209209 font-size: 90%;
 210+ font-weight: bold;
210211 line-height: 1em;
211212 width: 100%;
212213 }
Index: trunk/extensions/FlaggedRevs/client/review.js
@@ -45,7 +45,7 @@
4646 }
4747
4848 // Get quality level for this tag
49 - qualityLevel = wgFlaggedRevsParams.tags[tag];
 49+ qualityLevel = wgFlaggedRevsParams.tags[tag]['quality'];
5050
5151 if( selectedlevel < qualityLevel ) {
5252 quality = false; // not a quality review
@@ -189,22 +189,28 @@
190190 if( !wgAjaxReview.supported ) {
191191 return;
192192 }
193 - var response = request.responseText;
194 - if( (msg = response.substr(6)) ) {
195 - jsMsg( msg, 'review' ); // success notice
196 - window.scroll(0,0); // scroll up to notice
197 - tagBox = document.getElementById('mw-fr-revisiontag');
198 - if( tagBox ) tagBox.style.display = 'none'; // remove tag from draft
199 - }
200193 wgAjaxReview.inprogress = false;
201194 if( wgAjaxReview.timeoutID ) {
202195 window.clearTimeout(wgAjaxReview.timeoutID);
203196 }
 197+ var response = request.responseText;
 198+ var msg = response.substr(6); // remove <err#> or <suc#>
 199+ var regm = msg.match(/^<t#(\d)>/);
 200+ if( regm ) {
 201+ msg = msg.substr(5); // remove <t#x>
 202+ }
 203+ var tier = regm ? regm[1] : 0; // review tier
 204+ // Output any response message
 205+ if( msg.length ) {
 206+ jsMsg( msg, 'review' ); // success/failure notice
 207+ window.scroll(0,0); // scroll up to notice
 208+ }
204209 var rsubmit = document.getElementById("mw-fr-submitreview");
205210 var usubmit = document.getElementById("mw-fr-submitunreview");
206 - var binaryState = document.getElementById("mw-fr-reviewstate");
207211 var legend = document.getElementById("mw-fr-reviewformlegend");
208212 var diffNotice = document.getElementById("mw-fr-difftostable");
 213+ var diffRightTier = document.getElementById('mw-fr-diff-rtier');
 214+ var tagBox = document.getElementById('mw-fr-revisiontag');
209215 // On success...
210216 if( response.indexOf('<suc#>') == 0 ) {
211217 document.title = wgAjaxReview.actioncomplete;
@@ -228,6 +234,19 @@
229235 }
230236 // Hide "review this" box on diffs
231237 if( diffNotice ) diffNotice.style.display = 'none';
 238+ // Remove review tag from draft
 239+ if( tagBox ) tagBox.style.display = 'none';
 240+ // Set diff title messages
 241+ if( diffRightTier ) {
 242+ if( tier == 1 ) {
 243+ diffRightTier.innerHTML = '['+wgAjaxReview.sightedRev+']';
 244+ } else if( tier == 2 || tier == 3 ) {
 245+ diffRightTier.innerHTML = '['+wgAjaxReview.qualityRev+']';
 246+ } else {
 247+ diffRightTier.innerHTML = '['+wgAjaxReview.draftRev+']';
 248+ }
 249+ diffRightTier.className = 'flaggedrevs-color-'+tier;
 250+ }
232251 // On failure...
233252 } else {
234253 document.title = wgAjaxReview.actionfailed;
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php
@@ -284,8 +284,9 @@
285285 */
286286 protected function showUnreviewedPage( $tag, $prot ) {
287287 global $wgOut, $wgContLang;
288 - if( $wgOut->isPrintable() )
 288+ if( $wgOut->isPrintable() ) {
289289 return;
 290+ }
290291 // Simple icon-based UI
291292 if( FlaggedRevs::useSimpleUI() ) {
292293 // RTL langauges
@@ -293,13 +294,15 @@
294295 $msg = 'revreview-quick-none';
295296 $tag .= "{$prot}<span class='fr-icon-current plainlinks'></span>" .
296297 wfMsgExt($msg,array('parseinline'));
297 - $tag = "<div id='mw-fr-revisiontag' class='flaggedrevs_short{$rtl} plainlinks noprint'>" .
 298+ $css = 'flaggedrevs_short{$rtl} plainlinks noprint';
 299+ $tag = "<div id='mw-fr-revisiontag' class='$css'>" .
298300 "$tag</div>";
299301 $this->reviewNotice .= $tag;
300302 // Standard UI
301303 } else {
302304 $msg = 'revreview-noflagged';
303 - $tag = "<div id='mw-fr-revisiontag' class='flaggedrevs_notice plainlinks noprint'>" .
 305+ $css = 'flaggedrevs_notice plainlinks noprint';
 306+ $tag = "<div id='mw-fr-revisiontag' class='$css'>" .
304307 "{$prot}<span class='fr-icon-current plainlinks'></span>" .
305308 wfMsgExt($msg, array('parseinline')) . "</div>";
306309 $this->reviewNotice .= $tag;
@@ -372,31 +375,32 @@
373376 }
374377 $tooltip = wfMsgHtml($tooltip);
375378 $msgHTML = "{$prot}<span class='{$class}' title=\"{$tooltip}\"></span>$msgHTML";
376 - $tag .= FlaggedRevsXML::prettyRatingBox( $srev, $msgHTML, $revsSince,
377 - $synced, $synced, false );
 379+ $tag .= FlaggedRevsXML::prettyRatingBox( $srev, $msgHTML,
 380+ $revsSince, 'draft', $synced, false );
378381 // Standard UI
379382 } else {
380383 if( $synced ) {
381 - $msg = $quality ? 'revreview-quality-same' : 'revreview-basic-same';
382 - $class = $quality ? 'fr-icon-quality' : 'fr-icon-stable';
383 - $tooltip = $quality ? 'revreview-quality-title' : 'revreview-stable-title';
384 - $msgHTML = wfMsgExt( $msg, array('parseinline'), $srev->getRevId(),
385 - $time, $revsSince );
 384+ if( $quality ) {
 385+ $msg = 'revreview-quality-same';
 386+ $class = 'fr-icon-quality';
 387+ $tooltip = 'revreview-quality-title';
 388+ } else {
 389+ $msg = 'revreview-basic-same';
 390+ $class = 'fr-icon-stable';
 391+ $tooltip = 'revreview-stable-title';
 392+ }
 393+ $msgHTML = wfMsgExt( $msg, array('parseinline'),
 394+ $srev->getRevId(), $time, $revsSince );
386395 } else {
387 - $msg = $quality ? 'revreview-newest-quality' : 'revreview-newest-basic';
 396+ $msg = $quality
 397+ ? 'revreview-newest-quality'
 398+ : 'revreview-newest-basic';
388399 $msg .= ($revsSince == 0) ? '-i' : '';
389 - $msgHTML = wfMsgExt( $msg, array('parseinline'), $srev->getRevId(),
390 - $time, $revsSince );
 400+ $msgHTML = wfMsgExt( $msg, array('parseinline'),
 401+ $srev->getRevId(), $time, $revsSince );
391402 }
392403 $tooltip = wfMsgHtml($tooltip);
393404 $tag .= "{$prot}<span class='{$class}' title=\"{$tooltip}\"></span>" . $msgHTML;
394 - # Hide clutter
395 - if( !empty($flags) ) {
396 - $tag .= " " . FlaggedRevsXML::ratingToggle();
397 - $tag .= "<span id='mw-fr-revisionratings' style='display:block;'><br />" .
398 - wfMsgHtml('revreview-oldrating') .
399 - FlaggedRevsXML::addTagRatings( $flags ) . '</span>';
400 - }
401405 }
402406 }
403407 # Index the stable version only if it is the default
@@ -432,9 +436,12 @@
433437 # Construct some tagging for non-printable outputs. Note that the pending
434438 # notice has all this info already, so don't do this if we added that already.
435439 if( !$wgOut->isPrintable() ) {
436 - $class = $quality ? 'fr-icon-quality' : 'fr-icon-stable';
437 - $tooltip = $quality ? 'revreview-quality-title' : 'revreview-stable-title';
438 - $tooltip = wfMsgHtml($tooltip);
 440+ $class = $quality ?
 441+ 'fr-icon-quality' : 'fr-icon-stable';
 442+ $tooltip = $quality
 443+ ? 'revreview-quality-title'
 444+ : 'revreview-stable-title';
 445+ $tooltip = wfMsgHtml( $tooltip );
439446 // Simple icon-based UI
440447 if( FlaggedRevs::useSimpleUI() ) {
441448 $revsSince = FlaggedRevs::getRevCountSince( $this->article, $srev->getRevId() );
@@ -447,8 +454,8 @@
448455 $msgHTML = wfMsgExt( $msg, array('parseinline'), $frev->getRevId(), $time );
449456 }
450457 $msgHTML = "{$prot}<span class='{$class}' title=\"{$tooltip}\"></span>{$msgHTML}";
451 - $tag = FlaggedRevsXML::prettyRatingBox( $frev, $msgHTML, $revsSince,
452 - true /*stable*/, false /*synced*/, true /*old*/ );
 458+ $tag = FlaggedRevsXML::prettyRatingBox( $frev, $msgHTML,
 459+ $revsSince, 'oldstable', false /*synced*/ );
453460 // Standard UI
454461 } else {
455462 $msg = $quality ? 'revreview-quality-old' : 'revreview-basic-old';
@@ -526,7 +533,8 @@
527534 $srev->getRevId(), $revsSince );
528535 }
529536 $msgHTML = "{$prot}<span class='{$class}' title=\"{$tooltip}\"></span>{$msgHTML}";
530 - $tag = FlaggedRevsXML::prettyRatingBox( $srev, $msgHTML, $revsSince, true, $synced );
 537+ $tag = FlaggedRevsXML::prettyRatingBox( $srev, $msgHTML,
 538+ $revsSince, 'stable', $synced );
531539 // Standard UI
532540 } else {
533541 $msg = $quality ? 'revreview-quality' : 'revreview-basic';
@@ -582,11 +590,13 @@
583591 return false; // not viewing the draft
584592 }
585593 # Conditions are met to show diff...
586 - $leftNote = $quality ? 'revreview-quality-rev' : 'revreview-sighted-rev';
 594+ $leftNote = $quality ? 'hist-quality' : 'hist-stable';
587595 $rClass = FlaggedRevsXML::getQualityColor( false );
588596 $lClass = FlaggedRevsXML::getQualityColor( (int)$quality );
589 - $rightNote = "<span class='$rClass'>[".wfMsgHtml('revreview-draft-rev')."]</span>";
590 - $leftNote = "<span class='$lClass'>[".wfMsgHtml($leftNote)."]</span>";
 597+ $rightNote = "<span id='mw-fr-diff-rtier' class='$rClass'>[" .
 598+ wfMsgHtml('hist-draft') . "]</span>";
 599+ $leftNote = "<span id='mw-fr-diff-ltier' class='$lClass'>[" .
 600+ wfMsgHtml($leftNote)."]</span>";
591601 # Fetch the stable and draft revision text
592602 $oText = $srev->getRevText();
593603 if( $oText === false )
@@ -761,16 +771,17 @@
762772 }
763773
764774 # Conditions are met to show diff...
765 - $leftNote = $quality
766 - ? 'revreview-quality-rev'
767 - : 'revreview-sighted-rev';
 775+ $leftNote = $quality ? 'hist-quality' : 'hist-stable';
768776 $rClass = FlaggedRevsXML::getQualityColor( false );
769777 $lClass = FlaggedRevsXML::getQualityColor( (int)$quality );
770 - $rightNote = "<span class='$rClass'>[".wfMsgHtml('revreview-draft-rev')."]</span>";
771 - $leftNote = "<span class='$lClass'>[".wfMsgHtml($leftNote)."]</span>";
 778+ $rightNote = "<span id='mw-fr-diff-rtier' class='$rClass'>[".
 779+ wfMsgHtml('hist-draft')."]</span>";
 780+ $leftNote = "<span id='mw-fr-diff-ltier' class='$lClass'>[".
 781+ wfMsgHtml($leftNote)."]</span>";
772782 $text = $frev->getRevText();
773783 # Are we editing a section?
774 - $section = ($editPage->section == "") ? false : intval($editPage->section);
 784+ $section = ($editPage->section == "") ?
 785+ false : intval($editPage->section);
775786 if( $section !== false ) {
776787 $text = $this->article->getSection( $text, $section );
777788 }
@@ -1184,7 +1195,8 @@
11851196 $msg = 'hist-draft';
11861197 }
11871198 $wgOut->addHTML( "<td width='50%' align='center'>" );
1188 - $wgOut->addHTML( "<span class='$class'><b>[" . wfMsgHtml( $msg ) . "]</b></span>" );
 1199+ $wgOut->addHTML( "<span id='mw-fr-diff-ltier' class='$class'>[" .
 1200+ wfMsgHtml( $msg ) . "]</span>" );
11891201
11901202 $class = FlaggedRevsXML::getQualityColor( $newRevQ );
11911203 if( $newRevQ !== false ) {
@@ -1193,7 +1205,8 @@
11941206 $msg = 'hist-draft';
11951207 }
11961208 $wgOut->addHTML( "</td><td width='50%' align='center'>" );
1197 - $wgOut->addHTML( "<span class='$class'><b>[" . wfMsgHtml( $msg ) . "]</b></span>" );
 1209+ $wgOut->addHTML( "<span id='mw-fr-diff-rtier' class='$class'>[" .
 1210+ wfMsgHtml( $msg ) . "]</span>" );
11981211
11991212 $wgOut->addHTML( '</td></tr></table>' );
12001213 # New page "diffs" - just one rev
@@ -1203,11 +1216,12 @@
12041217 } else {
12051218 $msg = 'hist-draft';
12061219 }
 1220+ $class = FlaggedRevsXML::getQualityColor( $newRevQ );
12071221 $wgOut->addHTML(
12081222 "<table class='fr-diff-ratings'>" .
1209 - "<tr><td class='fr-$msg' align='center'>" .
1210 - '<b>[' . wfMsgHtml( $msg ) . ']</b>' .
1211 - '</td></tr></table>'
 1223+ "<tr><td><span id='mw-fr-diff-rtier' class='$class' align='center'>" .
 1224+ '[' . wfMsgHtml( $msg ) . ']' .
 1225+ '</span></td></tr></table>'
12121226 );
12131227 }
12141228 return true;

Status & tagging log