r43466 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r43465‎ | r43466 | r43467 >
Date:23:35, 13 November 2008
Author:aaron
Status:old (Comments)
Tags:
Comment:
* Add status/tag change log
* Mark stuff 'protected'
* Whitespace tweaks
Modified paths:
  • /trunk/extensions/CodeReview/CodeReview.i18n.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeRevisionCommitter.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeRevisionView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeReview.i18n.php
@@ -11,6 +11,11 @@
1212 $messages['en'] = array(
1313 'code' => 'Code Review',
1414 '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',
1520 'code-desc' => '[[Special:Code|Code review tool]] with [[Special:RepoAdmin|Subversion support]]',
1621 'code-no-repo' => 'No repository configured!',
1722 'code-notes' => 'review notes',
Index: trunk/extensions/CodeReview/CodeRevisionView.php
@@ -87,6 +87,12 @@
8888 "document.getElementById('wpReplyTo$id').focus();" .
8989 "});</script>\n";
9090 }
 91+
 92+ $changes = $this->formatPropChanges();
 93+ if( $changes ) {
 94+ $html .= "<h2 id='code-changes'>". wfMsgHtml( 'code-prop-changes' ) ."</h2>\n" . $changes;
 95+ }
 96+
9197 $html .= '<div>' .
9298 Xml::submitButton( wfMsg( 'code-rev-submit' ), array( 'name' => 'wpSave' ) ) .
9399 ' ' .
@@ -99,7 +105,7 @@
100106 $wgOut->addHTML( $html );
101107 }
102108
103 - function navigationLinks() {
 109+ protected function navigationLinks() {
104110 $rev = $this->mRev->getId();
105111 $prev = $this->mRev->getPrevious();
106112 $next = $this->mRev->getNext();
@@ -129,7 +135,7 @@
130136 return implode( ' | ', $links );
131137 }
132138
133 - function checkPostings() {
 139+ protected function checkPostings() {
134140 global $wgRequest, $wgUser;
135141 if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal('wpEditToken') ) ) {
136142 // Look for a posting...
@@ -145,7 +151,7 @@
146152 return false;
147153 }
148154
149 - function formatPathLine( $path, $action ) {
 155+ protected function formatPathLine( $path, $action ) {
150156 $desc = wfMsgHtml( 'code-rev-modified-'.strtolower( $action ) );
151157 // Find any ' (from x)' from rename comment in the path.
152158 preg_match( '/ \([^\)]+\)$/', $path, $matches );
@@ -178,7 +184,7 @@
179185 return "<li>$link ($desc)$diff</li>\n";
180186 }
181187
182 - function tagForm() {
 188+ protected function tagForm() {
183189 global $wgUser;
184190 $tags = $this->mRev->getTags();
185191 $list = '';
@@ -209,7 +215,7 @@
210216 }
211217 }
212218
213 - function buildStatusList() {
 219+ protected function buildStatusList() {
214220 $states = CodeRevision::getPossibleStates();
215221 $out = '';
216222 foreach( $states as $state ) {
@@ -222,7 +228,7 @@
223229 return $out;
224230 }
225231
226 - function addTagForm() {
 232+ protected function addTagForm() {
227233 global $wgUser;
228234 $repo = $this->mRepo->getName();
229235 $rev = $this->mRev->getId();
@@ -233,14 +239,14 @@
234240 '</td></tr></table></div>';
235241 }
236242
237 - function formatTag( $tag ) {
 243+ protected function formatTag( $tag ) {
238244 global $wgUser;
239245 $repo = $this->mRepo->getName();
240246 $special = SpecialPage::getTitleFor( 'Code', "$repo/tag/$tag" );
241247 return $this->mSkin->link( $special, htmlspecialchars( $tag ) );
242248 }
243249
244 - function formatDiff() {
 250+ protected function formatDiff() {
245251 global $wgEnableAPI;
246252
247253 // Asynchronous diff loads will require the API
@@ -269,7 +275,7 @@
270276 return $hilite->render( $diff );
271277 }
272278
273 - function stubDiffLoader() {
 279+ protected function stubDiffLoader() {
274280 global $wgOut, $wgScriptPath;
275281 $encRepo = Xml::encodeJsVar( $this->mRepo->getName() );
276282 $encRev = Xml::encodeJsVar( $this->mRev->getId() );
@@ -283,19 +289,27 @@
284290 return "Loading diff...";
285291 }
286292
287 - function formatComments() {
 293+ protected function formatComments() {
288294 $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();
293297 if( !$comments ) {
294298 return false;
295299 }
296300 return "<div class='mw-codereview-comments'>$comments</div>";
297301 }
 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+ }
298312
299 - function formatCommentInline( $comment ) {
 313+ protected function formatCommentInline( $comment ) {
300314 if( $comment->id === $this->mReplyTarget ) {
301315 return $this->formatComment( $comment,
302316 $this->postCommentForm( $comment->id ) );
@@ -304,7 +318,27 @@
305319 }
306320 }
307321
308 - function commentLink( $commentId ) {
 322+ protected function formatChangeInline( $change ) {
 323+ global $wgLang;
 324+ $line = $wgLang->timeanddate( $change->timestamp, true );
 325+ $line .= '&nbsp;' . $this->mSkin->userLink( $change->user, $change->userText );
 326+ $line .= $this->mSkin->userToolLinks( $change->user, $change->userText );
 327+ $line .= '&nbsp;' . 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 ? "&nbsp;" : "";
 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 ) {
309343 $repo = $this->mRepo->getName();
310344 $rev = $this->mRev->getId();
311345 $title = SpecialPage::getTitleFor( 'Code', "$repo/$rev" );
@@ -312,19 +346,19 @@
313347 return $title;
314348 }
315349
316 - function revLink() {
 350+ protected function revLink() {
317351 $repo = $this->mRepo->getName();
318352 $rev = $this->mRev->getId();
319353 $title = SpecialPage::getTitleFor( 'Code', "$repo/$rev" );
320354 return $title;
321355 }
322356
323 - function previewComment( $text, $review=0 ) {
 357+ protected function previewComment( $text, $review=0 ) {
324358 $comment = $this->mRev->previewComment( $text, $review );
325359 return $this->formatComment( $comment );
326360 }
327361
328 - function formatComment( $comment, $replyForm='' ) {
 362+ protected function formatComment( $comment, $replyForm='' ) {
329363 global $wgOut, $wgLang;
330364 $linker = new CodeCommentLinkerWiki( $this->mRepo );
331365
@@ -358,13 +392,13 @@
359393 '</div>';
360394 }
361395
362 - function commentStyle( $comment ) {
 396+ protected function commentStyle( $comment ) {
363397 $depth = $comment->threadDepth();
364398 $margin = ($depth - 1) * 48;
365399 return "margin-left: ${margin}px";
366400 }
367401
368 - function commentReplyLink( $id ) {
 402+ protected function commentReplyLink( $id ) {
369403 $repo = $this->mRepo->getName();
370404 $rev = $this->mRev->getId();
371405 $self = SpecialPage::getTitleFor( 'Code', "$repo/$rev/reply/$id" );
@@ -374,7 +408,7 @@
375409 ']';
376410 }
377411
378 - function postCommentForm( $parent=null ) {
 412+ protected function postCommentForm( $parent=null ) {
379413 global $wgUser;
380414 if( $this->mPreviewText != false && $parent === $this->mReplyTarget ) {
381415 $preview = $this->previewComment( $this->mPreviewText );
Index: trunk/extensions/CodeReview/CodeRevisionCommitter.php
@@ -27,6 +27,10 @@
2828 $dbw = wfGetDB( DB_MASTER );
2929
3030 $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+ }
3135 $addTags = $removeTags = array();
3236 if( $this->validPost('codereview-add-tag') && count($this->mAddTags) ) {
3337 $addTags = $this->mAddTags;
@@ -38,9 +42,7 @@
3943 if( count($addTags) || count($removeTags) ) {
4044 $this->mRev->changeTags( $addTags, $removeTags, $wgUser );
4145 }
42 - if( $this->validPost('codereview-set-status') && $this->mRev->isValidStatus($this->mStatus) ) {
43 - $this->mRev->setStatus( $this->mStatus, $wgUser );
44 - }
 46+ // Add any comments
4547 if( $this->validPost('codereview-post-comment') && strlen($this->text) ) {
4648 $parent = $wgRequest->getIntOrNull( 'wpParent' );
4749 $review = $wgRequest->getInt( 'wpReview' );

Comments

#Comment by Brion VIBBER (talk | contribs)   23:39, 13 November 2008

Woot! Maybe move the list below the buttons but it's lookin good

Status & tagging log