r48132 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48131‎ | r48132 | r48133 >
Date:17:14, 7 March 2009
Author:siebrand
Status:ok
Tags:
Comment:
* add a few comments with full message names used where the message name is composed of a prefix with and action or something else
* stylize.php for all php files
* trailing whitespace removed
Modified paths:
  • /trunk/extensions/CodeReview/ApiCodeComments.php (modified) (history)
  • /trunk/extensions/CodeReview/ApiCodeDiff.php (modified) (history)
  • /trunk/extensions/CodeReview/ApiCodeUpdate.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeAuthorListView.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeComment.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeCommentsListView.php (modified) (history)
  • /trunk/extensions/CodeReview/CodePropChange.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeReleaseNotes.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeRepoListView.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeRepository.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeReview.alias.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeReview.i18n.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeReview.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeRevision.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeRevisionAuthorLink.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeRevisionAuthorView.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeRevisionCommitter.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeRevisionListView.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeRevisionStatusView.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeRevisionTagView.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeRevisionView.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeStatusListView.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeTagListView.php (modified) (history)
  • /trunk/extensions/CodeReview/DiffHighlighter.php (modified) (history)
  • /trunk/extensions/CodeReview/SpecialCode.php (modified) (history)
  • /trunk/extensions/CodeReview/SpecialRepoAdmin.php (modified) (history)
  • /trunk/extensions/CodeReview/Subversion.php (modified) (history)
  • /trunk/extensions/CodeReview/codereview.js (modified) (history)
  • /trunk/extensions/CodeReview/codereview.sql (modified) (history)
  • /trunk/extensions/CodeReview/svnImport.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/codereview.sql
@@ -45,7 +45,7 @@
4646 -- This is *not* wikitext, but will get some light formatting
4747 -- on display...
4848 cr_message blob,
49 -
 49+
5050 -- Status key for how this thang is...
5151 -- 'new': Hasn't yet been reviewed
5252 -- 'fixme': This revision has some problem which needs to be resolved
@@ -58,7 +58,7 @@
5959 -- * if the revision change only one file, the file path
6060 -- * else, common directory for all changes (e.g. trunk/phase3/includes/ )
6161 cr_path varchar(255) binary,
62 -
 62+
6363 -- Text of the diff or ES url
6464 cr_diff mediumblob NULL,
6565 -- Text flags: gzip,utf-8,external
Index: trunk/extensions/CodeReview/ApiCodeUpdate.php
@@ -4,39 +4,39 @@
55
66 public function execute() {
77 $params = $this->extractRequestParams();
8 -
9 - if( !isset( $params['repo'] ) ) {
 8+
 9+ if ( !isset( $params['repo'] ) ) {
1010 $this->dieUsageMsg( array( 'missingparam', 'repo' ) );
1111 }
12 - if( !isset( $params['rev'] ) ) {
 12+ if ( !isset( $params['rev'] ) ) {
1313 $this->dieUsageMsg( array( 'missingparam', 'rev' ) );
1414 }
15 -
 15+
1616 $repo = CodeRepository::newFromName( $params['repo'] );
17 - if( !$repo ){
18 - $this->dieUsage("Invalid repo ``{$params['repo']}''", 'invalidrepo');
 17+ if ( !$repo ) {
 18+ $this->dieUsage( "Invalid repo ``{$params['repo']}''", 'invalidrepo' );
1919 }
20 -
 20+
2121 $svn = SubversionAdaptor::newFromRepo( $repo->getPath() );
2222 $lastStoredRev = $repo->getLastStoredRev();
23 -
24 - if( $lastStoredRev >= $params['rev'] ) {
 23+
 24+ if ( $lastStoredRev >= $params['rev'] ) {
2525 // Nothing to do, we're up to date.
2626 // Return an empty result
27 - $this->getResult()->addValue(null, $this->getModuleName(), array());
 27+ $this->getResult()->addValue( null, $this->getModuleName(), array() );
2828 return;
2929 }
30 -
 30+
3131 // FIXME: this could be a lot?
3232 $log = $svn->getLog( '', $lastStoredRev + 1, $params['rev'] );
33 - if( !$log ) {
 33+ if ( !$log ) {
3434 // FIXME: When and how often does this happen?
3535 // Should we use dieUsage() here instead?
3636 ApiBase::dieDebug( __METHOD__, "Something awry..." );
37 - }
38 -
 37+ }
 38+
3939 $result = array();
40 - foreach( $log as $data ) {
 40+ foreach ( $log as $data ) {
4141 $codeRev = CodeRevision::newFromSvn( $repo, $data );
4242 $codeRev->save();
4343 $result[] = array(
@@ -48,20 +48,20 @@
4949 }
5050 // Cache the diffs if there are a only a few.
5151 // Mainly for WMF post-commit ping hook...
52 - if( count($result) <= 2 ) {
53 - foreach( $result as $revData ) {
 52+ if ( count( $result ) <= 2 ) {
 53+ foreach ( $result as $revData ) {
5454 $diff = $repo->getDiff( $revData['id'] ); // trigger caching
5555 }
5656 }
57 - $this->getResult()->setIndexedTagName($result, 'rev');
58 - $this->getResult()->addValue(null, $this->getModuleName(), $result);
 57+ $this->getResult()->setIndexedTagName( $result, 'rev' );
 58+ $this->getResult()->addValue( null, $this->getModuleName(), $result );
5959 }
60 -
 60+
6161 public function mustBePosted() {
6262 // Discourage casual browsing :)
6363 return true;
6464 }
65 -
 65+
6666 public function getAllowedParams() {
6767 return array(
6868 'repo' => null,
@@ -71,24 +71,24 @@
7272 )
7373 );
7474 }
75 -
 75+
7676 public function getParamDescription() {
7777 return array(
7878 'repo' => 'Name of repository to update',
7979 'rev' => 'Revision ID number to update to' );
8080 }
81 -
 81+
8282 public function getDescription() {
8383 return array(
8484 'Update CodeReview repository data from master revision control system.' );
8585 }
86 -
 86+
8787 public function getExamples() {
8888 return array(
8989 'api.php?action=codeupdate&repo=MediaWiki&rev=42080',
9090 );
9191 }
92 -
 92+
9393 public function getVersion() {
9494 return __CLASS__ . ': $Id$';
9595 }
Index: trunk/extensions/CodeReview/CodeRevisionAuthorView.php
@@ -6,13 +6,13 @@
77 $this->mAuthor = $author;
88 $this->mUser = $this->authorWikiUser( $author );
99 }
10 -
 10+
1111 function getPager() {
1212 return new SvnRevAuthorTablePager( $this, $this->mAuthor );
1313 }
1414
1515 function linkStatus() {
16 - if ( !$this->mUser )
 16+ if ( !$this->mUser )
1717 return wfMsg( 'code-author-orphan' );
1818
1919 return wfMsgHtml( 'code-author-haslink',
@@ -27,9 +27,9 @@
2828
2929 if ( $wgUser->isAllowed( 'codereview-link-user' ) ) {
3030 $repo = $this->mRepo->getName();
31 - $page = SpecialPage::getTitleFor( 'Code', "$repo/author/$this->mAuthor/link");
32 - $linkInfo .= ' (' . $this->mSkin->link( $page,
33 - wfMsg( 'code-author-' . ($this->mUser?'un':'') . 'link') ) . ')' ;
 31+ $page = SpecialPage::getTitleFor( 'Code', "$repo/author/$this->mAuthor/link" );
 32+ $linkInfo .= ' (' . $this->mSkin->link( $page,
 33+ wfMsg( 'code-author-' . ( $this->mUser ? 'un':'' ) . 'link' ) ) . ')' ;
3434 }
3535
3636 $repoLink = $wgUser->getSkin()->link( SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() ),
@@ -39,7 +39,7 @@
4040 'code-rev-author' => $this->authorLink( $this->mAuthor ),
4141 );
4242
43 - $wgOut->addHTML($this->formatMetaData( $fields ) . $linkInfo );
 43+ $wgOut->addHTML( $this->formatMetaData( $fields ) . $linkInfo );
4444
4545 parent::execute();
4646 }
@@ -51,14 +51,14 @@
5252 parent::__construct( $view );
5353 $this->mAuthor = $author;
5454 }
55 -
 55+
5656 function getQueryInfo() {
5757 $info = parent::getQueryInfo();
5858 $info['conds']['cr_author'] = $this->mAuthor; // fixme: normalize input?
5959 return $info;
6060 }
6161
62 - function getTitle(){
 62+ function getTitle() {
6363 $repo = $this->mRepo->getName();
6464 return SpecialPage::getTitleFor( 'Code', "$repo/author/$this->mAuthor" );
6565 }
Index: trunk/extensions/CodeReview/CodeRevisionCommitter.php
@@ -2,61 +2,61 @@
33
44 class CodeRevisionCommitter extends CodeRevisionView {
55
6 - function __construct( $repoName, $rev ){
 6+ function __construct( $repoName, $rev ) {
77 // Parent should set $this->mRepo, $this->mRev, $this->mReplyTarget
88 parent::__construct( $repoName, $rev );
99 }
1010
1111 function execute() {
1212 global $wgRequest, $wgOut, $wgUser;
13 -
14 - if( !$wgUser->matchEditToken( $wgRequest->getVal('wpEditToken') ) ) {
15 - $wgOut->addHTML( '<strong>' . wfMsg('sessionfailure') . '</strong>' );
 13+
 14+ if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
 15+ $wgOut->addHTML( '<strong>' . wfMsg( 'sessionfailure' ) . '</strong>' );
1616 parent::execute();
1717 return;
1818 }
19 - if( !$this->mRev ) {
 19+ if ( !$this->mRev ) {
2020 parent::execute();
2121 return;
2222 }
23 -
 23+
2424 $redirTarget = null;
2525 $dbw = wfGetDB( DB_MASTER );
26 -
 26+
2727 $dbw->begin();
2828 // Change the status if allowed
29 - if( $this->validPost('codereview-set-status') && $this->mRev->isValidStatus($this->mStatus) ) {
 29+ if ( $this->validPost( 'codereview-set-status' ) && $this->mRev->isValidStatus( $this->mStatus ) ) {
3030 $this->mRev->setStatus( $this->mStatus, $wgUser );
3131 }
3232 $addTags = $removeTags = array();
33 - if( $this->validPost('codereview-add-tag') && count($this->mAddTags) ) {
 33+ if ( $this->validPost( 'codereview-add-tag' ) && count( $this->mAddTags ) ) {
3434 $addTags = $this->mAddTags;
3535 }
36 - if( $this->validPost('codereview-remove-tag') && count($this->mRemoveTags) ) {
 36+ if ( $this->validPost( 'codereview-remove-tag' ) && count( $this->mRemoveTags ) ) {
3737 $removeTags = $this->mRemoveTags;
3838 }
3939 // If allowed to change any tags, then do so
40 - if( count($addTags) || count($removeTags) ) {
 40+ if ( count( $addTags ) || count( $removeTags ) ) {
4141 $this->mRev->changeTags( $addTags, $removeTags, $wgUser );
4242 }
4343 // Add any comments
44 - if( $this->validPost('codereview-post-comment') && strlen($this->text) ) {
 44+ if ( $this->validPost( 'codereview-post-comment' ) && strlen( $this->text ) ) {
4545 $parent = $wgRequest->getIntOrNull( 'wpParent' );
4646 $review = $wgRequest->getInt( 'wpReview' );
4747 $isPreview = $wgRequest->getCheck( 'wpPreview' );
4848 $id = $this->mRev->saveComment( $this->text, $review, $parent );
4949 // For comments, take us back to the rev page focused on the new comment
50 - if( !$this->jumpToNext ) {
 50+ if ( !$this->jumpToNext ) {
5151 $redirTarget = $this->commentLink( $id );
5252 }
5353 }
5454 $dbw->commit();
55 -
 55+
5656 // Return to rev page
57 - if( !$redirTitle ) {
58 - if( $this->jumpToNext ) {
59 - if( $next = $this->mRev->getNextUnresolved() ) {
60 - $redirTitle = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName().'/'.$next );
 57+ if ( !$redirTitle ) {
 58+ if ( $this->jumpToNext ) {
 59+ if ( $next = $this->mRev->getNextUnresolved() ) {
 60+ $redirTitle = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/' . $next );
6161 } else {
6262 $redirTitle = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() );
6363 }
@@ -67,10 +67,10 @@
6868 }
6969 $wgOut->redirect( $redirTitle->getFullUrl() );
7070 }
71 -
 71+
7272 public function validPost( $permission ) {
7373 global $wgUser, $wgRequest;
74 - return parent::validPost($permission) && $wgRequest->wasPosted()
75 - && $wgUser->matchEditToken( $wgRequest->getVal('wpEditToken') );
 74+ return parent::validPost( $permission ) && $wgRequest->wasPosted()
 75+ && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) );
7676 }
7777 }
Index: trunk/extensions/CodeReview/CodeRevisionListView.php
@@ -8,7 +8,7 @@
99 parent::__construct();
1010 $this->mRepo = CodeRepository::newFromName( $repoName );
1111 $this->mPath = htmlspecialchars( trim( $wgRequest->getVal( 'path' ) ) );
12 - if( strlen($this->mPath) && $this->mPath[0] !== '/' ) {
 12+ if ( strlen( $this->mPath ) && $this->mPath[0] !== '/' ) {
1313 $this->mPath = "/{$this->mPath}"; // make sure this is a valid path
1414 }
1515 $this->mAuthor = null;
@@ -16,133 +16,133 @@
1717
1818 function execute() {
1919 global $wgOut, $wgUser, $wgRequest;
20 - if( !$this->mRepo ) {
 20+ if ( !$this->mRepo ) {
2121 $view = new CodeRepoListView();
2222 $view->execute();
2323 return;
2424 }
25 -
 25+
2626 // Check for batch change requests.
2727 $editToken = $wgRequest->getVal( 'wpBatchChangeEditToken' );
28 - if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $editToken ) ) {
 28+ if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $editToken ) ) {
2929 $this->doBatchChange();
3030 return;
3131 }
32 -
 32+
3333 $this->showForm();
3434 $pager = $this->getPager();
35 -
 35+
3636 // Build batch change interface as needed
37 - $this->batchForm = $wgUser->isAllowed('codereview-set-status') ||
38 - $wgUser->isAllowed('codereview-add-tag');
39 -
40 - $wgOut->addHTML(
 37+ $this->batchForm = $wgUser->isAllowed( 'codereview-set-status' ) ||
 38+ $wgUser->isAllowed( 'codereview-add-tag' );
 39+
 40+ $wgOut->addHTML(
4141 $pager->getNavigationBar() .
42 - $pager->getLimitForm() .
43 - Xml::openElement( 'form',
 42+ $pager->getLimitForm() .
 43+ Xml::openElement( 'form',
4444 array( 'action' => $pager->getTitle()->getLocalURL(), 'method' => 'post' )
4545 ) .
46 - $pager->getBody() .
 46+ $pager->getBody() .
4747 $pager->getNavigationBar() .
48 - ( $this->batchForm ? $this->buildBatchInterface( $pager ) : "" ).
 48+ ( $this->batchForm ? $this->buildBatchInterface( $pager ) : "" ) .
4949 Xml::closeElement( 'form' )
5050 );
5151 }
52 -
 52+
5353 function doBatchChange() {
5454 global $wgRequest;
55 -
 55+
5656 $revisions = $wgRequest->getArray( 'wpRevisionSelected' );
5757 $removeTags = $wgRequest->getVal( 'wpRemoveTag' );
5858 $addTags = $wgRequest->getVal( 'wpTag' );
5959 $status = $wgRequest->getVal( 'wpStatus' );
60 -
 60+
6161 // Grab data from the DB
6262 $dbr = wfGetDB( DB_SLAVE );
6363 $revObjects = array();
6464 $res = $dbr->select( 'code_rev', '*', array( 'cr_id' => $revisions ), __METHOD__ );
65 - while( $row = $dbr->fetchObject( $res ) ) {
 65+ while ( $row = $dbr->fetchObject( $res ) ) {
6666 $revObjects[] = CodeRevision::newFromRow( $this->mRepo, $row );
6767 }
68 -
 68+
6969 global $wgUser;
7070 if ( $wgUser->isAllowed( 'codereview-add-tag' ) &&
7171 $addTags || $removeTags ) {
7272 $addTags = array_map( 'trim', explode( ",", $addTags ) );
7373 $removeTags = array_map( 'trim', explode( ",", $removeTags ) );
74 -
75 - foreach( $revObjects as $id => $rev ) {
 74+
 75+ foreach ( $revObjects as $id => $rev ) {
7676 $rev->changeTags( $addTags, $removeTags, $wgUser );
7777 }
7878 }
79 -
80 - if( $wgUser->isAllowed( 'codereview-set-status' ) &&
 79+
 80+ if ( $wgUser->isAllowed( 'codereview-set-status' ) &&
8181 $revObjects[0]->isValidStatus( $status ) ) {
82 - foreach( $revObjects as $id => $rev ) {
 82+ foreach ( $revObjects as $id => $rev ) {
8383 $rev->setStatus( $status, $wgUser );
8484 }
8585 }
86 -
 86+
8787 // Automatically refresh
8888 // This way of getting GET parameters is horrible, but effective.
8989 $fields = array_merge( $_GET, $_POST );
90 - foreach( array_keys( $fields ) as $key ) {
 90+ foreach ( array_keys( $fields ) as $key ) {
9191 if ( substr( $key, 0, 2 ) == 'wp' || $key == 'title' )
9292 unset( $fields[$key] );
9393 }
94 -
 94+
9595 global $wgOut;
9696 $wgOut->redirect( $this->getPager()->getTitle()->getFullURL( $fields ) );
9797 }
98 -
 98+
9999 protected function buildBatchInterface( $pager ) {
100100 global $wgUser;
101 -
 101+
102102 $changeInterface = '';
103103 $changeFields = array();
104 -
105 - if( $wgUser->isAllowed( 'codereview-set-status' ) ) {
 104+
 105+ if ( $wgUser->isAllowed( 'codereview-set-status' ) ) {
106106 $changeFields['code-batch-status'] =
107 - Xml::tags( 'select', array( 'name' => 'wpStatus' ),
 107+ Xml::tags( 'select', array( 'name' => 'wpStatus' ),
108108 Xml::tags( 'option',
109109 array( 'value' => '', 'selected' => 'selected' ), ' '
110110 ) .
111111 CodeRevisionView::buildStatusList( null, $this )
112112 );
113113 }
114 -
115 - if( $wgUser->isAllowed( 'codereview-add-tag' ) ) {
 114+
 115+ if ( $wgUser->isAllowed( 'codereview-add-tag' ) ) {
116116 $changeFields['code-batch-tags'] = CodeRevisionView::addTagForm( '', '' );
117117 }
118 -
119 - if( !count($changeFields) ) return ''; // nothing to do here
120 -
121 - $changeInterface = Xml::fieldset( wfMsg('codereview-batch-title'),
 118+
 119+ if ( !count( $changeFields ) ) return ''; // nothing to do here
 120+
 121+ $changeInterface = Xml::fieldset( wfMsg( 'codereview-batch-title' ),
122122 Xml::buildForm( $changeFields, 'codereview-batch-submit' ) );
123 -
 123+
124124 $changeInterface .= $pager->getHiddenFields();
125125 $changeInterface .= Xml::hidden( 'wpBatchChangeEditToken', $wgUser->editToken() );
126 -
 126+
127127 return $changeInterface;
128128 }
129 -
 129+
130130 function showForm( $path = '' ) {
131131 global $wgOut, $wgScript;
132 - if( $this->mAuthor ) {
133 - $special = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName().'/author/'.$this->mAuthor );
 132+ if ( $this->mAuthor ) {
 133+ $special = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/author/' . $this->mAuthor );
134134 } else {
135 - $special = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName().'/path' );
 135+ $special = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/path' );
136136 }
137 - $wgOut->addHTML(
 137+ $wgOut->addHTML(
138138 Xml::openElement( 'form', array( 'action' => $wgScript, 'method' => 'get' ) ) .
139 - "<fieldset><legend>".wfMsgHtml('code-pathsearch-legend')."</legend>" .
 139+ "<fieldset><legend>" . wfMsgHtml( 'code-pathsearch-legend' ) . "</legend>" .
140140 Xml::hidden( 'title', $special->getPrefixedDBKey() ) .
141 - Xml::inputlabel( wfMsg("code-pathsearch-path"), 'path', 'path', 55, $this->mPath ) .
 141+ Xml::inputlabel( wfMsg( "code-pathsearch-path" ), 'path', 'path', 55, $this->mPath ) .
142142 '&nbsp;' . Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" .
143143 "</fieldset>" . Xml::closeElement( 'form' )
144144 );
145145 }
146 -
 146+
147147 function getPager() {
148148 return new SvnRevTablePager( $this );
149149 }
@@ -159,7 +159,7 @@
160160 $this->mCurSVN = SpecialVersion::getSvnRevision( $IP );
161161 parent::__construct();
162162 }
163 -
 163+
164164 function getSVNPath() {
165165 return $this->mView->mPath;
166166 }
@@ -174,18 +174,18 @@
175175
176176 function getQueryInfo() {
177177 // Path-based query...
178 - if( $this->getDefaultSort() === 'cp_rev_id' ) {
 178+ if ( $this->getDefaultSort() === 'cp_rev_id' ) {
179179 return array(
180180 'tables' => array( 'code_paths', 'code_rev', 'code_comment' ),
181181 'fields' => $this->getSelectFields(),
182 - 'conds' => array(
 182+ 'conds' => array(
183183 'cp_repo_id' => $this->mRepo->getId(),
184 - 'cp_path LIKE '.$this->mDb->addQuotes($this->mDb->escapeLike( $this->getSVNPath() ).'%'),
 184+ 'cp_path LIKE ' . $this->mDb->addQuotes( $this->mDb->escapeLike( $this->getSVNPath() ) . '%' ),
185185 // performance
186 - 'cp_rev_id > '.$this->mRepo->getLastStoredRev() - 20000
 186+ 'cp_rev_id > ' . $this->mRepo->getLastStoredRev() - 20000
187187 ),
188 - 'options' => array( 'GROUP BY' => 'cp_rev_id', 'USE INDEX' => array('code_path' => 'cp_repo_id') ),
189 - 'join_conds' => array(
 188+ 'options' => array( 'GROUP BY' => 'cp_rev_id', 'USE INDEX' => array( 'code_path' => 'cp_repo_id' ) ),
 189+ 'join_conds' => array(
190190 'code_rev' => array( 'INNER JOIN', 'cr_repo_id = cp_repo_id AND cr_id = cp_rev_id' ),
191191 'code_comment' => array( 'LEFT JOIN', 'cc_repo_id = cp_repo_id AND cc_rev_id = cp_rev_id' )
192192 )
@@ -197,14 +197,14 @@
198198 'fields' => $this->getSelectFields(),
199199 'conds' => array( 'cr_repo_id' => $this->mRepo->getId() ),
200200 'options' => array( 'GROUP BY' => 'cr_id' ),
201 - 'join_conds' => array(
202 - 'code_comment' => array('LEFT JOIN','cc_repo_id = cr_repo_id AND cc_rev_id = cr_id')
 201+ 'join_conds' => array(
 202+ 'code_comment' => array( 'LEFT JOIN', 'cc_repo_id = cr_repo_id AND cc_rev_id = cr_id' )
203203 )
204204 );
205205 }
206206 return false;
207207 }
208 -
 208+
209209 function getSelectFields() {
210210 return array( $this->getDefaultSort(), 'cr_status', 'COUNT( DISTINCT cc_id ) AS comments',
211211 'cr_path', 'cr_message', 'cr_author', 'cr_timestamp' );
@@ -221,14 +221,14 @@
222222 'cr_timestamp' => wfMsg( 'code-field-timestamp' ),
223223 );
224224 # Only show checkboxen as needed
225 - if( !empty($this->mView->batchForm) ) {
226 - $fields = array('selectforchange' => wfMsg('code-field-select') ) + $fields;
 225+ if ( !empty( $this->mView->batchForm ) ) {
 226+ $fields = array( 'selectforchange' => wfMsg( 'code-field-select' ) ) + $fields;
227227 }
228228 return $fields;
229229 }
230 -
231 - function formatValue( $name, $value ) {} // unused
232 -
 230+
 231+ function formatValue( $name, $value ) { } // unused
 232+
233233 function formatRevValue( $name, $value, $row ) {
234234 global $wgUser, $wgLang;
235235 switch( $name ) {
@@ -253,8 +253,8 @@
254254 global $wgLang;
255255 return $wgLang->timeanddate( $value, true );
256256 case 'comments':
257 - if( $value ) {
258 - $special = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName().'/'.$row->{$this->getDefaultSort()} );
 257+ if ( $value ) {
 258+ $special = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/' . $row-> { $this->getDefaultSort() } );
259259 $special->setFragment( '#code-comments' );
260260 return $this->mView->mSkin->link( $special, htmlspecialchars( $value ) );
261261 } else {
@@ -267,22 +267,22 @@
268268 $wgLang->truncate( (string)$value, 30 ) ) . "</div>";
269269 }
270270 }
271 -
 271+
272272 // Note: this function is poorly factored in the parent class
273273 function formatRow( $row ) {
274274 global $wgWikiSVN;
275275 $css = "mw-codereview-status-{$row->cr_status}";
276 - if( $this->mRepo->mName == $wgWikiSVN ) {
277 - $css .= " mw-codereview-" . ( $row->{$this->getDefaultSort()} <= $this->mCurSVN ? 'live' : 'notlive' );
 276+ if ( $this->mRepo->mName == $wgWikiSVN ) {
 277+ $css .= " mw-codereview-" . ( $row-> { $this->getDefaultSort() } <= $this->mCurSVN ? 'live' : 'notlive' );
278278 }
279279 $s = "<tr class=\"$css\">\n";
280280 // Some of this stolen from Pager.php...sigh
281281 $fieldNames = $this->getFieldNames();
282282 $this->mCurrentRow = $row; # In case formatValue needs to know
283 - foreach( $fieldNames as $field => $name ) {
 283+ foreach ( $fieldNames as $field => $name ) {
284284 $value = isset( $row->$field ) ? $row->$field : null;
285285 $formatted = strval( $this->formatRevValue( $field, $value, $row ) );
286 - if( $formatted == '' ) {
 286+ if ( $formatted == '' ) {
287287 $formatted = '&nbsp;';
288288 }
289289 $class = 'TablePager_col_' . htmlspecialchars( $field );
@@ -291,7 +291,7 @@
292292 $s .= "</tr>\n";
293293 return $s;
294294 }
295 -
 295+
296296 function getTitle() {
297297 return SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() );
298298 }
Index: trunk/extensions/CodeReview/CodeReleaseNotes.php
@@ -6,20 +6,20 @@
77 parent::__construct( $repoName );
88 $this->mRepo = CodeRepository::newFromName( $repoName );
99 $this->mPath = htmlspecialchars( trim( $wgRequest->getVal( 'path' ) ) );
10 - if( strlen($this->mPath) && $this->mPath[0] !== '/' ) {
 10+ if ( strlen( $this->mPath ) && $this->mPath[0] !== '/' ) {
1111 $this->mPath = "/{$this->mPath}"; // make sure this is a valid path
1212 }
1313 $this->mPath = preg_replace( '/\/$/', '', $this->mPath ); // kill last slash
14 - $this->mStartRev = $wgRequest->getIntOrNull('startrev');
15 - $this->mEndRev = $wgRequest->getIntOrNull('endrev');
 14+ $this->mStartRev = $wgRequest->getIntOrNull( 'startrev' );
 15+ $this->mEndRev = $wgRequest->getIntOrNull( 'endrev' );
1616 # Default start rev to last live one if possible
17 - if( !$this->mStartRev && $this->mRepo && $this->mRepo->getName() == $wgWikiSVN ) {
 17+ if ( !$this->mStartRev && $this->mRepo && $this->mRepo->getName() == $wgWikiSVN ) {
1818 $this->mStartRev = SpecialVersion::getSvnRevision( $IP ) + 1;
1919 }
2020 }
21 -
 21+
2222 function execute() {
23 - if( !$this->mRepo ) {
 23+ if ( !$this->mRepo ) {
2424 $view = new CodeRepoListView();
2525 $view->execute();
2626 return;
@@ -27,49 +27,49 @@
2828 $this->showForm();
2929 # Sanity/performance check...
3030 $lastRev = $this->mRepo->getLastStoredRev();
31 - if( $this->mStartRev < ($lastRev - 3000) )
 31+ if ( $this->mStartRev < ( $lastRev - 3000 ) )
3232 $this->mStartRev = NULL;
3333 # Show notes if we have at least a starting revision
34 - if( $this->mStartRev ) {
 34+ if ( $this->mStartRev ) {
3535 $this->showReleaseNotes();
3636 }
3737 }
38 -
 38+
3939 protected function showForm() {
4040 global $wgOut, $wgScript, $wgUser;
41 - $special = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName().'/releasenotes' );
42 - $wgOut->addHTML(
 41+ $special = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/releasenotes' );
 42+ $wgOut->addHTML(
4343 Xml::openElement( 'form', array( 'action' => $wgScript, 'method' => 'get' ) ) .
44 - "<fieldset><legend>".wfMsgHtml('code-release-legend')."</legend>" .
 44+ "<fieldset><legend>" . wfMsgHtml( 'code-release-legend' ) . "</legend>" .
4545 Xml::hidden( 'title', $special->getPrefixedDBKey() ) . '<b>' .
46 - Xml::inputlabel( wfMsg("code-release-startrev"), 'startrev', 'startrev', 10, $this->mStartRev ) .
 46+ Xml::inputlabel( wfMsg( "code-release-startrev" ), 'startrev', 'startrev', 10, $this->mStartRev ) .
4747 '</b>&nbsp;' .
48 - Xml::inputlabel( wfMsg("code-release-endrev"), 'endrev', 'endrev', 10, $this->mEndRev ) .
 48+ Xml::inputlabel( wfMsg( "code-release-endrev" ), 'endrev', 'endrev', 10, $this->mEndRev ) .
4949 '&nbsp;' .
50 - Xml::inputlabel( wfMsg("code-pathsearch-path"), 'path', 'path', 45, $this->mPath ) .
 50+ Xml::inputlabel( wfMsg( "code-pathsearch-path" ), 'path', 'path', 45, $this->mPath ) .
5151 '&nbsp;' .
5252 Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" .
5353 "</fieldset>" . Xml::closeElement( 'form' )
5454 );
5555 }
56 -
 56+
5757 protected function showReleaseNotes() {
5858 global $wgOut;
5959 $linker = new CodeCommentLinkerWiki( $this->mRepo );
6060 $dbr = wfGetDB( DB_SLAVE );
61 - if( $this->mEndRev ) {
62 - $where = 'cr_id BETWEEN '.intval($this->mStartRev).' AND '.intval($this->mEndRev);
 61+ if ( $this->mEndRev ) {
 62+ $where = 'cr_id BETWEEN ' . intval( $this->mStartRev ) . ' AND ' . intval( $this->mEndRev );
6363 } else {
64 - $where = 'cr_id >= '.intval($this->mStartRev);
 64+ $where = 'cr_id >= ' . intval( $this->mStartRev );
6565 }
66 - if( $this->mPath ) {
67 - $where .= ' AND (cr_path LIKE '.$dbr->addQuotes( $dbr->escapeLike("{$this->mPath}/").'%');
68 - $where .= ' OR cr_path = '.$dbr->addQuotes($this->mPath).')';
 66+ if ( $this->mPath ) {
 67+ $where .= ' AND (cr_path LIKE ' . $dbr->addQuotes( $dbr->escapeLike( "{$this->mPath}/" ) . '%' );
 68+ $where .= ' OR cr_path = ' . $dbr->addQuotes( $this->mPath ) . ')';
6969 }
7070 # Select commits within this range...
71 - $res = $dbr->select( array('code_rev','code_tags'),
72 - array('cr_message','cr_author','cr_id','ct_tag AS rnotes'),
73 - array(
 71+ $res = $dbr->select( array( 'code_rev', 'code_tags' ),
 72+ array( 'cr_message', 'cr_author', 'cr_id', 'ct_tag AS rnotes' ),
 73+ array(
7474 'cr_repo_id' => $this->mRepo->getId(), // this repo
7575 "cr_status NOT IN('reverted','deferred','fixme')", // not reverted/deferred/fixme
7676 "cr_message != ''",
@@ -77,24 +77,24 @@
7878 ),
7979 __METHOD__,
8080 array( 'ORDER BY' => 'cr_id DESC' ),
81 - array( 'code_tags' => array('LEFT JOIN', # Tagged for release notes?
82 - 'ct_repo_id = cr_repo_id AND ct_rev_id = cr_id AND ct_tag = "release-notes"')
 81+ array( 'code_tags' => array( 'LEFT JOIN', # Tagged for release notes?
 82+ 'ct_repo_id = cr_repo_id AND ct_rev_id = cr_id AND ct_tag = "release-notes"' )
8383 )
8484 );
8585 $wgOut->addHTML( '<ul>' );
8686 # Output any relevant seeming commits...
87 - while( $row = $dbr->fetchObject( $res ) ) {
88 - $summary = htmlspecialchars($row->cr_message);
 87+ while ( $row = $dbr->fetchObject( $res ) ) {
 88+ $summary = htmlspecialchars( $row->cr_message );
8989 # Add this commit summary if needed.
90 - if( $row->rnotes || $this->isRelevant($summary) ) {
 90+ if ( $row->rnotes || $this->isRelevant( $summary ) ) {
9191 # Keep it short if possible...
9292 $summary = $this->shortenSummary( $summary );
9393 # Anything left? (this can happen with some heuristics)
94 - if( $summary ) {
 94+ if ( $summary ) {
9595 $summary = str_replace( "\n", "<br/>", $summary ); // Newlines -> <br/>
9696 $wgOut->addHTML( "<li>" );
97 - $wikiText = $linker->link($summary) . " ''(".htmlspecialchars($row->cr_author) .
98 - ', ' . $linker->link("r{$row->cr_id}") . ")''";
 97+ $wikiText = $linker->link( $summary ) . " ''(" . htmlspecialchars( $row->cr_author ) .
 98+ ', ' . $linker->link( "r{$row->cr_id}" ) . ")''";
9999 $wgOut->addWikiText( $wikiText, false );
100100 $wgOut->addHTML( "</li>\n" );
101101 }
@@ -102,14 +102,14 @@
103103 }
104104 $wgOut->addHTML( '</ul>' );
105105 }
106 -
 106+
107107 private function shortenSummary( $summary, $first = true ) {
108108 # Astericks often used for point-by-point bullets
109 - if( preg_match('/(^|\n) ?\*/', $summary) ) {
110 - $blurbs = explode('*',$summary);
 109+ if ( preg_match( '/(^|\n) ?\*/', $summary ) ) {
 110+ $blurbs = explode( '*', $summary );
111111 # Double newlines separate importance generally
112 - } else if( strpos($summary,"\n\n") !== false ) {
113 - $blurbs = explode("\n\n",$summary);
 112+ } else if ( strpos( $summary, "\n\n" ) !== false ) {
 113+ $blurbs = explode( "\n\n", $summary );
114114 } else {
115115 return trim( $summary );
116116 }
@@ -117,49 +117,49 @@
118118 $blurbs = array_filter( $blurbs ); # Filter out any garbage
119119 # Doesn't start with '*' and has some length?
120120 # If so, then assume that the top bit is important.
121 - if( count($blurbs) ) {
122 - $header = strpos( ltrim($summary),'*' ) !== 0 && str_word_count($blurbs[0]) >= 5;
 121+ if ( count( $blurbs ) ) {
 122+ $header = strpos( ltrim( $summary ), '*' ) !== 0 && str_word_count( $blurbs[0] ) >= 5;
123123 } else {
124124 $header = false;
125125 }
126126 # Keep it short if possible...
127 - if( count($blurbs) > 1 ) {
 127+ if ( count( $blurbs ) > 1 ) {
128128 $summary = array();
129 - foreach( $blurbs as $blurb ) {
 129+ foreach ( $blurbs as $blurb ) {
130130 # Always show the first bit
131 - if( $header && $first && count($summary) == 0 ) {
132 - $summary[] = $this->shortenSummary($blurb,true);
 131+ if ( $header && $first && count( $summary ) == 0 ) {
 132+ $summary[] = $this->shortenSummary( $blurb, true );
133133 # Is this bit important? Does it mention a revision?
134 - } else if( $this->isRelevant($blurb) || preg_match('/\br(\d+)\b/',$blurb) ) {
135 - $bit = $this->shortenSummary($blurb,false);
136 - if( $bit ) $summary[] = $bit;
 134+ } else if ( $this->isRelevant( $blurb ) || preg_match( '/\br(\d+)\b/', $blurb ) ) {
 135+ $bit = $this->shortenSummary( $blurb, false );
 136+ if ( $bit ) $summary[] = $bit;
137137 }
138138 }
139 - $summary = implode("\n",$summary);
 139+ $summary = implode( "\n", $summary );
140140 } else {
141 - $summary = implode("\n",$blurbs);
 141+ $summary = implode( "\n", $blurbs );
142142 }
143143 return $summary;
144144 }
145 -
 145+
146146 // Quick relevance tests (these *should* be over-inclusive a little if anything)
147147 private function isRelevant( $summary, $whole = true ) {
148148 # Fixed a bug? Mentioned a config var?
149 - if( preg_match( '/\b(bug #?(\d+)|\$[we]g[0-9a-z]{3,50})\b/i', $summary ) )
 149+ if ( preg_match( '/\b(bug #?(\d+)|\$[we]g[0-9a-z]{3,50})\b/i', $summary ) )
150150 return true;
151151 # Sanity check: summary cannot be *too* short to be useful
152 - $words = str_word_count($summary);
153 - if( mb_strlen($summary) < 40 || $words <= 5 )
 152+ $words = str_word_count( $summary );
 153+ if ( mb_strlen( $summary ) < 40 || $words <= 5 )
154154 return false;
155 - # All caps words (like "BREAKING CHANGE"/magic words)?
156 - if( preg_match( '/\b[A-Z]{6,30}\b/', $summary ) )
 155+ # All caps words (like "BREAKING CHANGE"/magic words)?
 156+ if ( preg_match( '/\b[A-Z]{6,30}\b/', $summary ) )
157157 return true;
158158 # Random keywords
159 - if( preg_match( '/\b(wiki|HTML\d|CSS\d|UTF-?8|(Apache|PHP|CGI|Java|Perl|Python|\w+SQL) ?\d?\.?\d?)\b/i', $summary ) )
 159+ if ( preg_match( '/\b(wiki|HTML\d|CSS\d|UTF-?8|(Apache|PHP|CGI|Java|Perl|Python|\w+SQL) ?\d?\.?\d?)\b/i', $summary ) )
160160 return true;
161161 # Are we looking at the whole summary or an aspect of it?
162 - if( $whole ) {
163 - return preg_match('/(^|\n) ?\*/',$summary); # List of items?
 162+ if ( $whole ) {
 163+ return preg_match( '/(^|\n) ?\*/', $summary ); # List of items?
164164 } else {
165165 return true;
166166 }
Index: trunk/extensions/CodeReview/CodeRevisionView.php
@@ -3,7 +3,7 @@
44 // Special:Code/MediaWiki/40696
55 class CodeRevisionView extends CodeView {
66
7 - function __construct( $repoName, $rev, $replyTarget=null ){
 7+ function __construct( $repoName, $rev, $replyTarget = null ) {
88 global $wgRequest;
99 parent::__construct();
1010 $this->mRepo = CodeRepository::newFromName( $repoName );
@@ -11,26 +11,26 @@
1212 $this->mPreviewText = false;
1313 # URL params...
1414 $this->mAddTags = $wgRequest->getText( 'wpTag' );
15 - $this->mRemoveTags =$wgRequest->getText( 'wpRemoveTag' );
16 - $this->mStatus = $wgRequest->getText('wpStatus');
17 - $this->jumpToNext = $wgRequest->getCheck('wpSaveAndNext');
18 - $this->mReplyTarget = $replyTarget ?
 15+ $this->mRemoveTags = $wgRequest->getText( 'wpRemoveTag' );
 16+ $this->mStatus = $wgRequest->getText( 'wpStatus' );
 17+ $this->jumpToNext = $wgRequest->getCheck( 'wpSaveAndNext' );
 18+ $this->mReplyTarget = $replyTarget ?
1919 (int)$replyTarget : $wgRequest->getIntOrNull( 'wpParent' );
2020 $this->text = $wgRequest->getText( "wpReply{$this->mReplyTarget}" );
21 - $this->mSkipCache = ($wgRequest->getVal( 'action' ) == 'purge');
 21+ $this->mSkipCache = ( $wgRequest->getVal( 'action' ) == 'purge' );
2222 # Make tag arrays
2323 $this->mAddTags = $this->splitTags( $this->mAddTags );
2424 $this->mRemoveTags = $this->splitTags( $this->mRemoveTags );
2525 }
2626
27 - function execute(){
 27+ function execute() {
2828 global $wgOut, $wgUser, $wgLang;
29 - if( !$this->mRepo ) {
 29+ if ( !$this->mRepo ) {
3030 $view = new CodeRepoListView();
3131 $view->execute();
3232 return;
3333 }
34 - if( !$this->mRev ) {
 34+ if ( !$this->mRev ) {
3535 $view = new CodeRevisionListView( $this->mRepo->getName() );
3636 $view->execute();
3737 return;
@@ -38,7 +38,7 @@
3939 $this->mStatus = $this->mStatus ? $this->mStatus : $this->mRev->getStatus();
4040
4141 $redirectOnPost = $this->checkPostings();
42 - if( $redirectOnPost ) {
 42+ if ( $redirectOnPost ) {
4343 $wgOut->redirect( $redirectOnPost );
4444 return;
4545 }
@@ -48,16 +48,16 @@
4949 $revText = $this->navigationLinks();
5050 $paths = '';
5151 $modifiedPaths = $this->mRev->getModifiedPaths();
52 - foreach( $modifiedPaths as $row ){
 52+ foreach ( $modifiedPaths as $row ) {
5353 $paths .= $this->formatPathLine( $row->cp_path, $row->cp_action );
5454 }
55 - if( $paths ){
 55+ if ( $paths ) {
5656 $paths = "<div class='mw-codereview-paths'><ul>\n$paths</ul></div>\n";
5757 }
5858 $comments = $this->formatComments();
5959 $commentsLink = "";
60 - if( $comments ) {
61 - $commentsLink = " (<a href=\"#code-comments\">" . wfMsgHtml( 'code-comments' ) ."</a>)\n";
 60+ if ( $comments ) {
 61+ $commentsLink = " (<a href=\"#code-comments\">" . wfMsgHtml( 'code-comments' ) . "</a>)\n";
6262 }
6363 $fields = array(
6464 'code-rev-repo' => $repoLink,
@@ -69,49 +69,49 @@
7070 'code-rev-message' => $this->formatMessage( $this->mRev->getMessage() ),
7171 'code-rev-paths' => $paths,
7272 );
73 - $special = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName().'/'.$this->mRev->getId() );
 73+ $special = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/' . $this->mRev->getId() );
7474
7575 $html = Xml::openElement( 'form', array( 'action' => $special->getLocalUrl(), 'method' => 'post' ) );
7676
77 - if( $wgUser->isAllowed('codereview-post-comment') ) {
 77+ if ( $wgUser->isAllowed( 'codereview-post-comment' ) ) {
7878 $html .= $this->addActionButtons();
7979 }
80 -
 80+
8181 $html .= $this->formatMetaData( $fields );
8282
83 - if( $this->mRev->isDiffable() ) {
 83+ if ( $this->mRev->isDiffable() ) {
8484 $diffHtml = $this->formatDiff();
8585 $html .=
8686 "<h2>" . wfMsgHtml( 'code-rev-diff' ) .
8787 ' <small>[' . $wgUser->getSkin()->makeLinkObj( $special,
88 - wfMsg('code-rev-purge-link'), 'action=purge' ) . ']</small></h2>' .
 88+ wfMsg( 'code-rev-purge-link' ), 'action=purge' ) . ']</small></h2>' .
8989 "<div class='mw-codereview-diff' id='mw-codereview-diff'>" . $diffHtml . "</div>\n";
9090 }
91 - if( $comments ) {
92 - $html .= "<h2 id='code-comments'>". wfMsgHtml( 'code-comments' ) ."</h2>\n" . $comments;
 91+ if ( $comments ) {
 92+ $html .= "<h2 id='code-comments'>" . wfMsgHtml( 'code-comments' ) . "</h2>\n" . $comments;
9393 }
94 -
95 - if( $this->mReplyTarget ) {
 94+
 95+ if ( $this->mReplyTarget ) {
9696 global $wgJsMimeType;
9797 $id = intval( $this->mReplyTarget );
9898 $html .= "<script type=\"$wgJsMimeType\">addOnloadHook(function(){" .
9999 "document.getElementById('wpReplyTo$id').focus();" .
100100 "});</script>\n";
101101 }
102 -
103 - if( $wgUser->isAllowed('codereview-post-comment') ) {
 102+
 103+ if ( $wgUser->isAllowed( 'codereview-post-comment' ) ) {
104104 $html .= $this->addActionButtons();
105105 }
106 -
 106+
107107 $changes = $this->formatPropChanges();
108 - if( $changes ) {
109 - $html .= "<h2 id='code-changes'>". wfMsgHtml( 'code-prop-changes' ) ."</h2>\n" . $changes;
 108+ if ( $changes ) {
 109+ $html .= "<h2 id='code-changes'>" . wfMsgHtml( 'code-prop-changes' ) . "</h2>\n" . $changes;
110110 }
111111 $html .= xml::closeElement( 'form' );
112112
113113 $wgOut->addHTML( $html );
114114 }
115 -
 115+
116116 protected function navigationLinks() {
117117 global $wgLang;
118118
@@ -119,24 +119,24 @@
120120 $prev = $this->mRev->getPrevious();
121121 $next = $this->mRev->getNext();
122122 $repo = $this->mRepo->getName();
123 -
 123+
124124 $links = array();
125 -
126 - if( $prev ) {
 125+
 126+ if ( $prev ) {
127127 $prevTarget = SpecialPage::getTitleFor( 'Code', "$repo/$prev" );
128128 $links[] = '&lt;&nbsp;' . $this->mSkin->link( $prevTarget, "r$prev" );
129129 }
130 -
 130+
131131 $revText = "<b>r$rev</b>";
132132 $viewvc = $this->mRepo->getViewVcBase();
133 - if( $viewvc ){
 133+ if ( $viewvc ) {
134134 $url = htmlspecialchars( "$viewvc/?view=rev&revision=$rev" );
135135 $viewvcTxt = wfMsgHtml( 'code-rev-rev-viewvc' );
136136 $revText .= " (<a href=\"$url\" title=\"revision $rev\">$viewvcTxt</a>)";
137137 }
138138 $links[] = $revText;
139139
140 - if( $next ) {
 140+ if ( $next ) {
141141 $nextTarget = SpecialPage::getTitleFor( 'Code', "$repo/$next" );
142142 $links[] = $this->mSkin->link( $nextTarget, "r$next" ) . '&nbsp;&gt;';
143143 }
@@ -146,13 +146,13 @@
147147
148148 protected function checkPostings() {
149149 global $wgRequest, $wgUser;
150 - if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal('wpEditToken') ) ) {
 150+ if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
151151 // Look for a posting...
152152 $text = $wgRequest->getText( "wpReply{$this->mReplyTarget}" );
153153 $parent = $wgRequest->getIntOrNull( 'wpParent' );
154154 $review = $wgRequest->getInt( 'wpReview' );
155155 $isPreview = $wgRequest->getCheck( 'wpPreview' );
156 - if( $isPreview ) {
 156+ if ( $isPreview ) {
157157 // Save the text for reference on later comment display...
158158 $this->mPreviewText = $text;
159159 }
@@ -161,30 +161,31 @@
162162 }
163163
164164 protected function formatPathLine( $path, $action ) {
165 - $desc = wfMsgHtml( 'code-rev-modified-'.strtolower( $action ) );
 165+ // Uses messages 'code-rev-modified-a', 'code-rev-modified-r', 'code-rev-modified-d', 'code-rev-modified-m'
 166+ $desc = wfMsgHtml( 'code-rev-modified-' . strtolower( $action ) );
166167 // Find any ' (from x)' from rename comment in the path.
167168 preg_match( '/ \([^\)]+\)$/', $path, $matches );
168 - $from = isset($matches[0]) ? $matches[0] : '';
 169+ $from = isset( $matches[0] ) ? $matches[0] : '';
169170 // Remove ' (from x)' from rename comment in the path.
170171 $path = preg_replace( '/ \([^\)]+\)$/', '', $path );
171172 $viewvc = $this->mRepo->getViewVcBase();
172173 $diff = '';
173 - if( $viewvc ) {
 174+ if ( $viewvc ) {
174175 $rev = $this->mRev->getId();
175176 $prev = $rev - 1;
176177 $safePath = wfUrlEncode( $path );
177 - if( $action !== 'D' ) {
 178+ if ( $action !== 'D' ) {
178179 $link = $this->mSkin->makeExternalLink(
179180 "$viewvc$safePath?view=markup&pathrev=$rev",
180181 $path . $from );
181182 } else {
182183 $link = $safePath;
183184 }
184 - if( $action !== 'A' && $action !== 'D' ) {
 185+ if ( $action !== 'A' && $action !== 'D' ) {
185186 $diff = ' (' .
186187 $this->mSkin->makeExternalLink(
187 - "$viewvc$safePath?&pathrev=$rev&r1=$prev&r2=$rev",
188 - wfMsg('code-rev-diff-link') ) .
 188+ "$viewvc$safePath?&pathrev=$rev&r1=$prev&r2=$rev",
 189+ wfMsg( 'code-rev-diff-link' ) ) .
189190 ')';
190191 }
191192 } else {
@@ -192,76 +193,76 @@
193194 }
194195 return "<li>$link ($desc)$diff</li>\n";
195196 }
196 -
 197+
197198 protected function tagForm() {
198199 global $wgUser;
199200 $tags = $this->mRev->getTags();
200201 $list = '';
201 - if( count($tags) ) {
 202+ if ( count( $tags ) ) {
202203 $list = implode( ", ",
203204 array_map(
204205 array( $this, 'formatTag' ),
205 - $tags )
 206+ $tags )
206207 ) . '&nbsp;';
207208 }
208 - if( $wgUser->isAllowed( 'codereview-add-tag' ) ) {
 209+ if ( $wgUser->isAllowed( 'codereview-add-tag' ) ) {
209210 $list .= $this->addTagForm( $this->mAddTags, $this->mRemoveTags );
210211 }
211212 return $list;
212213 }
213 -
 214+
214215 protected function splitTags( $input ) {
215 - if( !$this->mRev ) return array();
 216+ if ( !$this->mRev ) return array();
216217 $tags = array_map( 'trim', explode( ",", $input ) );
217 - foreach( $tags as $key => $tag ) {
 218+ foreach ( $tags as $key => $tag ) {
218219 $normal = $this->mRev->normalizeTag( $tag );
219 - if( $normal === false ) {
 220+ if ( $normal === false ) {
220221 return null;
221222 }
222223 $tags[$key] = $normal;
223224 }
224225 return $tags;
225226 }
226 -
 227+
227228 static function listTags( $tags ) {
228 - if( empty($tags) )
 229+ if ( empty( $tags ) )
229230 return "";
230 - return implode(",",$tags);
 231+ return implode( ",", $tags );
231232 }
232 -
 233+
233234 protected function statusForm() {
234235 global $wgUser;
235 - if( $wgUser->isAllowed( 'codereview-set-status' ) ) {
 236+ if ( $wgUser->isAllowed( 'codereview-set-status' ) ) {
236237 $repo = $this->mRepo->getName();
237238 $rev = $this->mRev->getId();
238239 return Xml::openElement( 'select', array( 'name' => 'wpStatus' ) ) .
239240 self::buildStatusList( $this->mRev->getStatus(), $this ) .
240 - xml::closeElement('select');
 241+ xml::closeElement( 'select' );
241242 } else {
242243 return htmlspecialchars( $this->statusDesc( $this->mRev->getStatus() ) );
243244 }
244245 }
245 -
 246+
246247 static function buildStatusList( $status, $view ) {
247248 $states = CodeRevision::getPossibleStates();
248249 $out = '';
249 - foreach( $states as $state ) {
 250+ foreach ( $states as $state ) {
250251 $out .= Xml::option( $view->statusDesc( $state ), $state,
251252 $status === $state );
252253 }
253254 return $out;
254255 }
255 -
 256+
256257 /** Parameters are the tags to be added/removed sent with the request */
257258 static function addTagForm( $addTags, $removeTags ) {
258259 global $wgUser;
259260 return '<div><table><tr><td>' .
260 - Xml::inputLabel( wfMsg('code-rev-tag-add'), 'wpTag', 'wpTag', 20,
 261+ Xml::inputLabel( wfMsg( 'code-rev-tag-add' ), 'wpTag', 'wpTag', 20,
261262 self::listTags( $addTags ) ) . '</td><td>&nbsp;</td><td>' .
262 - Xml::inputLabel( wfMsg('code-rev-tag-remove'), 'wpRemoveTag', 'wpRemoveTag', 20,
 263+ Xml::inputLabel( wfMsg( 'code-rev-tag-remove' ), 'wpRemoveTag', 'wpRemoveTag', 20,
263264 self::listTags( $removeTags ) ) . '</td></tr></table></div>';
264265 }
265 -
 266+
266267 protected function formatTag( $tag ) {
267268 global $wgUser;
268269 $repo = $this->mRepo->getName();
@@ -271,16 +272,16 @@
272273
273274 protected function formatDiff() {
274275 global $wgEnableAPI;
275 -
 276+
276277 // Asynchronous diff loads will require the API
277278 // And JS in the client, but tough shit eh? ;)
278279 $deferDiffs = $wgEnableAPI;
279 -
280 - if( $this->mSkipCache ) {
 280+
 281+ if ( $this->mSkipCache ) {
281282 // We're purging the cache on purpose, probably
282283 // because the cached data was corrupt.
283284 $cache = 'skipcache';
284 - } elseif( $deferDiffs ) {
 285+ } elseif ( $deferDiffs ) {
285286 // If data is already cached, we'll take it now;
286287 // otherwise defer the load to an AJAX request.
287288 // This lets the page be manipulable even if the
@@ -290,7 +291,7 @@
291292 $cache = '';
292293 }
293294 $diff = $this->mRepo->getDiff( $this->mRev->getId(), $cache );
294 - if( !$diff && $deferDiffs ) {
 295+ if ( !$diff && $deferDiffs ) {
295296 // We'll try loading it by AJAX...
296297 return $this->stubDiffLoader();
297298 }
@@ -316,52 +317,53 @@
317318 $comments = implode( "\n",
318319 array_map( array( $this, 'formatCommentInline' ), $this->mRev->getComments() )
319320 ) . $this->postCommentForm();
320 - if( !$comments ) {
 321+ if ( !$comments ) {
321322 return false;
322323 }
323324 return "<div class='mw-codereview-comments'>$comments</div>";
324325 }
325 -
 326+
326327 protected function formatPropChanges() {
327328 $changes = implode( "\n",
328329 array_map( array( $this, 'formatChangeInline' ), $this->mRev->getPropChanges() )
329330 );
330 - if( !$changes ) {
 331+ if ( !$changes ) {
331332 return false;
332333 }
333334 return "<ul class='mw-codereview-changes'>$changes</ul>";
334335 }
335336
336337 protected function formatCommentInline( $comment ) {
337 - if( $comment->id === $this->mReplyTarget ) {
 338+ if ( $comment->id === $this->mReplyTarget ) {
338339 return $this->formatComment( $comment,
339340 $this->postCommentForm( $comment->id ) );
340341 } else {
341342 return $this->formatComment( $comment );
342343 }
343344 }
344 -
 345+
345346 protected function formatChangeInline( $change ) {
346347 global $wgLang;
347348 $revId = $change->rev->getId();
348349 $line = $wgLang->timeanddate( $change->timestamp, true );
349350 $line .= '&nbsp;' . $this->mSkin->userLink( $change->user, $change->userText );
350351 $line .= $this->mSkin->userToolLinks( $change->user, $change->userText );
351 - $line .= '&nbsp;' . wfMsgExt("code-change-{$change->attrib}",'parseinline',$revId);
 352+ // Uses messages 'code-change-status', 'code-change-tags'
 353+ $line .= '&nbsp;' . wfMsgExt( "code-change-{$change->attrib}", 'parseinline', $revId );
352354 $line .= " <i>[";
353 - if( $change->removed ) {
354 - $line .= '<b>'.wfMsg('code-change-removed').'</b> ';
355 - $line .= htmlspecialchars($change->removed);
 355+ if ( $change->removed ) {
 356+ $line .= '<b>' . wfMsg( 'code-change-removed' ) . '</b> ';
 357+ $line .= htmlspecialchars( $change->removed );
356358 $line .= $change->added ? "&nbsp;" : "";
357359 }
358 - if( $change->added ) {
359 - $line .= '<b>'.wfMsg('code-change-added').'</b> ';
360 - $line .= htmlspecialchars($change->added);
 360+ if ( $change->added ) {
 361+ $line .= '<b>' . wfMsg( 'code-change-added' ) . '</b> ';
 362+ $line .= htmlspecialchars( $change->added );
361363 }
362364 $line .= "]</i>";
363365 return "<li>$line</li>";
364366 }
365 -
 367+
366368 protected function commentLink( $commentId ) {
367369 $repo = $this->mRepo->getName();
368370 $rev = $this->mRev->getId();
@@ -369,31 +371,31 @@
370372 $title->setFragment( "#c{$commentId}" );
371373 return $title;
372374 }
373 -
 375+
374376 protected function revLink() {
375377 $repo = $this->mRepo->getName();
376378 $rev = $this->mRev->getId();
377379 $title = SpecialPage::getTitleFor( 'Code', "$repo/$rev" );
378380 return $title;
379 - }
380 -
381 - protected function previewComment( $text, $review=0 ) {
 381+ }
 382+
 383+ protected function previewComment( $text, $review = 0 ) {
382384 $comment = $this->mRev->previewComment( $text, $review );
383385 return $this->formatComment( $comment );
384386 }
385 -
386 - protected function formatComment( $comment, $replyForm='' ) {
 387+
 388+ protected function formatComment( $comment, $replyForm = '' ) {
387389 global $wgOut, $wgLang;
388390 $linker = new CodeCommentLinkerWiki( $this->mRepo );
389 -
390 - if( $comment->id === null ) {
 391+
 392+ if ( $comment->id === null ) {
391393 $linkId = 'cpreview';
392394 $permaLink = "<b>Preview:</b> ";
393395 } else {
394396 $linkId = 'c' . intval( $comment->id );
395397 $permaLink = $this->mSkin->link( $this->commentLink( $comment->id ), "#" );
396398 }
397 -
 399+
398400 return Xml::openElement( 'div',
399401 array(
400402 'class' => 'mw-codereview-comment',
@@ -418,23 +420,23 @@
419421
420422 protected function commentStyle( $comment ) {
421423 $depth = $comment->threadDepth();
422 - $margin = ($depth - 1) * 48;
 424+ $margin = ( $depth - 1 ) * 48;
423425 return "margin-left: ${margin}px";
424426 }
425 -
 427+
426428 protected function commentReplyLink( $id ) {
427429 global $wgUser;
428 - if( !$wgUser->isAllowed('codereview-post-comment') ) return '';
 430+ if ( !$wgUser->isAllowed( 'codereview-post-comment' ) ) return '';
429431 $repo = $this->mRepo->getName();
430432 $rev = $this->mRev->getId();
431433 $self = SpecialPage::getTitleFor( 'Code', "$repo/$rev/reply/$id" );
432434 $self->setFragment( "#c$id" );
433435 return '[' . $this->mSkin->link( $self, wfMsg( 'codereview-reply-link' ) ) . ']';
434436 }
435 -
436 - protected function postCommentForm( $parent=null ) {
 437+
 438+ protected function postCommentForm( $parent = null ) {
437439 global $wgUser;
438 - if( $this->mPreviewText !== false && $parent === $this->mReplyTarget ) {
 440+ if ( $this->mPreviewText !== false && $parent === $this->mReplyTarget ) {
439441 $preview = $this->previewComment( $this->mPreviewText );
440442 $text = htmlspecialchars( $this->mPreviewText );
441443 } else {
@@ -443,13 +445,13 @@
444446 }
445447 $repo = $this->mRepo->getName();
446448 $rev = $this->mRev->getId();
447 - if( !$wgUser->isAllowed('codereview-post-comment') ) {
 449+ if ( !$wgUser->isAllowed( 'codereview-post-comment' ) ) {
448450 return '';
449451 }
450452 return '<div class="mw-codereview-post-comment">' .
451453 $preview .
452454 Xml::hidden( 'wpEditToken', $wgUser->editToken() ) .
453 - ($parent ? Xml::hidden( 'wpParent', $parent ) : '') .
 455+ ( $parent ? Xml::hidden( 'wpParent', $parent ) : '' ) .
454456 '<div>' .
455457 Xml::openElement( 'textarea', array(
456458 'name' => "wpReply{$parent}",
Index: trunk/extensions/CodeReview/CodeRepoListView.php
@@ -6,18 +6,18 @@
77 function execute() {
88 global $wgOut;
99 $repos = CodeRepository::getRepoList();
10 - if( !count( $repos ) ){
 10+ if ( !count( $repos ) ) {
1111 $wgOut->addWikiMsg( 'code-no-repo' );
1212 return;
1313 }
1414 $text = '';
15 - foreach( $repos as $repo ){
 15+ foreach ( $repos as $repo ) {
1616 $name = $repo->getName();
17 - $text .= "* ".self::getNavItem( $name )."\n";
 17+ $text .= "* " . self::getNavItem( $name ) . "\n";
1818 }
1919 $wgOut->addWikiText( $text );
2020 }
21 -
 21+
2222 public static function getNavItem( $name ) {
2323 global $wgLang;
2424 $text = "'''[[Special:Code/$name|$name]]''' (";
Index: trunk/extensions/CodeReview/CodeRevision.php
@@ -1,12 +1,12 @@
22 <?php
3 -if (!defined('MEDIAWIKI')) die();
 3+if ( !defined( 'MEDIAWIKI' ) ) die();
44
55 class CodeRevision {
66 public static function newFromSvn( CodeRepository $repo, $data ) {
77 $rev = new CodeRevision();
88 $rev->mRepoId = $repo->getId();
99 $rev->mRepo = $repo;
10 - $rev->mId = intval($data['rev']);
 10+ $rev->mId = intval( $data['rev'] );
1111 $rev->mAuthor = $data['author'];
1212 $rev->mTimestamp = wfTimestamp( TS_MW, strtotime( $data['date'] ) );
1313 $rev->mMessage = rtrim( $data['msg'] );
@@ -14,28 +14,28 @@
1515 $rev->mStatus = 'new';
1616
1717 $common = null;
18 - if( $rev->mPaths ) {
19 - if (count($rev->mPaths) == 1)
 18+ if ( $rev->mPaths ) {
 19+ if ( count( $rev->mPaths ) == 1 )
2020 $common = $rev->mPaths[0]['path'];
2121 else {
2222 $first = array_shift( $rev->mPaths );
2323
2424 $common = explode( '/', $first['path'] );
2525
26 - foreach( $rev->mPaths as $path ) {
 26+ foreach ( $rev->mPaths as $path ) {
2727 $compare = explode( '/', $path['path'] );
2828
2929 // make sure $common is the shortest path
30 - if ( count($compare) < count($common) )
 30+ if ( count( $compare ) < count( $common ) )
3131 list( $compare, $common ) = array( $common, $compare );
3232
3333 $tmp = array();
3434 foreach ( $common as $k => $v )
35 - if ( $v==$compare[$k] ) $tmp[]= $v;
 35+ if ( $v == $compare[$k] ) $tmp[] = $v;
3636 else break;
3737 $common = $tmp;
3838 }
39 - $common = implode( '/', $common);
 39+ $common = implode( '/', $common );
4040
4141 array_unshift( $rev->mPaths, $first );
4242 }
@@ -46,12 +46,12 @@
4747
4848 public static function newFromRow( CodeRepository $repo, $row ) {
4949 $rev = new CodeRevision();
50 - $rev->mRepoId = intval($row->cr_repo_id);
51 - if( $rev->mRepoId != $repo->getId() ) {
 50+ $rev->mRepoId = intval( $row->cr_repo_id );
 51+ if ( $rev->mRepoId != $repo->getId() ) {
5252 throw new MWException( "Invalid repo ID in " . __METHOD__ );
5353 }
5454 $rev->mRepo = $repo;
55 - $rev->mId = intval($row->cr_id);
 55+ $rev->mId = intval( $row->cr_id );
5656 $rev->mAuthor = $row->cr_author;
5757 $rev->mTimestamp = wfTimestamp( TS_MW, $row->cr_timestamp );
5858 $rev->mMessage = $row->cr_message;
@@ -63,7 +63,7 @@
6464 public function getId() {
6565 return intval( $this->mId );
6666 }
67 -
 67+
6868 public function getRepoId() {
6969 return intval( $this->mRepoId );
7070 }
@@ -71,7 +71,7 @@
7272 public function getAuthor() {
7373 return $this->mAuthor;
7474 }
75 -
 75+
7676 public function getWikiUser() {
7777 return $this->mRepo->authorWikiUser( $this->getAuthor() );
7878 }
@@ -83,7 +83,7 @@
8484 public function getMessage() {
8585 return $this->mMessage;
8686 }
87 -
 87+
8888 public function getStatus() {
8989 return $this->mStatus;
9090 }
@@ -91,17 +91,17 @@
9292 public function getCommonPath() {
9393 return $this->mCommonPath;
9494 }
95 -
 95+
9696 public static function getPossibleStates() {
9797 return array( 'new', 'fixme', 'reverted', 'resolved', 'ok', 'deferred' );
9898 }
99 -
 99+
100100 public function isValidStatus( $status ) {
101101 return in_array( $status, self::getPossibleStates(), true );
102102 }
103 -
 103+
104104 public function setStatus( $status, $user ) {
105 - if( !$this->isValidStatus( $status ) ) {
 105+ if ( !$this->isValidStatus( $status ) ) {
106106 throw new MWException( "Tried to save invalid code revision status" );
107107 }
108108 // Get the old status from the master
@@ -111,7 +111,7 @@
112112 array( 'cr_repo_id' => $this->mRepoId, 'cr_id' => $this->mId ),
113113 __METHOD__
114114 );
115 - if( $oldStatus === $status ) {
 115+ if ( $oldStatus === $status ) {
116116 return false; // nothing to do here
117117 }
118118 // Update status
@@ -124,9 +124,9 @@
125125 __METHOD__
126126 );
127127 // Log this change
128 - if( $user && $user->getId() ) {
 128+ if ( $user && $user->getId() ) {
129129 $dbw->insert( 'code_prop_changes',
130 - array(
 130+ array(
131131 'cpc_repo_id' => $this->getRepoId(),
132132 'cpc_rev_id' => $this->getId(),
133133 'cpc_attrib' => 'status',
@@ -145,7 +145,7 @@
146146 public function save() {
147147 $dbw = wfGetDB( DB_MASTER );
148148 $dbw->begin();
149 -
 149+
150150 $dbw->insert( 'code_rev',
151151 array(
152152 'cr_repo_id' => $this->mRepoId,
@@ -158,22 +158,22 @@
159159 __METHOD__,
160160 array( 'IGNORE' ) );
161161 // Already exists? Update the row!
162 - if( !$dbw->affectedRows() ) {
 162+ if ( !$dbw->affectedRows() ) {
163163 $dbw->update( 'code_rev',
164164 array(
165165 'cr_author' => $this->mAuthor,
166166 'cr_timestamp' => $dbw->timestamp( $this->mTimestamp ),
167167 'cr_message' => $this->mMessage,
168 - 'cr_path' => $this->mCommonPath ),
 168+ 'cr_path' => $this->mCommonPath ),
169169 array(
170170 'cr_repo_id' => $this->mRepoId,
171171 'cr_id' => $this->mId ),
172172 __METHOD__ );
173173 }
174174 // Update path tracking used for output and searching
175 - if( $this->mPaths ) {
 175+ if ( $this->mPaths ) {
176176 $data = array();
177 - foreach( $this->mPaths as $path ) {
 177+ foreach ( $this->mPaths as $path ) {
178178 $data[] = array(
179179 'cp_repo_id' => $this->mRepoId,
180180 'cp_rev_id' => $this->mId,
@@ -198,24 +198,24 @@
199199 __METHOD__
200200 );
201201 }
202 -
 202+
203203 public function isDiffable() {
204204 $paths = $this->getModifiedPaths();
205 - if( !$paths->numRows() || $paths->numRows() > 20 ) {
 205+ if ( !$paths->numRows() || $paths->numRows() > 20 ) {
206206 return false; // things need to get done this year
207207 }
208208 return true;
209209 }
210210
211 - public function previewComment( $text, $review, $parent=null ) {
 211+ public function previewComment( $text, $review, $parent = null ) {
212212 $data = $this->commentData( $text, $review, $parent );
213213 $data['cc_id'] = null;
214214 return CodeComment::newFromData( $this, $data );
215215 }
216 -
217 - public function saveComment( $text, $review, $parent=null ) {
 216+
 217+ public function saveComment( $text, $review, $parent = null ) {
218218 global $wgUser;
219 - if( !strlen($text) ) {
 219+ if ( !strlen( $text ) ) {
220220 return 0;
221221 }
222222 $dbw = wfGetDB( DB_MASTER );
@@ -229,24 +229,24 @@
230230
231231 // Give email notices to committer and commenters
232232 global $wgCodeReviewENotif, $wgEnableEmail;
233 - if( $wgCodeReviewENotif && $wgEnableEmail ) {
 233+ if ( $wgCodeReviewENotif && $wgEnableEmail ) {
234234 // Make list of users to send emails to
235235 $users = $this->getCommentingUsers();
236 - if( $user = $this->getWikiUser() ) {
 236+ if ( $user = $this->getWikiUser() ) {
237237 $users[$user->getId()] = $user;
238238 }
239239 // Get repo and build comment title (for url)
240 - $title = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName().'/'.$this->mId );
 240+ $title = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/' . $this->mId );
241241 $title->setFragment( "#c{$commentId}" );
242242 $url = $title->getFullUrl();
243 - foreach( $users as $userId => $user ) {
 243+ foreach ( $users as $userId => $user ) {
244244 // No sense in notifying this commenter
245 - if( $wgUser->getId() == $user->getId() ) {
 245+ if ( $wgUser->getId() == $user->getId() ) {
246246 continue;
247247 }
248248 // Send message in receiver's language
249249 $lang = array( 'language' => $user->getOption( 'language' ) );
250 - if( $user->canReceiveEmail() ) {
 250+ if ( $user->canReceiveEmail() ) {
251251 $user->sendMail(
252252 wfMsgExt( 'codereview-email-subj', $lang, $this->mRepo->getName(), $this->mId ),
253253 wfMsgExt( 'codereview-email-body', $lang, $wgUser->getName(), $url, $this->mId, $text )
@@ -254,11 +254,11 @@
255255 }
256256 }
257257 }
258 -
 258+
259259 return $commentId;
260260 }
261 -
262 - protected function commentData( $text, $review, $parent=null ) {
 261+
 262+ protected function commentData( $text, $review, $parent = null ) {
263263 global $wgUser;
264264 $dbw = wfGetDB( DB_MASTER );
265265 $ts = wfTimestamp( TS_MW );
@@ -276,7 +276,7 @@
277277 }
278278
279279 protected function threadedSortKey( $parent, $ts ) {
280 - if( $parent ) {
 280+ if ( $parent ) {
281281 // We construct a threaded sort key by concatenating the timestamps
282282 // of all our parent comments
283283 $dbw = wfGetDB( DB_MASTER );
@@ -284,7 +284,7 @@
285285 'cc_sortkey',
286286 array( 'cc_id' => $parent ),
287287 __METHOD__ );
288 - if( $parentKey ) {
 288+ if ( $parentKey ) {
289289 return $parentKey . ',' . $ts;
290290 } else {
291291 // hmmmm
@@ -315,16 +315,16 @@
316316 'ORDER BY' => 'cc_sortkey' )
317317 );
318318 $comments = array();
319 - foreach( $result as $row ) {
 319+ foreach ( $result as $row ) {
320320 $comments[] = CodeComment::newFromRow( $this, $row );
321321 }
322322 $result->free();
323323 return $comments;
324324 }
325 -
 325+
326326 public function getPropChanges() {
327327 $dbr = wfGetDB( DB_SLAVE );
328 - $result = $dbr->select( array('code_prop_changes','user'),
 328+ $result = $dbr->select( array( 'code_prop_changes', 'user' ),
329329 array(
330330 'cpc_attrib',
331331 'cpc_removed',
@@ -339,16 +339,16 @@
340340 ),
341341 __METHOD__,
342342 array( 'ORDER BY' => 'cpc_timestamp DESC' ),
343 - array( 'user' => array('LEFT JOIN','cpc_user = user_id') )
 343+ array( 'user' => array( 'LEFT JOIN', 'cpc_user = user_id' ) )
344344 );
345345 $changes = array();
346 - foreach( $result as $row ) {
 346+ foreach ( $result as $row ) {
347347 $changes[] = CodePropChange::newFromRow( $this, $row );
348348 }
349349 $result->free();
350350 return $changes;
351351 }
352 -
 352+
353353 protected function getCommentingUsers() {
354354 $dbr = wfGetDB( DB_SLAVE );
355355 $res = $dbr->select( 'code_comment',
@@ -358,15 +358,15 @@
359359 'cc_rev_id' => $this->mId,
360360 'cc_user != 0' // users only
361361 ),
362 - __METHOD__
 362+ __METHOD__
363363 );
364364 $users = array();
365 - while( $row = $res->fetchObject() ) {
 365+ while ( $row = $res->fetchObject() ) {
366366 $users[$row->cc_user] = User::newFromId( $row->cc_user );
367367 }
368368 return $users;
369369 }
370 -
 370+
371371 public function getTags( $from = DB_SLAVE ) {
372372 $db = wfGetDB( $from );
373373 $result = $db->select( 'code_tags',
@@ -375,14 +375,14 @@
376376 'ct_repo_id' => $this->mRepoId,
377377 'ct_rev_id' => $this->mId ),
378378 __METHOD__ );
379 -
 379+
380380 $tags = array();
381 - foreach( $result as $row ) {
 381+ foreach ( $result as $row ) {
382382 $tags[] = $row->ct_tag;
383383 }
384384 return $tags;
385385 }
386 -
 386+
387387 public function changeTags( $addTags, $removeTags, $user = NULL ) {
388388 // Get the current tags and see what changes
389389 $tagsNow = $this->getTags( DB_MASTER );
@@ -393,16 +393,16 @@
394394 $removeTags = array_intersect( $removeTags, $tagsNow );
395395 // Do the queries
396396 $dbw = wfGetDB( DB_MASTER );
397 - if( $addTags ) {
 397+ if ( $addTags ) {
398398 $dbw->insert( 'code_tags',
399399 $this->tagData( $addTags ),
400400 __METHOD__,
401401 array( 'IGNORE' )
402402 );
403403 }
404 - if( $removeTags ) {
 404+ if ( $removeTags ) {
405405 $dbw->delete( 'code_tags',
406 - array(
 406+ array(
407407 'ct_repo_id' => $this->mRepoId,
408408 'ct_rev_id' => $this->mId,
409409 'ct_tag' => $removeTags ),
@@ -410,14 +410,14 @@
411411 );
412412 }
413413 // Log this change
414 - if( ($removeTags || $addTags) && $user && $user->getId() ) {
 414+ if ( ( $removeTags || $addTags ) && $user && $user->getId() ) {
415415 $dbw->insert( 'code_prop_changes',
416 - array(
 416+ array(
417417 'cpc_repo_id' => $this->getRepoId(),
418418 'cpc_rev_id' => $this->getId(),
419419 'cpc_attrib' => 'tags',
420 - 'cpc_removed' => implode(',',$removeTags),
421 - 'cpc_added' => implode(',',$addTags),
 420+ 'cpc_removed' => implode( ',', $removeTags ),
 421+ 'cpc_added' => implode( ',', $addTags ),
422422 'cpc_timestamp' => $dbw->timestamp(),
423423 'cpc_user' => $user->getId(),
424424 'cpc_user_text' => $user->getName()
@@ -426,18 +426,18 @@
427427 );
428428 }
429429 }
430 -
 430+
431431 protected function normalizeTags( $tags ) {
432432 $out = array();
433 - foreach( $tags as $tag ) {
 433+ foreach ( $tags as $tag ) {
434434 $out[] = $this->normalizeTag( $tag );
435435 }
436436 return $out;
437437 }
438 -
 438+
439439 protected function tagData( $tags ) {
440440 $data = array();
441 - foreach( $tags as $tag ) {
 441+ foreach ( $tags as $tag ) {
442442 $data[] = array(
443443 'ct_repo_id' => $this->mRepoId,
444444 'ct_rev_id' => $this->mId,
@@ -445,32 +445,32 @@
446446 }
447447 return $data;
448448 }
449 -
 449+
450450 public function normalizeTag( $tag ) {
451451 global $wgContLang;
452452 $lower = $wgContLang->lc( $tag );
453 -
 453+
454454 $title = Title::newFromText( $tag );
455 - if( $title && $lower === $wgContLang->lc( $title->getPrefixedText() ) ) {
 455+ if ( $title && $lower === $wgContLang->lc( $title->getPrefixedText() ) ) {
456456 return $lower;
457457 } else {
458458 return false;
459459 }
460460 }
461 -
 461+
462462 public function isValidTag( $tag ) {
463 - return ($this->normalizeTag( $tag ) !== false );
 463+ return ( $this->normalizeTag( $tag ) !== false );
464464 }
465 -
 465+
466466 public function getPrevious() {
467467 // hack!
468 - if( $this->mId > 1 ) {
 468+ if ( $this->mId > 1 ) {
469469 return $this->mId - 1;
470470 } else {
471471 return false;
472472 }
473473 }
474 -
 474+
475475 public function getNext() {
476476 $dbr = wfGetDB( DB_SLAVE );
477477 $encId = $dbr->addQuotes( $this->mId );
@@ -483,14 +483,14 @@
484484 array(
485485 'ORDER BY' => 'cr_repo_id, cr_id',
486486 'LIMIT' => 1 ) );
487 -
488 - if( $row ) {
489 - return intval($row->cr_id);
 487+
 488+ if ( $row ) {
 489+ return intval( $row->cr_id );
490490 } else {
491491 return false;
492492 }
493493 }
494 -
 494+
495495 public function getNextUnresolved() {
496496 $dbr = wfGetDB( DB_SLAVE );
497497 $encId = $dbr->addQuotes( $this->mId );
@@ -499,14 +499,14 @@
500500 array(
501501 'cr_repo_id' => $this->mRepoId,
502502 "cr_id > $encId",
503 - 'cr_status' => array('new','fixme') ),
 503+ 'cr_status' => array( 'new', 'fixme' ) ),
504504 __METHOD__,
505505 array(
506506 'ORDER BY' => 'cr_repo_id, cr_id',
507507 'LIMIT' => 1 )
508508 );
509 - if( $row ) {
510 - return intval($row->cr_id);
 509+ if ( $row ) {
 510+ return intval( $row->cr_id );
511511 } else {
512512 return false;
513513 }
Index: trunk/extensions/CodeReview/CodeRevisionAuthorLink.php
@@ -12,7 +12,7 @@
1313 function getTitle() {
1414 $repo = $this->mRepo->getName();
1515 $auth = $this->mAuthor;
16 - return SpecialPage::getTitleFor( 'Code', "$repo/author/$auth/link");
 16+ return SpecialPage::getTitleFor( 'Code', "$repo/author/$auth/link" );
1717 }
1818
1919 function execute() {
@@ -27,10 +27,10 @@
2828 $this->doForm();
2929 }
3030 }
31 -
 31+
3232 function doForm() {
3333 global $wgOut;
34 - $form = Xml::openElement( 'form', array( 'method' => 'post',
 34+ $form = Xml::openElement( 'form', array( 'method' => 'post',
3535 'action' => $this->getTitle()->getLocalUrl(),
3636 'name' => 'uluser', 'id' => 'mw-codeauthor-form1' ) );
3737 $form .= Xml::openElement( 'fieldset' );
@@ -45,10 +45,10 @@
4646 Xml::closeElement( 'fieldset' );
4747 } else {
4848 $form .= Xml::element( 'legend', array(), wfMsg( 'code-author-dolink' ) );
49 - }
 49+ }
5050
51 - $form .= Xml::inputLabel( wfMsg( 'code-author-name' ), 'linktouser', 'username', 30, '') . ' ' .
52 - Xml::submitButton( wfMsg( 'ok' ), array( 'name' => 'newname') ) .
 51+ $form .= Xml::inputLabel( wfMsg( 'code-author-name' ), 'linktouser', 'username', 30, '' ) . ' ' .
 52+ Xml::submitButton( wfMsg( 'ok' ), array( 'name' => 'newname' ) ) .
5353 Xml::closeElement( 'fieldset' ) .
5454 $additional .
5555 Xml::closeElement( 'form' ) . "\n";
@@ -59,17 +59,17 @@
6060 function doSubmit() {
6161 global $wgOut, $wgRequest;
6262 // Link an author to a wiki user
63 - if ( strlen($this->mTarget) && $wgRequest->getCheck( 'newname' ) ) {
 63+ if ( strlen( $this->mTarget ) && $wgRequest->getCheck( 'newname' ) ) {
6464 $user = User::newFromName( $this->mTarget, false );
65 - if( !$user || !$user->getId() ) {
 65+ if ( !$user || !$user->getId() ) {
6666 $wgOut->addWikiMsg( 'nosuchusershort', $this->mTarget );
6767 return;
6868 }
6969 $this->mRepo->linkUser( $this->mAuthor, $user );
70 - $userlink = $this->mSkin->userLink( $user->getId(), $user->getName() );
 70+ $userlink = $this->mSkin->userLink( $user->getId(), $user->getName() );
7171 $wgOut->addHTML(
72 - '<div class="successbox">' .
73 - wfMsgHtml( 'code-author-success', $this->authorLink( $this->mAuthor ), $userlink) .
 72+ '<div class="successbox">' .
 73+ wfMsgHtml( 'code-author-success', $this->authorLink( $this->mAuthor ), $userlink ) .
7474 '</div>'
7575 );
7676 // Unlink an author to a wiki users
@@ -80,7 +80,7 @@
8181 }
8282 $this->mRepo->unlinkUser( $this->mAuthor );
8383 $wgOut->addHTML(
84 - '<div class="successbox">' .
 84+ '<div class="successbox">' .
8585 wfMsgHtml( 'code-author-unlinksuccess', $this->authorLink( $this->mAuthor ) ) .
8686 '</div>'
8787 );
Index: trunk/extensions/CodeReview/CodeReview.php
@@ -1,5 +1,5 @@
22 <?php
3 -if (!defined('MEDIAWIKI')) die();
 3+if ( !defined( 'MEDIAWIKI' ) ) die();
44 /**
55 *
66 * @author Brion Vibber
@@ -36,7 +36,7 @@
3737 'descriptionmsg' => 'code-desc',
3838 );
3939
40 -$dir = dirname(__FILE__) . '/';
 40+$dir = dirname( __FILE__ ) . '/';
4141
4242 $wgAutoloadClasses['ApiCodeUpdate'] = $dir . 'ApiCodeUpdate.php';
4343 $wgAutoloadClasses['ApiCodeDiff'] = $dir . 'ApiCodeDiff.php';
Index: trunk/extensions/CodeReview/CodeComment.php
@@ -1,18 +1,18 @@
22 <?php
3 -if (!defined('MEDIAWIKI')) die();
 3+if ( !defined( 'MEDIAWIKI' ) ) die();
44
55 class CodeComment {
66 function __construct( $rev ) {
77 $this->rev = $rev;
88 }
9 -
 9+
1010 static function newFromRow( $rev, $row ) {
1111 return self::newFromData( $rev, get_object_vars( $row ) );
1212 }
13 -
 13+
1414 static function newFromData( $rev, $data ) {
1515 $comment = new CodeComment( $rev );
16 - $comment->id = intval($data['cc_id']);
 16+ $comment->id = intval( $data['cc_id'] );
1717 $comment->text = $data['cc_text']; // fixme
1818 $comment->user = $data['cc_user'];
1919 $comment->userText = $data['cc_user_text'];
@@ -21,7 +21,7 @@
2222 $comment->sortkey = $data['cc_sortkey'];
2323 return $comment;
2424 }
25 -
 25+
2626 function threadDepth() {
2727 $timestamps = explode( ",", $this->sortkey );
2828 return count( $timestamps );
Index: trunk/extensions/CodeReview/Subversion.php
@@ -1,14 +1,14 @@
22 <?php
3 -if (!defined('MEDIAWIKI')) die();
 3+if ( !defined( 'MEDIAWIKI' ) ) die();
44
55 abstract class SubversionAdaptor {
66 protected $mRepo;
77
88 public static function newFromRepo( $repo ) {
99 global $wgSubversionProxy, $wgSubversionProxyTimeout;
10 - if( $wgSubversionProxy ) {
 10+ if ( $wgSubversionProxy ) {
1111 return new SubversionProxy( $repo, $wgSubversionProxy, $wgSubversionProxyTimeout );
12 - } elseif( function_exists( 'svn_log' ) ) {
 12+ } elseif ( function_exists( 'svn_log' ) ) {
1313 return new SubversionPecl( $repo );
1414 } else {
1515 return new SubversionShell( $repo );
@@ -19,7 +19,7 @@
2020 $this->mRepo = $repo;
2121 }
2222
23 - abstract function getFile( $path, $rev=null );
 23+ abstract function getFile( $path, $rev = null );
2424
2525 abstract function getDiff( $path, $rev1, $rev2 );
2626
@@ -39,10 +39,10 @@
4040 ...
4141 )
4242 */
43 - abstract function getLog( $path, $startRev=null, $endRev=null );
 43+ abstract function getLog( $path, $startRev = null, $endRev = null );
4444
4545 protected function _rev( $rev, $default ) {
46 - if( $rev === null ) {
 46+ if ( $rev === null ) {
4747 return $default;
4848 } else {
4949 return intval( $rev );
@@ -54,7 +54,7 @@
5555 * Using the SVN PECL extension...
5656 */
5757 class SubversionPecl extends SubversionAdaptor {
58 - function getFile( $path, $rev=null ) {
 58+ function getFile( $path, $rev = null ) {
5959 return svn_cat( $this->mRepo . $path, $rev );
6060 }
6161
@@ -63,18 +63,18 @@
6464 $this->mRepo . $path, $rev1,
6565 $this->mRepo . $path, $rev2 );
6666
67 - if( $fout ) {
 67+ if ( $fout ) {
6868 // We have to read out the file descriptors. :P
6969 $out = '';
70 - while( !feof( $fout ) ) {
 70+ while ( !feof( $fout ) ) {
7171 $out .= fgets( $fout );
7272 }
7373 fclose( $fout );
7474 fclose( $ferr );
75 -
 75+
7676 return $out;
7777 } else {
78 - return new MWException("Diffing error");
 78+ return new MWException( "Diffing error" );
7979 }
8080 }
8181
@@ -83,7 +83,7 @@
8484 $this->_rev( $rev, SVN_REVISION_HEAD ) );
8585 }
8686
87 - function getLog( $path, $startRev=null, $endRev=null ) {
 87+ function getLog( $path, $startRev = null, $endRev = null ) {
8888 return svn_log( $this->mRepo . $path,
8989 $this->_rev( $startRev, SVN_REVISION_INITIAL ),
9090 $this->_rev( $endRev, SVN_REVISION_HEAD ) );
@@ -94,8 +94,8 @@
9595 * Using the thingy-bobber
9696 */
9797 class SubversionShell extends SubversionAdaptor {
98 - function getFile( $path, $rev=null ) {
99 - if( $rev )
 98+ function getFile( $path, $rev = null ) {
 99+ if ( $rev )
100100 $path .= "@$rev";
101101 $command = sprintf(
102102 "svn cat --non-interactive %s %s",
@@ -116,7 +116,7 @@
117117 return wfShellExec( $command );
118118 }
119119
120 - function getLog( $path, $startRev=null, $endRev=null ) {
 120+ function getLog( $path, $startRev = null, $endRev = null ) {
121121 $lang = wfIsWindows() ? "" : "LC_ALL=en_US.utf-8 ";
122122 $command = sprintf(
123123 "{$lang}svn log -v -r%s:%s --non-interactive %s %s",
@@ -136,29 +136,29 @@
137137 'lines' => '/^(\d+) lines?$/',
138138 );
139139 $state = "start";
140 - foreach( $lines as $line ) {
 140+ foreach ( $lines as $line ) {
141141 $line = rtrim( $line );
142142
143143 switch( $state ) {
144144 case "start":
145 - if( $line == $divider ) {
 145+ if ( $line == $divider ) {
146146 $state = "revdata";
147147 break;
148148 } else {
149149 return $out;
150 - #throw new MWException( "Unexpected start line: $line" );
 150+ # throw new MWException( "Unexpected start line: $line" );
151151 }
152152 case "revdata":
153 - if( $line == "" ) {
 153+ if ( $line == "" ) {
154154 $state = "done";
155155 break;
156156 }
157157 $data = array();
158158 $bits = explode( " | ", $line );
159159 $i = 0;
160 - foreach( $formats as $key => $regex ) {
 160+ foreach ( $formats as $key => $regex ) {
161161 $text = $bits[$i++];
162 - if( preg_match( $regex, $text, $matches ) ) {
 162+ if ( preg_match( $regex, $text, $matches ) ) {
163163 $data[$key] = $matches[1];
164164 } else {
165165 throw new MWException(
@@ -170,9 +170,9 @@
171171 $state = 'changedpaths';
172172 break;
173173 case "changedpaths":
174 - if( $line == "Changed paths:" ) { // broken when svn messages are not in English
 174+ if ( $line == "Changed paths:" ) { // broken when svn messages are not in English
175175 $state = "path";
176 - } elseif( $line == "" ) {
 176+ } elseif ( $line == "" ) {
177177 // No changed paths?
178178 $state = "msg";
179179 } else {
@@ -181,11 +181,11 @@
182182 }
183183 break;
184184 case "path":
185 - if( $line == "" ) {
 185+ if ( $line == "" ) {
186186 // Out of paths. Move on to the message...
187187 $state = 'msg';
188188 } else {
189 - if( preg_match( '/^ (.) (.*)$/', $line, $matches ) ) {
 189+ if ( preg_match( '/^ (.) (.*)$/', $line, $matches ) ) {
190190 $data['paths'][] = array(
191191 'action' => $matches[1],
192192 'path' => $matches[2] );
@@ -194,7 +194,7 @@
195195 break;
196196 case "msg":
197197 $data['msg'] .= $line;
198 - if( --$data['lines'] ) {
 198+ if ( --$data['lines'] ) {
199199 $data['msg'] .= "\n";
200200 } else {
201201 unset( $data['lines'] );
@@ -211,20 +211,20 @@
212212
213213 return $out;
214214 }
215 -
 215+
216216 function getDirList( $path, $rev = null ) {
217217 $command = sprintf(
218218 "svn list --xml -r%s --non-interactive %s %s",
219219 wfEscapeShellArg( $this->_rev( $rev, 'HEAD' ) ),
220220 $this->getExtraArgs(),
221221 wfEscapeShellArg( $this->mRepo . $path ) );
222 - $document = new DOMDocument();
223 -
 222+ $document = new DOMDocument();
 223+
224224 if ( !@$document->loadXML( wfShellExec( $command ) ) )
225225 // svn list --xml returns invalid XML if the file does not exist
226226 // FIXME: report bug upstream
227227 return false;
228 -
 228+
229229 $entries = $document->getElementsByTagName( 'entry' );
230230 $result = array();
231231 foreach ( $entries as $entry ) {
@@ -236,7 +236,7 @@
237237 $item['name'] = $child->textContent;
238238 break;
239239 case 'size':
240 - $item['size'] = intval( $child->textContent );
 240+ $item['size'] = intval( $child->textContent );
241241 break;
242242 case 'commit':
243243 $item['created_rev'] = intval( $child->getAttribute( 'revision' ) );
@@ -246,26 +246,26 @@
247247 $item['last_author'] = $commitEntry->textContent;
248248 break;
249249 case 'date':
250 - $item['time_t'] = wfTimestamp( TS_UNIX, $commitEntry->textContent );
 250+ $item['time_t'] = wfTimestamp( TS_UNIX, $commitEntry->textContent );
251251 break;
252252 }
253253 }
254 - break;
 254+ break;
255255 }
256256 }
257257 $result[] = $item;
258258 }
259259 return $result;
260260 }
261 -
 261+
262262 /**
263263 * Returns a string of extra arguments to be passed into the shell commands
264264 */
265265 private function getExtraArgs() {
266266 global $wgSubversionUser, $wgSubversionPassword;
267 - if($wgSubversionUser) {
268 - return '--username ' . wfEscapeShellArg($wgSubversionUser)
269 - . ' --password ' . wfEscapeShellArg($wgSubversionPassword);
 267+ if ( $wgSubversionUser ) {
 268+ return '--username ' . wfEscapeShellArg( $wgSubversionUser )
 269+ . ' --password ' . wfEscapeShellArg( $wgSubversionPassword );
270270 }
271271 return '';
272272 }
@@ -275,13 +275,13 @@
276276 * Using a remote JSON proxy
277277 */
278278 class SubversionProxy extends SubversionAdaptor {
279 - function __construct( $repo, $proxy, $timeout=30 ) {
 279+ function __construct( $repo, $proxy, $timeout = 30 ) {
280280 parent::__construct( $repo );
281281 $this->mProxy = $proxy;
282282 $this->mTimeout = $timeout;
283283 }
284 -
285 - function getFile( $path, $rev=null ) {
 284+
 285+ function getFile( $path, $rev = null ) {
286286 throw new MWException( "NYI" );
287287 }
288288
@@ -293,31 +293,31 @@
294294 'rev2' => $rev2 ) );
295295 }
296296
297 - function getLog( $path, $startRev=null, $endRev=null ) {
 297+ function getLog( $path, $startRev = null, $endRev = null ) {
298298 return $this->_proxy( array(
299299 'action' => 'log',
300300 'path' => $path,
301301 'start' => $startRev,
302302 'end' => $endRev ) );
303303 }
304 -
 304+
305305 function getDirList( $path, $rev = null ) {
306306 return $this->_proxy( array(
307307 'action' => 'list',
308308 'path' => $path,
309309 'rev' => $rev ) );
310310 }
311 -
 311+
312312 protected function _proxy( $params ) {
313 - foreach( $params as $key => $val ) {
314 - if( is_null( $val ) ) {
 313+ foreach ( $params as $key => $val ) {
 314+ if ( is_null( $val ) ) {
315315 // Don't pass nulls to remote
316316 unset( $params[$key] );
317317 }
318318 }
319319 $target = $this->mProxy . '?' . wfArrayToCgi( $params );
320320 $blob = Http::get( $target, $this->mTimeout );
321 - if( $blob === false ) {
 321+ if ( $blob === false ) {
322322 throw new MWException( "SVN proxy error" );
323323 }
324324 $data = unserialize( $blob );
Index: trunk/extensions/CodeReview/CodeStatusListView.php
@@ -11,11 +11,10 @@
1212 global $wgOut;
1313 $name = $this->mRepo->getName();
1414 $states = CodeRevision::getPossibleStates();
15 - $text = "== " . wfMsg ("code-field-status") . " ==\n";
16 - foreach( $states as $state ) {
17 - $text .= "* [[Special:Code/$name/status/$state|" . wfMsg ("code-status-" . $state) . "]]\n";
 15+ $text = "== " . wfMsg ( "code-field-status" ) . " ==\n";
 16+ foreach ( $states as $state ) {
 17+ $text .= "* [[Special:Code/$name/status/$state|" . wfMsg ( "code-status-" . $state ) . "]]\n";
1818 }
1919 $wgOut->addWikiText( $text );
2020 }
2121 }
22 -
Index: trunk/extensions/CodeReview/CodeCommentsListView.php
@@ -12,10 +12,10 @@
1313 function execute() {
1414 global $wgOut;
1515 $pager = $this->getPager();
16 - $wgOut->addHTML(
 16+ $wgOut->addHTML(
1717 $pager->getNavigationBar() .
18 - $pager->getLimitForm() .
19 - $pager->getBody() .
 18+ $pager->getLimitForm() .
 19+ $pager->getBody() .
2020 $pager->getNavigationBar()
2121 );
2222 }
@@ -31,7 +31,7 @@
3232 // Pager for CodeRevisionListView
3333 class CodeCommentsTablePager extends TablePager {
3434
35 - function __construct( CodeCommentsListView $view ){
 35+ function __construct( CodeCommentsListView $view ) {
3636 global $IP;
3737 $this->mView = $view;
3838 $this->mRepo = $view->mRepo;
@@ -40,24 +40,24 @@
4141 parent::__construct();
4242 }
4343
44 - function isFieldSortable( $field ){
 44+ function isFieldSortable( $field ) {
4545 return $field == 'cr_timestamp';
4646 }
4747
48 - function getDefaultSort(){ return 'cc_timestamp'; }
 48+ function getDefaultSort() { return 'cc_timestamp'; }
4949
50 - function getQueryInfo(){
 50+ function getQueryInfo() {
5151 return array(
5252 'tables' => array( 'code_comment', 'code_rev' ),
5353 'fields' => array_keys( $this->getFieldNames() ),
5454 'conds' => array( 'cc_repo_id' => $this->mRepo->getId() ),
55 - 'join_conds' => array(
 55+ 'join_conds' => array(
5656 'code_rev' => array( 'LEFT JOIN', 'cc_repo_id = cr_repo_id AND cc_rev_id = cr_id' )
5757 )
5858 );
5959 }
6060
61 - function getFieldNames(){
 61+ function getFieldNames() {
6262 return array(
6363 'cc_timestamp' => wfMsg( 'code-field-timestamp' ),
6464 'cc_user_text' => wfMsg( 'code-field-user' ),
@@ -68,9 +68,9 @@
6969 );
7070 }
7171
72 - function formatValue( $name, $value ){
 72+ function formatValue( $name, $value ) {
7373 global $wgUser, $wgLang;
74 - switch( $name ){
 74+ switch( $name ) {
7575 case 'cc_rev_id':
7676 return $this->mView->mSkin->link(
7777 SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/' . $value . '#code-comments' ),
@@ -92,12 +92,12 @@
9393 return $wgLang->timeanddate( $value, true );
9494 }
9595 }
96 -
 96+
9797 // Note: this function is poorly factored in the parent class
9898 function formatRow( $row ) {
9999 global $wgWikiSVN;
100100 $class = "mw-codereview-status-{$row->cr_status}";
101 - if($this->mRepo->mName == $wgWikiSVN){
 101+ if ( $this->mRepo->mName == $wgWikiSVN ) {
102102 $class .= " mw-codereview-" . ( $row->cc_rev_id <= $this->mCurSVN ? 'live' : 'notlive' );
103103 }
104104 return str_replace(
@@ -107,7 +107,7 @@
108108 parent::formatRow( $row ) );
109109 }
110110
111 - function getTitle(){
 111+ function getTitle() {
112112 return SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/comments' );
113113 }
114114 }
Index: trunk/extensions/CodeReview/CodeReview.i18n.php
@@ -18,7 +18,7 @@
1919 'code-prop-changes' => 'Status & tagging log',
2020 'code-desc' => '[[Special:Code|Code review tool]] with [[Special:RepoAdmin|Subversion support]]',
2121 'code-no-repo' => 'No repository configured!',
22 - 'code-load-diff'=> 'Loading diff…',
 22+ 'code-load-diff' => 'Loading diff…',
2323 'code-notes' => 'recent comments',
2424 'code-authors' => 'authors',
2525 'code-status' => 'status',
@@ -76,28 +76,28 @@
7777 'code-pathsearch-path' => 'Path:',
7878 'code-rev-submit' => 'Save changes',
7979 'code-rev-submit-next' => 'Save & next unresolved',
80 -
 80+
8181 'code-batch-status' => 'Change status:',
8282 'code-batch-tags' => 'Change tags:',
8383 'codereview-batch-title' => 'Change all selected revisions',
8484 'codereview-batch-submit' => 'Submit',
85 -
 85+
8686 'code-releasenotes' => 'release notes',
8787 'code-release-legend' => 'Generate release notes',
8888 'code-release-startrev' => 'Start rev:',
8989 'code-release-endrev' => 'Last rev:',
90 -
 90+
9191 'codereview-subtitle' => 'For $1',
92 -
 92+
9393 'codereview-reply-link' => 'reply',
94 -
 94+
9595 'codereview-email-subj' => '[$1] [r$2]: New comment added',
9696 'codereview-email-body' => 'User "$1" posted a comment on r$3.
97 -
 97+
9898 Full URL: $2
9999
100100 Comment:
101 -
 101+
102102 $4',
103103
104104 'repoadmin' => 'Repository Administration',
@@ -117,7 +117,7 @@
118118 'right-codereview-post-comment' => 'Add comments on revisions',
119119 'right-codereview-set-status' => 'Change revisions status',
120120 'right-codereview-link-user' => 'Link authors to wiki users',
121 -
 121+
122122 'specialpages-group-developer' => 'Developer tools',
123123 );
124124
Index: trunk/extensions/CodeReview/CodeRepository.php
@@ -1,5 +1,5 @@
22 <?php
3 -if (!defined('MEDIAWIKI')) die();
 3+if ( !defined( 'MEDIAWIKI' ) ) die();
44
55 class CodeRepository {
66 static $userLinks = array();
@@ -17,13 +17,13 @@
1818 array( 'repo_name' => $name ),
1919 __METHOD__ );
2020
21 - if( $row ) {
 21+ if ( $row ) {
2222 return self::newFromRow( $row );
2323 } else {
2424 return null;
2525 }
2626 }
27 -
 27+
2828 public static function newFromId( $id ) {
2929 $dbw = wfGetDB( DB_MASTER );
3030 $row = $dbw->selectRow(
@@ -34,10 +34,10 @@
3535 'repo_path',
3636 'repo_viewvc',
3737 'repo_bugzilla' ),
38 - array( 'repo_id' => intval($id) ),
 38+ array( 'repo_id' => intval( $id ) ),
3939 __METHOD__ );
4040
41 - if( $row ) {
 41+ if ( $row ) {
4242 return self::newFromRow( $row );
4343 } else {
4444 return null;
@@ -46,7 +46,7 @@
4747
4848 static function newFromRow( $row ) {
4949 $repo = new CodeRepository();
50 - $repo->mId = intval($row->repo_id);
 50+ $repo->mId = intval( $row->repo_id );
5151 $repo->mName = $row->repo_name;
5252 $repo->mPath = $row->repo_path;
5353 $repo->mViewVc = $row->repo_viewvc;
@@ -54,11 +54,11 @@
5555 return $repo;
5656 }
5757
58 - static function getRepoList(){
 58+ static function getRepoList() {
5959 $dbr = wfGetDB( DB_SLAVE );
6060 $res = $dbr->select( 'code_repo', '*', array(), __METHOD__ );
6161 $repos = array();
62 - foreach( $res as $row ){
 62+ foreach ( $res as $row ) {
6363 $repos[] = self::newFromRow( $row );
6464 }
6565 return $repos;
@@ -72,11 +72,11 @@
7373 return $this->mName;
7474 }
7575
76 - public function getPath(){
 76+ public function getPath() {
7777 return $this->mPath;
7878 }
7979
80 - public function getViewVcBase(){
 80+ public function getViewVcBase() {
8181 return $this->mViewVc;
8282 }
8383
@@ -84,7 +84,7 @@
8585 * Return a bug URL or false.
8686 */
8787 public function getBugPath( $bugId ) {
88 - if( $this->mBugzilla ) {
 88+ if ( $this->mBugzilla ) {
8989 return str_replace( '$1',
9090 urlencode( $bugId ), $this->mBugzilla );
9191 }
@@ -101,52 +101,52 @@
102102 );
103103 return intval( $row );
104104 }
105 -
 105+
106106 public function getAuthorList() {
107107 global $wgMemc;
108108 $key = wfMemcKey( 'codereview', 'authors', $this->getId() );
109109 $authors = $wgMemc->get( $key );
110 - if( is_array($authors) ) {
 110+ if ( is_array( $authors ) ) {
111111 return $authors;
112112 }
113113 $dbr = wfGetDB( DB_SLAVE );
114 - $res = $dbr->select(
 114+ $res = $dbr->select(
115115 'code_rev',
116116 array( 'cr_author', 'MAX(cr_timestamp) AS time' ),
117117 array( 'cr_repo_id' => $this->getId() ),
118118 __METHOD__,
119 - array( 'GROUP BY' => 'cr_author',
 119+ array( 'GROUP BY' => 'cr_author',
120120 'ORDER BY' => 'time DESC', 'LIMIT' => 500 )
121121 );
122122 $authors = array();
123 - while( $row = $dbr->fetchObject( $res ) ) {
 123+ while ( $row = $dbr->fetchObject( $res ) ) {
124124 $authors[] = $row->cr_author;
125125 }
126 - $wgMemc->set( $key, $authors, 3600*24*3 );
 126+ $wgMemc->set( $key, $authors, 3600 * 24 * 3 );
127127 return $authors;
128128 }
129 -
 129+
130130 public function getTagList() {
131131 global $wgMemc;
132132 $key = wfMemcKey( 'codereview', 'tags', $this->getId() );
133133 $tags = $wgMemc->get( $key );
134 - if( is_array($tags) ) {
 134+ if ( is_array( $tags ) ) {
135135 return $tags;
136136 }
137137 $dbr = wfGetDB( DB_SLAVE );
138 - $res = $dbr->select(
 138+ $res = $dbr->select(
139139 'code_tags',
140140 array( 'ct_tag', 'COUNT(*) AS revs' ),
141141 array( 'ct_repo_id' => $this->getId() ),
142142 __METHOD__,
143 - array( 'GROUP BY' => 'ct_tag',
 143+ array( 'GROUP BY' => 'ct_tag',
144144 'ORDER BY' => 'revs DESC', 'LIMIT' => 500 )
145145 );
146146 $tags = array();
147 - while( $row = $dbr->fetchObject( $res ) ) {
 147+ while ( $row = $dbr->fetchObject( $res ) ) {
148148 $tags[] = $row->ct_tag;
149149 }
150 - $wgMemc->set( $key, $tags, 3600*24*3 );
 150+ $wgMemc->set( $key, $tags, 3600 * 24 * 3 );
151151 return $tags;
152152 }
153153
@@ -166,7 +166,7 @@
167167 ),
168168 __METHOD__
169169 );
170 - if( !$row )
 170+ if ( !$row )
171171 throw new MWException( 'Failed to load expected revision data' );
172172 return CodeRevision::newFromRow( $this, $row );
173173 }
@@ -182,34 +182,34 @@
183183
184184 $rev1 = $rev - 1;
185185 $rev2 = $rev;
186 -
 186+
187187 $revision = $this->getRevision( $rev );
188 - if( $revision == null || !$revision->isDiffable() ) {
 188+ if ( $revision == null || !$revision->isDiffable() ) {
189189 wfProfileOut( __METHOD__ );
190190 return false;
191191 }
192192
193193 # Try memcached...
194194 $key = wfMemcKey( 'svn', md5( $this->mPath ), 'diff', $rev1, $rev2 );
195 - if( $useCache === 'skipcache' ) {
 195+ if ( $useCache === 'skipcache' ) {
196196 $data = NULL;
197197 } else {
198198 $data = $wgMemc->get( $key );
199199 }
200200
201201 # Try the database...
202 - if( !$data && $useCache != 'skipcache' ) {
 202+ if ( !$data && $useCache != 'skipcache' ) {
203203 $dbr = wfGetDB( DB_SLAVE );
204 - $row = $dbr->selectRow( 'code_rev',
 204+ $row = $dbr->selectRow( 'code_rev',
205205 array( 'cr_diff', 'cr_flags' ),
206206 array( 'cr_repo_id' => $this->mId, 'cr_id' => $rev, 'cr_diff IS NOT NULL' ),
207207 __METHOD__
208208 );
209 - if( $row ) {
 209+ if ( $row ) {
210210 $flags = explode( ',', $row->cr_flags );
211211 $data = $row->cr_diff;
212212 // If the text was fetched without an error, convert it
213 - if( $data !== false && in_array( 'gzip', $flags ) ) {
 213+ if ( $data !== false && in_array( 'gzip', $flags ) ) {
214214 # Deal with optional compression of archived pages.
215215 # This can be done periodically via maintenance/compressOld.php, and
216216 # as pages are saved if $wgCompressRevisions is set.
@@ -219,16 +219,16 @@
220220 }
221221
222222 # Generate the diff as needed...
223 - if( !$data && $useCache !== 'cached' ) {
 223+ if ( !$data && $useCache !== 'cached' ) {
224224 $svn = SubversionAdaptor::newFromRepo( $this->mPath );
225225 $data = $svn->getDiff( '', $rev1, $rev2 );
226226 // Store to cache
227 - $wgMemc->set( $key, $data, 3600*24*3 );
 227+ $wgMemc->set( $key, $data, 3600 * 24 * 3 );
228228 // Permanent DB storage
229229 $storedData = $data;
230230 $flags = Revision::compressRevisionText( $storedData );
231231 $dbw = wfGetDB( DB_MASTER );
232 - $dbw->update( 'code_rev',
 232+ $dbw->update( 'code_rev',
233233 array( 'cr_diff' => $storedData, 'cr_flags' => $flags ),
234234 array( 'cr_repo_id' => $this->mId, 'cr_id' => $rev ),
235235 __METHOD__
@@ -250,7 +250,7 @@
251251 }
252252 return false;
253253 }
254 -
 254+
255255 /*
256256 * Link the $author to the wikiuser $user
257257 * @param string $author
@@ -259,7 +259,7 @@
260260 */
261261 public function linkUser( $author, User $user ) {
262262 // We must link to an existing user
263 - if( !$user->getId() ) {
 263+ if ( !$user->getId() ) {
264264 return false;
265265 }
266266 $dbw = wfGetDB( DB_MASTER );
@@ -275,7 +275,7 @@
276276 array( 'IGNORE' )
277277 );
278278 // If the last query already found a row, then update it.
279 - if( !$dbw->affectedRows() ) {
 279+ if ( !$dbw->affectedRows() ) {
280280 $dbw->update(
281281 'code_authors',
282282 array( 'ca_user_text' => $user->getName() ),
@@ -308,13 +308,13 @@
309309 self::$userLinks[$author] = false;
310310 return ( $dbw->affectedRows() > 0 );
311311 }
312 -
313 - /*
 312+
 313+ /*
314314 * returns a User object if $author has a wikiuser associated,
315315 * or false
316316 */
317317 public function authorWikiUser( $author ) {
318 - if( isset( self::$userLinks[$author] ) )
 318+ if ( isset( self::$userLinks[$author] ) )
319319 return self::$userLinks[$author];
320320
321321 $dbr = wfGetDB( DB_SLAVE );
@@ -328,9 +328,9 @@
329329 __METHOD__
330330 );
331331 $user = null;
332 - if( $wikiUser )
 332+ if ( $wikiUser )
333333 $user = User::newFromName( $wikiUser );
334 - if( $user instanceof User )
 334+ if ( $user instanceof User )
335335 $res = $user;
336336 else
337337 $res = false;
Index: trunk/extensions/CodeReview/ApiCodeComments.php
@@ -27,25 +27,25 @@
2828 public function __construct( $query, $moduleName ) {
2929 parent::__construct( $query, $moduleName, 'cc' );
3030 }
31 -
 31+
3232 public function execute() {
3333 $params = $this->extractRequestParams();
3434 if ( is_null( $params['repo'] ) )
3535 $this->dieUsageMsg( array( 'missingparam', 'repo' ) );
3636 $this->props = array_flip( $params['prop'] );
37 -
 37+
3838 $listview = new CodeCommentsListView( $params['repo'] );
39 - if( is_null( $listview->getRepo() ) )
 39+ if ( is_null( $listview->getRepo() ) )
4040 $this->dieUsage( "Invalid repo ``{$params['repo']}''", 'invalidrepo' );
4141 $pager = $listview->getPager();
42 -
 42+
4343 if ( !is_null( $params['start'] ) )
4444 $pager->setOffset( $this->getDB()->timestamp( $params['start'] ) );
4545 $limit = $params['limit'];
4646 $pager->setLimit( $limit );
47 -
 47+
4848 $pager->doQuery();
49 -
 49+
5050 $comments = $pager->getResult();
5151 $data = array();
5252
@@ -57,18 +57,18 @@
5858 wfTimestamp( TS_ISO_8601, $lastTimestamp ) );
5959 break;
6060 }
61 -
 61+
6262 $data[] = $this->formatRow( $row );
6363 $lastTimestamp = $row->cc_timestamp;
6464 $count++;
6565 }
6666 $comments->free();
67 -
 67+
6868 $result = $this->getResult();
6969 $result->setIndexedTagName( $data, 'comment' );
7070 $result->addValue( 'query', $this->getModuleName(), $data );
7171 }
72 -
 72+
7373 private function formatRow( $row ) {
7474 $item = array();
7575 if ( isset( $this->props['timestamp'] ) )
@@ -81,7 +81,7 @@
8282 ApiResult::setContent( $item, $row->cc_text );
8383 return $item;
8484 }
85 -
 85+
8686 public function getAllowedParams() {
8787 return array (
8888 'repo' => null,
@@ -92,7 +92,7 @@
9393 ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1,
9494 ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
9595 ),
96 - 'start' => array(
 96+ 'start' => array(
9797 ApiBase :: PARAM_TYPE => 'timestamp'
9898 ),
9999 'prop' => array (
@@ -107,7 +107,7 @@
108108 ),
109109 );
110110 }
111 -
 111+
112112 public function getParamDescription() {
113113 return array(
114114 'repo' => 'Name of the repository',
@@ -116,19 +116,19 @@
117117 'prop' => 'Which properties to return',
118118 );
119119 }
120 -
 120+
121121 public function getDescription() {
122122 return 'List comments on revisions in CodeReview';
123123 }
124 -
 124+
125125 public function getExamples() {
126126 return array(
127127 'api.php?action=query&list=codecomments&ccrepo=MediaWiki',
128128 'api.php?action=query&list=codecomments&ccrepo=MediaWiki&ccprop=timestamp|user|revision|text',
129129 );
130130 }
131 -
 131+
132132 public function getVersion() {
133133 return __CLASS__ . ': $Id$';
134 - }
 134+ }
135135 }
Index: trunk/extensions/CodeReview/SpecialCode.php
@@ -1,5 +1,5 @@
22 <?php
3 -if (!defined('MEDIAWIKI')) die();
 3+if ( !defined( 'MEDIAWIKI' ) ) die();
44
55 class SpecialCode extends SpecialPage {
66 function __construct() {
@@ -14,9 +14,9 @@
1515 $this->setHeaders();
1616 $wgOut->addStyle( "$wgScriptPath/extensions/CodeReview/codereview.css?$wgCodeReviewStyleVersion" );
1717 # Remove stray slashes
18 - $subpage = preg_replace( '/\/$/','', $subpage );
 18+ $subpage = preg_replace( '/\/$/', '', $subpage );
1919
20 - if( $subpage == '' ) {
 20+ if ( $subpage == '' ) {
2121 $view = new CodeRepoListView();
2222 } else {
2323 $params = explode( '/', $subpage );
@@ -25,23 +25,23 @@
2626 $view = new CodeRevisionListView( $params[0] );
2727 break;
2828 case 2:
29 - if( $params[1] === 'tag' ) {
 29+ if ( $params[1] === 'tag' ) {
3030 $view = new CodeTagListView( $params[0] );
3131 break;
32 - } elseif( $params[1] === 'author' ) {
 32+ } elseif ( $params[1] === 'author' ) {
3333 $view = new CodeAuthorListView( $params[0] );
3434 break;
35 - } elseif( $params[1] === 'status' ) {
 35+ } elseif ( $params[1] === 'status' ) {
3636 $view = new CodeStatusListView( $params[0] );
3737 break;
38 - } elseif( $params[1] === 'comments' ) {
 38+ } elseif ( $params[1] === 'comments' ) {
3939 $view = new CodeCommentsListView( $params[0] );
4040 break;
41 - } elseif( $params[1] === 'releasenotes' ) {
 41+ } elseif ( $params[1] === 'releasenotes' ) {
4242 $view = new CodeReleaseNotes( $params[0] );
4343 break;
44 - } else if( $wgRequest->wasPosted() && !$wgRequest->getCheck('wpPreview') ) {
45 - # Add any tags, Set status, Adds comments
 44+ } else if ( $wgRequest->wasPosted() && !$wgRequest->getCheck( 'wpPreview' ) ) {
 45+ # Add any tags, Set status, Adds comments
4646 $submit = new CodeRevisionCommitter( $params[0], $params[1] );
4747 $submit->execute();
4848 return;
@@ -50,46 +50,46 @@
5151 break;
5252 }
5353 case 3:
54 - if( $params[1] === 'tag' ) {
 54+ if ( $params[1] === 'tag' ) {
5555 $view = new CodeRevisionTagView( $params[0], $params[2] );
5656 break;
57 - } elseif( $params[1] === 'author' ) {
 57+ } elseif ( $params[1] === 'author' ) {
5858 $view = new CodeRevisionAuthorView( $params[0], $params[2] );
5959 break;
60 - } elseif( $params[1] === 'status' ) {
 60+ } elseif ( $params[1] === 'status' ) {
6161 $view = new CodeRevisionStatusView( $params[0], $params[2] );
6262 break;
63 - } elseif( $params[1] === 'comments' ) {
 63+ } elseif ( $params[1] === 'comments' ) {
6464 $view = new CodeCommentsListView( $params[0] );
6565 break;
6666 } else {
6767 # Nonsense parameters, back out
68 - if( empty($params[1]) )
 68+ if ( empty( $params[1] ) )
6969 $view = new CodeRevisionListView( $params[0] );
7070 else
7171 $view = new CodeRevisionView( $params[0], $params[1] );
7272 break;
7373 }
7474 case 4:
75 - if ( $params[1] == 'author' && $params[3] == 'link') {
 75+ if ( $params[1] == 'author' && $params[3] == 'link' ) {
7676 $view = new CodeRevisionAuthorLink( $params[0], $params[2] );
7777 break;
7878 }
7979 default:
80 - if( $params[2] == 'reply' ) {
 80+ if ( $params[2] == 'reply' ) {
8181 $view = new CodeRevisionView( $params[0], $params[1], $params[3] );
8282 break;
8383 }
84 - $wgOut->addWikiText( wfMsg('nosuchactiontext') );
 84+ $wgOut->addWikiText( wfMsg( 'nosuchactiontext' ) );
8585 $wgOut->returnToMain( null, SpecialPage::getTitleFor( 'Code' ) );
8686 return;
8787 }
8888 }
8989 $view->execute();
90 -
 90+
9191 // Add subtitle for easy navigation
9292 global $wgOut;
93 - if( $view instanceof CodeView && ($repo = $view->getRepo()) ) {
 93+ if ( $view instanceof CodeView && ( $repo = $view->getRepo() ) ) {
9494 $wgOut->setSubtitle( wfMsgExt( 'codereview-subtitle', 'parse', CodeRepoListView::getNavItem( $repo->getName() ) ) );
9595 }
9696 }
@@ -105,17 +105,17 @@
106106 global $wgUser;
107107 $this->mSkin = $wgUser->getSkin();
108108 }
109 -
 109+
110110 function validPost( $permission ) {
111111 global $wgRequest, $wgUser;
112112 return $wgRequest->wasPosted()
113 - && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) )
 113+ && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) )
114114 && $wgUser->isAllowed( $permission );
115115 }
116116
117117 abstract function execute();
118118
119 - /*
 119+ /*
120120 * returns a User object if $author has a wikiuser associated,
121121 * of false
122122 */
@@ -128,12 +128,12 @@
129129 $special = SpecialPage::getTitleFor( 'Code', "$repo/author/$author" );
130130 return $this->mSkin->link( $special, htmlspecialchars( $author ) );
131131 }
132 -
 132+
133133 function statusDesc( $status ) {
134134 return wfMsg( "code-status-$status" );
135135 }
136136
137 - function formatMessage( $text ){
 137+ function formatMessage( $text ) {
138138 $text = nl2br( htmlspecialchars( $text ) );
139139 $linker = new CodeCommentLinkerHtml( $this->mRepo );
140140 return $linker->link( $text );
@@ -153,12 +153,12 @@
154154 */
155155 function formatMetaData( $fields ) {
156156 $html = '<table class="mw-codereview-meta">';
157 - foreach( $fields as $label => $data ) {
 157+ foreach ( $fields as $label => $data ) {
158158 $html .= "<tr><td>" . wfMsgHtml( $label ) . "</td><td>$data</td></tr>\n";
159159 }
160160 return $html . "</table>\n";
161161 }
162 -
 162+
163163 function getRepo() {
164164 if ( $this->mRepo )
165165 return $this->mRepo;
@@ -176,23 +176,23 @@
177177 function link( $text ) {
178178 # Catch links like http://www.mediawiki.org/wiki/Special:Code/MediaWiki/44245#c829
179179 # Ended by space or brackets (like those pesky <br/> tags)
180 - $text = preg_replace_callback( '/(\b)('.wfUrlProtocols().')([^ <>]+)(\b)/', array( $this, 'generalLink' ), $text );
 180+ $text = preg_replace_callback( '/(\b)(' . wfUrlProtocols() . ')([^ <>]+)(\b)/', array( $this, 'generalLink' ), $text );
181181 $text = preg_replace_callback( '/\br(\d+)\b/', array( $this, 'messageRevLink' ), $text );
182182 $text = preg_replace_callback( '/\bbug #?(\d+)\b/i', array( $this, 'messageBugLink' ), $text );
183183 return $text;
184184 }
185 -
 185+
186186 function generalLink( $arr ) {
187187 $url = $arr[2] . $arr[3];
188188 // Re-add the surrounding space/punctuation
189 - return $arr[1] . $this->makeExternalLink( $url, $url ). $arr[4];
 189+ return $arr[1] . $this->makeExternalLink( $url, $url ) . $arr[4];
190190 }
191191
192192 function messageBugLink( $arr ) {
193193 $text = $arr[0];
194194 $bugNo = intval( $arr[1] );
195195 $url = $this->mRepo->getBugPath( $bugNo );
196 - if( $url ) {
 196+ if ( $url ) {
197197 return $this->makeExternalLink( $url, $text );
198198 } else {
199199 return $text;
Index: trunk/extensions/CodeReview/SpecialRepoAdmin.php
@@ -1,5 +1,5 @@
22 <?php
3 -if (!defined('MEDIAWIKI')) die();
 3+if ( !defined( 'MEDIAWIKI' ) ) die();
44
55 class SpecialRepoAdmin extends SpecialPage {
66 function __construct() {
@@ -12,13 +12,13 @@
1313 wfLoadExtensionMessages( 'CodeReview' );
1414 $this->setHeaders();
1515
16 - if( !$this->userCanExecute( $wgUser ) ){
 16+ if ( !$this->userCanExecute( $wgUser ) ) {
1717 $this->displayRestrictionError();
1818 return;
1919 }
2020
2121 $repo = $wgRequest->getVal( 'repo', $subpage );
22 - if( $repo == '' ) {
 22+ if ( $repo == '' ) {
2323 $view = new RepoAdminListView( $this );
2424 } else {
2525 $view = new RepoAdminRepoView( $this, $repo );
@@ -48,11 +48,11 @@
4949 global $wgOut;
5050 $wgOut->addHTML( $this->getForm() );
5151 $repos = CodeRepository::getRepoList();
52 - if( !count( $repos ) ){
 52+ if ( !count( $repos ) ) {
5353 return;
5454 }
5555 $text = '';
56 - foreach( $repos as $repo ){
 56+ foreach ( $repos as $repo ) {
5757 $name = $repo->getName();
5858 $text .= "* [[Special:RepoAdmin/$name|$name]]\n";
5959 }
@@ -75,10 +75,10 @@
7676 $repoPath = $wgRequest->getVal( 'wpRepoPath', $repoExists ? $this->mRepo->mPath : '' );
7777 $bugPath = $wgRequest->getVal( 'wpBugPath', $repoExists ? $this->mRepo->mBugzilla : '' );
7878 $viewPath = $wgRequest->getVal( 'wpViewPath', $repoExists ? $this->mRepo->mViewVc : '' );
79 - if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ), $this->mRepoName ) ){
 79+ if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ), $this->mRepoName ) ) {
8080 // @todo log
8181 $dbw = wfGetDB( DB_MASTER );
82 - if( $repoExists ){
 82+ if ( $repoExists ) {
8383 $dbw->update(
8484 'code_repo',
8585 array(
Index: trunk/extensions/CodeReview/CodeRevisionTagView.php
@@ -5,7 +5,7 @@
66 parent::__construct( $repoName );
77 $this->mTag = $tag;
88 }
9 -
 9+
1010 function getPager() {
1111 return new SvnRevTagTablePager( $this, $this->mTag );
1212 }
@@ -16,7 +16,7 @@
1717 parent::__construct( $view );
1818 $this->mTag = $tag;
1919 }
20 -
 20+
2121 function getQueryInfo() {
2222 $info = parent::getQueryInfo();
2323 $info['tables'][] = 'code_tags';
@@ -26,7 +26,7 @@
2727 return $info;
2828 }
2929
30 - function getTitle(){
 30+ function getTitle() {
3131 $repo = $this->mRepo->getName();
3232 return SpecialPage::getTitleFor( 'Code', "$repo/tag/$this->mTag" );
3333 }
Index: trunk/extensions/CodeReview/codereview.js
@@ -12,12 +12,12 @@
1313 injectSpinner(CodeReview.diffTarget(), 'codereview-diff');
1414 xmlhttp.open("GET", path, true);
1515 xmlhttp.onreadystatechange=function(){
16 - if (xmlhttp.readyState==4) {
 16+ if (xmlhttp.readyState==4) {
1717 CodeReview.decodeAndShowDiff(xmlhttp.responseText);
1818 removeSpinner('codereview-diff');
1919 }
2020 };
21 - xmlhttp.send(null);
 21+ xmlhttp.send(null);
2222 } catch (e) {
2323 if (window.location.hostname == "localhost") {
2424 alert("Your browser blocks XMLHttpRequest to 'localhost', try using a real hostname for development/testing.");
Index: trunk/extensions/CodeReview/CodePropChange.php
@@ -1,15 +1,15 @@
22 <?php
3 -if (!defined('MEDIAWIKI')) die();
 3+if ( !defined( 'MEDIAWIKI' ) ) die();
44
55 class CodePropChange {
66 function __construct( $rev ) {
77 $this->rev = $rev;
88 }
9 -
 9+
1010 static function newFromRow( $rev, $row ) {
1111 return self::newFromData( $rev, get_object_vars( $row ) );
1212 }
13 -
 13+
1414 static function newFromData( $rev, $data ) {
1515 $change = new CodeComment( $rev );
1616 $change->attrib = $data['cpc_attrib'];
@@ -17,7 +17,7 @@
1818 $change->added = $data['cpc_added'];
1919 $change->user = $data['cpc_user'];
2020 // We'd prefer the up to date user table name
21 - $change->userText = isset($data['user_name']) ? $data['user_name'] : $data['cpc_user_text'];
 21+ $change->userText = isset( $data['user_name'] ) ? $data['user_name'] : $data['cpc_user_text'];
2222 $change->timestamp = wfTimestamp( TS_MW, $data['cpc_timestamp'] );
2323 return $change;
2424 }
Index: trunk/extensions/CodeReview/CodeAuthorListView.php
@@ -12,11 +12,10 @@
1313 $authors = $this->mRepo->getAuthorList();
1414 $name = $this->mRepo->getName();
1515 $text = wfMsg( 'code-authors-text' ) . "\n";
16 - foreach( $authors as $user ) {
17 - if( $user )
 16+ foreach ( $authors as $user ) {
 17+ if ( $user )
1818 $text .= "* [[Special:Code/$name/author/$user|$user]]\n";
1919 }
2020 $wgOut->addWikiText( $text );
2121 }
2222 }
23 -
Index: trunk/extensions/CodeReview/CodeReview.alias.php
@@ -159,4 +159,3 @@
160160 'Code' => array( 'Kodigo', 'Pagsusuri ng kodigo' ),
161161 'RepoAdmin' => array( 'Tagapangasiwa ng repositoryo' ),
162162 );
163 -
Index: trunk/extensions/CodeReview/DiffHighlighter.php
@@ -4,7 +4,7 @@
55 * Highlight a SVN diff for easier readibility
66 */
77 class CodeDiffHighlighter {
8 -
 8+
99 /**
1010 * Main entry point. Given a diff text, highlight it
1111 * and wrap it in a div
@@ -16,7 +16,7 @@
1717 $this->splitLines( $text ) .
1818 "</pre>\n";
1919 }
20 -
 20+
2121 /**
2222 * Given a bunch of text, split it into individual
2323 * lines, color them, then put it back into one big
@@ -29,7 +29,7 @@
3030 array_map( array( $this, 'colorLine' ),
3131 explode( "\n", $text ) ) );
3232 }
33 -
 33+
3434 /**
3535 * Turn a diff line into a properly formatted string suitable
3636 * for output
@@ -40,7 +40,7 @@
4141 list( $element, $attribs ) = $this->tagForLine( $line );
4242 return Xml::element( $element, $attribs, $line );
4343 }
44 -
 44+
4545 /**
4646 * Take a line of a diff and apply the appropriate stylings
4747 * @param $line string Line to check
@@ -55,10 +55,10 @@
5656 ' ' => array( 'span', array() ),
5757 );
5858 $first = substr( $line, 0, 1 );
59 - if( isset( $tags[$first] ) )
 59+ if ( isset( $tags[$first] ) )
6060 return $tags[$first];
6161 else
6262 return $default;
6363 }
64 -
 64+
6565 }
Index: trunk/extensions/CodeReview/CodeRevisionStatusView.php
@@ -5,7 +5,7 @@
66 parent::__construct( $repoName );
77 $this->mStatus = $status;
88 }
9 -
 9+
1010 function getPager() {
1111 return new SvnRevStatusTablePager( $this, $this->mStatus );
1212 }
@@ -16,14 +16,14 @@
1717 parent::__construct( $view );
1818 $this->mStatus = $status;
1919 }
20 -
 20+
2121 function getQueryInfo() {
2222 $info = parent::getQueryInfo();
23 - $info['conds']['cr_status'] = $this->mStatus; // fixme: normalize input?
 23+ $info['conds']['cr_status'] = $this->mStatus; // FIXME: normalize input?
2424 return $info;
2525 }
2626
27 - function getTitle(){
 27+ function getTitle() {
2828 $repo = $this->mRepo->getName();
2929 return SpecialPage::getTitleFor( 'Code', "$repo/status/$this->mStatus" );
3030 }
Index: trunk/extensions/CodeReview/CodeTagListView.php
@@ -12,10 +12,9 @@
1313 $tags = $this->mRepo->getTagList();
1414 $name = $this->mRepo->getName();
1515 $text = '';
16 - foreach( $tags as $tag ) {
 16+ foreach ( $tags as $tag ) {
1717 $text .= "* [[Special:Code/$name/tag/$tag|$tag]]\n";
1818 }
1919 $wgOut->addWikiText( $text );
2020 }
2121 }
22 -
Index: trunk/extensions/CodeReview/ApiCodeDiff.php
@@ -4,36 +4,36 @@
55
66 public function execute() {
77 $params = $this->extractRequestParams();
8 -
9 - if( !isset( $params['repo'] ) ) {
 8+
 9+ if ( !isset( $params['repo'] ) ) {
1010 $this->dieUsageMsg( array( 'missingparam', 'repo' ) );
1111 }
12 - if( !isset( $params['rev'] ) ) {
 12+ if ( !isset( $params['rev'] ) ) {
1313 $this->dieUsageMsg( array( 'missingparam', 'rev' ) );
1414 }
15 -
 15+
1616 $repo = CodeRepository::newFromName( $params['repo'] );
17 - if( !$repo ){
18 - $this->dieUsage("Invalid repo ``{$params['repo']}''", 'invalidrepo');
 17+ if ( !$repo ) {
 18+ $this->dieUsage( "Invalid repo ``{$params['repo']}''", 'invalidrepo' );
1919 }
20 -
 20+
2121 $svn = SubversionAdaptor::newFromRepo( $repo->getPath() );
2222 $lastStoredRev = $repo->getLastStoredRev();
23 -
24 - if( $params['rev'] > $lastStoredRev ) {
25 - $this->dieUsage("There is no revision with ID {$params['rev']}", 'nosuchrev');
 23+
 24+ if ( $params['rev'] > $lastStoredRev ) {
 25+ $this->dieUsage( "There is no revision with ID {$params['rev']}", 'nosuchrev' );
2626 }
27 -
 27+
2828 $diff = $repo->getDiff( $params['rev'] );
29 -
30 - if( $diff ) {
 29+
 30+ if ( $diff ) {
3131 $hilite = new CodeDiffHighlighter();
3232 $html = $hilite->render( $diff );
3333 } else {
3434 // FIXME: Are we sure we don't want to throw an error here?
3535 $html = 'Failed to load diff.';
3636 }
37 -
 37+
3838 $data = array(
3939 'repo' => $params['repo'],
4040 'id' => $params['rev'],
@@ -41,7 +41,7 @@
4242 );
4343 $this->getResult()->addValue( 'code', 'rev', $data );
4444 }
45 -
 45+
4646 public function getAllowedParams() {
4747 return array(
4848 'repo' => null,
@@ -51,24 +51,24 @@
5252 )
5353 );
5454 }
55 -
 55+
5656 public function getParamDescription() {
5757 return array(
5858 'repo' => 'Name of repository to look at',
5959 'rev' => 'Revision ID to fetch diff of' );
6060 }
61 -
 61+
6262 public function getDescription() {
6363 return array(
6464 'Fetch formatted diff from CodeReview\'s backing revision control system.' );
6565 }
66 -
 66+
6767 public function getExamples() {
6868 return array(
6969 'api.php?action=codediff&repo=MediaWiki&rev=42080',
7070 );
7171 }
72 -
 72+
7373 public function getVersion() {
7474 return __CLASS__ . ': $Id$';
7575 }
Index: trunk/extensions/CodeReview/svnImport.php
@@ -1,18 +1,18 @@
22 <?php
33
44 $IP = getenv( 'MW_INSTALL_PATH' );
5 -if( $IP === false )
6 - $IP = dirname( __FILE__ ). '/../..';
 5+if ( $IP === false )
 6+ $IP = dirname( __FILE__ ) . '/../..';
77 require "$IP/maintenance/commandLine.inc";
88
9 -if( !isset( $args[0] ) ){
 9+if ( !isset( $args[0] ) ) {
1010 echo "Usage: php svnImport.php <repo> [<start>]\n";
1111 die;
1212 }
1313
1414 $repo = CodeRepository::newFromName( $args[0] );
1515
16 -if( !$repo ){
 16+if ( !$repo ) {
1717 echo "Invalid repo {$args[0]}\n";
1818 die;
1919 }
@@ -24,32 +24,32 @@
2525
2626 $startTime = microtime( true );
2727 $revCount = 0;
28 -$start = isset( $args[1] ) ? intval($args[1]) : $lastStoredRev + 1;
29 -if( $start > ($lastStoredRev + 1) ){
 28+$start = isset( $args[1] ) ? intval( $args[1] ) : $lastStoredRev + 1;
 29+if ( $start > ( $lastStoredRev + 1 ) ) {
3030 echo "Invalid starting point r{$start}\n";
3131 die;
3232 }
3333
3434 echo "Syncing repo {$args[0]} from r$start to HEAD...\n";
35 -while( true ) {
 35+while ( true ) {
3636 $log = $svn->getLog( '', $start, $start + $chunkSize - 1 );
37 - if( empty($log) ) {
 37+ if ( empty( $log ) ) {
3838 # Repo seems to give a blank when max rev is invalid, which
3939 # stops new revisions from being added. Try to avoid this
4040 # by trying less at a time from the last point.
41 - if( $chunkSize <= 1 ) {
 41+ if ( $chunkSize <= 1 ) {
4242 break; // done!
4343 }
44 - $chunkSize = max( 1, floor($chunkSize/4) );
 44+ $chunkSize = max( 1, floor( $chunkSize / 4 ) );
4545 continue;
4646 } else {
4747 $start += $chunkSize;
4848 }
49 - if( !is_array( $log ) ) {
 49+ if ( !is_array( $log ) ) {
5050 var_dump( $log );
5151 die( 'wtf' );
5252 }
53 - foreach( $log as $data ) {
 53+ foreach ( $log as $data ) {
5454 $revCount++;
5555 $delta = microtime( true ) - $startTime;
5656 $revSpeed = $revCount / $delta;
@@ -68,12 +68,12 @@
6969
7070 echo "Pre-caching the latest 50 diffs...\n";
7171 $dbw = wfGetDB( DB_MASTER );
72 -$res = $dbw->select( 'code_rev', 'cr_id',
73 - array( 'cr_repo_id' => $repo->getId() ),
74 - __METHOD__,
 72+$res = $dbw->select( 'code_rev', 'cr_id',
 73+ array( 'cr_repo_id' => $repo->getId() ),
 74+ __METHOD__,
7575 array( 'ORDER BY' => 'cr_id DESC', 'LIMIT' => 50 )
7676 );
77 -while( $row = $dbw->fetchObject( $res ) ) {
 77+while ( $row = $dbw->fetchObject( $res ) ) {
7878 $rev = $repo->getRevision( $row->cr_id );
7979 $diff = $repo->getDiff( $row->cr_id ); // trigger caching
8080 echo "Diff r{$row->cr_id} done\n";

Status & tagging log