r56014 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56013‎ | r56014 | r56015 >
Date:04:30, 8 September 2009
Author:aaron
Status:ok
Tags:
Comment:
bug 20058 Add option for editors in preferences to always show diff to latest flagged revision
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/language/FlaggedRevs.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -541,6 +541,7 @@
542542 $wgDefaultUserOptions['flaggedrevssimpleui'] = (int)$wgSimpleFlaggedRevsUI;
543543 $wgDefaultUserOptions['flaggedrevsstable'] = false;
544544 $wgDefaultUserOptions['flaggedrevseditdiffs'] = true;
 545+$wgDefaultUserOptions['flaggedrevsviewdiffs'] = false;
545546
546547 # Cache update
547548 $wgSpecialPageCacheUpdates[] = 'efFlaggedRevsUnreviewedPagesUpdate';
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -377,7 +377,11 @@
378378 $revsSince = FlaggedRevs::getRevCountSince( $this->parent, $srev->getRevId() );
379379 # Get stable version sync status
380380 $synced = FlaggedRevs::stableVersionIsSynced( $srev, $this->parent );
381 - if( $synced ) $this->getReviewNotes( $srev ); // Still the same
 381+ if( $synced ) {
 382+ $this->getReviewNotes( $srev ); // Still the same
 383+ } else {
 384+ $this->maybeShowTopDiff( $srev, $quality ); // user may want diff (via prefs)
 385+ }
382386 $pending = '';
383387 # Give notice to newer users if an unreviewed edit was completed...
384388 if( !$synced && $wgRequest->getVal('shownotice') && !$wgUser->isAllowed('review') ) {
@@ -559,6 +563,61 @@
560564 }
561565
562566 /**
 567+ * @param FlaggedRevision $srev, stable version
 568+ * @param bool $quality, revision is quality
 569+ * Parser cache control deferred to caller
 570+ */
 571+ protected function maybeShowTopDiff( $srev, $quality ) {
 572+ global $wgUser, $wgOut, $wgMemc;
 573+ if( !$wgUser->getBoolOption('flaggedrevsviewdiffs') )
 574+ return false; // nothing to do here
 575+ if( !$wgUser->isAllowed('review') )
 576+ return false; // does not apply to this user
 577+ # Diff should only show for the draft
 578+ $oldid = $this->parent->getOldIDFromRequest();
 579+ if( $oldid && $oldid != $this->parent->getLatest() ) {
 580+ return false; // not viewing the draft
 581+ }
 582+ # Conditions are met to show diff...
 583+ wfLoadExtensionMessages( 'FlaggedRevs' ); // load required messages
 584+ $leftNote = $quality ? 'revreview-quality-title' : 'revreview-stable-title';
 585+ $rClass = FlaggedRevsXML::getQualityColor( false );
 586+ $lClass = FlaggedRevsXML::getQualityColor( (int)$quality );
 587+ $rightNote = "<span class='$rClass'>[".wfMsgHtml('revreview-draft-title')."]</span>";
 588+ $leftNote = "<span class='$lClass'>[".wfMsgHtml($leftNote)."]</span>";
 589+ # Fetch the stable and draft revision text
 590+ $oText = $srev->getRevText();
 591+ if( $oText === false )
 592+ return false; // deleted revision or something?
 593+ $nText = $this->parent->getContent();
 594+ if( $nText === false )
 595+ return false; // deleted revision or something?
 596+ # Build diff at the top of the page
 597+ if( strcmp($oText,$nText) !== 0 ) {
 598+ $diffEngine = new DifferenceEngine();
 599+ $diffEngine->showDiffStyle();
 600+ $wgOut->addHTML(
 601+ "<div>" .
 602+ "<table border='0' width='98%' cellpadding='0' cellspacing='4' class='diff'>" .
 603+ "<col class='diff-marker' />" .
 604+ "<col class='diff-content' />" .
 605+ "<col class='diff-marker' />" .
 606+ "<col class='diff-content' />" .
 607+ "<tr>" .
 608+ "<td colspan='2' width='50%' align='center' class='diff-otitle'><b>" .
 609+ $leftNote . "</b></td>" .
 610+ "<td colspan='2' width='50%' align='center' class='diff-ntitle'><b>" .
 611+ $rightNote . "</b></td>" .
 612+ "</tr>" .
 613+ $diffEngine->generateDiffBody( $oText, $nText ) .
 614+ "</table>" .
 615+ "</div>\n"
 616+ );
 617+ }
 618+ return true;
 619+ }
 620+
 621+ /**
563622 * Get the normal and display files for the underlying ImagePage.
564623 * If the a stable version needs to be displayed, this will set $normalFile
565624 * to the current version, and $displayFile to the desired version.
@@ -740,7 +799,8 @@
741800 "</tr>" .
742801 $diffEngine->generateDiffBody( $text, $editPage->textbox1 ) .
743802 "</table>" .
744 - "</div>\n" );
 803+ "</div>\n"
 804+ );
745805 }
746806 }
747807 }
Index: trunk/extensions/FlaggedRevs/language/FlaggedRevs.i18n.php
@@ -28,6 +28,7 @@
2929 'flaggedrevs-prefs-stable' => 'Always show the stable version of content pages by default (if there is one)',
3030 'flaggedrevs-prefs-watch' => 'Add pages I review to my watchlist',
3131 'flaggedrevs-prefs-editdiffs' => 'Show diff to stable when editing pages',
 32+ 'flaggedrevs-prefs-viewdiffs' => 'Show diff to stable when viewing page drafts',
3233 'group-editor' => 'Editors',
3334 'group-editor-member' => 'editor',
3435 'group-reviewer' => 'Reviewers',
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -1312,13 +1312,6 @@
13131313
13141314 /** Add user preferences */
13151315 public static function onGetPreferences( $user, &$preferences ) {
1316 - // Default versions...
1317 - $preferences['flaggedrevsstable'] =
1318 - array(
1319 - 'type' => 'toggle',
1320 - 'section' => 'flaggedrevs',
1321 - 'label-message' => 'flaggedrevs-prefs-stable',
1322 - );
13231316 // Box or bar UI
13241317 $preferences['flaggedrevssimpleui'] =
13251318 array(
@@ -1330,23 +1323,36 @@
13311324 wfMsg( 'flaggedrevs-pref-UI-1' ) => 1,
13321325 ),
13331326 );
1334 - // Watching reviewed pages
1335 - if ($user->isAllowed( 'review' ) ) {
 1327+ // Default versions...
 1328+ $preferences['flaggedrevsstable'] =
 1329+ array(
 1330+ 'type' => 'toggle',
 1331+ 'section' => 'flaggedrevs',
 1332+ 'label-message' => 'flaggedrevs-prefs-stable',
 1333+ );
 1334+ // Review-related rights...
 1335+ if( $user->isAllowed( 'review' ) ) {
 1336+ // Watching reviewed pages
13361337 $preferences['flaggedrevswatch'] =
13371338 array(
13381339 'type' => 'toggle',
13391340 'section' => 'watchlist/advancedwatchlist',
13401341 'label-message' => 'flaggedrevs-prefs-watch',
13411342 );
1342 - }
1343 - // Diff-to-stable on edit
1344 - if ($user->isAllowed( 'review' ) ) {
 1343+ // Diff-to-stable on edit
13451344 $preferences['flaggedrevseditdiffs'] =
13461345 array(
13471346 'type' => 'toggle',
13481347 'section' => 'flaggedrevs',
13491348 'label-message' => 'flaggedrevs-prefs-editdiffs',
13501349 );
 1350+ // Diff-to-stable on draft view
 1351+ $preferences['flaggedrevsviewdiffs'] =
 1352+ array(
 1353+ 'type' => 'toggle',
 1354+ 'section' => 'flaggedrevs',
 1355+ 'label-message' => 'flaggedrevs-prefs-viewdiffs',
 1356+ );
13511357 }
13521358 return true;
13531359 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r56015Tweak form position and tag defaults for r56014aaron04:47, 8 September 2009

Status & tagging log