Index: trunk/extensions/CodeReview/CodeReview.i18n.php |
— | — | @@ -11,6 +11,11 @@ |
12 | 12 | $messages['en'] = array( |
13 | 13 | 'code' => 'Code Review', |
14 | 14 | 'code-comments' => 'Comments', |
| 15 | + 'code-change-status' => 'changed the \'\'\'status\'\'\' of this revision', |
| 16 | + 'code-change-tags' => 'changed the \'\'\'tags\'\'\' for this revision', |
| 17 | + 'code-change-removed' => 'removed:', |
| 18 | + 'code-change-added' => 'added:', |
| 19 | + 'code-prop-changes' => 'Status & tagging log', |
15 | 20 | 'code-desc' => '[[Special:Code|Code review tool]] with [[Special:RepoAdmin|Subversion support]]', |
16 | 21 | 'code-no-repo' => 'No repository configured!', |
17 | 22 | 'code-notes' => 'review notes', |
Index: trunk/extensions/CodeReview/CodeRevisionView.php |
— | — | @@ -87,6 +87,12 @@ |
88 | 88 | "document.getElementById('wpReplyTo$id').focus();" . |
89 | 89 | "});</script>\n"; |
90 | 90 | } |
| 91 | + |
| 92 | + $changes = $this->formatPropChanges(); |
| 93 | + if( $changes ) { |
| 94 | + $html .= "<h2 id='code-changes'>". wfMsgHtml( 'code-prop-changes' ) ."</h2>\n" . $changes; |
| 95 | + } |
| 96 | + |
91 | 97 | $html .= '<div>' . |
92 | 98 | Xml::submitButton( wfMsg( 'code-rev-submit' ), array( 'name' => 'wpSave' ) ) . |
93 | 99 | ' ' . |
— | — | @@ -99,7 +105,7 @@ |
100 | 106 | $wgOut->addHTML( $html ); |
101 | 107 | } |
102 | 108 | |
103 | | - function navigationLinks() { |
| 109 | + protected function navigationLinks() { |
104 | 110 | $rev = $this->mRev->getId(); |
105 | 111 | $prev = $this->mRev->getPrevious(); |
106 | 112 | $next = $this->mRev->getNext(); |
— | — | @@ -129,7 +135,7 @@ |
130 | 136 | return implode( ' | ', $links ); |
131 | 137 | } |
132 | 138 | |
133 | | - function checkPostings() { |
| 139 | + protected function checkPostings() { |
134 | 140 | global $wgRequest, $wgUser; |
135 | 141 | if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal('wpEditToken') ) ) { |
136 | 142 | // Look for a posting... |
— | — | @@ -145,7 +151,7 @@ |
146 | 152 | return false; |
147 | 153 | } |
148 | 154 | |
149 | | - function formatPathLine( $path, $action ) { |
| 155 | + protected function formatPathLine( $path, $action ) { |
150 | 156 | $desc = wfMsgHtml( 'code-rev-modified-'.strtolower( $action ) ); |
151 | 157 | // Find any ' (from x)' from rename comment in the path. |
152 | 158 | preg_match( '/ \([^\)]+\)$/', $path, $matches ); |
— | — | @@ -178,7 +184,7 @@ |
179 | 185 | return "<li>$link ($desc)$diff</li>\n"; |
180 | 186 | } |
181 | 187 | |
182 | | - function tagForm() { |
| 188 | + protected function tagForm() { |
183 | 189 | global $wgUser; |
184 | 190 | $tags = $this->mRev->getTags(); |
185 | 191 | $list = ''; |
— | — | @@ -209,7 +215,7 @@ |
210 | 216 | } |
211 | 217 | } |
212 | 218 | |
213 | | - function buildStatusList() { |
| 219 | + protected function buildStatusList() { |
214 | 220 | $states = CodeRevision::getPossibleStates(); |
215 | 221 | $out = ''; |
216 | 222 | foreach( $states as $state ) { |
— | — | @@ -222,7 +228,7 @@ |
223 | 229 | return $out; |
224 | 230 | } |
225 | 231 | |
226 | | - function addTagForm() { |
| 232 | + protected function addTagForm() { |
227 | 233 | global $wgUser; |
228 | 234 | $repo = $this->mRepo->getName(); |
229 | 235 | $rev = $this->mRev->getId(); |
— | — | @@ -233,14 +239,14 @@ |
234 | 240 | '</td></tr></table></div>'; |
235 | 241 | } |
236 | 242 | |
237 | | - function formatTag( $tag ) { |
| 243 | + protected function formatTag( $tag ) { |
238 | 244 | global $wgUser; |
239 | 245 | $repo = $this->mRepo->getName(); |
240 | 246 | $special = SpecialPage::getTitleFor( 'Code', "$repo/tag/$tag" ); |
241 | 247 | return $this->mSkin->link( $special, htmlspecialchars( $tag ) ); |
242 | 248 | } |
243 | 249 | |
244 | | - function formatDiff() { |
| 250 | + protected function formatDiff() { |
245 | 251 | global $wgEnableAPI; |
246 | 252 | |
247 | 253 | // Asynchronous diff loads will require the API |
— | — | @@ -269,7 +275,7 @@ |
270 | 276 | return $hilite->render( $diff ); |
271 | 277 | } |
272 | 278 | |
273 | | - function stubDiffLoader() { |
| 279 | + protected function stubDiffLoader() { |
274 | 280 | global $wgOut, $wgScriptPath; |
275 | 281 | $encRepo = Xml::encodeJsVar( $this->mRepo->getName() ); |
276 | 282 | $encRev = Xml::encodeJsVar( $this->mRev->getId() ); |
— | — | @@ -283,19 +289,27 @@ |
284 | 290 | return "Loading diff..."; |
285 | 291 | } |
286 | 292 | |
287 | | - function formatComments() { |
| 293 | + protected function formatComments() { |
288 | 294 | $comments = implode( "\n", |
289 | | - array_map( |
290 | | - array( $this, 'formatCommentInline' ), |
291 | | - $this->mRev->getComments() ) ) . |
292 | | - $this->postCommentForm(); |
| 295 | + array_map( array( $this, 'formatCommentInline' ), $this->mRev->getComments() ) |
| 296 | + ) . $this->postCommentForm(); |
293 | 297 | if( !$comments ) { |
294 | 298 | return false; |
295 | 299 | } |
296 | 300 | return "<div class='mw-codereview-comments'>$comments</div>"; |
297 | 301 | } |
| 302 | + |
| 303 | + protected function formatPropChanges() { |
| 304 | + $changes = implode( "\n", |
| 305 | + array_map( array( $this, 'formatChangeInline' ), $this->mRev->getPropChanges() ) |
| 306 | + ); |
| 307 | + if( !$changes ) { |
| 308 | + return false; |
| 309 | + } |
| 310 | + return "<ul class='mw-codereview-changes'>$changes</ul>"; |
| 311 | + } |
298 | 312 | |
299 | | - function formatCommentInline( $comment ) { |
| 313 | + protected function formatCommentInline( $comment ) { |
300 | 314 | if( $comment->id === $this->mReplyTarget ) { |
301 | 315 | return $this->formatComment( $comment, |
302 | 316 | $this->postCommentForm( $comment->id ) ); |
— | — | @@ -304,7 +318,27 @@ |
305 | 319 | } |
306 | 320 | } |
307 | 321 | |
308 | | - function commentLink( $commentId ) { |
| 322 | + protected function formatChangeInline( $change ) { |
| 323 | + global $wgLang; |
| 324 | + $line = $wgLang->timeanddate( $change->timestamp, true ); |
| 325 | + $line .= ' ' . $this->mSkin->userLink( $change->user, $change->userText ); |
| 326 | + $line .= $this->mSkin->userToolLinks( $change->user, $change->userText ); |
| 327 | + $line .= ' ' . wfMsgExt("code-change-{$change->attrib}",array('parseinline')); |
| 328 | + $line .= " <i>["; |
| 329 | + if( $change->removed ) { |
| 330 | + $line .= '<b>'.wfMsg('code-change-removed').'</b> '; |
| 331 | + $line .= htmlspecialchars($change->removed); |
| 332 | + $line .= $change->added ? " " : ""; |
| 333 | + } |
| 334 | + if( $change->added ) { |
| 335 | + $line .= '<b>'.wfMsg('code-change-added').'</b> '; |
| 336 | + $line .= htmlspecialchars($change->added); |
| 337 | + } |
| 338 | + $line .= "]</i>"; |
| 339 | + return "<li>$line</li>"; |
| 340 | + } |
| 341 | + |
| 342 | + protected function commentLink( $commentId ) { |
309 | 343 | $repo = $this->mRepo->getName(); |
310 | 344 | $rev = $this->mRev->getId(); |
311 | 345 | $title = SpecialPage::getTitleFor( 'Code', "$repo/$rev" ); |
— | — | @@ -312,19 +346,19 @@ |
313 | 347 | return $title; |
314 | 348 | } |
315 | 349 | |
316 | | - function revLink() { |
| 350 | + protected function revLink() { |
317 | 351 | $repo = $this->mRepo->getName(); |
318 | 352 | $rev = $this->mRev->getId(); |
319 | 353 | $title = SpecialPage::getTitleFor( 'Code', "$repo/$rev" ); |
320 | 354 | return $title; |
321 | 355 | } |
322 | 356 | |
323 | | - function previewComment( $text, $review=0 ) { |
| 357 | + protected function previewComment( $text, $review=0 ) { |
324 | 358 | $comment = $this->mRev->previewComment( $text, $review ); |
325 | 359 | return $this->formatComment( $comment ); |
326 | 360 | } |
327 | 361 | |
328 | | - function formatComment( $comment, $replyForm='' ) { |
| 362 | + protected function formatComment( $comment, $replyForm='' ) { |
329 | 363 | global $wgOut, $wgLang; |
330 | 364 | $linker = new CodeCommentLinkerWiki( $this->mRepo ); |
331 | 365 | |
— | — | @@ -358,13 +392,13 @@ |
359 | 393 | '</div>'; |
360 | 394 | } |
361 | 395 | |
362 | | - function commentStyle( $comment ) { |
| 396 | + protected function commentStyle( $comment ) { |
363 | 397 | $depth = $comment->threadDepth(); |
364 | 398 | $margin = ($depth - 1) * 48; |
365 | 399 | return "margin-left: ${margin}px"; |
366 | 400 | } |
367 | 401 | |
368 | | - function commentReplyLink( $id ) { |
| 402 | + protected function commentReplyLink( $id ) { |
369 | 403 | $repo = $this->mRepo->getName(); |
370 | 404 | $rev = $this->mRev->getId(); |
371 | 405 | $self = SpecialPage::getTitleFor( 'Code', "$repo/$rev/reply/$id" ); |
— | — | @@ -374,7 +408,7 @@ |
375 | 409 | ']'; |
376 | 410 | } |
377 | 411 | |
378 | | - function postCommentForm( $parent=null ) { |
| 412 | + protected function postCommentForm( $parent=null ) { |
379 | 413 | global $wgUser; |
380 | 414 | if( $this->mPreviewText != false && $parent === $this->mReplyTarget ) { |
381 | 415 | $preview = $this->previewComment( $this->mPreviewText ); |
Index: trunk/extensions/CodeReview/CodeRevisionCommitter.php |
— | — | @@ -27,6 +27,10 @@ |
28 | 28 | $dbw = wfGetDB( DB_MASTER ); |
29 | 29 | |
30 | 30 | $dbw->begin(); |
| 31 | + // Change the status if allowed |
| 32 | + if( $this->validPost('codereview-set-status') && $this->mRev->isValidStatus($this->mStatus) ) { |
| 33 | + $this->mRev->setStatus( $this->mStatus, $wgUser ); |
| 34 | + } |
31 | 35 | $addTags = $removeTags = array(); |
32 | 36 | if( $this->validPost('codereview-add-tag') && count($this->mAddTags) ) { |
33 | 37 | $addTags = $this->mAddTags; |
— | — | @@ -38,9 +42,7 @@ |
39 | 43 | if( count($addTags) || count($removeTags) ) { |
40 | 44 | $this->mRev->changeTags( $addTags, $removeTags, $wgUser ); |
41 | 45 | } |
42 | | - if( $this->validPost('codereview-set-status') && $this->mRev->isValidStatus($this->mStatus) ) { |
43 | | - $this->mRev->setStatus( $this->mStatus, $wgUser ); |
44 | | - } |
| 46 | + // Add any comments |
45 | 47 | if( $this->validPost('codereview-post-comment') && strlen($this->text) ) { |
46 | 48 | $parent = $wgRequest->getIntOrNull( 'wpParent' ); |
47 | 49 | $review = $wgRequest->getInt( 'wpReview' ); |