Index: trunk/extensions/CodeReview/CodeReview.i18n.php |
— | — | @@ -46,6 +46,7 @@ |
47 | 47 | 'code-status-fixme' => 'fixme', |
48 | 48 | 'code-status-resolved' => 'resolved', |
49 | 49 | 'code-status-ok' => 'ok', |
| 50 | + 'code-rev-submit' => 'Commit changes', |
50 | 51 | |
51 | 52 | 'codereview-reply-link' => 'reply', |
52 | 53 | |
Index: trunk/extensions/CodeReview/SpecialCode.php |
— | — | @@ -23,32 +23,42 @@ |
24 | 24 | $view = new CodeRevisionListView( $params[0] ); |
25 | 25 | break; |
26 | 26 | case 2: |
| 27 | + if( $wgRequest->wasPosted() ) { |
| 28 | + # Add any tags |
| 29 | + $crt = new CodeRevisionTagger( $params[0], $params[1] ); |
| 30 | + $crt->execute(); |
| 31 | + # Set status |
| 32 | + $crs = new CodeRevisionStatusSetter( $params[0], $params[1] ); |
| 33 | + $crs->execute(); |
| 34 | + } |
| 35 | + # Adds comments and makes output |
| 36 | + $view = new CodeRevisionView( $params[0], $params[1] ); |
| 37 | + break; |
27 | 38 | case 3: |
28 | | - if( is_numeric( $params[1] ) ) { |
29 | | - $view = new CodeRevisionView( $params[0], $params[1] ); |
30 | | - break; |
31 | | - } |
32 | | - if( $params[1] == 'tag' ) { |
| 39 | + if( $params[1] === 'tag' ) { |
33 | 40 | if( empty($params[2]) ) |
34 | 41 | $view = new CodeRevisionTagListView( $params[0] ); |
35 | 42 | else |
36 | 43 | $view = new CodeRevisionTagView( $params[0], $params[2] ); |
37 | 44 | break; |
38 | | - } elseif( $params[1] == 'author' ) { |
| 45 | + } elseif( $params[1] === 'author' ) { |
39 | 46 | if( empty($params[2]) ) |
40 | 47 | $view = new CodeRevisionAuthorListView( $params[0] ); |
41 | 48 | else |
42 | 49 | $view = new CodeRevisionAuthorView( $params[0], $params[2] ); |
43 | 50 | break; |
44 | | - } elseif( $params[1] == 'status' ) { |
| 51 | + } elseif( $params[1] === 'status' ) { |
45 | 52 | if( empty($params[2]) ) |
46 | 53 | $view = new CodeRevisionStatusListView( $params[0] ); |
47 | 54 | else |
48 | 55 | $view = new CodeRevisionStatusView( $params[0], $params[2] ); |
49 | 56 | break; |
50 | 57 | } else { |
51 | | - # Nonsense param, back out |
52 | | - $view = new CodeRevisionListView( $params[0] ); |
| 58 | + # Nonsense parameters, back out |
| 59 | + if( empty($params[1]) ) |
| 60 | + $view = new CodeRevisionListView( $params[0] ); |
| 61 | + else |
| 62 | + $view = new CodeRevisionView( $params[0], $params[1] ); |
53 | 63 | break; |
54 | 64 | } |
55 | 65 | case 4: |
Index: trunk/extensions/CodeReview/CodeRevisionTagger.php |
— | — | @@ -18,10 +18,6 @@ |
19 | 19 | $repo = $this->mRepo->getName(); |
20 | 20 | $rev = $this->mRev->getId(); |
21 | 21 | $special = SpecialPage::getTitleFor( 'Code', "$repo/$rev" ); |
22 | | - |
23 | | - $wgOut->redirect( $special->getFullUrl() ); |
24 | | - } else { |
25 | | - throw new MWException( 'Attempted to add invalid tag (fixme UI)' ); |
26 | 22 | } |
27 | 23 | } |
28 | 24 | |
Index: trunk/extensions/CodeReview/CodeRevisionStatusSetter.php |
— | — | @@ -18,10 +18,6 @@ |
19 | 19 | $repo = $this->mRepo->getName(); |
20 | 20 | $rev = $this->mRev->getId(); |
21 | 21 | $special = SpecialPage::getTitleFor( 'Code', "$repo/$rev" ); |
22 | | - |
23 | | - $wgOut->redirect( $special->getFullUrl() ); |
24 | | - } else { |
25 | | - throw new MWException( 'Attempted to save invalid status.' ); |
26 | 22 | } |
27 | 23 | } |
28 | 24 | |
Index: trunk/extensions/CodeReview/CodeRevisionView.php |
— | — | @@ -4,11 +4,13 @@ |
5 | 5 | class CodeRevisionView extends CodeView { |
6 | 6 | |
7 | 7 | function __construct( $repoName, $rev, $replyTarget=null ){ |
| 8 | + global $wgRequest; |
8 | 9 | parent::__construct(); |
9 | 10 | $this->mRepo = CodeRepository::newFromName( $repoName ); |
10 | 11 | $this->mRev = $this->mRepo ? $this->mRepo->getRevision( intval( $rev ) ) : null; |
11 | | - $this->mReplyTarget = $replyTarget; |
12 | 12 | $this->mPreviewText = false; |
| 13 | + $this->mReplyTarget = $replyTarget ? |
| 14 | + (int)$replyTarget : $wgRequest->getIntOrNull( 'wpParent' ); |
13 | 15 | } |
14 | 16 | |
15 | 17 | function execute(){ |
— | — | @@ -34,7 +36,7 @@ |
35 | 37 | $paths .= $this->formatPathLine( $row->cp_path, $row->cp_action ); |
36 | 38 | } |
37 | 39 | if( $paths ){ |
38 | | - $paths = "<ul>\n$paths</ul>"; |
| 40 | + $paths = "<ul>\n$paths</ul>\n"; |
39 | 41 | } |
40 | 42 | $fields = array( |
41 | 43 | 'code-rev-repo' => $repoLink, |
— | — | @@ -43,13 +45,16 @@ |
44 | 46 | 'code-rev-status' => $this->statusForm(), |
45 | 47 | 'code-rev-message' => $this->formatMessage( $this->mRev->getMessage() ), |
46 | 48 | 'code-rev-paths' => $paths, |
47 | | - 'code-rev-tags' => $this->formatTags(), |
| 49 | + 'code-rev-tags' => $this->tagForm(), |
48 | 50 | ); |
49 | | - $html = '<table class="mw-codereview-meta">'; |
| 51 | + |
| 52 | + $special = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName().'/'.$this->mRev->getId() ); |
| 53 | + $html = Xml::openElement( 'form', array( 'action' => $special->getLocalUrl(), 'method' => 'post' ) ); |
| 54 | + $html .= '<table class="mw-codereview-meta">'; |
50 | 55 | foreach( $fields as $label => $data ) { |
51 | 56 | $html .= "<tr><td>" . wfMsgHtml( $label ) . "</td><td>$data</td></tr>\n"; |
52 | 57 | } |
53 | | - $html .= '</table>'; |
| 58 | + $html .= "</table>\n"; |
54 | 59 | |
55 | 60 | $diffHtml = $this->formatDiff(); |
56 | 61 | if( $diffHtml ) { |
— | — | @@ -57,10 +62,10 @@ |
58 | 63 | "<h2>" . wfMsgHtml( 'code-rev-diff' ) . "</h2>" . |
59 | 64 | "<div class='mw-codereview-diff'>" . |
60 | 65 | $diffHtml . |
61 | | - "</div>"; |
| 66 | + "</div>\n"; |
62 | 67 | } |
63 | 68 | $html .= |
64 | | - '<h2>'. wfMsgHtml( 'code-comments' ) .'</h2>' . |
| 69 | + "<h2>". wfMsgHtml( 'code-comments' ) ."</h2>\n" . |
65 | 70 | $this->formatComments(); |
66 | 71 | |
67 | 72 | if( $this->mReplyTarget ) { |
— | — | @@ -68,8 +73,14 @@ |
69 | 74 | $id = intval( $this->mReplyTarget ); |
70 | 75 | $html .= "<script type=\"$wgJsMimeType\">addOnloadHook(function(){" . |
71 | 76 | "document.getElementById('wpReplyTo$id').focus();" . |
72 | | - "});</script>"; |
| 77 | + "});</script>\n"; |
73 | 78 | } |
| 79 | + $html .= '<div>' . |
| 80 | + Xml::submitButton( wfMsg( 'code-rev-submit' ), array( 'name' => 'wpSave' ) ) . |
| 81 | + ' ' . |
| 82 | + Xml::submitButton( wfMsg( 'code-rev-comment-preview' ), array( 'name' => 'wpPreview' ) ) . |
| 83 | + '</div>' . |
| 84 | + '</form>'; |
74 | 85 | |
75 | 86 | $wgOut->addHtml( $html ); |
76 | 87 | } |
— | — | @@ -109,14 +120,14 @@ |
110 | 121 | if( $wgRequest->wasPosted() |
111 | 122 | && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
112 | 123 | // Look for a posting... |
113 | | - $text = $wgRequest->getText( 'wpReply' ); |
| 124 | + $text = $wgRequest->getText( "wpReply{$this->mReplyTarget}" ); |
114 | 125 | $parent = $wgRequest->getIntOrNull( 'wpParent' ); |
115 | 126 | $review = $wgRequest->getInt( 'wpReview' ); |
116 | 127 | $isPreview = $wgRequest->getCheck( 'wpPreview' ); |
117 | 128 | if( $isPreview ) { |
118 | 129 | // Save the text for reference on later comment display... |
119 | 130 | $this->mPreviewText = $text; |
120 | | - } else { |
| 131 | + } else if( $text ) { // don't save blank comments |
121 | 132 | $id = $this->mRev->saveComment( $text, $review, $parent ); |
122 | 133 | |
123 | 134 | // Redirect to the just-saved comment; this avoids POST |
— | — | @@ -150,19 +161,17 @@ |
151 | 162 | return "<li>$link ($desc)$diff</li>\n"; |
152 | 163 | } |
153 | 164 | |
154 | | - function formatTags() { |
| 165 | + function tagForm() { |
155 | 166 | global $wgUser; |
156 | | - |
157 | 167 | $tags = $this->mRev->getTags(); |
158 | 168 | $list = implode( ", ", |
159 | 169 | array_map( |
160 | 170 | array( $this, 'formatTag' ), |
161 | | - $tags ) ); |
162 | | - |
| 171 | + $tags ) |
| 172 | + ) . ' '; |
163 | 173 | if( $wgUser->isAllowed( 'codereview-add-tag' ) ) { |
164 | 174 | $list .= $this->addTagForm(); |
165 | 175 | } |
166 | | - |
167 | 176 | return $list; |
168 | 177 | } |
169 | 178 | |
— | — | @@ -173,18 +182,10 @@ |
174 | 183 | $rev = $this->mRev->getId(); |
175 | 184 | $special = SpecialPage::getTitleFor( 'Code', "$repo/$rev/set/status" ); |
176 | 185 | return |
177 | | - Xml::openElement( 'form', |
178 | | - array( |
179 | | - 'action' => $special->getLocalUrl(), |
180 | | - 'method' => 'post' ) ) . |
181 | 186 | Xml::openElement( 'select', |
182 | 187 | array( 'name' => 'wpStatus' ) ) . |
183 | 188 | $this->buildStatusList() . |
184 | | - '</select>' . |
185 | | - Xml::hidden( 'wpEditToken', $wgUser->editToken() ) . |
186 | | - ' ' . |
187 | | - Xml::submitButton( wfMsg( 'code-rev-status-set' ) ) . |
188 | | - '</form>'; |
| 189 | + '</select>'; |
189 | 190 | } else { |
190 | 191 | return htmlspecialchars( $this->statusDesc( $this->mRev->getStatus() ) ); |
191 | 192 | } |
— | — | @@ -208,24 +209,13 @@ |
209 | 210 | $repo = $this->mRepo->getName(); |
210 | 211 | $rev = $this->mRev->getId(); |
211 | 212 | $special = SpecialPage::getTitleFor( 'Code', "$repo/$rev/add/tag" ); |
212 | | - return |
213 | | - Xml::openElement( 'form', |
214 | | - array( |
215 | | - 'action' => $special->getLocalUrl(), |
216 | | - 'method' => 'post' ) ) . |
217 | | - Xml::input( 'wpTag', '' ) . |
218 | | - Xml::hidden( 'wpEditToken', $wgUser->editToken() ) . |
219 | | - ' ' . |
220 | | - Xml::submitButton( wfMsg( 'code-rev-tag-add' ) ) . |
221 | | - '</form>'; |
| 213 | + return Xml::input( 'wpTag', '' ); |
222 | 214 | } |
223 | 215 | |
224 | 216 | function formatTag( $tag ) { |
225 | 217 | global $wgUser; |
226 | | - |
227 | 218 | $repo = $this->mRepo->getName(); |
228 | 219 | $special = SpecialPage::getTitleFor( 'Code', "$repo/tag/$tag" ); |
229 | | - |
230 | 220 | return $this->mSkin->link( $special, htmlspecialchars( $tag ) ); |
231 | 221 | } |
232 | 222 | |
— | — | @@ -249,7 +239,7 @@ |
250 | 240 | } |
251 | 241 | |
252 | 242 | function formatCommentInline( $comment ) { |
253 | | - if( $comment->id == $this->mReplyTarget ) { |
| 243 | + if( $comment->id === $this->mReplyTarget ) { |
254 | 244 | return $this->formatComment( $comment, |
255 | 245 | $this->postCommentForm( $comment->id ) ); |
256 | 246 | } else { |
— | — | @@ -331,34 +321,19 @@ |
332 | 322 | } |
333 | 323 | $repo = $this->mRepo->getName(); |
334 | 324 | $rev = $this->mRev->getId(); |
335 | | - if( $parent ) { |
336 | | - $special = SpecialPage::getTitleFor( 'Code', "$repo/$rev/reply/$parent" ); |
337 | | - } else { |
338 | | - $special = SpecialPage::getTitleFor( 'Code', "$repo/$rev" ); |
339 | | - } |
340 | 325 | return '<div class="mw-codereview-post-comment">' . |
341 | 326 | $preview . |
342 | | - Xml::openElement( 'form', |
343 | | - array( |
344 | | - 'action' => $special->getLocalUrl(), |
345 | | - 'method' => 'post' ) ) . |
346 | 327 | Xml::hidden( 'wpEditToken', $wgUser->editToken() ) . |
347 | 328 | ($parent ? Xml::hidden( 'wpParent', $parent ) : '') . |
348 | 329 | '<div>' . |
349 | 330 | Xml::openElement( 'textarea', array( |
350 | | - 'name' => 'wpReply', |
| 331 | + 'name' => "wpReply{$parent}", |
351 | 332 | 'id' => "wpReplyTo{$parent}", |
352 | 333 | 'cols' => 40, |
353 | 334 | 'rows' => 5 ) ) . |
354 | 335 | $text . |
355 | 336 | '</textarea>' . |
356 | 337 | '</div>' . |
357 | | - '<div>' . |
358 | | - Xml::submitButton( wfMsg( 'code-rev-comment-submit' ), array( 'name' => 'wpSave' ) ) . |
359 | | - ' ' . |
360 | | - Xml::submitButton( wfMsg( 'code-rev-comment-preview' ), array( 'name' => 'wpPreview' ) ) . |
361 | | - '</div>' . |
362 | | - '</form>' . |
363 | 338 | '</div>'; |
364 | 339 | } |
365 | 340 | } |