Index: trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php |
— | — | @@ -289,6 +289,7 @@ |
290 | 290 | return 'review_cannot_reject'; // not really a use case |
291 | 291 | } |
292 | 292 | $article = new Article( $this->page ); |
| 293 | + # Get text with changes after $oldRev up to and including $newRev removed |
293 | 294 | $new_text = $article->getUndoText( $newRev, $oldRev ); |
294 | 295 | if ( $new_text === false ) { |
295 | 296 | return 'review_cannot_undo'; |
Index: trunk/extensions/FlaggedRevs/presentation/RevisionReviewFormGUI.php |
— | — | @@ -6,7 +6,8 @@ |
7 | 7 | */ |
8 | 8 | class RevisionReviewFormGUI { |
9 | 9 | protected $user, $article, $rev; |
10 | | - protected $refId = 0, $topNotice = ''; |
| 10 | + protected $refRev = null; |
| 11 | + protected $topNotice = ''; |
11 | 12 | protected $templateIDs = null, $imageSHA1Keys = null; |
12 | 13 | |
13 | 14 | /** |
— | — | @@ -22,13 +23,13 @@ |
23 | 24 | } |
24 | 25 | |
25 | 26 | /* |
26 | | - * If $refId > 0: |
27 | | - * (a) Show "reject" button |
28 | | - * (b) default the rating tags to those of $rev if it was flagged |
29 | | - * @param int $refId Left side version ID for diffs, $rev is the right rev |
| 27 | + * Call this only when the form is shown on a diff: |
| 28 | + * (a) Shows the "reject" button |
| 29 | + * (b) Default the rating tags to those of $this->rev (if flagged) |
| 30 | + * @param Revision $refRev Old revision for diffs ($this->rev is the new rev) |
30 | 31 | */ |
31 | | - public function setDiffLeftId( $refId ) { |
32 | | - $this->refId = $refId; |
| 32 | + public function setDiffPriorRev( Revision $refRev ) { |
| 33 | + $this->refRev = $refRev; |
33 | 34 | } |
34 | 35 | |
35 | 36 | /* |
— | — | @@ -54,7 +55,7 @@ |
55 | 56 | */ |
56 | 57 | public function getHtml() { |
57 | 58 | global $wgOut, $wgLang, $wgParser, $wgEnableParserCache; |
58 | | - $id = $this->rev->getId(); |
| 59 | + $revId = $this->rev->getId(); |
59 | 60 | if ( $this->rev->isDeleted( Revision::DELETED_TEXT ) ) { |
60 | 61 | return array( '', 'review_bad_oldid' ); # The revision must be valid and public |
61 | 62 | } |
— | — | @@ -62,20 +63,21 @@ |
63 | 64 | |
64 | 65 | $srev = $article->getStableRev(); |
65 | 66 | # See if the version being displayed is flagged... |
66 | | - if ( $id == $article->getStable() ) { |
| 67 | + if ( $revId == $article->getStable() ) { |
67 | 68 | $frev = $srev; // avoid query |
68 | 69 | } else { |
69 | | - $frev = FlaggedRevision::newFromTitle( $article->getTitle(), $id ); |
| 70 | + $frev = FlaggedRevision::newFromTitle( $article->getTitle(), $revId ); |
70 | 71 | } |
71 | 72 | $oldFlags = $frev |
72 | 73 | ? $frev->getTags() // existing tags |
73 | 74 | : FlaggedRevs::quickTags( FR_CHECKED ); // basic tags |
74 | 75 | $reviewTime = $frev ? $frev->getTimestamp() : ''; // last review of rev |
75 | 76 | |
| 77 | + $priorRevId = $this->refRev ? $this->refRev->getId() : 0; |
76 | 78 | # If we are reviewing updates to a page, start off with the stable revision's |
77 | 79 | # flags. Otherwise, we just fill them in with the selected revision's flags. |
78 | 80 | # @TODO: do we want to carry over info for other diffs? |
79 | | - if ( $srev && $srev->getRevId() == $this->refId ) { // diff-to-stable |
| 81 | + if ( $srev && $srev->getRevId() == $priorRevId ) { // diff-to-stable |
80 | 82 | $flags = $srev->getTags(); |
81 | 83 | # Check if user is allowed to renew the stable version. |
82 | 84 | # If not, then get the flags for the new revision itself. |
— | — | @@ -83,7 +85,7 @@ |
84 | 86 | $flags = $oldFlags; |
85 | 87 | } |
86 | 88 | # Re-review button is need for template/file only review case |
87 | | - $reviewIncludes = ( $srev->getRevId() == $id && !$article->stableVersionIsSynced() ); |
| 89 | + $reviewIncludes = ( $srev->getRevId() == $revId && !$article->stableVersionIsSynced() ); |
88 | 90 | } else { // views |
89 | 91 | $flags = $oldFlags; |
90 | 92 | $reviewIncludes = false; // re-review button not needed |
— | — | @@ -112,18 +114,18 @@ |
113 | 115 | $form .= Xml::closeElement( 'legend' ) . "\n"; |
114 | 116 | # Show explanatory text |
115 | 117 | $form .= $this->topNotice; |
116 | | - # Show possible conflict warning msg |
117 | | - if ( $this->refId ) { |
| 118 | + # Show possible conflict warning msg... |
| 119 | + if ( $priorRevId ) { |
118 | 120 | list( $u, $ts ) = |
119 | | - FRUserActivity::getUserReviewingDiff( $this->refId, $this->rev->getId() ); |
| 121 | + FRUserActivity::getUserReviewingDiff( $priorRevId, $this->rev->getId() ); |
120 | 122 | } else { |
121 | 123 | list( $u, $ts ) = FRUserActivity::getUserReviewingPage( $this->rev->getPage() ); |
122 | 124 | } |
123 | 125 | if ( $u !== null && $u != $this->user->getName() ) { |
124 | | - $msg = $this->refId ? 'revreview-poss-conflict-c' : 'revreview-poss-conflict-p'; |
| 126 | + $msg = $priorRevId ? 'revreview-poss-conflict-c' : 'revreview-poss-conflict-p'; |
125 | 127 | $form .= '<p><span class="fr-under-review">' . |
126 | | - wfMsgExt( $msg, 'parseinline', $u, |
127 | | - $wgLang->date( $ts, true ), $wgLang->time( $ts, true ) ) . |
| 128 | + wfMsgExt( $msg, 'parseinline', |
| 129 | + $u, $wgLang->date( $ts, true ), $wgLang->time( $ts, true ) ) . |
128 | 130 | '</span></p>'; |
129 | 131 | } |
130 | 132 | |
— | — | @@ -158,10 +160,7 @@ |
159 | 161 | array( 'class' => 'fr-comment-box' ) ) . "   </span>"; |
160 | 162 | } |
161 | 163 | # Determine if there will be reject button |
162 | | - $rejectId = 0; |
163 | | - if ( $this->refId == $article->getStable() && $id != $this->refId ) { |
164 | | - $rejectId = $this->refId; // left rev must be stable and right one newer |
165 | | - } |
| 164 | + $rejectId = $this->rejectRefRevId(); |
166 | 165 | # Add the submit buttons |
167 | 166 | $form .= self::submitButtons( $rejectId, $frev, (bool)$disabled, $reviewIncludes ); |
168 | 167 | # Show stability log if there is anything interesting... |
— | — | @@ -178,8 +177,8 @@ |
179 | 178 | # Hidden params |
180 | 179 | $form .= Html::hidden( 'title', $reviewTitle->getPrefixedText() ) . "\n"; |
181 | 180 | $form .= Html::hidden( 'target', $article->getTitle()->getPrefixedDBKey() ) . "\n"; |
182 | | - $form .= Html::hidden( 'refid', $this->refId ) . "\n"; |
183 | | - $form .= Html::hidden( 'oldid', $id ) . "\n"; |
| 181 | + $form .= Html::hidden( 'refid', $priorRevId ) . "\n"; |
| 182 | + $form .= Html::hidden( 'oldid', $revId ) . "\n"; |
184 | 183 | $form .= Html::hidden( 'action', 'submit' ) . "\n"; |
185 | 184 | $form .= Html::hidden( 'wpEditToken', $this->user->editToken() ) . "\n"; |
186 | 185 | $form .= Html::hidden( 'changetime', $reviewTime, |
— | — | @@ -190,7 +189,7 @@ |
191 | 190 | $form .= Html::hidden( 'fileVersion', $fileVersion ) . "\n"; |
192 | 191 | # Special token to discourage fiddling... |
193 | 192 | $checkCode = RevisionReviewForm::validationKey( |
194 | | - $templateParams, $imageParams, $fileVersion, $id |
| 193 | + $templateParams, $imageParams, $fileVersion, $revId |
195 | 194 | ); |
196 | 195 | $form .= Html::hidden( 'validatedParams', $checkCode ) . "\n"; |
197 | 196 | |
— | — | @@ -200,6 +199,22 @@ |
201 | 200 | return array( $form, true /* ok */ ); |
202 | 201 | } |
203 | 202 | |
| 203 | + /* |
| 204 | + * If the REJECT button should show then get the ID of the last good rev |
| 205 | + * @return int |
| 206 | + */ |
| 207 | + protected function rejectRefRevId() { |
| 208 | + if ( $this->refRev ) { |
| 209 | + $priorId = $this->refRev->getId(); |
| 210 | + if ( $priorId == $this->article->getStable() && $priorId != $this->rev->getId() ) { |
| 211 | + if ( $this->rev->getText() != $this->refRev->getText() ) { |
| 212 | + return $priorId; // left rev must be stable and right one newer |
| 213 | + } |
| 214 | + } |
| 215 | + } |
| 216 | + return 0; |
| 217 | + } |
| 218 | + |
204 | 219 | /** |
205 | 220 | * @param User $user |
206 | 221 | * @param array $flags, selected flags |
Index: trunk/extensions/FlaggedRevs/presentation/FlaggedArticleView.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | class FlaggedArticleView { |
7 | 7 | protected $article = null; |
8 | 8 | |
9 | | - protected $diffRevs = null; |
| 9 | + protected $diffRevs = null; // assoc array of old and new Revisions for diffs |
10 | 10 | protected $isReviewableDiff = false; |
11 | 11 | protected $isDiffFromStable = false; |
12 | 12 | protected $isMultiPageDiff = false; |
— | — | @@ -1072,8 +1072,10 @@ |
1073 | 1073 | # Build the review form as needed |
1074 | 1074 | if ( $rev && ( !$this->diffRevs || $this->isReviewableDiff ) ) { |
1075 | 1075 | $form = new RevisionReviewFormGUI( $wgUser, $this->article, $rev ); |
1076 | | - # Tag default and "reject" button depend on context |
1077 | | - $form->setDiffLeftId( $this->diffRevs['old'] ); |
| 1076 | + # Default tags and existence of "reject" button depend on context |
| 1077 | + if ( $this->diffRevs ) { |
| 1078 | + $form->setDiffPriorRev( $this->diffRevs['old'] ); |
| 1079 | + } |
1078 | 1080 | # Review notice box goes in top of form |
1079 | 1081 | $form->setTopNotice( $this->diffNoticeBox ); |
1080 | 1082 | # $wgOut may not already have the inclusion IDs, such as for diffonly=1. |
— | — | @@ -1579,7 +1581,7 @@ |
1580 | 1582 | $this->isReviewableDiff = true; |
1581 | 1583 | } |
1582 | 1584 | } |
1583 | | - $this->diffRevs = array( 'old' => $oldRev->getId(), 'new' => $newRev->getId() ); |
| 1585 | + $this->diffRevs = array( 'old' => $oldRev, 'new' => $newRev ); |
1584 | 1586 | } |
1585 | 1587 | return true; |
1586 | 1588 | } |