r76958 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76957‎ | r76958 | r76959 >
Date:20:55, 18 November 2010
Author:aaron
Status:deferred
Tags:
Comment:
* Made "pending version" notice show only for the simpler UI since it's redundant otherwise.
* Minor setReviewNotes() cleanups.
* maybeShowTopDiff() changes:
** Removed nonsense isAllowed() check.
** Added html to $this->reviewNotice instead of $wgOut.
** Use getDiffBody() to avoid code duplication. Also better for cache and line number localization.
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticleView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php
@@ -388,7 +388,10 @@
389389 if ( $synced ) {
390390 $this->setReviewNotes( $srev ); // Still the same
391391 } else {
392 - $this->setPendingNotice( $srev );
 392+ # Make sure there is always a notice bar when viewing the draft
 393+ if ( $this->useSimpleUI() ) { // already one for detailed UI
 394+ $this->setPendingNotice( $srev );
 395+ }
393396 $this->maybeShowTopDiff( $srev, $quality ); // user may want diff (via prefs)
394397 }
395398 # If they are synced, do special styling
@@ -677,12 +680,10 @@
678681 * @returns bool, diff added to output
679682 */
680683 protected function maybeShowTopDiff( FlaggedRevision $srev, $quality ) {
681 - global $wgUser, $wgOut;
 684+ global $wgUser;
682685 $this->load();
683686 if ( !$wgUser->getBoolOption( 'flaggedrevsviewdiffs' ) ) {
684687 return false; // nothing to do here
685 - } elseif ( !$wgUser->isAllowed( 'review' ) ) {
686 - return false; // does not apply to this user
687688 }
688689 # Diff should only show for the draft
689690 $oldid = $this->article->getOldIDFromRequest();
@@ -694,35 +695,24 @@
695696 if ( !$revsSince ) {
696697 return false; // no pending changes
697698 }
698 - # Conditions are met to show diff...
699 - # Left side of diff...
 699+ $title = $this->article->getTitle(); // convenience
 700+ # Review status of left diff revision...
700701 $leftNote = $quality
701702 ? 'revreview-hist-quality'
702703 : 'revreview-hist-basic';
703704 $lClass = FlaggedRevsXML::getQualityColor( (int)$quality );
704705 $leftNote = "<span class='$lClass'>[" . wfMsgHtml( $leftNote ) . "]</span>";
705 - # Right side of diff...
 706+ # Review status of right diff revision...
706707 $rClass = FlaggedRevsXML::getQualityColor( false );
707708 $rightNote = "<span class='$rClass'>[" .
708709 wfMsgHtml( 'revreview-hist-pending' ) . "]</span>";
709 - # Fetch the stable and draft revision text
710 - $oText = $srev->getRevText();
711 - if ( $oText === false ) {
712 - return false; // deleted revision or something?
713 - }
714 - $nText = $this->article->getContent();
715 - if ( $nText === false ) {
716 - return false; // deleted revision or something?
717 - }
718 - # Build diff at the top of the page
719 - if ( strcmp( $oText, $nText ) !== 0 ) {
720 - $diffEngine = new DifferenceEngine( $this->article->getTitle() );
721 - $diffEngine->showDiffStyle();
722 - $diffBody = $diffEngine->generateDiffBody( $oText, $nText );
 710+ # Get the actual body of the diff...
 711+ $diffEngine = new DifferenceEngine( $title, $srev->getRevId(), $latest );
 712+ $diffBody = $diffEngine->getDiffBody();
 713+ if ( strlen( $diffBody ) > 0 ) {
723714 $nEdits = $revsSince - 1; // full diff-to-stable, no need for query
724715 if ( $nEdits ) {
725 - $nUsers = $this->article->getTitle()->countAuthorsBetween(
726 - $this->article->getStable(), $latest, 101 );
 716+ $nUsers = $title->countAuthorsBetween( $srev->getRevId(), $latest, 101 );
727717 $multiNotice = DifferenceEngine::intermediateEditsMsg( $nEdits, $nUsers, 100 );
728718 } else {
729719 $multiNotice = '';
@@ -740,7 +730,8 @@
741731 $html .= '<tr><td>' . $item . '</td></tr>';
742732 }
743733 $html .= '</table>';
744 - $wgOut->addHtml( $html );
 734+ $this->reviewNotice .= $html;
 735+ $diffEngine->showDiffStyle(); // add CSS
745736 $this->isDiffFromStable = true; // alter default review form tags
746737 return true;
747738 }
@@ -921,7 +912,6 @@
922913 }
923914 if ( $text !== false && strcmp( $text, $editPage->textbox1 ) !== 0 ) {
924915 $diffEngine = new DifferenceEngine( $this->article->getTitle() );
925 - $diffEngine->showDiffStyle();
926916 $diffBody = $diffEngine->generateDiffBody( $text, $editPage->textbox1 );
927917 $diffHtml =
928918 wfMsgExt( 'review-edit-diff', 'parseinline' ) . ' ' .
@@ -930,6 +920,7 @@
931921 self::getFormattedDiff( $diffBody, '', $leftNote, $rightNote ) .
932922 "</div>\n";
933923 $items[] = $diffHtml;
 924+ $diffEngine->showDiffStyle(); // add CSS
934925 }
935926 }
936927 # Output items
@@ -1259,24 +1250,24 @@
12601251 * @param FlaggedRevision $frev
12611252 * @return void
12621253 */
1263 - public function setReviewNotes( $frev ) {
 1254+ public function setReviewNotes( FlaggedRevision $frev ) {
12641255 global $wgUser;
12651256 $this->load();
1266 - if ( $frev && FlaggedRevs::allowComments() && $frev->getComment() != '' ) {
 1257+ if ( FlaggedRevs::allowComments() && $frev->getComment() != '' ) {
12671258 $this->reviewNotes = "<br /><div class='flaggedrevs_notes plainlinks'>";
1268 - $this->reviewNotes .= wfMsgExt( 'revreview-note', array( 'parseinline' ),
 1259+ $this->reviewNotes .= wfMsgExt( 'revreview-note', 'parseinline',
12691260 User::whoIs( $frev->getUser() ) );
12701261 $this->reviewNotes .= '<br /><i>' .
12711262 $wgUser->getSkin()->formatComment( $frev->getComment() ) . '</i></div>';
12721263 }
12731264 }
1274 -
 1265+
12751266 /**
12761267 * Adds a notice saying that this revision is pending review
12771268 * @param FlaggedRevision $frev
12781269 * @return void
12791270 */
1280 - public function setPendingNotice( $frev ) {
 1271+ public function setPendingNotice( FlaggedRevision $frev ) {
12811272 global $wgLang;
12821273 $this->load();
12831274 $time = $wgLang->date( $frev->getTimestamp(), true );

Status & tagging log