Revision: 43466
Author:   aaron
Date:     2008-11-13 23:35:18 +0000 (Thu, 13 Nov 2008)

Log Message:
-----------
* Add status/tag change log
* Mark stuff 'protected'
* Whitespace tweaks

Modified Paths:
--------------
    trunk/extensions/CodeReview/CodeReview.i18n.php
    trunk/extensions/CodeReview/CodeRevisionCommitter.php
    trunk/extensions/CodeReview/CodeRevisionView.php

Modified: trunk/extensions/CodeReview/CodeReview.i18n.php
===================================================================
--- trunk/extensions/CodeReview/CodeReview.i18n.php     2008-11-13 23:18:01 UTC 
(rev 43465)
+++ trunk/extensions/CodeReview/CodeReview.i18n.php     2008-11-13 23:35:18 UTC 
(rev 43466)
@@ -11,6 +11,11 @@
 $messages['en'] = array(
        'code' => 'Code Review',
        'code-comments' => 'Comments',
+       'code-change-status' => 'changed the \'\'\'status\'\'\' of this 
revision',
+       'code-change-tags' => 'changed the \'\'\'tags\'\'\' for this revision',
+       'code-change-removed' => 'removed:',
+       'code-change-added' => 'added:',
+       'code-prop-changes' => 'Status & tagging log',
        'code-desc' => '[[Special:Code|Code review tool]] with 
[[Special:RepoAdmin|Subversion support]]',
        'code-no-repo' => 'No repository configured!',
        'code-notes' => 'review notes',

Modified: trunk/extensions/CodeReview/CodeRevisionCommitter.php
===================================================================
--- trunk/extensions/CodeReview/CodeRevisionCommitter.php       2008-11-13 
23:18:01 UTC (rev 43465)
+++ trunk/extensions/CodeReview/CodeRevisionCommitter.php       2008-11-13 
23:35:18 UTC (rev 43466)
@@ -27,6 +27,10 @@
                $dbw = wfGetDB( DB_MASTER );
                
                $dbw->begin();
+               // Change the status if allowed
+               if( $this->validPost('codereview-set-status') && 
$this->mRev->isValidStatus($this->mStatus) ) {
+                       $this->mRev->setStatus( $this->mStatus, $wgUser );
+               }
                $addTags = $removeTags = array();
                if( $this->validPost('codereview-add-tag') && 
count($this->mAddTags) ) {
                        $addTags = $this->mAddTags;
@@ -38,9 +42,7 @@
                if( count($addTags) || count($removeTags) ) {
                        $this->mRev->changeTags( $addTags, $removeTags, $wgUser 
);
                }
-               if( $this->validPost('codereview-set-status') && 
$this->mRev->isValidStatus($this->mStatus) ) {
-                       $this->mRev->setStatus( $this->mStatus, $wgUser );
-               }
+               // Add any comments
                if( $this->validPost('codereview-post-comment') && 
strlen($this->text) ) {
                        $parent = $wgRequest->getIntOrNull( 'wpParent' );
                        $review = $wgRequest->getInt( 'wpReview' );

Modified: trunk/extensions/CodeReview/CodeRevisionView.php
===================================================================
--- trunk/extensions/CodeReview/CodeRevisionView.php    2008-11-13 23:18:01 UTC 
(rev 43465)
+++ trunk/extensions/CodeReview/CodeRevisionView.php    2008-11-13 23:35:18 UTC 
(rev 43466)
@@ -87,6 +87,12 @@
                                
"document.getElementById('wpReplyTo$id').focus();" .
                                "});</script>\n";
                }
+               
+               $changes = $this->formatPropChanges();
+               if( $changes ) {
+                       $html .= "<h2 id='code-changes'>". wfMsgHtml( 
'code-prop-changes' ) ."</h2>\n" . $changes;
+               }
+               
                $html .= '<div>' .
                        Xml::submitButton( wfMsg( 'code-rev-submit' ), array( 
'name' => 'wpSave' ) ) .
                        ' ' .
@@ -99,7 +105,7 @@
                $wgOut->addHTML( $html );
        }
        
-       function navigationLinks() {
+       protected function navigationLinks() {
                $rev = $this->mRev->getId();
                $prev = $this->mRev->getPrevious();
                $next = $this->mRev->getNext();
@@ -129,7 +135,7 @@
                return implode( ' | ', $links );
        }
 
-       function checkPostings() {
+       protected function checkPostings() {
                global $wgRequest, $wgUser;
                if( $wgRequest->wasPosted() && $wgUser->matchEditToken( 
$wgRequest->getVal('wpEditToken') ) ) {
                        // Look for a posting...
@@ -145,7 +151,7 @@
                return false;
        }
 
-       function formatPathLine( $path, $action ) {
+       protected function formatPathLine( $path, $action ) {
                $desc = wfMsgHtml( 'code-rev-modified-'.strtolower( $action ) );
                // Find any ' (from x)' from rename comment in the path.
                preg_match( '/ \([^\)]+\)$/', $path, $matches );
@@ -178,7 +184,7 @@
                return "<li>$link ($desc)$diff</li>\n";
        }
        
-       function tagForm() {
+       protected function tagForm() {
                global $wgUser;
                $tags = $this->mRev->getTags();
                $list = '';
@@ -209,7 +215,7 @@
                }
        }
        
-       function buildStatusList() {
+       protected function buildStatusList() {
                $states = CodeRevision::getPossibleStates();
                $out = '';
                foreach( $states as $state ) {
@@ -222,7 +228,7 @@
                return $out;
        }
        
-       function addTagForm() {
+       protected function addTagForm() {
                global $wgUser;
                $repo = $this->mRepo->getName();
                $rev = $this->mRev->getId();
@@ -233,14 +239,14 @@
                        '</td></tr></table></div>';
        }
        
-       function formatTag( $tag ) {
+       protected function formatTag( $tag ) {
                global $wgUser;
                $repo = $this->mRepo->getName();
                $special = SpecialPage::getTitleFor( 'Code', "$repo/tag/$tag" );
                return $this->mSkin->link( $special, htmlspecialchars( $tag ) );
        }
 
-       function formatDiff() {
+       protected function formatDiff() {
                global $wgEnableAPI;
                
                // Asynchronous diff loads will require the API
@@ -269,7 +275,7 @@
                return $hilite->render( $diff );
        }
        
-       function stubDiffLoader() {
+       protected function stubDiffLoader() {
                global $wgOut, $wgScriptPath;
                $encRepo = Xml::encodeJsVar( $this->mRepo->getName() );
                $encRev = Xml::encodeJsVar( $this->mRev->getId() );
@@ -283,19 +289,27 @@
                return "Loading diff...";
        }
 
-       function formatComments() {
+       protected function formatComments() {
                $comments = implode( "\n",
-                               array_map(
-                                       array( $this, 'formatCommentInline' ),
-                                       $this->mRev->getComments() ) ) .
-                       $this->postCommentForm();
+                       array_map( array( $this, 'formatCommentInline' ), 
$this->mRev->getComments() )
+               ) . $this->postCommentForm();
                if( !$comments ) {
                        return false;
                }
                return "<div class='mw-codereview-comments'>$comments</div>";
        }
+       
+       protected function formatPropChanges() {
+               $changes = implode( "\n",
+                       array_map( array( $this, 'formatChangeInline' ), 
$this->mRev->getPropChanges() )
+               );
+               if( !$changes ) {
+                       return false;
+               }
+               return "<ul class='mw-codereview-changes'>$changes</ul>";
+       }
 
-       function formatCommentInline( $comment ) {
+       protected function formatCommentInline( $comment ) {
                if( $comment->id === $this->mReplyTarget ) {
                        return $this->formatComment( $comment,
                                $this->postCommentForm( $comment->id ) );
@@ -304,7 +318,27 @@
                }
        }
        
-       function commentLink( $commentId ) {
+       protected function formatChangeInline( $change ) {
+               global $wgLang;
+               $line = $wgLang->timeanddate( $change->timestamp, true );
+               $line .= '&nbsp;' . $this->mSkin->userLink( $change->user, 
$change->userText );
+               $line .= $this->mSkin->userToolLinks( $change->user, 
$change->userText );
+               $line .= '&nbsp;' . 
wfMsgExt("code-change-{$change->attrib}",array('parseinline'));
+               $line .= " <i>[";
+               if( $change->removed ) {
+                       $line .= '<b>'.wfMsg('code-change-removed').'</b> ';
+                       $line .= htmlspecialchars($change->removed);
+                       $line .= $change->added ? "&nbsp;" : "";
+               }
+               if( $change->added ) {
+                       $line .= '<b>'.wfMsg('code-change-added').'</b> ';
+                       $line .=  htmlspecialchars($change->added);
+               }
+               $line .= "]</i>";
+               return "<li>$line</li>";
+       }
+       
+       protected function commentLink( $commentId ) {
                $repo = $this->mRepo->getName();
                $rev = $this->mRev->getId();
                $title = SpecialPage::getTitleFor( 'Code', "$repo/$rev" );
@@ -312,19 +346,19 @@
                return $title;
        }
        
-       function revLink() {
+       protected function revLink() {
                $repo = $this->mRepo->getName();
                $rev = $this->mRev->getId();
                $title = SpecialPage::getTitleFor( 'Code', "$repo/$rev" );
                return $title;
        }       
        
-       function previewComment( $text, $review=0 ) {
+       protected function previewComment( $text, $review=0 ) {
                $comment = $this->mRev->previewComment( $text, $review );
                return $this->formatComment( $comment );
        }
        
-       function formatComment( $comment, $replyForm='' ) {
+       protected function formatComment( $comment, $replyForm='' ) {
                global $wgOut, $wgLang;
                $linker = new CodeCommentLinkerWiki( $this->mRepo );
                
@@ -358,13 +392,13 @@
                        '</div>';
        }
 
-       function commentStyle( $comment ) {
+       protected function commentStyle( $comment ) {
                $depth = $comment->threadDepth();
                $margin = ($depth - 1) * 48;
                return "margin-left: ${margin}px";
        }
        
-       function commentReplyLink( $id ) {
+       protected function commentReplyLink( $id ) {
                $repo = $this->mRepo->getName();
                $rev = $this->mRev->getId();
                $self = SpecialPage::getTitleFor( 'Code', 
"$repo/$rev/reply/$id" );
@@ -374,7 +408,7 @@
                        ']';
        }
        
-       function postCommentForm( $parent=null ) {
+       protected function postCommentForm( $parent=null ) {
                global $wgUser;
                if( $this->mPreviewText != false && $parent === 
$this->mReplyTarget ) {
                        $preview = $this->previewComment( $this->mPreviewText );



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to