Index: trunk/extensions/CodeReview/CodeRevision.php |
— | — | @@ -95,6 +95,8 @@ |
96 | 96 | 'cc_review' => $review, |
97 | 97 | 'cc_sortkey' => $sortkey ), |
98 | 98 | __METHOD__ ); |
| 99 | + |
| 100 | + return $dbw->insertId(); |
99 | 101 | } |
100 | 102 | |
101 | 103 | protected function threadedSortKey( $parent, $ts ) { |
Index: trunk/extensions/CodeReview/SpecialCode.php |
— | — | @@ -257,7 +257,11 @@ |
258 | 258 | return; |
259 | 259 | } |
260 | 260 | |
261 | | - $this->checkPostings(); |
| 261 | + $redirectOnPost = $this->checkPostings(); |
| 262 | + if( $redirectOnPost ) { |
| 263 | + $wgOut->redirect( $redirectOnPost ); |
| 264 | + return; |
| 265 | + } |
262 | 266 | |
263 | 267 | $repoLink = $wgUser->getSkin()->link( SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() ), |
264 | 268 | htmlspecialchars( $this->mRepo->getName() ) ); |
— | — | @@ -293,6 +297,14 @@ |
294 | 298 | $html .= |
295 | 299 | "<h2>Comments</h2>" . |
296 | 300 | $this->formatComments(); |
| 301 | + |
| 302 | + if( $this->mReplyTarget ) { |
| 303 | + $id = intval( $this->mReplyTarget ); |
| 304 | + $html .= "<script>addOnloadHook(function(){" . |
| 305 | + "document.getElementById('wpReplyTo$id').focus();" . |
| 306 | + "});</script>"; |
| 307 | + } |
| 308 | + |
297 | 309 | $wgOut->addHtml( $html ); |
298 | 310 | } |
299 | 311 | |
— | — | @@ -301,17 +313,22 @@ |
302 | 314 | if( $wgRequest->wasPosted() |
303 | 315 | && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
304 | 316 | // Look for a posting... |
305 | | - $text = $wgRequest->getText( 'wpTextbox1' ); |
| 317 | + $text = $wgRequest->getText( 'wpReply' ); |
306 | 318 | $parent = $wgRequest->getIntOrNull( 'wpParent' ); |
307 | 319 | $review = $wgRequest->getInt( 'wpReview' ); |
308 | 320 | $isPreview = $wgRequest->getCheck( 'wpCommentPreview' ); |
309 | 321 | if( $isPreview ) { |
310 | 322 | // NYI |
311 | 323 | } else { |
312 | | - $this->mRev->saveComment( $text, $review, $parent ); |
313 | | - // fixme -- won't show up in slave load |
| 324 | + $id = $this->mRev->saveComment( $text, $review, $parent ); |
| 325 | + |
| 326 | + // Redirect to the just-saved comment; this avoids POST |
| 327 | + // horrors on forward/rewind. Hope we don't have slave issues? |
| 328 | + $permaLink = $this->commentLink( $id ); |
| 329 | + return $permaLink->getFullUrl(); |
314 | 330 | } |
315 | 331 | } |
| 332 | + return false; |
316 | 333 | } |
317 | 334 | |
318 | 335 | function formatPathLine( $path, $action ) { |
— | — | @@ -354,22 +371,25 @@ |
355 | 372 | } |
356 | 373 | } |
357 | 374 | |
| 375 | + function commentLink( $commentId ) { |
| 376 | + $repo = $this->mRepo->getName(); |
| 377 | + $rev = $this->mRev->getId(); |
| 378 | + $title = SpecialPage::getTitleFor( 'Code', "$repo/$rev" ); |
| 379 | + $title->setFragment( "#c{$commentId}" ); |
| 380 | + return $title; |
| 381 | + } |
| 382 | + |
358 | 383 | function formatComment( $comment, $replyForm='' ) { |
359 | 384 | global $wgOut, $wgLang; |
360 | 385 | $linker = new CodeCommentLinkerWiki( $this->mRepo ); |
361 | 386 | |
362 | | - $repo = $this->mRepo->getName(); |
363 | | - $rev = $this->mRev->getId(); |
364 | | - $perma = SpecialPage::getTitleFor( 'Code', "$repo/$rev" ); |
365 | | - $perma->setFragment( "#c{$comment->id}" ); |
366 | | - |
367 | 387 | return Xml::openElement( 'div', |
368 | 388 | array( |
369 | 389 | 'class' => 'mw-codereview-comment', |
370 | 390 | 'id' => 'c' . intval( $comment->id ), |
371 | 391 | 'style' => $this->commentStyle( $comment ) ) ) . |
372 | 392 | '<div class="mw-codereview-comment-meta">' . |
373 | | - $this->mSkin->link( $perma, "#" ) . |
| 393 | + $this->mSkin->link( $this->commentLink( $comment->id ), "#" ) . |
374 | 394 | wfMsgHtml( 'code-rev-comment-by', |
375 | 395 | $this->mSkin->userLink( $comment->user, $comment->userText ) . |
376 | 396 | $this->mSkin->userToolLinks( $comment->user, $comment->userText ) ) . |
— | — | @@ -411,7 +431,12 @@ |
412 | 432 | Xml::hidden( 'wpEditToken', $wgUser->editToken() ) . |
413 | 433 | ($parent ? Xml::hidden( 'wpParent', $parent ) : '') . |
414 | 434 | '<div>' . |
415 | | - Xml::textArea( 'wpTextbox1', '' ) . |
| 435 | + Xml::openElement( 'textarea', array( |
| 436 | + 'name' => 'wpReply', |
| 437 | + 'id' => "wpReplyTo{$parent}", |
| 438 | + 'cols' => 40, |
| 439 | + 'rows' => 5 ) ) . |
| 440 | + '</textarea>' . |
416 | 441 | '</div>' . |
417 | 442 | '<div>' . |
418 | 443 | Xml::submitButton( wfMsg( 'code-rev-comment-submit' ), array( 'name' => 'wpSave' ) ) . |