Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -541,6 +541,7 @@ |
542 | 542 | $wgDefaultUserOptions['flaggedrevssimpleui'] = (int)$wgSimpleFlaggedRevsUI; |
543 | 543 | $wgDefaultUserOptions['flaggedrevsstable'] = false; |
544 | 544 | $wgDefaultUserOptions['flaggedrevseditdiffs'] = true; |
| 545 | +$wgDefaultUserOptions['flaggedrevsviewdiffs'] = false; |
545 | 546 | |
546 | 547 | # Cache update |
547 | 548 | $wgSpecialPageCacheUpdates[] = 'efFlaggedRevsUnreviewedPagesUpdate'; |
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -377,7 +377,11 @@ |
378 | 378 | $revsSince = FlaggedRevs::getRevCountSince( $this->parent, $srev->getRevId() ); |
379 | 379 | # Get stable version sync status |
380 | 380 | $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 | + } |
382 | 386 | $pending = ''; |
383 | 387 | # Give notice to newer users if an unreviewed edit was completed... |
384 | 388 | if( !$synced && $wgRequest->getVal('shownotice') && !$wgUser->isAllowed('review') ) { |
— | — | @@ -559,6 +563,61 @@ |
560 | 564 | } |
561 | 565 | |
562 | 566 | /** |
| 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 | + /** |
563 | 622 | * Get the normal and display files for the underlying ImagePage. |
564 | 623 | * If the a stable version needs to be displayed, this will set $normalFile |
565 | 624 | * to the current version, and $displayFile to the desired version. |
— | — | @@ -740,7 +799,8 @@ |
741 | 800 | "</tr>" . |
742 | 801 | $diffEngine->generateDiffBody( $text, $editPage->textbox1 ) . |
743 | 802 | "</table>" . |
744 | | - "</div>\n" ); |
| 803 | + "</div>\n" |
| 804 | + ); |
745 | 805 | } |
746 | 806 | } |
747 | 807 | } |
Index: trunk/extensions/FlaggedRevs/language/FlaggedRevs.i18n.php |
— | — | @@ -28,6 +28,7 @@ |
29 | 29 | 'flaggedrevs-prefs-stable' => 'Always show the stable version of content pages by default (if there is one)', |
30 | 30 | 'flaggedrevs-prefs-watch' => 'Add pages I review to my watchlist', |
31 | 31 | 'flaggedrevs-prefs-editdiffs' => 'Show diff to stable when editing pages', |
| 32 | + 'flaggedrevs-prefs-viewdiffs' => 'Show diff to stable when viewing page drafts', |
32 | 33 | 'group-editor' => 'Editors', |
33 | 34 | 'group-editor-member' => 'editor', |
34 | 35 | 'group-reviewer' => 'Reviewers', |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -1312,13 +1312,6 @@ |
1313 | 1313 | |
1314 | 1314 | /** Add user preferences */ |
1315 | 1315 | 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 | | - ); |
1323 | 1316 | // Box or bar UI |
1324 | 1317 | $preferences['flaggedrevssimpleui'] = |
1325 | 1318 | array( |
— | — | @@ -1330,23 +1323,36 @@ |
1331 | 1324 | wfMsg( 'flaggedrevs-pref-UI-1' ) => 1, |
1332 | 1325 | ), |
1333 | 1326 | ); |
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 |
1336 | 1337 | $preferences['flaggedrevswatch'] = |
1337 | 1338 | array( |
1338 | 1339 | 'type' => 'toggle', |
1339 | 1340 | 'section' => 'watchlist/advancedwatchlist', |
1340 | 1341 | 'label-message' => 'flaggedrevs-prefs-watch', |
1341 | 1342 | ); |
1342 | | - } |
1343 | | - // Diff-to-stable on edit |
1344 | | - if ($user->isAllowed( 'review' ) ) { |
| 1343 | + // Diff-to-stable on edit |
1345 | 1344 | $preferences['flaggedrevseditdiffs'] = |
1346 | 1345 | array( |
1347 | 1346 | 'type' => 'toggle', |
1348 | 1347 | 'section' => 'flaggedrevs', |
1349 | 1348 | 'label-message' => 'flaggedrevs-prefs-editdiffs', |
1350 | 1349 | ); |
| 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 | + ); |
1351 | 1357 | } |
1352 | 1358 | return true; |
1353 | 1359 | } |