Index: trunk/extensions/CodeReview/CodeRevisionView.php |
— | — | @@ -51,7 +51,16 @@ |
52 | 52 | ); |
53 | 53 | $special = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName().'/'.$this->mRev->getId() ); |
54 | 54 | |
55 | | - $html = $this->formatMetaData( $fields ); |
| 55 | + $html = Xml::openElement( 'form', array( 'action' => $special->getLocalUrl(), 'method' => 'post' ) ); |
| 56 | + $html .= '<div>' . |
| 57 | + Xml::submitButton( wfMsg( 'code-rev-submit' ), array( 'name' => 'wpSave' ) ) . |
| 58 | + ' ' . |
| 59 | + Xml::submitButton( wfMsg( 'code-rev-submit-next' ), array( 'name' => 'wpSaveAndNext' ) ) . |
| 60 | + ' ' . |
| 61 | + Xml::submitButton( wfMsg( 'code-rev-comment-preview' ), array( 'name' => 'wpPreview' ) ) . |
| 62 | + '</div>'; |
| 63 | + |
| 64 | + $html .= $this->formatMetaData( $fields ); |
56 | 65 | |
57 | 66 | if( $this->mRev->isDiffable() ) { |
58 | 67 | $diffHtml = $this->formatDiff(); |
— | — | @@ -61,8 +70,10 @@ |
62 | 71 | wfMsg('code-rev-purge-link'), 'action=purge' ) . ']</small></h2>' . |
63 | 72 | "<div class='mw-codereview-diff' id='mw-codereview-diff'>" . $diffHtml . "</div>\n"; |
64 | 73 | } |
65 | | - |
66 | | - $html .= $this->formatComments(); |
| 74 | + $comments = $this->formatComments(); |
| 75 | + if( $comments ) { |
| 76 | + $html .= "<h2 id='code-comments'>". wfMsgHtml( 'code-comments' ) ."</h2>\n" . $comments; |
| 77 | + } |
67 | 78 | |
68 | 79 | if( $this->mReplyTarget ) { |
69 | 80 | global $wgJsMimeType; |
— | — | @@ -71,11 +82,14 @@ |
72 | 83 | "document.getElementById('wpReplyTo$id').focus();" . |
73 | 84 | "});</script>\n"; |
74 | 85 | } |
75 | | - |
76 | | - if ($wgUser->isAllowed( 'codereview-post-comment' ) ) { |
77 | | - $html = Xml::tags( 'form', array( 'action' => $special->getLocalUrl(), 'method' => 'post' ), |
78 | | - $this->submitButtons() . $html . $this->submitButtons() ); |
79 | | - } |
| 86 | + $html .= '<div>' . |
| 87 | + Xml::submitButton( wfMsg( 'code-rev-submit' ), array( 'name' => 'wpSave' ) ) . |
| 88 | + ' ' . |
| 89 | + Xml::submitButton( wfMsg( 'code-rev-submit-next' ), array( 'name' => 'wpSaveAndNext' ) ) . |
| 90 | + ' ' . |
| 91 | + Xml::submitButton( wfMsg( 'code-rev-comment-preview' ), array( 'name' => 'wpPreview' ) ) . |
| 92 | + '</div>' . |
| 93 | + '</form>'; |
80 | 94 | |
81 | 95 | $wgOut->addHtml( $html ); |
82 | 96 | } |
— | — | @@ -254,19 +268,13 @@ |
255 | 269 | } |
256 | 270 | |
257 | 271 | function formatComments() { |
258 | | - $comments = implode( "\n", |
259 | | - array_map( |
260 | | - array( $this, 'formatCommentInline' ), |
261 | | - $this->mRev->getComments() |
262 | | - ) ) . |
263 | | - $this->postCommentForm(); |
264 | | - |
265 | | - if( $comments ) { |
266 | | - //Can be empty if : no comments && no postCommentForm |
267 | | - $comments = "<h2 id='code-comments'>". wfMsgHtml( 'code-comments' ) ."</h2>\n" . |
268 | | - Xml::tags( 'div', array( 'class' => 'mw-codereview-comments' ), $comments ) . "\n"; |
269 | | - } |
270 | | - return $comments; |
| 272 | + return "<div class='mw-codereview-comments'>" . |
| 273 | + implode( "\n", |
| 274 | + array_map( |
| 275 | + array( $this, 'formatCommentInline' ), |
| 276 | + $this->mRev->getComments() ) ) . |
| 277 | + $this->postCommentForm() . |
| 278 | + "</div>"; |
271 | 279 | } |
272 | 280 | |
273 | 281 | function formatCommentInline( $comment ) { |
— | — | @@ -350,11 +358,6 @@ |
351 | 359 | |
352 | 360 | function postCommentForm( $parent=null ) { |
353 | 361 | global $wgUser; |
354 | | - |
355 | | - if( !$wgUser->isAllowed('codereview-post-comment') ) { |
356 | | - return ''; |
357 | | - } |
358 | | - |
359 | 362 | if( $this->mPreviewText != false && $parent === $this->mReplyTarget ) { |
360 | 363 | $preview = $this->previewComment( $this->mPreviewText ); |
361 | 364 | $text = htmlspecialchars( $this->mPreviewText ); |
— | — | @@ -364,6 +367,9 @@ |
365 | 368 | } |
366 | 369 | $repo = $this->mRepo->getName(); |
367 | 370 | $rev = $this->mRev->getId(); |
| 371 | + if( !$wgUser->isAllowed('codereview-post-comment') ) { |
| 372 | + return ''; |
| 373 | + } |
368 | 374 | return '<div class="mw-codereview-post-comment">' . |
369 | 375 | $preview . |
370 | 376 | Xml::hidden( 'wpEditToken', $wgUser->editToken() ) . |
— | — | @@ -379,15 +385,4 @@ |
380 | 386 | '</div>' . |
381 | 387 | '</div>'; |
382 | 388 | } |
383 | | - |
384 | | - function submitButtons() { |
385 | | - return |
386 | | - '<div>' . |
387 | | - Xml::submitButton( wfMsg( 'code-rev-submit' ), array( 'name' => 'wpSave' ) ) . |
388 | | - ' ' . |
389 | | - Xml::submitButton( wfMsg( 'code-rev-submit-next' ), array( 'name' => 'wpSaveAndNext' ) ) . |
390 | | - ' ' . |
391 | | - Xml::submitButton( wfMsg( 'code-rev-comment-preview' ), array( 'name' => 'wpPreview' ) ) . |
392 | | - "</div>\n"; |
393 | | - } |
394 | 389 | } |