Index: trunk/extensions/CodeReview/codereview.sql |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | -- This is *not* wikitext, but will get some light formatting |
47 | 47 | -- on display... |
48 | 48 | cr_message blob, |
49 | | - |
| 49 | + |
50 | 50 | -- Status key for how this thang is... |
51 | 51 | -- 'new': Hasn't yet been reviewed |
52 | 52 | -- 'fixme': This revision has some problem which needs to be resolved |
— | — | @@ -58,7 +58,7 @@ |
59 | 59 | -- * if the revision change only one file, the file path |
60 | 60 | -- * else, common directory for all changes (e.g. trunk/phase3/includes/ ) |
61 | 61 | cr_path varchar(255) binary, |
62 | | - |
| 62 | + |
63 | 63 | -- Text of the diff or ES url |
64 | 64 | cr_diff mediumblob NULL, |
65 | 65 | -- Text flags: gzip,utf-8,external |
Index: trunk/extensions/CodeReview/ApiCodeUpdate.php |
— | — | @@ -4,39 +4,39 @@ |
5 | 5 | |
6 | 6 | public function execute() { |
7 | 7 | $params = $this->extractRequestParams(); |
8 | | - |
9 | | - if( !isset( $params['repo'] ) ) { |
| 8 | + |
| 9 | + if ( !isset( $params['repo'] ) ) { |
10 | 10 | $this->dieUsageMsg( array( 'missingparam', 'repo' ) ); |
11 | 11 | } |
12 | | - if( !isset( $params['rev'] ) ) { |
| 12 | + if ( !isset( $params['rev'] ) ) { |
13 | 13 | $this->dieUsageMsg( array( 'missingparam', 'rev' ) ); |
14 | 14 | } |
15 | | - |
| 15 | + |
16 | 16 | $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' ); |
19 | 19 | } |
20 | | - |
| 20 | + |
21 | 21 | $svn = SubversionAdaptor::newFromRepo( $repo->getPath() ); |
22 | 22 | $lastStoredRev = $repo->getLastStoredRev(); |
23 | | - |
24 | | - if( $lastStoredRev >= $params['rev'] ) { |
| 23 | + |
| 24 | + if ( $lastStoredRev >= $params['rev'] ) { |
25 | 25 | // Nothing to do, we're up to date. |
26 | 26 | // Return an empty result |
27 | | - $this->getResult()->addValue(null, $this->getModuleName(), array()); |
| 27 | + $this->getResult()->addValue( null, $this->getModuleName(), array() ); |
28 | 28 | return; |
29 | 29 | } |
30 | | - |
| 30 | + |
31 | 31 | // FIXME: this could be a lot? |
32 | 32 | $log = $svn->getLog( '', $lastStoredRev + 1, $params['rev'] ); |
33 | | - if( !$log ) { |
| 33 | + if ( !$log ) { |
34 | 34 | // FIXME: When and how often does this happen? |
35 | 35 | // Should we use dieUsage() here instead? |
36 | 36 | ApiBase::dieDebug( __METHOD__, "Something awry..." ); |
37 | | - } |
38 | | - |
| 37 | + } |
| 38 | + |
39 | 39 | $result = array(); |
40 | | - foreach( $log as $data ) { |
| 40 | + foreach ( $log as $data ) { |
41 | 41 | $codeRev = CodeRevision::newFromSvn( $repo, $data ); |
42 | 42 | $codeRev->save(); |
43 | 43 | $result[] = array( |
— | — | @@ -48,20 +48,20 @@ |
49 | 49 | } |
50 | 50 | // Cache the diffs if there are a only a few. |
51 | 51 | // 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 ) { |
54 | 54 | $diff = $repo->getDiff( $revData['id'] ); // trigger caching |
55 | 55 | } |
56 | 56 | } |
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 ); |
59 | 59 | } |
60 | | - |
| 60 | + |
61 | 61 | public function mustBePosted() { |
62 | 62 | // Discourage casual browsing :) |
63 | 63 | return true; |
64 | 64 | } |
65 | | - |
| 65 | + |
66 | 66 | public function getAllowedParams() { |
67 | 67 | return array( |
68 | 68 | 'repo' => null, |
— | — | @@ -71,24 +71,24 @@ |
72 | 72 | ) |
73 | 73 | ); |
74 | 74 | } |
75 | | - |
| 75 | + |
76 | 76 | public function getParamDescription() { |
77 | 77 | return array( |
78 | 78 | 'repo' => 'Name of repository to update', |
79 | 79 | 'rev' => 'Revision ID number to update to' ); |
80 | 80 | } |
81 | | - |
| 81 | + |
82 | 82 | public function getDescription() { |
83 | 83 | return array( |
84 | 84 | 'Update CodeReview repository data from master revision control system.' ); |
85 | 85 | } |
86 | | - |
| 86 | + |
87 | 87 | public function getExamples() { |
88 | 88 | return array( |
89 | 89 | 'api.php?action=codeupdate&repo=MediaWiki&rev=42080', |
90 | 90 | ); |
91 | 91 | } |
92 | | - |
| 92 | + |
93 | 93 | public function getVersion() { |
94 | 94 | return __CLASS__ . ': $Id$'; |
95 | 95 | } |
Index: trunk/extensions/CodeReview/CodeRevisionAuthorView.php |
— | — | @@ -6,13 +6,13 @@ |
7 | 7 | $this->mAuthor = $author; |
8 | 8 | $this->mUser = $this->authorWikiUser( $author ); |
9 | 9 | } |
10 | | - |
| 10 | + |
11 | 11 | function getPager() { |
12 | 12 | return new SvnRevAuthorTablePager( $this, $this->mAuthor ); |
13 | 13 | } |
14 | 14 | |
15 | 15 | function linkStatus() { |
16 | | - if ( !$this->mUser ) |
| 16 | + if ( !$this->mUser ) |
17 | 17 | return wfMsg( 'code-author-orphan' ); |
18 | 18 | |
19 | 19 | return wfMsgHtml( 'code-author-haslink', |
— | — | @@ -27,9 +27,9 @@ |
28 | 28 | |
29 | 29 | if ( $wgUser->isAllowed( 'codereview-link-user' ) ) { |
30 | 30 | $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' ) ) . ')' ; |
34 | 34 | } |
35 | 35 | |
36 | 36 | $repoLink = $wgUser->getSkin()->link( SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() ), |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | 'code-rev-author' => $this->authorLink( $this->mAuthor ), |
41 | 41 | ); |
42 | 42 | |
43 | | - $wgOut->addHTML($this->formatMetaData( $fields ) . $linkInfo ); |
| 43 | + $wgOut->addHTML( $this->formatMetaData( $fields ) . $linkInfo ); |
44 | 44 | |
45 | 45 | parent::execute(); |
46 | 46 | } |
— | — | @@ -51,14 +51,14 @@ |
52 | 52 | parent::__construct( $view ); |
53 | 53 | $this->mAuthor = $author; |
54 | 54 | } |
55 | | - |
| 55 | + |
56 | 56 | function getQueryInfo() { |
57 | 57 | $info = parent::getQueryInfo(); |
58 | 58 | $info['conds']['cr_author'] = $this->mAuthor; // fixme: normalize input? |
59 | 59 | return $info; |
60 | 60 | } |
61 | 61 | |
62 | | - function getTitle(){ |
| 62 | + function getTitle() { |
63 | 63 | $repo = $this->mRepo->getName(); |
64 | 64 | return SpecialPage::getTitleFor( 'Code', "$repo/author/$this->mAuthor" ); |
65 | 65 | } |
Index: trunk/extensions/CodeReview/CodeRevisionCommitter.php |
— | — | @@ -2,61 +2,61 @@ |
3 | 3 | |
4 | 4 | class CodeRevisionCommitter extends CodeRevisionView { |
5 | 5 | |
6 | | - function __construct( $repoName, $rev ){ |
| 6 | + function __construct( $repoName, $rev ) { |
7 | 7 | // Parent should set $this->mRepo, $this->mRev, $this->mReplyTarget |
8 | 8 | parent::__construct( $repoName, $rev ); |
9 | 9 | } |
10 | 10 | |
11 | 11 | function execute() { |
12 | 12 | 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>' ); |
16 | 16 | parent::execute(); |
17 | 17 | return; |
18 | 18 | } |
19 | | - if( !$this->mRev ) { |
| 19 | + if ( !$this->mRev ) { |
20 | 20 | parent::execute(); |
21 | 21 | return; |
22 | 22 | } |
23 | | - |
| 23 | + |
24 | 24 | $redirTarget = null; |
25 | 25 | $dbw = wfGetDB( DB_MASTER ); |
26 | | - |
| 26 | + |
27 | 27 | $dbw->begin(); |
28 | 28 | // 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 ) ) { |
30 | 30 | $this->mRev->setStatus( $this->mStatus, $wgUser ); |
31 | 31 | } |
32 | 32 | $addTags = $removeTags = array(); |
33 | | - if( $this->validPost('codereview-add-tag') && count($this->mAddTags) ) { |
| 33 | + if ( $this->validPost( 'codereview-add-tag' ) && count( $this->mAddTags ) ) { |
34 | 34 | $addTags = $this->mAddTags; |
35 | 35 | } |
36 | | - if( $this->validPost('codereview-remove-tag') && count($this->mRemoveTags) ) { |
| 36 | + if ( $this->validPost( 'codereview-remove-tag' ) && count( $this->mRemoveTags ) ) { |
37 | 37 | $removeTags = $this->mRemoveTags; |
38 | 38 | } |
39 | 39 | // If allowed to change any tags, then do so |
40 | | - if( count($addTags) || count($removeTags) ) { |
| 40 | + if ( count( $addTags ) || count( $removeTags ) ) { |
41 | 41 | $this->mRev->changeTags( $addTags, $removeTags, $wgUser ); |
42 | 42 | } |
43 | 43 | // Add any comments |
44 | | - if( $this->validPost('codereview-post-comment') && strlen($this->text) ) { |
| 44 | + if ( $this->validPost( 'codereview-post-comment' ) && strlen( $this->text ) ) { |
45 | 45 | $parent = $wgRequest->getIntOrNull( 'wpParent' ); |
46 | 46 | $review = $wgRequest->getInt( 'wpReview' ); |
47 | 47 | $isPreview = $wgRequest->getCheck( 'wpPreview' ); |
48 | 48 | $id = $this->mRev->saveComment( $this->text, $review, $parent ); |
49 | 49 | // For comments, take us back to the rev page focused on the new comment |
50 | | - if( !$this->jumpToNext ) { |
| 50 | + if ( !$this->jumpToNext ) { |
51 | 51 | $redirTarget = $this->commentLink( $id ); |
52 | 52 | } |
53 | 53 | } |
54 | 54 | $dbw->commit(); |
55 | | - |
| 55 | + |
56 | 56 | // 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 ); |
61 | 61 | } else { |
62 | 62 | $redirTitle = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() ); |
63 | 63 | } |
— | — | @@ -67,10 +67,10 @@ |
68 | 68 | } |
69 | 69 | $wgOut->redirect( $redirTitle->getFullUrl() ); |
70 | 70 | } |
71 | | - |
| 71 | + |
72 | 72 | public function validPost( $permission ) { |
73 | 73 | 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' ) ); |
76 | 76 | } |
77 | 77 | } |
Index: trunk/extensions/CodeReview/CodeRevisionListView.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | parent::__construct(); |
10 | 10 | $this->mRepo = CodeRepository::newFromName( $repoName ); |
11 | 11 | $this->mPath = htmlspecialchars( trim( $wgRequest->getVal( 'path' ) ) ); |
12 | | - if( strlen($this->mPath) && $this->mPath[0] !== '/' ) { |
| 12 | + if ( strlen( $this->mPath ) && $this->mPath[0] !== '/' ) { |
13 | 13 | $this->mPath = "/{$this->mPath}"; // make sure this is a valid path |
14 | 14 | } |
15 | 15 | $this->mAuthor = null; |
— | — | @@ -16,133 +16,133 @@ |
17 | 17 | |
18 | 18 | function execute() { |
19 | 19 | global $wgOut, $wgUser, $wgRequest; |
20 | | - if( !$this->mRepo ) { |
| 20 | + if ( !$this->mRepo ) { |
21 | 21 | $view = new CodeRepoListView(); |
22 | 22 | $view->execute(); |
23 | 23 | return; |
24 | 24 | } |
25 | | - |
| 25 | + |
26 | 26 | // Check for batch change requests. |
27 | 27 | $editToken = $wgRequest->getVal( 'wpBatchChangeEditToken' ); |
28 | | - if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $editToken ) ) { |
| 28 | + if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $editToken ) ) { |
29 | 29 | $this->doBatchChange(); |
30 | 30 | return; |
31 | 31 | } |
32 | | - |
| 32 | + |
33 | 33 | $this->showForm(); |
34 | 34 | $pager = $this->getPager(); |
35 | | - |
| 35 | + |
36 | 36 | // 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( |
41 | 41 | $pager->getNavigationBar() . |
42 | | - $pager->getLimitForm() . |
43 | | - Xml::openElement( 'form', |
| 42 | + $pager->getLimitForm() . |
| 43 | + Xml::openElement( 'form', |
44 | 44 | array( 'action' => $pager->getTitle()->getLocalURL(), 'method' => 'post' ) |
45 | 45 | ) . |
46 | | - $pager->getBody() . |
| 46 | + $pager->getBody() . |
47 | 47 | $pager->getNavigationBar() . |
48 | | - ( $this->batchForm ? $this->buildBatchInterface( $pager ) : "" ). |
| 48 | + ( $this->batchForm ? $this->buildBatchInterface( $pager ) : "" ) . |
49 | 49 | Xml::closeElement( 'form' ) |
50 | 50 | ); |
51 | 51 | } |
52 | | - |
| 52 | + |
53 | 53 | function doBatchChange() { |
54 | 54 | global $wgRequest; |
55 | | - |
| 55 | + |
56 | 56 | $revisions = $wgRequest->getArray( 'wpRevisionSelected' ); |
57 | 57 | $removeTags = $wgRequest->getVal( 'wpRemoveTag' ); |
58 | 58 | $addTags = $wgRequest->getVal( 'wpTag' ); |
59 | 59 | $status = $wgRequest->getVal( 'wpStatus' ); |
60 | | - |
| 60 | + |
61 | 61 | // Grab data from the DB |
62 | 62 | $dbr = wfGetDB( DB_SLAVE ); |
63 | 63 | $revObjects = array(); |
64 | 64 | $res = $dbr->select( 'code_rev', '*', array( 'cr_id' => $revisions ), __METHOD__ ); |
65 | | - while( $row = $dbr->fetchObject( $res ) ) { |
| 65 | + while ( $row = $dbr->fetchObject( $res ) ) { |
66 | 66 | $revObjects[] = CodeRevision::newFromRow( $this->mRepo, $row ); |
67 | 67 | } |
68 | | - |
| 68 | + |
69 | 69 | global $wgUser; |
70 | 70 | if ( $wgUser->isAllowed( 'codereview-add-tag' ) && |
71 | 71 | $addTags || $removeTags ) { |
72 | 72 | $addTags = array_map( 'trim', explode( ",", $addTags ) ); |
73 | 73 | $removeTags = array_map( 'trim', explode( ",", $removeTags ) ); |
74 | | - |
75 | | - foreach( $revObjects as $id => $rev ) { |
| 74 | + |
| 75 | + foreach ( $revObjects as $id => $rev ) { |
76 | 76 | $rev->changeTags( $addTags, $removeTags, $wgUser ); |
77 | 77 | } |
78 | 78 | } |
79 | | - |
80 | | - if( $wgUser->isAllowed( 'codereview-set-status' ) && |
| 79 | + |
| 80 | + if ( $wgUser->isAllowed( 'codereview-set-status' ) && |
81 | 81 | $revObjects[0]->isValidStatus( $status ) ) { |
82 | | - foreach( $revObjects as $id => $rev ) { |
| 82 | + foreach ( $revObjects as $id => $rev ) { |
83 | 83 | $rev->setStatus( $status, $wgUser ); |
84 | 84 | } |
85 | 85 | } |
86 | | - |
| 86 | + |
87 | 87 | // Automatically refresh |
88 | 88 | // This way of getting GET parameters is horrible, but effective. |
89 | 89 | $fields = array_merge( $_GET, $_POST ); |
90 | | - foreach( array_keys( $fields ) as $key ) { |
| 90 | + foreach ( array_keys( $fields ) as $key ) { |
91 | 91 | if ( substr( $key, 0, 2 ) == 'wp' || $key == 'title' ) |
92 | 92 | unset( $fields[$key] ); |
93 | 93 | } |
94 | | - |
| 94 | + |
95 | 95 | global $wgOut; |
96 | 96 | $wgOut->redirect( $this->getPager()->getTitle()->getFullURL( $fields ) ); |
97 | 97 | } |
98 | | - |
| 98 | + |
99 | 99 | protected function buildBatchInterface( $pager ) { |
100 | 100 | global $wgUser; |
101 | | - |
| 101 | + |
102 | 102 | $changeInterface = ''; |
103 | 103 | $changeFields = array(); |
104 | | - |
105 | | - if( $wgUser->isAllowed( 'codereview-set-status' ) ) { |
| 104 | + |
| 105 | + if ( $wgUser->isAllowed( 'codereview-set-status' ) ) { |
106 | 106 | $changeFields['code-batch-status'] = |
107 | | - Xml::tags( 'select', array( 'name' => 'wpStatus' ), |
| 107 | + Xml::tags( 'select', array( 'name' => 'wpStatus' ), |
108 | 108 | Xml::tags( 'option', |
109 | 109 | array( 'value' => '', 'selected' => 'selected' ), ' ' |
110 | 110 | ) . |
111 | 111 | CodeRevisionView::buildStatusList( null, $this ) |
112 | 112 | ); |
113 | 113 | } |
114 | | - |
115 | | - if( $wgUser->isAllowed( 'codereview-add-tag' ) ) { |
| 114 | + |
| 115 | + if ( $wgUser->isAllowed( 'codereview-add-tag' ) ) { |
116 | 116 | $changeFields['code-batch-tags'] = CodeRevisionView::addTagForm( '', '' ); |
117 | 117 | } |
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' ), |
122 | 122 | Xml::buildForm( $changeFields, 'codereview-batch-submit' ) ); |
123 | | - |
| 123 | + |
124 | 124 | $changeInterface .= $pager->getHiddenFields(); |
125 | 125 | $changeInterface .= Xml::hidden( 'wpBatchChangeEditToken', $wgUser->editToken() ); |
126 | | - |
| 126 | + |
127 | 127 | return $changeInterface; |
128 | 128 | } |
129 | | - |
| 129 | + |
130 | 130 | function showForm( $path = '' ) { |
131 | 131 | 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 ); |
134 | 134 | } else { |
135 | | - $special = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName().'/path' ); |
| 135 | + $special = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/path' ); |
136 | 136 | } |
137 | | - $wgOut->addHTML( |
| 137 | + $wgOut->addHTML( |
138 | 138 | Xml::openElement( 'form', array( 'action' => $wgScript, 'method' => 'get' ) ) . |
139 | | - "<fieldset><legend>".wfMsgHtml('code-pathsearch-legend')."</legend>" . |
| 139 | + "<fieldset><legend>" . wfMsgHtml( 'code-pathsearch-legend' ) . "</legend>" . |
140 | 140 | 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 ) . |
142 | 142 | ' ' . Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" . |
143 | 143 | "</fieldset>" . Xml::closeElement( 'form' ) |
144 | 144 | ); |
145 | 145 | } |
146 | | - |
| 146 | + |
147 | 147 | function getPager() { |
148 | 148 | return new SvnRevTablePager( $this ); |
149 | 149 | } |
— | — | @@ -159,7 +159,7 @@ |
160 | 160 | $this->mCurSVN = SpecialVersion::getSvnRevision( $IP ); |
161 | 161 | parent::__construct(); |
162 | 162 | } |
163 | | - |
| 163 | + |
164 | 164 | function getSVNPath() { |
165 | 165 | return $this->mView->mPath; |
166 | 166 | } |
— | — | @@ -174,18 +174,18 @@ |
175 | 175 | |
176 | 176 | function getQueryInfo() { |
177 | 177 | // Path-based query... |
178 | | - if( $this->getDefaultSort() === 'cp_rev_id' ) { |
| 178 | + if ( $this->getDefaultSort() === 'cp_rev_id' ) { |
179 | 179 | return array( |
180 | 180 | 'tables' => array( 'code_paths', 'code_rev', 'code_comment' ), |
181 | 181 | 'fields' => $this->getSelectFields(), |
182 | | - 'conds' => array( |
| 182 | + 'conds' => array( |
183 | 183 | '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() ) . '%' ), |
185 | 185 | // performance |
186 | | - 'cp_rev_id > '.$this->mRepo->getLastStoredRev() - 20000 |
| 186 | + 'cp_rev_id > ' . $this->mRepo->getLastStoredRev() - 20000 |
187 | 187 | ), |
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( |
190 | 190 | 'code_rev' => array( 'INNER JOIN', 'cr_repo_id = cp_repo_id AND cr_id = cp_rev_id' ), |
191 | 191 | 'code_comment' => array( 'LEFT JOIN', 'cc_repo_id = cp_repo_id AND cc_rev_id = cp_rev_id' ) |
192 | 192 | ) |
— | — | @@ -197,14 +197,14 @@ |
198 | 198 | 'fields' => $this->getSelectFields(), |
199 | 199 | 'conds' => array( 'cr_repo_id' => $this->mRepo->getId() ), |
200 | 200 | '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' ) |
203 | 203 | ) |
204 | 204 | ); |
205 | 205 | } |
206 | 206 | return false; |
207 | 207 | } |
208 | | - |
| 208 | + |
209 | 209 | function getSelectFields() { |
210 | 210 | return array( $this->getDefaultSort(), 'cr_status', 'COUNT( DISTINCT cc_id ) AS comments', |
211 | 211 | 'cr_path', 'cr_message', 'cr_author', 'cr_timestamp' ); |
— | — | @@ -221,14 +221,14 @@ |
222 | 222 | 'cr_timestamp' => wfMsg( 'code-field-timestamp' ), |
223 | 223 | ); |
224 | 224 | # 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; |
227 | 227 | } |
228 | 228 | return $fields; |
229 | 229 | } |
230 | | - |
231 | | - function formatValue( $name, $value ) {} // unused |
232 | | - |
| 230 | + |
| 231 | + function formatValue( $name, $value ) { } // unused |
| 232 | + |
233 | 233 | function formatRevValue( $name, $value, $row ) { |
234 | 234 | global $wgUser, $wgLang; |
235 | 235 | switch( $name ) { |
— | — | @@ -253,8 +253,8 @@ |
254 | 254 | global $wgLang; |
255 | 255 | return $wgLang->timeanddate( $value, true ); |
256 | 256 | 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() } ); |
259 | 259 | $special->setFragment( '#code-comments' ); |
260 | 260 | return $this->mView->mSkin->link( $special, htmlspecialchars( $value ) ); |
261 | 261 | } else { |
— | — | @@ -267,22 +267,22 @@ |
268 | 268 | $wgLang->truncate( (string)$value, 30 ) ) . "</div>"; |
269 | 269 | } |
270 | 270 | } |
271 | | - |
| 271 | + |
272 | 272 | // Note: this function is poorly factored in the parent class |
273 | 273 | function formatRow( $row ) { |
274 | 274 | global $wgWikiSVN; |
275 | 275 | $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' ); |
278 | 278 | } |
279 | 279 | $s = "<tr class=\"$css\">\n"; |
280 | 280 | // Some of this stolen from Pager.php...sigh |
281 | 281 | $fieldNames = $this->getFieldNames(); |
282 | 282 | $this->mCurrentRow = $row; # In case formatValue needs to know |
283 | | - foreach( $fieldNames as $field => $name ) { |
| 283 | + foreach ( $fieldNames as $field => $name ) { |
284 | 284 | $value = isset( $row->$field ) ? $row->$field : null; |
285 | 285 | $formatted = strval( $this->formatRevValue( $field, $value, $row ) ); |
286 | | - if( $formatted == '' ) { |
| 286 | + if ( $formatted == '' ) { |
287 | 287 | $formatted = ' '; |
288 | 288 | } |
289 | 289 | $class = 'TablePager_col_' . htmlspecialchars( $field ); |
— | — | @@ -291,7 +291,7 @@ |
292 | 292 | $s .= "</tr>\n"; |
293 | 293 | return $s; |
294 | 294 | } |
295 | | - |
| 295 | + |
296 | 296 | function getTitle() { |
297 | 297 | return SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() ); |
298 | 298 | } |
Index: trunk/extensions/CodeReview/CodeReleaseNotes.php |
— | — | @@ -6,20 +6,20 @@ |
7 | 7 | parent::__construct( $repoName ); |
8 | 8 | $this->mRepo = CodeRepository::newFromName( $repoName ); |
9 | 9 | $this->mPath = htmlspecialchars( trim( $wgRequest->getVal( 'path' ) ) ); |
10 | | - if( strlen($this->mPath) && $this->mPath[0] !== '/' ) { |
| 10 | + if ( strlen( $this->mPath ) && $this->mPath[0] !== '/' ) { |
11 | 11 | $this->mPath = "/{$this->mPath}"; // make sure this is a valid path |
12 | 12 | } |
13 | 13 | $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' ); |
16 | 16 | # 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 ) { |
18 | 18 | $this->mStartRev = SpecialVersion::getSvnRevision( $IP ) + 1; |
19 | 19 | } |
20 | 20 | } |
21 | | - |
| 21 | + |
22 | 22 | function execute() { |
23 | | - if( !$this->mRepo ) { |
| 23 | + if ( !$this->mRepo ) { |
24 | 24 | $view = new CodeRepoListView(); |
25 | 25 | $view->execute(); |
26 | 26 | return; |
— | — | @@ -27,49 +27,49 @@ |
28 | 28 | $this->showForm(); |
29 | 29 | # Sanity/performance check... |
30 | 30 | $lastRev = $this->mRepo->getLastStoredRev(); |
31 | | - if( $this->mStartRev < ($lastRev - 3000) ) |
| 31 | + if ( $this->mStartRev < ( $lastRev - 3000 ) ) |
32 | 32 | $this->mStartRev = NULL; |
33 | 33 | # Show notes if we have at least a starting revision |
34 | | - if( $this->mStartRev ) { |
| 34 | + if ( $this->mStartRev ) { |
35 | 35 | $this->showReleaseNotes(); |
36 | 36 | } |
37 | 37 | } |
38 | | - |
| 38 | + |
39 | 39 | protected function showForm() { |
40 | 40 | 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( |
43 | 43 | Xml::openElement( 'form', array( 'action' => $wgScript, 'method' => 'get' ) ) . |
44 | | - "<fieldset><legend>".wfMsgHtml('code-release-legend')."</legend>" . |
| 44 | + "<fieldset><legend>" . wfMsgHtml( 'code-release-legend' ) . "</legend>" . |
45 | 45 | 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 ) . |
47 | 47 | '</b> ' . |
48 | | - Xml::inputlabel( wfMsg("code-release-endrev"), 'endrev', 'endrev', 10, $this->mEndRev ) . |
| 48 | + Xml::inputlabel( wfMsg( "code-release-endrev" ), 'endrev', 'endrev', 10, $this->mEndRev ) . |
49 | 49 | ' ' . |
50 | | - Xml::inputlabel( wfMsg("code-pathsearch-path"), 'path', 'path', 45, $this->mPath ) . |
| 50 | + Xml::inputlabel( wfMsg( "code-pathsearch-path" ), 'path', 'path', 45, $this->mPath ) . |
51 | 51 | ' ' . |
52 | 52 | Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" . |
53 | 53 | "</fieldset>" . Xml::closeElement( 'form' ) |
54 | 54 | ); |
55 | 55 | } |
56 | | - |
| 56 | + |
57 | 57 | protected function showReleaseNotes() { |
58 | 58 | global $wgOut; |
59 | 59 | $linker = new CodeCommentLinkerWiki( $this->mRepo ); |
60 | 60 | $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 ); |
63 | 63 | } else { |
64 | | - $where = 'cr_id >= '.intval($this->mStartRev); |
| 64 | + $where = 'cr_id >= ' . intval( $this->mStartRev ); |
65 | 65 | } |
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 ) . ')'; |
69 | 69 | } |
70 | 70 | # 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( |
74 | 74 | 'cr_repo_id' => $this->mRepo->getId(), // this repo |
75 | 75 | "cr_status NOT IN('reverted','deferred','fixme')", // not reverted/deferred/fixme |
76 | 76 | "cr_message != ''", |
— | — | @@ -77,24 +77,24 @@ |
78 | 78 | ), |
79 | 79 | __METHOD__, |
80 | 80 | 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"' ) |
83 | 83 | ) |
84 | 84 | ); |
85 | 85 | $wgOut->addHTML( '<ul>' ); |
86 | 86 | # 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 ); |
89 | 89 | # Add this commit summary if needed. |
90 | | - if( $row->rnotes || $this->isRelevant($summary) ) { |
| 90 | + if ( $row->rnotes || $this->isRelevant( $summary ) ) { |
91 | 91 | # Keep it short if possible... |
92 | 92 | $summary = $this->shortenSummary( $summary ); |
93 | 93 | # Anything left? (this can happen with some heuristics) |
94 | | - if( $summary ) { |
| 94 | + if ( $summary ) { |
95 | 95 | $summary = str_replace( "\n", "<br/>", $summary ); // Newlines -> <br/> |
96 | 96 | $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}" ) . ")''"; |
99 | 99 | $wgOut->addWikiText( $wikiText, false ); |
100 | 100 | $wgOut->addHTML( "</li>\n" ); |
101 | 101 | } |
— | — | @@ -102,14 +102,14 @@ |
103 | 103 | } |
104 | 104 | $wgOut->addHTML( '</ul>' ); |
105 | 105 | } |
106 | | - |
| 106 | + |
107 | 107 | private function shortenSummary( $summary, $first = true ) { |
108 | 108 | # 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 ); |
111 | 111 | # 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 ); |
114 | 114 | } else { |
115 | 115 | return trim( $summary ); |
116 | 116 | } |
— | — | @@ -117,49 +117,49 @@ |
118 | 118 | $blurbs = array_filter( $blurbs ); # Filter out any garbage |
119 | 119 | # Doesn't start with '*' and has some length? |
120 | 120 | # 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; |
123 | 123 | } else { |
124 | 124 | $header = false; |
125 | 125 | } |
126 | 126 | # Keep it short if possible... |
127 | | - if( count($blurbs) > 1 ) { |
| 127 | + if ( count( $blurbs ) > 1 ) { |
128 | 128 | $summary = array(); |
129 | | - foreach( $blurbs as $blurb ) { |
| 129 | + foreach ( $blurbs as $blurb ) { |
130 | 130 | # 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 ); |
133 | 133 | # 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; |
137 | 137 | } |
138 | 138 | } |
139 | | - $summary = implode("\n",$summary); |
| 139 | + $summary = implode( "\n", $summary ); |
140 | 140 | } else { |
141 | | - $summary = implode("\n",$blurbs); |
| 141 | + $summary = implode( "\n", $blurbs ); |
142 | 142 | } |
143 | 143 | return $summary; |
144 | 144 | } |
145 | | - |
| 145 | + |
146 | 146 | // Quick relevance tests (these *should* be over-inclusive a little if anything) |
147 | 147 | private function isRelevant( $summary, $whole = true ) { |
148 | 148 | # 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 ) ) |
150 | 150 | return true; |
151 | 151 | # 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 ) |
154 | 154 | 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 ) ) |
157 | 157 | return true; |
158 | 158 | # 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 ) ) |
160 | 160 | return true; |
161 | 161 | # 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? |
164 | 164 | } else { |
165 | 165 | return true; |
166 | 166 | } |
Index: trunk/extensions/CodeReview/CodeRevisionView.php |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | // Special:Code/MediaWiki/40696 |
5 | 5 | class CodeRevisionView extends CodeView { |
6 | 6 | |
7 | | - function __construct( $repoName, $rev, $replyTarget=null ){ |
| 7 | + function __construct( $repoName, $rev, $replyTarget = null ) { |
8 | 8 | global $wgRequest; |
9 | 9 | parent::__construct(); |
10 | 10 | $this->mRepo = CodeRepository::newFromName( $repoName ); |
— | — | @@ -11,26 +11,26 @@ |
12 | 12 | $this->mPreviewText = false; |
13 | 13 | # URL params... |
14 | 14 | $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 ? |
19 | 19 | (int)$replyTarget : $wgRequest->getIntOrNull( 'wpParent' ); |
20 | 20 | $this->text = $wgRequest->getText( "wpReply{$this->mReplyTarget}" ); |
21 | | - $this->mSkipCache = ($wgRequest->getVal( 'action' ) == 'purge'); |
| 21 | + $this->mSkipCache = ( $wgRequest->getVal( 'action' ) == 'purge' ); |
22 | 22 | # Make tag arrays |
23 | 23 | $this->mAddTags = $this->splitTags( $this->mAddTags ); |
24 | 24 | $this->mRemoveTags = $this->splitTags( $this->mRemoveTags ); |
25 | 25 | } |
26 | 26 | |
27 | | - function execute(){ |
| 27 | + function execute() { |
28 | 28 | global $wgOut, $wgUser, $wgLang; |
29 | | - if( !$this->mRepo ) { |
| 29 | + if ( !$this->mRepo ) { |
30 | 30 | $view = new CodeRepoListView(); |
31 | 31 | $view->execute(); |
32 | 32 | return; |
33 | 33 | } |
34 | | - if( !$this->mRev ) { |
| 34 | + if ( !$this->mRev ) { |
35 | 35 | $view = new CodeRevisionListView( $this->mRepo->getName() ); |
36 | 36 | $view->execute(); |
37 | 37 | return; |
— | — | @@ -38,7 +38,7 @@ |
39 | 39 | $this->mStatus = $this->mStatus ? $this->mStatus : $this->mRev->getStatus(); |
40 | 40 | |
41 | 41 | $redirectOnPost = $this->checkPostings(); |
42 | | - if( $redirectOnPost ) { |
| 42 | + if ( $redirectOnPost ) { |
43 | 43 | $wgOut->redirect( $redirectOnPost ); |
44 | 44 | return; |
45 | 45 | } |
— | — | @@ -48,16 +48,16 @@ |
49 | 49 | $revText = $this->navigationLinks(); |
50 | 50 | $paths = ''; |
51 | 51 | $modifiedPaths = $this->mRev->getModifiedPaths(); |
52 | | - foreach( $modifiedPaths as $row ){ |
| 52 | + foreach ( $modifiedPaths as $row ) { |
53 | 53 | $paths .= $this->formatPathLine( $row->cp_path, $row->cp_action ); |
54 | 54 | } |
55 | | - if( $paths ){ |
| 55 | + if ( $paths ) { |
56 | 56 | $paths = "<div class='mw-codereview-paths'><ul>\n$paths</ul></div>\n"; |
57 | 57 | } |
58 | 58 | $comments = $this->formatComments(); |
59 | 59 | $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"; |
62 | 62 | } |
63 | 63 | $fields = array( |
64 | 64 | 'code-rev-repo' => $repoLink, |
— | — | @@ -69,49 +69,49 @@ |
70 | 70 | 'code-rev-message' => $this->formatMessage( $this->mRev->getMessage() ), |
71 | 71 | 'code-rev-paths' => $paths, |
72 | 72 | ); |
73 | | - $special = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName().'/'.$this->mRev->getId() ); |
| 73 | + $special = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/' . $this->mRev->getId() ); |
74 | 74 | |
75 | 75 | $html = Xml::openElement( 'form', array( 'action' => $special->getLocalUrl(), 'method' => 'post' ) ); |
76 | 76 | |
77 | | - if( $wgUser->isAllowed('codereview-post-comment') ) { |
| 77 | + if ( $wgUser->isAllowed( 'codereview-post-comment' ) ) { |
78 | 78 | $html .= $this->addActionButtons(); |
79 | 79 | } |
80 | | - |
| 80 | + |
81 | 81 | $html .= $this->formatMetaData( $fields ); |
82 | 82 | |
83 | | - if( $this->mRev->isDiffable() ) { |
| 83 | + if ( $this->mRev->isDiffable() ) { |
84 | 84 | $diffHtml = $this->formatDiff(); |
85 | 85 | $html .= |
86 | 86 | "<h2>" . wfMsgHtml( 'code-rev-diff' ) . |
87 | 87 | ' <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>' . |
89 | 89 | "<div class='mw-codereview-diff' id='mw-codereview-diff'>" . $diffHtml . "</div>\n"; |
90 | 90 | } |
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; |
93 | 93 | } |
94 | | - |
95 | | - if( $this->mReplyTarget ) { |
| 94 | + |
| 95 | + if ( $this->mReplyTarget ) { |
96 | 96 | global $wgJsMimeType; |
97 | 97 | $id = intval( $this->mReplyTarget ); |
98 | 98 | $html .= "<script type=\"$wgJsMimeType\">addOnloadHook(function(){" . |
99 | 99 | "document.getElementById('wpReplyTo$id').focus();" . |
100 | 100 | "});</script>\n"; |
101 | 101 | } |
102 | | - |
103 | | - if( $wgUser->isAllowed('codereview-post-comment') ) { |
| 102 | + |
| 103 | + if ( $wgUser->isAllowed( 'codereview-post-comment' ) ) { |
104 | 104 | $html .= $this->addActionButtons(); |
105 | 105 | } |
106 | | - |
| 106 | + |
107 | 107 | $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; |
110 | 110 | } |
111 | 111 | $html .= xml::closeElement( 'form' ); |
112 | 112 | |
113 | 113 | $wgOut->addHTML( $html ); |
114 | 114 | } |
115 | | - |
| 115 | + |
116 | 116 | protected function navigationLinks() { |
117 | 117 | global $wgLang; |
118 | 118 | |
— | — | @@ -119,24 +119,24 @@ |
120 | 120 | $prev = $this->mRev->getPrevious(); |
121 | 121 | $next = $this->mRev->getNext(); |
122 | 122 | $repo = $this->mRepo->getName(); |
123 | | - |
| 123 | + |
124 | 124 | $links = array(); |
125 | | - |
126 | | - if( $prev ) { |
| 125 | + |
| 126 | + if ( $prev ) { |
127 | 127 | $prevTarget = SpecialPage::getTitleFor( 'Code', "$repo/$prev" ); |
128 | 128 | $links[] = '< ' . $this->mSkin->link( $prevTarget, "r$prev" ); |
129 | 129 | } |
130 | | - |
| 130 | + |
131 | 131 | $revText = "<b>r$rev</b>"; |
132 | 132 | $viewvc = $this->mRepo->getViewVcBase(); |
133 | | - if( $viewvc ){ |
| 133 | + if ( $viewvc ) { |
134 | 134 | $url = htmlspecialchars( "$viewvc/?view=rev&revision=$rev" ); |
135 | 135 | $viewvcTxt = wfMsgHtml( 'code-rev-rev-viewvc' ); |
136 | 136 | $revText .= " (<a href=\"$url\" title=\"revision $rev\">$viewvcTxt</a>)"; |
137 | 137 | } |
138 | 138 | $links[] = $revText; |
139 | 139 | |
140 | | - if( $next ) { |
| 140 | + if ( $next ) { |
141 | 141 | $nextTarget = SpecialPage::getTitleFor( 'Code', "$repo/$next" ); |
142 | 142 | $links[] = $this->mSkin->link( $nextTarget, "r$next" ) . ' >'; |
143 | 143 | } |
— | — | @@ -146,13 +146,13 @@ |
147 | 147 | |
148 | 148 | protected function checkPostings() { |
149 | 149 | global $wgRequest, $wgUser; |
150 | | - if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal('wpEditToken') ) ) { |
| 150 | + if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
151 | 151 | // Look for a posting... |
152 | 152 | $text = $wgRequest->getText( "wpReply{$this->mReplyTarget}" ); |
153 | 153 | $parent = $wgRequest->getIntOrNull( 'wpParent' ); |
154 | 154 | $review = $wgRequest->getInt( 'wpReview' ); |
155 | 155 | $isPreview = $wgRequest->getCheck( 'wpPreview' ); |
156 | | - if( $isPreview ) { |
| 156 | + if ( $isPreview ) { |
157 | 157 | // Save the text for reference on later comment display... |
158 | 158 | $this->mPreviewText = $text; |
159 | 159 | } |
— | — | @@ -161,30 +161,31 @@ |
162 | 162 | } |
163 | 163 | |
164 | 164 | 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 ) ); |
166 | 167 | // Find any ' (from x)' from rename comment in the path. |
167 | 168 | preg_match( '/ \([^\)]+\)$/', $path, $matches ); |
168 | | - $from = isset($matches[0]) ? $matches[0] : ''; |
| 169 | + $from = isset( $matches[0] ) ? $matches[0] : ''; |
169 | 170 | // Remove ' (from x)' from rename comment in the path. |
170 | 171 | $path = preg_replace( '/ \([^\)]+\)$/', '', $path ); |
171 | 172 | $viewvc = $this->mRepo->getViewVcBase(); |
172 | 173 | $diff = ''; |
173 | | - if( $viewvc ) { |
| 174 | + if ( $viewvc ) { |
174 | 175 | $rev = $this->mRev->getId(); |
175 | 176 | $prev = $rev - 1; |
176 | 177 | $safePath = wfUrlEncode( $path ); |
177 | | - if( $action !== 'D' ) { |
| 178 | + if ( $action !== 'D' ) { |
178 | 179 | $link = $this->mSkin->makeExternalLink( |
179 | 180 | "$viewvc$safePath?view=markup&pathrev=$rev", |
180 | 181 | $path . $from ); |
181 | 182 | } else { |
182 | 183 | $link = $safePath; |
183 | 184 | } |
184 | | - if( $action !== 'A' && $action !== 'D' ) { |
| 185 | + if ( $action !== 'A' && $action !== 'D' ) { |
185 | 186 | $diff = ' (' . |
186 | 187 | $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' ) ) . |
189 | 190 | ')'; |
190 | 191 | } |
191 | 192 | } else { |
— | — | @@ -192,76 +193,76 @@ |
193 | 194 | } |
194 | 195 | return "<li>$link ($desc)$diff</li>\n"; |
195 | 196 | } |
196 | | - |
| 197 | + |
197 | 198 | protected function tagForm() { |
198 | 199 | global $wgUser; |
199 | 200 | $tags = $this->mRev->getTags(); |
200 | 201 | $list = ''; |
201 | | - if( count($tags) ) { |
| 202 | + if ( count( $tags ) ) { |
202 | 203 | $list = implode( ", ", |
203 | 204 | array_map( |
204 | 205 | array( $this, 'formatTag' ), |
205 | | - $tags ) |
| 206 | + $tags ) |
206 | 207 | ) . ' '; |
207 | 208 | } |
208 | | - if( $wgUser->isAllowed( 'codereview-add-tag' ) ) { |
| 209 | + if ( $wgUser->isAllowed( 'codereview-add-tag' ) ) { |
209 | 210 | $list .= $this->addTagForm( $this->mAddTags, $this->mRemoveTags ); |
210 | 211 | } |
211 | 212 | return $list; |
212 | 213 | } |
213 | | - |
| 214 | + |
214 | 215 | protected function splitTags( $input ) { |
215 | | - if( !$this->mRev ) return array(); |
| 216 | + if ( !$this->mRev ) return array(); |
216 | 217 | $tags = array_map( 'trim', explode( ",", $input ) ); |
217 | | - foreach( $tags as $key => $tag ) { |
| 218 | + foreach ( $tags as $key => $tag ) { |
218 | 219 | $normal = $this->mRev->normalizeTag( $tag ); |
219 | | - if( $normal === false ) { |
| 220 | + if ( $normal === false ) { |
220 | 221 | return null; |
221 | 222 | } |
222 | 223 | $tags[$key] = $normal; |
223 | 224 | } |
224 | 225 | return $tags; |
225 | 226 | } |
226 | | - |
| 227 | + |
227 | 228 | static function listTags( $tags ) { |
228 | | - if( empty($tags) ) |
| 229 | + if ( empty( $tags ) ) |
229 | 230 | return ""; |
230 | | - return implode(",",$tags); |
| 231 | + return implode( ",", $tags ); |
231 | 232 | } |
232 | | - |
| 233 | + |
233 | 234 | protected function statusForm() { |
234 | 235 | global $wgUser; |
235 | | - if( $wgUser->isAllowed( 'codereview-set-status' ) ) { |
| 236 | + if ( $wgUser->isAllowed( 'codereview-set-status' ) ) { |
236 | 237 | $repo = $this->mRepo->getName(); |
237 | 238 | $rev = $this->mRev->getId(); |
238 | 239 | return Xml::openElement( 'select', array( 'name' => 'wpStatus' ) ) . |
239 | 240 | self::buildStatusList( $this->mRev->getStatus(), $this ) . |
240 | | - xml::closeElement('select'); |
| 241 | + xml::closeElement( 'select' ); |
241 | 242 | } else { |
242 | 243 | return htmlspecialchars( $this->statusDesc( $this->mRev->getStatus() ) ); |
243 | 244 | } |
244 | 245 | } |
245 | | - |
| 246 | + |
246 | 247 | static function buildStatusList( $status, $view ) { |
247 | 248 | $states = CodeRevision::getPossibleStates(); |
248 | 249 | $out = ''; |
249 | | - foreach( $states as $state ) { |
| 250 | + foreach ( $states as $state ) { |
250 | 251 | $out .= Xml::option( $view->statusDesc( $state ), $state, |
251 | 252 | $status === $state ); |
252 | 253 | } |
253 | 254 | return $out; |
254 | 255 | } |
255 | | - |
| 256 | + |
256 | 257 | /** Parameters are the tags to be added/removed sent with the request */ |
257 | 258 | static function addTagForm( $addTags, $removeTags ) { |
258 | 259 | global $wgUser; |
259 | 260 | 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, |
261 | 262 | self::listTags( $addTags ) ) . '</td><td> </td><td>' . |
262 | | - Xml::inputLabel( wfMsg('code-rev-tag-remove'), 'wpRemoveTag', 'wpRemoveTag', 20, |
| 263 | + Xml::inputLabel( wfMsg( 'code-rev-tag-remove' ), 'wpRemoveTag', 'wpRemoveTag', 20, |
263 | 264 | self::listTags( $removeTags ) ) . '</td></tr></table></div>'; |
264 | 265 | } |
265 | | - |
| 266 | + |
266 | 267 | protected function formatTag( $tag ) { |
267 | 268 | global $wgUser; |
268 | 269 | $repo = $this->mRepo->getName(); |
— | — | @@ -271,16 +272,16 @@ |
272 | 273 | |
273 | 274 | protected function formatDiff() { |
274 | 275 | global $wgEnableAPI; |
275 | | - |
| 276 | + |
276 | 277 | // Asynchronous diff loads will require the API |
277 | 278 | // And JS in the client, but tough shit eh? ;) |
278 | 279 | $deferDiffs = $wgEnableAPI; |
279 | | - |
280 | | - if( $this->mSkipCache ) { |
| 280 | + |
| 281 | + if ( $this->mSkipCache ) { |
281 | 282 | // We're purging the cache on purpose, probably |
282 | 283 | // because the cached data was corrupt. |
283 | 284 | $cache = 'skipcache'; |
284 | | - } elseif( $deferDiffs ) { |
| 285 | + } elseif ( $deferDiffs ) { |
285 | 286 | // If data is already cached, we'll take it now; |
286 | 287 | // otherwise defer the load to an AJAX request. |
287 | 288 | // This lets the page be manipulable even if the |
— | — | @@ -290,7 +291,7 @@ |
291 | 292 | $cache = ''; |
292 | 293 | } |
293 | 294 | $diff = $this->mRepo->getDiff( $this->mRev->getId(), $cache ); |
294 | | - if( !$diff && $deferDiffs ) { |
| 295 | + if ( !$diff && $deferDiffs ) { |
295 | 296 | // We'll try loading it by AJAX... |
296 | 297 | return $this->stubDiffLoader(); |
297 | 298 | } |
— | — | @@ -316,52 +317,53 @@ |
317 | 318 | $comments = implode( "\n", |
318 | 319 | array_map( array( $this, 'formatCommentInline' ), $this->mRev->getComments() ) |
319 | 320 | ) . $this->postCommentForm(); |
320 | | - if( !$comments ) { |
| 321 | + if ( !$comments ) { |
321 | 322 | return false; |
322 | 323 | } |
323 | 324 | return "<div class='mw-codereview-comments'>$comments</div>"; |
324 | 325 | } |
325 | | - |
| 326 | + |
326 | 327 | protected function formatPropChanges() { |
327 | 328 | $changes = implode( "\n", |
328 | 329 | array_map( array( $this, 'formatChangeInline' ), $this->mRev->getPropChanges() ) |
329 | 330 | ); |
330 | | - if( !$changes ) { |
| 331 | + if ( !$changes ) { |
331 | 332 | return false; |
332 | 333 | } |
333 | 334 | return "<ul class='mw-codereview-changes'>$changes</ul>"; |
334 | 335 | } |
335 | 336 | |
336 | 337 | protected function formatCommentInline( $comment ) { |
337 | | - if( $comment->id === $this->mReplyTarget ) { |
| 338 | + if ( $comment->id === $this->mReplyTarget ) { |
338 | 339 | return $this->formatComment( $comment, |
339 | 340 | $this->postCommentForm( $comment->id ) ); |
340 | 341 | } else { |
341 | 342 | return $this->formatComment( $comment ); |
342 | 343 | } |
343 | 344 | } |
344 | | - |
| 345 | + |
345 | 346 | protected function formatChangeInline( $change ) { |
346 | 347 | global $wgLang; |
347 | 348 | $revId = $change->rev->getId(); |
348 | 349 | $line = $wgLang->timeanddate( $change->timestamp, true ); |
349 | 350 | $line .= ' ' . $this->mSkin->userLink( $change->user, $change->userText ); |
350 | 351 | $line .= $this->mSkin->userToolLinks( $change->user, $change->userText ); |
351 | | - $line .= ' ' . wfMsgExt("code-change-{$change->attrib}",'parseinline',$revId); |
| 352 | + // Uses messages 'code-change-status', 'code-change-tags' |
| 353 | + $line .= ' ' . wfMsgExt( "code-change-{$change->attrib}", 'parseinline', $revId ); |
352 | 354 | $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 ); |
356 | 358 | $line .= $change->added ? " " : ""; |
357 | 359 | } |
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 ); |
361 | 363 | } |
362 | 364 | $line .= "]</i>"; |
363 | 365 | return "<li>$line</li>"; |
364 | 366 | } |
365 | | - |
| 367 | + |
366 | 368 | protected function commentLink( $commentId ) { |
367 | 369 | $repo = $this->mRepo->getName(); |
368 | 370 | $rev = $this->mRev->getId(); |
— | — | @@ -369,31 +371,31 @@ |
370 | 372 | $title->setFragment( "#c{$commentId}" ); |
371 | 373 | return $title; |
372 | 374 | } |
373 | | - |
| 375 | + |
374 | 376 | protected function revLink() { |
375 | 377 | $repo = $this->mRepo->getName(); |
376 | 378 | $rev = $this->mRev->getId(); |
377 | 379 | $title = SpecialPage::getTitleFor( 'Code', "$repo/$rev" ); |
378 | 380 | return $title; |
379 | | - } |
380 | | - |
381 | | - protected function previewComment( $text, $review=0 ) { |
| 381 | + } |
| 382 | + |
| 383 | + protected function previewComment( $text, $review = 0 ) { |
382 | 384 | $comment = $this->mRev->previewComment( $text, $review ); |
383 | 385 | return $this->formatComment( $comment ); |
384 | 386 | } |
385 | | - |
386 | | - protected function formatComment( $comment, $replyForm='' ) { |
| 387 | + |
| 388 | + protected function formatComment( $comment, $replyForm = '' ) { |
387 | 389 | global $wgOut, $wgLang; |
388 | 390 | $linker = new CodeCommentLinkerWiki( $this->mRepo ); |
389 | | - |
390 | | - if( $comment->id === null ) { |
| 391 | + |
| 392 | + if ( $comment->id === null ) { |
391 | 393 | $linkId = 'cpreview'; |
392 | 394 | $permaLink = "<b>Preview:</b> "; |
393 | 395 | } else { |
394 | 396 | $linkId = 'c' . intval( $comment->id ); |
395 | 397 | $permaLink = $this->mSkin->link( $this->commentLink( $comment->id ), "#" ); |
396 | 398 | } |
397 | | - |
| 399 | + |
398 | 400 | return Xml::openElement( 'div', |
399 | 401 | array( |
400 | 402 | 'class' => 'mw-codereview-comment', |
— | — | @@ -418,23 +420,23 @@ |
419 | 421 | |
420 | 422 | protected function commentStyle( $comment ) { |
421 | 423 | $depth = $comment->threadDepth(); |
422 | | - $margin = ($depth - 1) * 48; |
| 424 | + $margin = ( $depth - 1 ) * 48; |
423 | 425 | return "margin-left: ${margin}px"; |
424 | 426 | } |
425 | | - |
| 427 | + |
426 | 428 | protected function commentReplyLink( $id ) { |
427 | 429 | global $wgUser; |
428 | | - if( !$wgUser->isAllowed('codereview-post-comment') ) return ''; |
| 430 | + if ( !$wgUser->isAllowed( 'codereview-post-comment' ) ) return ''; |
429 | 431 | $repo = $this->mRepo->getName(); |
430 | 432 | $rev = $this->mRev->getId(); |
431 | 433 | $self = SpecialPage::getTitleFor( 'Code', "$repo/$rev/reply/$id" ); |
432 | 434 | $self->setFragment( "#c$id" ); |
433 | 435 | return '[' . $this->mSkin->link( $self, wfMsg( 'codereview-reply-link' ) ) . ']'; |
434 | 436 | } |
435 | | - |
436 | | - protected function postCommentForm( $parent=null ) { |
| 437 | + |
| 438 | + protected function postCommentForm( $parent = null ) { |
437 | 439 | global $wgUser; |
438 | | - if( $this->mPreviewText !== false && $parent === $this->mReplyTarget ) { |
| 440 | + if ( $this->mPreviewText !== false && $parent === $this->mReplyTarget ) { |
439 | 441 | $preview = $this->previewComment( $this->mPreviewText ); |
440 | 442 | $text = htmlspecialchars( $this->mPreviewText ); |
441 | 443 | } else { |
— | — | @@ -443,13 +445,13 @@ |
444 | 446 | } |
445 | 447 | $repo = $this->mRepo->getName(); |
446 | 448 | $rev = $this->mRev->getId(); |
447 | | - if( !$wgUser->isAllowed('codereview-post-comment') ) { |
| 449 | + if ( !$wgUser->isAllowed( 'codereview-post-comment' ) ) { |
448 | 450 | return ''; |
449 | 451 | } |
450 | 452 | return '<div class="mw-codereview-post-comment">' . |
451 | 453 | $preview . |
452 | 454 | Xml::hidden( 'wpEditToken', $wgUser->editToken() ) . |
453 | | - ($parent ? Xml::hidden( 'wpParent', $parent ) : '') . |
| 455 | + ( $parent ? Xml::hidden( 'wpParent', $parent ) : '' ) . |
454 | 456 | '<div>' . |
455 | 457 | Xml::openElement( 'textarea', array( |
456 | 458 | 'name' => "wpReply{$parent}", |
Index: trunk/extensions/CodeReview/CodeRepoListView.php |
— | — | @@ -6,18 +6,18 @@ |
7 | 7 | function execute() { |
8 | 8 | global $wgOut; |
9 | 9 | $repos = CodeRepository::getRepoList(); |
10 | | - if( !count( $repos ) ){ |
| 10 | + if ( !count( $repos ) ) { |
11 | 11 | $wgOut->addWikiMsg( 'code-no-repo' ); |
12 | 12 | return; |
13 | 13 | } |
14 | 14 | $text = ''; |
15 | | - foreach( $repos as $repo ){ |
| 15 | + foreach ( $repos as $repo ) { |
16 | 16 | $name = $repo->getName(); |
17 | | - $text .= "* ".self::getNavItem( $name )."\n"; |
| 17 | + $text .= "* " . self::getNavItem( $name ) . "\n"; |
18 | 18 | } |
19 | 19 | $wgOut->addWikiText( $text ); |
20 | 20 | } |
21 | | - |
| 21 | + |
22 | 22 | public static function getNavItem( $name ) { |
23 | 23 | global $wgLang; |
24 | 24 | $text = "'''[[Special:Code/$name|$name]]''' ("; |
Index: trunk/extensions/CodeReview/CodeRevision.php |
— | — | @@ -1,12 +1,12 @@ |
2 | 2 | <?php |
3 | | -if (!defined('MEDIAWIKI')) die(); |
| 3 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
4 | 4 | |
5 | 5 | class CodeRevision { |
6 | 6 | public static function newFromSvn( CodeRepository $repo, $data ) { |
7 | 7 | $rev = new CodeRevision(); |
8 | 8 | $rev->mRepoId = $repo->getId(); |
9 | 9 | $rev->mRepo = $repo; |
10 | | - $rev->mId = intval($data['rev']); |
| 10 | + $rev->mId = intval( $data['rev'] ); |
11 | 11 | $rev->mAuthor = $data['author']; |
12 | 12 | $rev->mTimestamp = wfTimestamp( TS_MW, strtotime( $data['date'] ) ); |
13 | 13 | $rev->mMessage = rtrim( $data['msg'] ); |
— | — | @@ -14,28 +14,28 @@ |
15 | 15 | $rev->mStatus = 'new'; |
16 | 16 | |
17 | 17 | $common = null; |
18 | | - if( $rev->mPaths ) { |
19 | | - if (count($rev->mPaths) == 1) |
| 18 | + if ( $rev->mPaths ) { |
| 19 | + if ( count( $rev->mPaths ) == 1 ) |
20 | 20 | $common = $rev->mPaths[0]['path']; |
21 | 21 | else { |
22 | 22 | $first = array_shift( $rev->mPaths ); |
23 | 23 | |
24 | 24 | $common = explode( '/', $first['path'] ); |
25 | 25 | |
26 | | - foreach( $rev->mPaths as $path ) { |
| 26 | + foreach ( $rev->mPaths as $path ) { |
27 | 27 | $compare = explode( '/', $path['path'] ); |
28 | 28 | |
29 | 29 | // make sure $common is the shortest path |
30 | | - if ( count($compare) < count($common) ) |
| 30 | + if ( count( $compare ) < count( $common ) ) |
31 | 31 | list( $compare, $common ) = array( $common, $compare ); |
32 | 32 | |
33 | 33 | $tmp = array(); |
34 | 34 | foreach ( $common as $k => $v ) |
35 | | - if ( $v==$compare[$k] ) $tmp[]= $v; |
| 35 | + if ( $v == $compare[$k] ) $tmp[] = $v; |
36 | 36 | else break; |
37 | 37 | $common = $tmp; |
38 | 38 | } |
39 | | - $common = implode( '/', $common); |
| 39 | + $common = implode( '/', $common ); |
40 | 40 | |
41 | 41 | array_unshift( $rev->mPaths, $first ); |
42 | 42 | } |
— | — | @@ -46,12 +46,12 @@ |
47 | 47 | |
48 | 48 | public static function newFromRow( CodeRepository $repo, $row ) { |
49 | 49 | $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() ) { |
52 | 52 | throw new MWException( "Invalid repo ID in " . __METHOD__ ); |
53 | 53 | } |
54 | 54 | $rev->mRepo = $repo; |
55 | | - $rev->mId = intval($row->cr_id); |
| 55 | + $rev->mId = intval( $row->cr_id ); |
56 | 56 | $rev->mAuthor = $row->cr_author; |
57 | 57 | $rev->mTimestamp = wfTimestamp( TS_MW, $row->cr_timestamp ); |
58 | 58 | $rev->mMessage = $row->cr_message; |
— | — | @@ -63,7 +63,7 @@ |
64 | 64 | public function getId() { |
65 | 65 | return intval( $this->mId ); |
66 | 66 | } |
67 | | - |
| 67 | + |
68 | 68 | public function getRepoId() { |
69 | 69 | return intval( $this->mRepoId ); |
70 | 70 | } |
— | — | @@ -71,7 +71,7 @@ |
72 | 72 | public function getAuthor() { |
73 | 73 | return $this->mAuthor; |
74 | 74 | } |
75 | | - |
| 75 | + |
76 | 76 | public function getWikiUser() { |
77 | 77 | return $this->mRepo->authorWikiUser( $this->getAuthor() ); |
78 | 78 | } |
— | — | @@ -83,7 +83,7 @@ |
84 | 84 | public function getMessage() { |
85 | 85 | return $this->mMessage; |
86 | 86 | } |
87 | | - |
| 87 | + |
88 | 88 | public function getStatus() { |
89 | 89 | return $this->mStatus; |
90 | 90 | } |
— | — | @@ -91,17 +91,17 @@ |
92 | 92 | public function getCommonPath() { |
93 | 93 | return $this->mCommonPath; |
94 | 94 | } |
95 | | - |
| 95 | + |
96 | 96 | public static function getPossibleStates() { |
97 | 97 | return array( 'new', 'fixme', 'reverted', 'resolved', 'ok', 'deferred' ); |
98 | 98 | } |
99 | | - |
| 99 | + |
100 | 100 | public function isValidStatus( $status ) { |
101 | 101 | return in_array( $status, self::getPossibleStates(), true ); |
102 | 102 | } |
103 | | - |
| 103 | + |
104 | 104 | public function setStatus( $status, $user ) { |
105 | | - if( !$this->isValidStatus( $status ) ) { |
| 105 | + if ( !$this->isValidStatus( $status ) ) { |
106 | 106 | throw new MWException( "Tried to save invalid code revision status" ); |
107 | 107 | } |
108 | 108 | // Get the old status from the master |
— | — | @@ -111,7 +111,7 @@ |
112 | 112 | array( 'cr_repo_id' => $this->mRepoId, 'cr_id' => $this->mId ), |
113 | 113 | __METHOD__ |
114 | 114 | ); |
115 | | - if( $oldStatus === $status ) { |
| 115 | + if ( $oldStatus === $status ) { |
116 | 116 | return false; // nothing to do here |
117 | 117 | } |
118 | 118 | // Update status |
— | — | @@ -124,9 +124,9 @@ |
125 | 125 | __METHOD__ |
126 | 126 | ); |
127 | 127 | // Log this change |
128 | | - if( $user && $user->getId() ) { |
| 128 | + if ( $user && $user->getId() ) { |
129 | 129 | $dbw->insert( 'code_prop_changes', |
130 | | - array( |
| 130 | + array( |
131 | 131 | 'cpc_repo_id' => $this->getRepoId(), |
132 | 132 | 'cpc_rev_id' => $this->getId(), |
133 | 133 | 'cpc_attrib' => 'status', |
— | — | @@ -145,7 +145,7 @@ |
146 | 146 | public function save() { |
147 | 147 | $dbw = wfGetDB( DB_MASTER ); |
148 | 148 | $dbw->begin(); |
149 | | - |
| 149 | + |
150 | 150 | $dbw->insert( 'code_rev', |
151 | 151 | array( |
152 | 152 | 'cr_repo_id' => $this->mRepoId, |
— | — | @@ -158,22 +158,22 @@ |
159 | 159 | __METHOD__, |
160 | 160 | array( 'IGNORE' ) ); |
161 | 161 | // Already exists? Update the row! |
162 | | - if( !$dbw->affectedRows() ) { |
| 162 | + if ( !$dbw->affectedRows() ) { |
163 | 163 | $dbw->update( 'code_rev', |
164 | 164 | array( |
165 | 165 | 'cr_author' => $this->mAuthor, |
166 | 166 | 'cr_timestamp' => $dbw->timestamp( $this->mTimestamp ), |
167 | 167 | 'cr_message' => $this->mMessage, |
168 | | - 'cr_path' => $this->mCommonPath ), |
| 168 | + 'cr_path' => $this->mCommonPath ), |
169 | 169 | array( |
170 | 170 | 'cr_repo_id' => $this->mRepoId, |
171 | 171 | 'cr_id' => $this->mId ), |
172 | 172 | __METHOD__ ); |
173 | 173 | } |
174 | 174 | // Update path tracking used for output and searching |
175 | | - if( $this->mPaths ) { |
| 175 | + if ( $this->mPaths ) { |
176 | 176 | $data = array(); |
177 | | - foreach( $this->mPaths as $path ) { |
| 177 | + foreach ( $this->mPaths as $path ) { |
178 | 178 | $data[] = array( |
179 | 179 | 'cp_repo_id' => $this->mRepoId, |
180 | 180 | 'cp_rev_id' => $this->mId, |
— | — | @@ -198,24 +198,24 @@ |
199 | 199 | __METHOD__ |
200 | 200 | ); |
201 | 201 | } |
202 | | - |
| 202 | + |
203 | 203 | public function isDiffable() { |
204 | 204 | $paths = $this->getModifiedPaths(); |
205 | | - if( !$paths->numRows() || $paths->numRows() > 20 ) { |
| 205 | + if ( !$paths->numRows() || $paths->numRows() > 20 ) { |
206 | 206 | return false; // things need to get done this year |
207 | 207 | } |
208 | 208 | return true; |
209 | 209 | } |
210 | 210 | |
211 | | - public function previewComment( $text, $review, $parent=null ) { |
| 211 | + public function previewComment( $text, $review, $parent = null ) { |
212 | 212 | $data = $this->commentData( $text, $review, $parent ); |
213 | 213 | $data['cc_id'] = null; |
214 | 214 | return CodeComment::newFromData( $this, $data ); |
215 | 215 | } |
216 | | - |
217 | | - public function saveComment( $text, $review, $parent=null ) { |
| 216 | + |
| 217 | + public function saveComment( $text, $review, $parent = null ) { |
218 | 218 | global $wgUser; |
219 | | - if( !strlen($text) ) { |
| 219 | + if ( !strlen( $text ) ) { |
220 | 220 | return 0; |
221 | 221 | } |
222 | 222 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -229,24 +229,24 @@ |
230 | 230 | |
231 | 231 | // Give email notices to committer and commenters |
232 | 232 | global $wgCodeReviewENotif, $wgEnableEmail; |
233 | | - if( $wgCodeReviewENotif && $wgEnableEmail ) { |
| 233 | + if ( $wgCodeReviewENotif && $wgEnableEmail ) { |
234 | 234 | // Make list of users to send emails to |
235 | 235 | $users = $this->getCommentingUsers(); |
236 | | - if( $user = $this->getWikiUser() ) { |
| 236 | + if ( $user = $this->getWikiUser() ) { |
237 | 237 | $users[$user->getId()] = $user; |
238 | 238 | } |
239 | 239 | // 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 ); |
241 | 241 | $title->setFragment( "#c{$commentId}" ); |
242 | 242 | $url = $title->getFullUrl(); |
243 | | - foreach( $users as $userId => $user ) { |
| 243 | + foreach ( $users as $userId => $user ) { |
244 | 244 | // No sense in notifying this commenter |
245 | | - if( $wgUser->getId() == $user->getId() ) { |
| 245 | + if ( $wgUser->getId() == $user->getId() ) { |
246 | 246 | continue; |
247 | 247 | } |
248 | 248 | // Send message in receiver's language |
249 | 249 | $lang = array( 'language' => $user->getOption( 'language' ) ); |
250 | | - if( $user->canReceiveEmail() ) { |
| 250 | + if ( $user->canReceiveEmail() ) { |
251 | 251 | $user->sendMail( |
252 | 252 | wfMsgExt( 'codereview-email-subj', $lang, $this->mRepo->getName(), $this->mId ), |
253 | 253 | wfMsgExt( 'codereview-email-body', $lang, $wgUser->getName(), $url, $this->mId, $text ) |
— | — | @@ -254,11 +254,11 @@ |
255 | 255 | } |
256 | 256 | } |
257 | 257 | } |
258 | | - |
| 258 | + |
259 | 259 | return $commentId; |
260 | 260 | } |
261 | | - |
262 | | - protected function commentData( $text, $review, $parent=null ) { |
| 261 | + |
| 262 | + protected function commentData( $text, $review, $parent = null ) { |
263 | 263 | global $wgUser; |
264 | 264 | $dbw = wfGetDB( DB_MASTER ); |
265 | 265 | $ts = wfTimestamp( TS_MW ); |
— | — | @@ -276,7 +276,7 @@ |
277 | 277 | } |
278 | 278 | |
279 | 279 | protected function threadedSortKey( $parent, $ts ) { |
280 | | - if( $parent ) { |
| 280 | + if ( $parent ) { |
281 | 281 | // We construct a threaded sort key by concatenating the timestamps |
282 | 282 | // of all our parent comments |
283 | 283 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -284,7 +284,7 @@ |
285 | 285 | 'cc_sortkey', |
286 | 286 | array( 'cc_id' => $parent ), |
287 | 287 | __METHOD__ ); |
288 | | - if( $parentKey ) { |
| 288 | + if ( $parentKey ) { |
289 | 289 | return $parentKey . ',' . $ts; |
290 | 290 | } else { |
291 | 291 | // hmmmm |
— | — | @@ -315,16 +315,16 @@ |
316 | 316 | 'ORDER BY' => 'cc_sortkey' ) |
317 | 317 | ); |
318 | 318 | $comments = array(); |
319 | | - foreach( $result as $row ) { |
| 319 | + foreach ( $result as $row ) { |
320 | 320 | $comments[] = CodeComment::newFromRow( $this, $row ); |
321 | 321 | } |
322 | 322 | $result->free(); |
323 | 323 | return $comments; |
324 | 324 | } |
325 | | - |
| 325 | + |
326 | 326 | public function getPropChanges() { |
327 | 327 | $dbr = wfGetDB( DB_SLAVE ); |
328 | | - $result = $dbr->select( array('code_prop_changes','user'), |
| 328 | + $result = $dbr->select( array( 'code_prop_changes', 'user' ), |
329 | 329 | array( |
330 | 330 | 'cpc_attrib', |
331 | 331 | 'cpc_removed', |
— | — | @@ -339,16 +339,16 @@ |
340 | 340 | ), |
341 | 341 | __METHOD__, |
342 | 342 | 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' ) ) |
344 | 344 | ); |
345 | 345 | $changes = array(); |
346 | | - foreach( $result as $row ) { |
| 346 | + foreach ( $result as $row ) { |
347 | 347 | $changes[] = CodePropChange::newFromRow( $this, $row ); |
348 | 348 | } |
349 | 349 | $result->free(); |
350 | 350 | return $changes; |
351 | 351 | } |
352 | | - |
| 352 | + |
353 | 353 | protected function getCommentingUsers() { |
354 | 354 | $dbr = wfGetDB( DB_SLAVE ); |
355 | 355 | $res = $dbr->select( 'code_comment', |
— | — | @@ -358,15 +358,15 @@ |
359 | 359 | 'cc_rev_id' => $this->mId, |
360 | 360 | 'cc_user != 0' // users only |
361 | 361 | ), |
362 | | - __METHOD__ |
| 362 | + __METHOD__ |
363 | 363 | ); |
364 | 364 | $users = array(); |
365 | | - while( $row = $res->fetchObject() ) { |
| 365 | + while ( $row = $res->fetchObject() ) { |
366 | 366 | $users[$row->cc_user] = User::newFromId( $row->cc_user ); |
367 | 367 | } |
368 | 368 | return $users; |
369 | 369 | } |
370 | | - |
| 370 | + |
371 | 371 | public function getTags( $from = DB_SLAVE ) { |
372 | 372 | $db = wfGetDB( $from ); |
373 | 373 | $result = $db->select( 'code_tags', |
— | — | @@ -375,14 +375,14 @@ |
376 | 376 | 'ct_repo_id' => $this->mRepoId, |
377 | 377 | 'ct_rev_id' => $this->mId ), |
378 | 378 | __METHOD__ ); |
379 | | - |
| 379 | + |
380 | 380 | $tags = array(); |
381 | | - foreach( $result as $row ) { |
| 381 | + foreach ( $result as $row ) { |
382 | 382 | $tags[] = $row->ct_tag; |
383 | 383 | } |
384 | 384 | return $tags; |
385 | 385 | } |
386 | | - |
| 386 | + |
387 | 387 | public function changeTags( $addTags, $removeTags, $user = NULL ) { |
388 | 388 | // Get the current tags and see what changes |
389 | 389 | $tagsNow = $this->getTags( DB_MASTER ); |
— | — | @@ -393,16 +393,16 @@ |
394 | 394 | $removeTags = array_intersect( $removeTags, $tagsNow ); |
395 | 395 | // Do the queries |
396 | 396 | $dbw = wfGetDB( DB_MASTER ); |
397 | | - if( $addTags ) { |
| 397 | + if ( $addTags ) { |
398 | 398 | $dbw->insert( 'code_tags', |
399 | 399 | $this->tagData( $addTags ), |
400 | 400 | __METHOD__, |
401 | 401 | array( 'IGNORE' ) |
402 | 402 | ); |
403 | 403 | } |
404 | | - if( $removeTags ) { |
| 404 | + if ( $removeTags ) { |
405 | 405 | $dbw->delete( 'code_tags', |
406 | | - array( |
| 406 | + array( |
407 | 407 | 'ct_repo_id' => $this->mRepoId, |
408 | 408 | 'ct_rev_id' => $this->mId, |
409 | 409 | 'ct_tag' => $removeTags ), |
— | — | @@ -410,14 +410,14 @@ |
411 | 411 | ); |
412 | 412 | } |
413 | 413 | // Log this change |
414 | | - if( ($removeTags || $addTags) && $user && $user->getId() ) { |
| 414 | + if ( ( $removeTags || $addTags ) && $user && $user->getId() ) { |
415 | 415 | $dbw->insert( 'code_prop_changes', |
416 | | - array( |
| 416 | + array( |
417 | 417 | 'cpc_repo_id' => $this->getRepoId(), |
418 | 418 | 'cpc_rev_id' => $this->getId(), |
419 | 419 | 'cpc_attrib' => 'tags', |
420 | | - 'cpc_removed' => implode(',',$removeTags), |
421 | | - 'cpc_added' => implode(',',$addTags), |
| 420 | + 'cpc_removed' => implode( ',', $removeTags ), |
| 421 | + 'cpc_added' => implode( ',', $addTags ), |
422 | 422 | 'cpc_timestamp' => $dbw->timestamp(), |
423 | 423 | 'cpc_user' => $user->getId(), |
424 | 424 | 'cpc_user_text' => $user->getName() |
— | — | @@ -426,18 +426,18 @@ |
427 | 427 | ); |
428 | 428 | } |
429 | 429 | } |
430 | | - |
| 430 | + |
431 | 431 | protected function normalizeTags( $tags ) { |
432 | 432 | $out = array(); |
433 | | - foreach( $tags as $tag ) { |
| 433 | + foreach ( $tags as $tag ) { |
434 | 434 | $out[] = $this->normalizeTag( $tag ); |
435 | 435 | } |
436 | 436 | return $out; |
437 | 437 | } |
438 | | - |
| 438 | + |
439 | 439 | protected function tagData( $tags ) { |
440 | 440 | $data = array(); |
441 | | - foreach( $tags as $tag ) { |
| 441 | + foreach ( $tags as $tag ) { |
442 | 442 | $data[] = array( |
443 | 443 | 'ct_repo_id' => $this->mRepoId, |
444 | 444 | 'ct_rev_id' => $this->mId, |
— | — | @@ -445,32 +445,32 @@ |
446 | 446 | } |
447 | 447 | return $data; |
448 | 448 | } |
449 | | - |
| 449 | + |
450 | 450 | public function normalizeTag( $tag ) { |
451 | 451 | global $wgContLang; |
452 | 452 | $lower = $wgContLang->lc( $tag ); |
453 | | - |
| 453 | + |
454 | 454 | $title = Title::newFromText( $tag ); |
455 | | - if( $title && $lower === $wgContLang->lc( $title->getPrefixedText() ) ) { |
| 455 | + if ( $title && $lower === $wgContLang->lc( $title->getPrefixedText() ) ) { |
456 | 456 | return $lower; |
457 | 457 | } else { |
458 | 458 | return false; |
459 | 459 | } |
460 | 460 | } |
461 | | - |
| 461 | + |
462 | 462 | public function isValidTag( $tag ) { |
463 | | - return ($this->normalizeTag( $tag ) !== false ); |
| 463 | + return ( $this->normalizeTag( $tag ) !== false ); |
464 | 464 | } |
465 | | - |
| 465 | + |
466 | 466 | public function getPrevious() { |
467 | 467 | // hack! |
468 | | - if( $this->mId > 1 ) { |
| 468 | + if ( $this->mId > 1 ) { |
469 | 469 | return $this->mId - 1; |
470 | 470 | } else { |
471 | 471 | return false; |
472 | 472 | } |
473 | 473 | } |
474 | | - |
| 474 | + |
475 | 475 | public function getNext() { |
476 | 476 | $dbr = wfGetDB( DB_SLAVE ); |
477 | 477 | $encId = $dbr->addQuotes( $this->mId ); |
— | — | @@ -483,14 +483,14 @@ |
484 | 484 | array( |
485 | 485 | 'ORDER BY' => 'cr_repo_id, cr_id', |
486 | 486 | 'LIMIT' => 1 ) ); |
487 | | - |
488 | | - if( $row ) { |
489 | | - return intval($row->cr_id); |
| 487 | + |
| 488 | + if ( $row ) { |
| 489 | + return intval( $row->cr_id ); |
490 | 490 | } else { |
491 | 491 | return false; |
492 | 492 | } |
493 | 493 | } |
494 | | - |
| 494 | + |
495 | 495 | public function getNextUnresolved() { |
496 | 496 | $dbr = wfGetDB( DB_SLAVE ); |
497 | 497 | $encId = $dbr->addQuotes( $this->mId ); |
— | — | @@ -499,14 +499,14 @@ |
500 | 500 | array( |
501 | 501 | 'cr_repo_id' => $this->mRepoId, |
502 | 502 | "cr_id > $encId", |
503 | | - 'cr_status' => array('new','fixme') ), |
| 503 | + 'cr_status' => array( 'new', 'fixme' ) ), |
504 | 504 | __METHOD__, |
505 | 505 | array( |
506 | 506 | 'ORDER BY' => 'cr_repo_id, cr_id', |
507 | 507 | 'LIMIT' => 1 ) |
508 | 508 | ); |
509 | | - if( $row ) { |
510 | | - return intval($row->cr_id); |
| 509 | + if ( $row ) { |
| 510 | + return intval( $row->cr_id ); |
511 | 511 | } else { |
512 | 512 | return false; |
513 | 513 | } |
Index: trunk/extensions/CodeReview/CodeRevisionAuthorLink.php |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | function getTitle() { |
14 | 14 | $repo = $this->mRepo->getName(); |
15 | 15 | $auth = $this->mAuthor; |
16 | | - return SpecialPage::getTitleFor( 'Code', "$repo/author/$auth/link"); |
| 16 | + return SpecialPage::getTitleFor( 'Code', "$repo/author/$auth/link" ); |
17 | 17 | } |
18 | 18 | |
19 | 19 | function execute() { |
— | — | @@ -27,10 +27,10 @@ |
28 | 28 | $this->doForm(); |
29 | 29 | } |
30 | 30 | } |
31 | | - |
| 31 | + |
32 | 32 | function doForm() { |
33 | 33 | global $wgOut; |
34 | | - $form = Xml::openElement( 'form', array( 'method' => 'post', |
| 34 | + $form = Xml::openElement( 'form', array( 'method' => 'post', |
35 | 35 | 'action' => $this->getTitle()->getLocalUrl(), |
36 | 36 | 'name' => 'uluser', 'id' => 'mw-codeauthor-form1' ) ); |
37 | 37 | $form .= Xml::openElement( 'fieldset' ); |
— | — | @@ -45,10 +45,10 @@ |
46 | 46 | Xml::closeElement( 'fieldset' ); |
47 | 47 | } else { |
48 | 48 | $form .= Xml::element( 'legend', array(), wfMsg( 'code-author-dolink' ) ); |
49 | | - } |
| 49 | + } |
50 | 50 | |
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' ) ) . |
53 | 53 | Xml::closeElement( 'fieldset' ) . |
54 | 54 | $additional . |
55 | 55 | Xml::closeElement( 'form' ) . "\n"; |
— | — | @@ -59,17 +59,17 @@ |
60 | 60 | function doSubmit() { |
61 | 61 | global $wgOut, $wgRequest; |
62 | 62 | // Link an author to a wiki user |
63 | | - if ( strlen($this->mTarget) && $wgRequest->getCheck( 'newname' ) ) { |
| 63 | + if ( strlen( $this->mTarget ) && $wgRequest->getCheck( 'newname' ) ) { |
64 | 64 | $user = User::newFromName( $this->mTarget, false ); |
65 | | - if( !$user || !$user->getId() ) { |
| 65 | + if ( !$user || !$user->getId() ) { |
66 | 66 | $wgOut->addWikiMsg( 'nosuchusershort', $this->mTarget ); |
67 | 67 | return; |
68 | 68 | } |
69 | 69 | $this->mRepo->linkUser( $this->mAuthor, $user ); |
70 | | - $userlink = $this->mSkin->userLink( $user->getId(), $user->getName() ); |
| 70 | + $userlink = $this->mSkin->userLink( $user->getId(), $user->getName() ); |
71 | 71 | $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 ) . |
74 | 74 | '</div>' |
75 | 75 | ); |
76 | 76 | // Unlink an author to a wiki users |
— | — | @@ -80,7 +80,7 @@ |
81 | 81 | } |
82 | 82 | $this->mRepo->unlinkUser( $this->mAuthor ); |
83 | 83 | $wgOut->addHTML( |
84 | | - '<div class="successbox">' . |
| 84 | + '<div class="successbox">' . |
85 | 85 | wfMsgHtml( 'code-author-unlinksuccess', $this->authorLink( $this->mAuthor ) ) . |
86 | 86 | '</div>' |
87 | 87 | ); |
Index: trunk/extensions/CodeReview/CodeReview.php |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | <?php |
3 | | -if (!defined('MEDIAWIKI')) die(); |
| 3 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
4 | 4 | /** |
5 | 5 | * |
6 | 6 | * @author Brion Vibber |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | 'descriptionmsg' => 'code-desc', |
38 | 38 | ); |
39 | 39 | |
40 | | -$dir = dirname(__FILE__) . '/'; |
| 40 | +$dir = dirname( __FILE__ ) . '/'; |
41 | 41 | |
42 | 42 | $wgAutoloadClasses['ApiCodeUpdate'] = $dir . 'ApiCodeUpdate.php'; |
43 | 43 | $wgAutoloadClasses['ApiCodeDiff'] = $dir . 'ApiCodeDiff.php'; |
Index: trunk/extensions/CodeReview/CodeComment.php |
— | — | @@ -1,18 +1,18 @@ |
2 | 2 | <?php |
3 | | -if (!defined('MEDIAWIKI')) die(); |
| 3 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
4 | 4 | |
5 | 5 | class CodeComment { |
6 | 6 | function __construct( $rev ) { |
7 | 7 | $this->rev = $rev; |
8 | 8 | } |
9 | | - |
| 9 | + |
10 | 10 | static function newFromRow( $rev, $row ) { |
11 | 11 | return self::newFromData( $rev, get_object_vars( $row ) ); |
12 | 12 | } |
13 | | - |
| 13 | + |
14 | 14 | static function newFromData( $rev, $data ) { |
15 | 15 | $comment = new CodeComment( $rev ); |
16 | | - $comment->id = intval($data['cc_id']); |
| 16 | + $comment->id = intval( $data['cc_id'] ); |
17 | 17 | $comment->text = $data['cc_text']; // fixme |
18 | 18 | $comment->user = $data['cc_user']; |
19 | 19 | $comment->userText = $data['cc_user_text']; |
— | — | @@ -21,7 +21,7 @@ |
22 | 22 | $comment->sortkey = $data['cc_sortkey']; |
23 | 23 | return $comment; |
24 | 24 | } |
25 | | - |
| 25 | + |
26 | 26 | function threadDepth() { |
27 | 27 | $timestamps = explode( ",", $this->sortkey ); |
28 | 28 | return count( $timestamps ); |
Index: trunk/extensions/CodeReview/Subversion.php |
— | — | @@ -1,14 +1,14 @@ |
2 | 2 | <?php |
3 | | -if (!defined('MEDIAWIKI')) die(); |
| 3 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
4 | 4 | |
5 | 5 | abstract class SubversionAdaptor { |
6 | 6 | protected $mRepo; |
7 | 7 | |
8 | 8 | public static function newFromRepo( $repo ) { |
9 | 9 | global $wgSubversionProxy, $wgSubversionProxyTimeout; |
10 | | - if( $wgSubversionProxy ) { |
| 10 | + if ( $wgSubversionProxy ) { |
11 | 11 | return new SubversionProxy( $repo, $wgSubversionProxy, $wgSubversionProxyTimeout ); |
12 | | - } elseif( function_exists( 'svn_log' ) ) { |
| 12 | + } elseif ( function_exists( 'svn_log' ) ) { |
13 | 13 | return new SubversionPecl( $repo ); |
14 | 14 | } else { |
15 | 15 | return new SubversionShell( $repo ); |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | $this->mRepo = $repo; |
21 | 21 | } |
22 | 22 | |
23 | | - abstract function getFile( $path, $rev=null ); |
| 23 | + abstract function getFile( $path, $rev = null ); |
24 | 24 | |
25 | 25 | abstract function getDiff( $path, $rev1, $rev2 ); |
26 | 26 | |
— | — | @@ -39,10 +39,10 @@ |
40 | 40 | ... |
41 | 41 | ) |
42 | 42 | */ |
43 | | - abstract function getLog( $path, $startRev=null, $endRev=null ); |
| 43 | + abstract function getLog( $path, $startRev = null, $endRev = null ); |
44 | 44 | |
45 | 45 | protected function _rev( $rev, $default ) { |
46 | | - if( $rev === null ) { |
| 46 | + if ( $rev === null ) { |
47 | 47 | return $default; |
48 | 48 | } else { |
49 | 49 | return intval( $rev ); |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | * Using the SVN PECL extension... |
56 | 56 | */ |
57 | 57 | class SubversionPecl extends SubversionAdaptor { |
58 | | - function getFile( $path, $rev=null ) { |
| 58 | + function getFile( $path, $rev = null ) { |
59 | 59 | return svn_cat( $this->mRepo . $path, $rev ); |
60 | 60 | } |
61 | 61 | |
— | — | @@ -63,18 +63,18 @@ |
64 | 64 | $this->mRepo . $path, $rev1, |
65 | 65 | $this->mRepo . $path, $rev2 ); |
66 | 66 | |
67 | | - if( $fout ) { |
| 67 | + if ( $fout ) { |
68 | 68 | // We have to read out the file descriptors. :P |
69 | 69 | $out = ''; |
70 | | - while( !feof( $fout ) ) { |
| 70 | + while ( !feof( $fout ) ) { |
71 | 71 | $out .= fgets( $fout ); |
72 | 72 | } |
73 | 73 | fclose( $fout ); |
74 | 74 | fclose( $ferr ); |
75 | | - |
| 75 | + |
76 | 76 | return $out; |
77 | 77 | } else { |
78 | | - return new MWException("Diffing error"); |
| 78 | + return new MWException( "Diffing error" ); |
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
— | — | @@ -83,7 +83,7 @@ |
84 | 84 | $this->_rev( $rev, SVN_REVISION_HEAD ) ); |
85 | 85 | } |
86 | 86 | |
87 | | - function getLog( $path, $startRev=null, $endRev=null ) { |
| 87 | + function getLog( $path, $startRev = null, $endRev = null ) { |
88 | 88 | return svn_log( $this->mRepo . $path, |
89 | 89 | $this->_rev( $startRev, SVN_REVISION_INITIAL ), |
90 | 90 | $this->_rev( $endRev, SVN_REVISION_HEAD ) ); |
— | — | @@ -94,8 +94,8 @@ |
95 | 95 | * Using the thingy-bobber |
96 | 96 | */ |
97 | 97 | class SubversionShell extends SubversionAdaptor { |
98 | | - function getFile( $path, $rev=null ) { |
99 | | - if( $rev ) |
| 98 | + function getFile( $path, $rev = null ) { |
| 99 | + if ( $rev ) |
100 | 100 | $path .= "@$rev"; |
101 | 101 | $command = sprintf( |
102 | 102 | "svn cat --non-interactive %s %s", |
— | — | @@ -116,7 +116,7 @@ |
117 | 117 | return wfShellExec( $command ); |
118 | 118 | } |
119 | 119 | |
120 | | - function getLog( $path, $startRev=null, $endRev=null ) { |
| 120 | + function getLog( $path, $startRev = null, $endRev = null ) { |
121 | 121 | $lang = wfIsWindows() ? "" : "LC_ALL=en_US.utf-8 "; |
122 | 122 | $command = sprintf( |
123 | 123 | "{$lang}svn log -v -r%s:%s --non-interactive %s %s", |
— | — | @@ -136,29 +136,29 @@ |
137 | 137 | 'lines' => '/^(\d+) lines?$/', |
138 | 138 | ); |
139 | 139 | $state = "start"; |
140 | | - foreach( $lines as $line ) { |
| 140 | + foreach ( $lines as $line ) { |
141 | 141 | $line = rtrim( $line ); |
142 | 142 | |
143 | 143 | switch( $state ) { |
144 | 144 | case "start": |
145 | | - if( $line == $divider ) { |
| 145 | + if ( $line == $divider ) { |
146 | 146 | $state = "revdata"; |
147 | 147 | break; |
148 | 148 | } else { |
149 | 149 | return $out; |
150 | | - #throw new MWException( "Unexpected start line: $line" ); |
| 150 | + # throw new MWException( "Unexpected start line: $line" ); |
151 | 151 | } |
152 | 152 | case "revdata": |
153 | | - if( $line == "" ) { |
| 153 | + if ( $line == "" ) { |
154 | 154 | $state = "done"; |
155 | 155 | break; |
156 | 156 | } |
157 | 157 | $data = array(); |
158 | 158 | $bits = explode( " | ", $line ); |
159 | 159 | $i = 0; |
160 | | - foreach( $formats as $key => $regex ) { |
| 160 | + foreach ( $formats as $key => $regex ) { |
161 | 161 | $text = $bits[$i++]; |
162 | | - if( preg_match( $regex, $text, $matches ) ) { |
| 162 | + if ( preg_match( $regex, $text, $matches ) ) { |
163 | 163 | $data[$key] = $matches[1]; |
164 | 164 | } else { |
165 | 165 | throw new MWException( |
— | — | @@ -170,9 +170,9 @@ |
171 | 171 | $state = 'changedpaths'; |
172 | 172 | break; |
173 | 173 | 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 |
175 | 175 | $state = "path"; |
176 | | - } elseif( $line == "" ) { |
| 176 | + } elseif ( $line == "" ) { |
177 | 177 | // No changed paths? |
178 | 178 | $state = "msg"; |
179 | 179 | } else { |
— | — | @@ -181,11 +181,11 @@ |
182 | 182 | } |
183 | 183 | break; |
184 | 184 | case "path": |
185 | | - if( $line == "" ) { |
| 185 | + if ( $line == "" ) { |
186 | 186 | // Out of paths. Move on to the message... |
187 | 187 | $state = 'msg'; |
188 | 188 | } else { |
189 | | - if( preg_match( '/^ (.) (.*)$/', $line, $matches ) ) { |
| 189 | + if ( preg_match( '/^ (.) (.*)$/', $line, $matches ) ) { |
190 | 190 | $data['paths'][] = array( |
191 | 191 | 'action' => $matches[1], |
192 | 192 | 'path' => $matches[2] ); |
— | — | @@ -194,7 +194,7 @@ |
195 | 195 | break; |
196 | 196 | case "msg": |
197 | 197 | $data['msg'] .= $line; |
198 | | - if( --$data['lines'] ) { |
| 198 | + if ( --$data['lines'] ) { |
199 | 199 | $data['msg'] .= "\n"; |
200 | 200 | } else { |
201 | 201 | unset( $data['lines'] ); |
— | — | @@ -211,20 +211,20 @@ |
212 | 212 | |
213 | 213 | return $out; |
214 | 214 | } |
215 | | - |
| 215 | + |
216 | 216 | function getDirList( $path, $rev = null ) { |
217 | 217 | $command = sprintf( |
218 | 218 | "svn list --xml -r%s --non-interactive %s %s", |
219 | 219 | wfEscapeShellArg( $this->_rev( $rev, 'HEAD' ) ), |
220 | 220 | $this->getExtraArgs(), |
221 | 221 | wfEscapeShellArg( $this->mRepo . $path ) ); |
222 | | - $document = new DOMDocument(); |
223 | | - |
| 222 | + $document = new DOMDocument(); |
| 223 | + |
224 | 224 | if ( !@$document->loadXML( wfShellExec( $command ) ) ) |
225 | 225 | // svn list --xml returns invalid XML if the file does not exist |
226 | 226 | // FIXME: report bug upstream |
227 | 227 | return false; |
228 | | - |
| 228 | + |
229 | 229 | $entries = $document->getElementsByTagName( 'entry' ); |
230 | 230 | $result = array(); |
231 | 231 | foreach ( $entries as $entry ) { |
— | — | @@ -236,7 +236,7 @@ |
237 | 237 | $item['name'] = $child->textContent; |
238 | 238 | break; |
239 | 239 | case 'size': |
240 | | - $item['size'] = intval( $child->textContent ); |
| 240 | + $item['size'] = intval( $child->textContent ); |
241 | 241 | break; |
242 | 242 | case 'commit': |
243 | 243 | $item['created_rev'] = intval( $child->getAttribute( 'revision' ) ); |
— | — | @@ -246,26 +246,26 @@ |
247 | 247 | $item['last_author'] = $commitEntry->textContent; |
248 | 248 | break; |
249 | 249 | case 'date': |
250 | | - $item['time_t'] = wfTimestamp( TS_UNIX, $commitEntry->textContent ); |
| 250 | + $item['time_t'] = wfTimestamp( TS_UNIX, $commitEntry->textContent ); |
251 | 251 | break; |
252 | 252 | } |
253 | 253 | } |
254 | | - break; |
| 254 | + break; |
255 | 255 | } |
256 | 256 | } |
257 | 257 | $result[] = $item; |
258 | 258 | } |
259 | 259 | return $result; |
260 | 260 | } |
261 | | - |
| 261 | + |
262 | 262 | /** |
263 | 263 | * Returns a string of extra arguments to be passed into the shell commands |
264 | 264 | */ |
265 | 265 | private function getExtraArgs() { |
266 | 266 | 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 ); |
270 | 270 | } |
271 | 271 | return ''; |
272 | 272 | } |
— | — | @@ -275,13 +275,13 @@ |
276 | 276 | * Using a remote JSON proxy |
277 | 277 | */ |
278 | 278 | class SubversionProxy extends SubversionAdaptor { |
279 | | - function __construct( $repo, $proxy, $timeout=30 ) { |
| 279 | + function __construct( $repo, $proxy, $timeout = 30 ) { |
280 | 280 | parent::__construct( $repo ); |
281 | 281 | $this->mProxy = $proxy; |
282 | 282 | $this->mTimeout = $timeout; |
283 | 283 | } |
284 | | - |
285 | | - function getFile( $path, $rev=null ) { |
| 284 | + |
| 285 | + function getFile( $path, $rev = null ) { |
286 | 286 | throw new MWException( "NYI" ); |
287 | 287 | } |
288 | 288 | |
— | — | @@ -293,31 +293,31 @@ |
294 | 294 | 'rev2' => $rev2 ) ); |
295 | 295 | } |
296 | 296 | |
297 | | - function getLog( $path, $startRev=null, $endRev=null ) { |
| 297 | + function getLog( $path, $startRev = null, $endRev = null ) { |
298 | 298 | return $this->_proxy( array( |
299 | 299 | 'action' => 'log', |
300 | 300 | 'path' => $path, |
301 | 301 | 'start' => $startRev, |
302 | 302 | 'end' => $endRev ) ); |
303 | 303 | } |
304 | | - |
| 304 | + |
305 | 305 | function getDirList( $path, $rev = null ) { |
306 | 306 | return $this->_proxy( array( |
307 | 307 | 'action' => 'list', |
308 | 308 | 'path' => $path, |
309 | 309 | 'rev' => $rev ) ); |
310 | 310 | } |
311 | | - |
| 311 | + |
312 | 312 | 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 ) ) { |
315 | 315 | // Don't pass nulls to remote |
316 | 316 | unset( $params[$key] ); |
317 | 317 | } |
318 | 318 | } |
319 | 319 | $target = $this->mProxy . '?' . wfArrayToCgi( $params ); |
320 | 320 | $blob = Http::get( $target, $this->mTimeout ); |
321 | | - if( $blob === false ) { |
| 321 | + if ( $blob === false ) { |
322 | 322 | throw new MWException( "SVN proxy error" ); |
323 | 323 | } |
324 | 324 | $data = unserialize( $blob ); |
Index: trunk/extensions/CodeReview/CodeStatusListView.php |
— | — | @@ -11,11 +11,10 @@ |
12 | 12 | global $wgOut; |
13 | 13 | $name = $this->mRepo->getName(); |
14 | 14 | $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"; |
18 | 18 | } |
19 | 19 | $wgOut->addWikiText( $text ); |
20 | 20 | } |
21 | 21 | } |
22 | | - |
Index: trunk/extensions/CodeReview/CodeCommentsListView.php |
— | — | @@ -12,10 +12,10 @@ |
13 | 13 | function execute() { |
14 | 14 | global $wgOut; |
15 | 15 | $pager = $this->getPager(); |
16 | | - $wgOut->addHTML( |
| 16 | + $wgOut->addHTML( |
17 | 17 | $pager->getNavigationBar() . |
18 | | - $pager->getLimitForm() . |
19 | | - $pager->getBody() . |
| 18 | + $pager->getLimitForm() . |
| 19 | + $pager->getBody() . |
20 | 20 | $pager->getNavigationBar() |
21 | 21 | ); |
22 | 22 | } |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | // Pager for CodeRevisionListView |
33 | 33 | class CodeCommentsTablePager extends TablePager { |
34 | 34 | |
35 | | - function __construct( CodeCommentsListView $view ){ |
| 35 | + function __construct( CodeCommentsListView $view ) { |
36 | 36 | global $IP; |
37 | 37 | $this->mView = $view; |
38 | 38 | $this->mRepo = $view->mRepo; |
— | — | @@ -40,24 +40,24 @@ |
41 | 41 | parent::__construct(); |
42 | 42 | } |
43 | 43 | |
44 | | - function isFieldSortable( $field ){ |
| 44 | + function isFieldSortable( $field ) { |
45 | 45 | return $field == 'cr_timestamp'; |
46 | 46 | } |
47 | 47 | |
48 | | - function getDefaultSort(){ return 'cc_timestamp'; } |
| 48 | + function getDefaultSort() { return 'cc_timestamp'; } |
49 | 49 | |
50 | | - function getQueryInfo(){ |
| 50 | + function getQueryInfo() { |
51 | 51 | return array( |
52 | 52 | 'tables' => array( 'code_comment', 'code_rev' ), |
53 | 53 | 'fields' => array_keys( $this->getFieldNames() ), |
54 | 54 | 'conds' => array( 'cc_repo_id' => $this->mRepo->getId() ), |
55 | | - 'join_conds' => array( |
| 55 | + 'join_conds' => array( |
56 | 56 | 'code_rev' => array( 'LEFT JOIN', 'cc_repo_id = cr_repo_id AND cc_rev_id = cr_id' ) |
57 | 57 | ) |
58 | 58 | ); |
59 | 59 | } |
60 | 60 | |
61 | | - function getFieldNames(){ |
| 61 | + function getFieldNames() { |
62 | 62 | return array( |
63 | 63 | 'cc_timestamp' => wfMsg( 'code-field-timestamp' ), |
64 | 64 | 'cc_user_text' => wfMsg( 'code-field-user' ), |
— | — | @@ -68,9 +68,9 @@ |
69 | 69 | ); |
70 | 70 | } |
71 | 71 | |
72 | | - function formatValue( $name, $value ){ |
| 72 | + function formatValue( $name, $value ) { |
73 | 73 | global $wgUser, $wgLang; |
74 | | - switch( $name ){ |
| 74 | + switch( $name ) { |
75 | 75 | case 'cc_rev_id': |
76 | 76 | return $this->mView->mSkin->link( |
77 | 77 | SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/' . $value . '#code-comments' ), |
— | — | @@ -92,12 +92,12 @@ |
93 | 93 | return $wgLang->timeanddate( $value, true ); |
94 | 94 | } |
95 | 95 | } |
96 | | - |
| 96 | + |
97 | 97 | // Note: this function is poorly factored in the parent class |
98 | 98 | function formatRow( $row ) { |
99 | 99 | global $wgWikiSVN; |
100 | 100 | $class = "mw-codereview-status-{$row->cr_status}"; |
101 | | - if($this->mRepo->mName == $wgWikiSVN){ |
| 101 | + if ( $this->mRepo->mName == $wgWikiSVN ) { |
102 | 102 | $class .= " mw-codereview-" . ( $row->cc_rev_id <= $this->mCurSVN ? 'live' : 'notlive' ); |
103 | 103 | } |
104 | 104 | return str_replace( |
— | — | @@ -107,7 +107,7 @@ |
108 | 108 | parent::formatRow( $row ) ); |
109 | 109 | } |
110 | 110 | |
111 | | - function getTitle(){ |
| 111 | + function getTitle() { |
112 | 112 | return SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/comments' ); |
113 | 113 | } |
114 | 114 | } |
Index: trunk/extensions/CodeReview/CodeReview.i18n.php |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | 'code-prop-changes' => 'Status & tagging log', |
20 | 20 | 'code-desc' => '[[Special:Code|Code review tool]] with [[Special:RepoAdmin|Subversion support]]', |
21 | 21 | 'code-no-repo' => 'No repository configured!', |
22 | | - 'code-load-diff'=> 'Loading diff…', |
| 22 | + 'code-load-diff' => 'Loading diff…', |
23 | 23 | 'code-notes' => 'recent comments', |
24 | 24 | 'code-authors' => 'authors', |
25 | 25 | 'code-status' => 'status', |
— | — | @@ -76,28 +76,28 @@ |
77 | 77 | 'code-pathsearch-path' => 'Path:', |
78 | 78 | 'code-rev-submit' => 'Save changes', |
79 | 79 | 'code-rev-submit-next' => 'Save & next unresolved', |
80 | | - |
| 80 | + |
81 | 81 | 'code-batch-status' => 'Change status:', |
82 | 82 | 'code-batch-tags' => 'Change tags:', |
83 | 83 | 'codereview-batch-title' => 'Change all selected revisions', |
84 | 84 | 'codereview-batch-submit' => 'Submit', |
85 | | - |
| 85 | + |
86 | 86 | 'code-releasenotes' => 'release notes', |
87 | 87 | 'code-release-legend' => 'Generate release notes', |
88 | 88 | 'code-release-startrev' => 'Start rev:', |
89 | 89 | 'code-release-endrev' => 'Last rev:', |
90 | | - |
| 90 | + |
91 | 91 | 'codereview-subtitle' => 'For $1', |
92 | | - |
| 92 | + |
93 | 93 | 'codereview-reply-link' => 'reply', |
94 | | - |
| 94 | + |
95 | 95 | 'codereview-email-subj' => '[$1] [r$2]: New comment added', |
96 | 96 | 'codereview-email-body' => 'User "$1" posted a comment on r$3. |
97 | | - |
| 97 | + |
98 | 98 | Full URL: $2 |
99 | 99 | |
100 | 100 | Comment: |
101 | | - |
| 101 | + |
102 | 102 | $4', |
103 | 103 | |
104 | 104 | 'repoadmin' => 'Repository Administration', |
— | — | @@ -117,7 +117,7 @@ |
118 | 118 | 'right-codereview-post-comment' => 'Add comments on revisions', |
119 | 119 | 'right-codereview-set-status' => 'Change revisions status', |
120 | 120 | 'right-codereview-link-user' => 'Link authors to wiki users', |
121 | | - |
| 121 | + |
122 | 122 | 'specialpages-group-developer' => 'Developer tools', |
123 | 123 | ); |
124 | 124 | |
Index: trunk/extensions/CodeReview/CodeRepository.php |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | <?php |
3 | | -if (!defined('MEDIAWIKI')) die(); |
| 3 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
4 | 4 | |
5 | 5 | class CodeRepository { |
6 | 6 | static $userLinks = array(); |
— | — | @@ -17,13 +17,13 @@ |
18 | 18 | array( 'repo_name' => $name ), |
19 | 19 | __METHOD__ ); |
20 | 20 | |
21 | | - if( $row ) { |
| 21 | + if ( $row ) { |
22 | 22 | return self::newFromRow( $row ); |
23 | 23 | } else { |
24 | 24 | return null; |
25 | 25 | } |
26 | 26 | } |
27 | | - |
| 27 | + |
28 | 28 | public static function newFromId( $id ) { |
29 | 29 | $dbw = wfGetDB( DB_MASTER ); |
30 | 30 | $row = $dbw->selectRow( |
— | — | @@ -34,10 +34,10 @@ |
35 | 35 | 'repo_path', |
36 | 36 | 'repo_viewvc', |
37 | 37 | 'repo_bugzilla' ), |
38 | | - array( 'repo_id' => intval($id) ), |
| 38 | + array( 'repo_id' => intval( $id ) ), |
39 | 39 | __METHOD__ ); |
40 | 40 | |
41 | | - if( $row ) { |
| 41 | + if ( $row ) { |
42 | 42 | return self::newFromRow( $row ); |
43 | 43 | } else { |
44 | 44 | return null; |
— | — | @@ -46,7 +46,7 @@ |
47 | 47 | |
48 | 48 | static function newFromRow( $row ) { |
49 | 49 | $repo = new CodeRepository(); |
50 | | - $repo->mId = intval($row->repo_id); |
| 50 | + $repo->mId = intval( $row->repo_id ); |
51 | 51 | $repo->mName = $row->repo_name; |
52 | 52 | $repo->mPath = $row->repo_path; |
53 | 53 | $repo->mViewVc = $row->repo_viewvc; |
— | — | @@ -54,11 +54,11 @@ |
55 | 55 | return $repo; |
56 | 56 | } |
57 | 57 | |
58 | | - static function getRepoList(){ |
| 58 | + static function getRepoList() { |
59 | 59 | $dbr = wfGetDB( DB_SLAVE ); |
60 | 60 | $res = $dbr->select( 'code_repo', '*', array(), __METHOD__ ); |
61 | 61 | $repos = array(); |
62 | | - foreach( $res as $row ){ |
| 62 | + foreach ( $res as $row ) { |
63 | 63 | $repos[] = self::newFromRow( $row ); |
64 | 64 | } |
65 | 65 | return $repos; |
— | — | @@ -72,11 +72,11 @@ |
73 | 73 | return $this->mName; |
74 | 74 | } |
75 | 75 | |
76 | | - public function getPath(){ |
| 76 | + public function getPath() { |
77 | 77 | return $this->mPath; |
78 | 78 | } |
79 | 79 | |
80 | | - public function getViewVcBase(){ |
| 80 | + public function getViewVcBase() { |
81 | 81 | return $this->mViewVc; |
82 | 82 | } |
83 | 83 | |
— | — | @@ -84,7 +84,7 @@ |
85 | 85 | * Return a bug URL or false. |
86 | 86 | */ |
87 | 87 | public function getBugPath( $bugId ) { |
88 | | - if( $this->mBugzilla ) { |
| 88 | + if ( $this->mBugzilla ) { |
89 | 89 | return str_replace( '$1', |
90 | 90 | urlencode( $bugId ), $this->mBugzilla ); |
91 | 91 | } |
— | — | @@ -101,52 +101,52 @@ |
102 | 102 | ); |
103 | 103 | return intval( $row ); |
104 | 104 | } |
105 | | - |
| 105 | + |
106 | 106 | public function getAuthorList() { |
107 | 107 | global $wgMemc; |
108 | 108 | $key = wfMemcKey( 'codereview', 'authors', $this->getId() ); |
109 | 109 | $authors = $wgMemc->get( $key ); |
110 | | - if( is_array($authors) ) { |
| 110 | + if ( is_array( $authors ) ) { |
111 | 111 | return $authors; |
112 | 112 | } |
113 | 113 | $dbr = wfGetDB( DB_SLAVE ); |
114 | | - $res = $dbr->select( |
| 114 | + $res = $dbr->select( |
115 | 115 | 'code_rev', |
116 | 116 | array( 'cr_author', 'MAX(cr_timestamp) AS time' ), |
117 | 117 | array( 'cr_repo_id' => $this->getId() ), |
118 | 118 | __METHOD__, |
119 | | - array( 'GROUP BY' => 'cr_author', |
| 119 | + array( 'GROUP BY' => 'cr_author', |
120 | 120 | 'ORDER BY' => 'time DESC', 'LIMIT' => 500 ) |
121 | 121 | ); |
122 | 122 | $authors = array(); |
123 | | - while( $row = $dbr->fetchObject( $res ) ) { |
| 123 | + while ( $row = $dbr->fetchObject( $res ) ) { |
124 | 124 | $authors[] = $row->cr_author; |
125 | 125 | } |
126 | | - $wgMemc->set( $key, $authors, 3600*24*3 ); |
| 126 | + $wgMemc->set( $key, $authors, 3600 * 24 * 3 ); |
127 | 127 | return $authors; |
128 | 128 | } |
129 | | - |
| 129 | + |
130 | 130 | public function getTagList() { |
131 | 131 | global $wgMemc; |
132 | 132 | $key = wfMemcKey( 'codereview', 'tags', $this->getId() ); |
133 | 133 | $tags = $wgMemc->get( $key ); |
134 | | - if( is_array($tags) ) { |
| 134 | + if ( is_array( $tags ) ) { |
135 | 135 | return $tags; |
136 | 136 | } |
137 | 137 | $dbr = wfGetDB( DB_SLAVE ); |
138 | | - $res = $dbr->select( |
| 138 | + $res = $dbr->select( |
139 | 139 | 'code_tags', |
140 | 140 | array( 'ct_tag', 'COUNT(*) AS revs' ), |
141 | 141 | array( 'ct_repo_id' => $this->getId() ), |
142 | 142 | __METHOD__, |
143 | | - array( 'GROUP BY' => 'ct_tag', |
| 143 | + array( 'GROUP BY' => 'ct_tag', |
144 | 144 | 'ORDER BY' => 'revs DESC', 'LIMIT' => 500 ) |
145 | 145 | ); |
146 | 146 | $tags = array(); |
147 | | - while( $row = $dbr->fetchObject( $res ) ) { |
| 147 | + while ( $row = $dbr->fetchObject( $res ) ) { |
148 | 148 | $tags[] = $row->ct_tag; |
149 | 149 | } |
150 | | - $wgMemc->set( $key, $tags, 3600*24*3 ); |
| 150 | + $wgMemc->set( $key, $tags, 3600 * 24 * 3 ); |
151 | 151 | return $tags; |
152 | 152 | } |
153 | 153 | |
— | — | @@ -166,7 +166,7 @@ |
167 | 167 | ), |
168 | 168 | __METHOD__ |
169 | 169 | ); |
170 | | - if( !$row ) |
| 170 | + if ( !$row ) |
171 | 171 | throw new MWException( 'Failed to load expected revision data' ); |
172 | 172 | return CodeRevision::newFromRow( $this, $row ); |
173 | 173 | } |
— | — | @@ -182,34 +182,34 @@ |
183 | 183 | |
184 | 184 | $rev1 = $rev - 1; |
185 | 185 | $rev2 = $rev; |
186 | | - |
| 186 | + |
187 | 187 | $revision = $this->getRevision( $rev ); |
188 | | - if( $revision == null || !$revision->isDiffable() ) { |
| 188 | + if ( $revision == null || !$revision->isDiffable() ) { |
189 | 189 | wfProfileOut( __METHOD__ ); |
190 | 190 | return false; |
191 | 191 | } |
192 | 192 | |
193 | 193 | # Try memcached... |
194 | 194 | $key = wfMemcKey( 'svn', md5( $this->mPath ), 'diff', $rev1, $rev2 ); |
195 | | - if( $useCache === 'skipcache' ) { |
| 195 | + if ( $useCache === 'skipcache' ) { |
196 | 196 | $data = NULL; |
197 | 197 | } else { |
198 | 198 | $data = $wgMemc->get( $key ); |
199 | 199 | } |
200 | 200 | |
201 | 201 | # Try the database... |
202 | | - if( !$data && $useCache != 'skipcache' ) { |
| 202 | + if ( !$data && $useCache != 'skipcache' ) { |
203 | 203 | $dbr = wfGetDB( DB_SLAVE ); |
204 | | - $row = $dbr->selectRow( 'code_rev', |
| 204 | + $row = $dbr->selectRow( 'code_rev', |
205 | 205 | array( 'cr_diff', 'cr_flags' ), |
206 | 206 | array( 'cr_repo_id' => $this->mId, 'cr_id' => $rev, 'cr_diff IS NOT NULL' ), |
207 | 207 | __METHOD__ |
208 | 208 | ); |
209 | | - if( $row ) { |
| 209 | + if ( $row ) { |
210 | 210 | $flags = explode( ',', $row->cr_flags ); |
211 | 211 | $data = $row->cr_diff; |
212 | 212 | // 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 ) ) { |
214 | 214 | # Deal with optional compression of archived pages. |
215 | 215 | # This can be done periodically via maintenance/compressOld.php, and |
216 | 216 | # as pages are saved if $wgCompressRevisions is set. |
— | — | @@ -219,16 +219,16 @@ |
220 | 220 | } |
221 | 221 | |
222 | 222 | # Generate the diff as needed... |
223 | | - if( !$data && $useCache !== 'cached' ) { |
| 223 | + if ( !$data && $useCache !== 'cached' ) { |
224 | 224 | $svn = SubversionAdaptor::newFromRepo( $this->mPath ); |
225 | 225 | $data = $svn->getDiff( '', $rev1, $rev2 ); |
226 | 226 | // Store to cache |
227 | | - $wgMemc->set( $key, $data, 3600*24*3 ); |
| 227 | + $wgMemc->set( $key, $data, 3600 * 24 * 3 ); |
228 | 228 | // Permanent DB storage |
229 | 229 | $storedData = $data; |
230 | 230 | $flags = Revision::compressRevisionText( $storedData ); |
231 | 231 | $dbw = wfGetDB( DB_MASTER ); |
232 | | - $dbw->update( 'code_rev', |
| 232 | + $dbw->update( 'code_rev', |
233 | 233 | array( 'cr_diff' => $storedData, 'cr_flags' => $flags ), |
234 | 234 | array( 'cr_repo_id' => $this->mId, 'cr_id' => $rev ), |
235 | 235 | __METHOD__ |
— | — | @@ -250,7 +250,7 @@ |
251 | 251 | } |
252 | 252 | return false; |
253 | 253 | } |
254 | | - |
| 254 | + |
255 | 255 | /* |
256 | 256 | * Link the $author to the wikiuser $user |
257 | 257 | * @param string $author |
— | — | @@ -259,7 +259,7 @@ |
260 | 260 | */ |
261 | 261 | public function linkUser( $author, User $user ) { |
262 | 262 | // We must link to an existing user |
263 | | - if( !$user->getId() ) { |
| 263 | + if ( !$user->getId() ) { |
264 | 264 | return false; |
265 | 265 | } |
266 | 266 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -275,7 +275,7 @@ |
276 | 276 | array( 'IGNORE' ) |
277 | 277 | ); |
278 | 278 | // If the last query already found a row, then update it. |
279 | | - if( !$dbw->affectedRows() ) { |
| 279 | + if ( !$dbw->affectedRows() ) { |
280 | 280 | $dbw->update( |
281 | 281 | 'code_authors', |
282 | 282 | array( 'ca_user_text' => $user->getName() ), |
— | — | @@ -308,13 +308,13 @@ |
309 | 309 | self::$userLinks[$author] = false; |
310 | 310 | return ( $dbw->affectedRows() > 0 ); |
311 | 311 | } |
312 | | - |
313 | | - /* |
| 312 | + |
| 313 | + /* |
314 | 314 | * returns a User object if $author has a wikiuser associated, |
315 | 315 | * or false |
316 | 316 | */ |
317 | 317 | public function authorWikiUser( $author ) { |
318 | | - if( isset( self::$userLinks[$author] ) ) |
| 318 | + if ( isset( self::$userLinks[$author] ) ) |
319 | 319 | return self::$userLinks[$author]; |
320 | 320 | |
321 | 321 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -328,9 +328,9 @@ |
329 | 329 | __METHOD__ |
330 | 330 | ); |
331 | 331 | $user = null; |
332 | | - if( $wikiUser ) |
| 332 | + if ( $wikiUser ) |
333 | 333 | $user = User::newFromName( $wikiUser ); |
334 | | - if( $user instanceof User ) |
| 334 | + if ( $user instanceof User ) |
335 | 335 | $res = $user; |
336 | 336 | else |
337 | 337 | $res = false; |
Index: trunk/extensions/CodeReview/ApiCodeComments.php |
— | — | @@ -27,25 +27,25 @@ |
28 | 28 | public function __construct( $query, $moduleName ) { |
29 | 29 | parent::__construct( $query, $moduleName, 'cc' ); |
30 | 30 | } |
31 | | - |
| 31 | + |
32 | 32 | public function execute() { |
33 | 33 | $params = $this->extractRequestParams(); |
34 | 34 | if ( is_null( $params['repo'] ) ) |
35 | 35 | $this->dieUsageMsg( array( 'missingparam', 'repo' ) ); |
36 | 36 | $this->props = array_flip( $params['prop'] ); |
37 | | - |
| 37 | + |
38 | 38 | $listview = new CodeCommentsListView( $params['repo'] ); |
39 | | - if( is_null( $listview->getRepo() ) ) |
| 39 | + if ( is_null( $listview->getRepo() ) ) |
40 | 40 | $this->dieUsage( "Invalid repo ``{$params['repo']}''", 'invalidrepo' ); |
41 | 41 | $pager = $listview->getPager(); |
42 | | - |
| 42 | + |
43 | 43 | if ( !is_null( $params['start'] ) ) |
44 | 44 | $pager->setOffset( $this->getDB()->timestamp( $params['start'] ) ); |
45 | 45 | $limit = $params['limit']; |
46 | 46 | $pager->setLimit( $limit ); |
47 | | - |
| 47 | + |
48 | 48 | $pager->doQuery(); |
49 | | - |
| 49 | + |
50 | 50 | $comments = $pager->getResult(); |
51 | 51 | $data = array(); |
52 | 52 | |
— | — | @@ -57,18 +57,18 @@ |
58 | 58 | wfTimestamp( TS_ISO_8601, $lastTimestamp ) ); |
59 | 59 | break; |
60 | 60 | } |
61 | | - |
| 61 | + |
62 | 62 | $data[] = $this->formatRow( $row ); |
63 | 63 | $lastTimestamp = $row->cc_timestamp; |
64 | 64 | $count++; |
65 | 65 | } |
66 | 66 | $comments->free(); |
67 | | - |
| 67 | + |
68 | 68 | $result = $this->getResult(); |
69 | 69 | $result->setIndexedTagName( $data, 'comment' ); |
70 | 70 | $result->addValue( 'query', $this->getModuleName(), $data ); |
71 | 71 | } |
72 | | - |
| 72 | + |
73 | 73 | private function formatRow( $row ) { |
74 | 74 | $item = array(); |
75 | 75 | if ( isset( $this->props['timestamp'] ) ) |
— | — | @@ -81,7 +81,7 @@ |
82 | 82 | ApiResult::setContent( $item, $row->cc_text ); |
83 | 83 | return $item; |
84 | 84 | } |
85 | | - |
| 85 | + |
86 | 86 | public function getAllowedParams() { |
87 | 87 | return array ( |
88 | 88 | 'repo' => null, |
— | — | @@ -92,7 +92,7 @@ |
93 | 93 | ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1, |
94 | 94 | ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2 |
95 | 95 | ), |
96 | | - 'start' => array( |
| 96 | + 'start' => array( |
97 | 97 | ApiBase :: PARAM_TYPE => 'timestamp' |
98 | 98 | ), |
99 | 99 | 'prop' => array ( |
— | — | @@ -107,7 +107,7 @@ |
108 | 108 | ), |
109 | 109 | ); |
110 | 110 | } |
111 | | - |
| 111 | + |
112 | 112 | public function getParamDescription() { |
113 | 113 | return array( |
114 | 114 | 'repo' => 'Name of the repository', |
— | — | @@ -116,19 +116,19 @@ |
117 | 117 | 'prop' => 'Which properties to return', |
118 | 118 | ); |
119 | 119 | } |
120 | | - |
| 120 | + |
121 | 121 | public function getDescription() { |
122 | 122 | return 'List comments on revisions in CodeReview'; |
123 | 123 | } |
124 | | - |
| 124 | + |
125 | 125 | public function getExamples() { |
126 | 126 | return array( |
127 | 127 | 'api.php?action=query&list=codecomments&ccrepo=MediaWiki', |
128 | 128 | 'api.php?action=query&list=codecomments&ccrepo=MediaWiki&ccprop=timestamp|user|revision|text', |
129 | 129 | ); |
130 | 130 | } |
131 | | - |
| 131 | + |
132 | 132 | public function getVersion() { |
133 | 133 | return __CLASS__ . ': $Id$'; |
134 | | - } |
| 134 | + } |
135 | 135 | } |
Index: trunk/extensions/CodeReview/SpecialCode.php |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | <?php |
3 | | -if (!defined('MEDIAWIKI')) die(); |
| 3 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
4 | 4 | |
5 | 5 | class SpecialCode extends SpecialPage { |
6 | 6 | function __construct() { |
— | — | @@ -14,9 +14,9 @@ |
15 | 15 | $this->setHeaders(); |
16 | 16 | $wgOut->addStyle( "$wgScriptPath/extensions/CodeReview/codereview.css?$wgCodeReviewStyleVersion" ); |
17 | 17 | # Remove stray slashes |
18 | | - $subpage = preg_replace( '/\/$/','', $subpage ); |
| 18 | + $subpage = preg_replace( '/\/$/', '', $subpage ); |
19 | 19 | |
20 | | - if( $subpage == '' ) { |
| 20 | + if ( $subpage == '' ) { |
21 | 21 | $view = new CodeRepoListView(); |
22 | 22 | } else { |
23 | 23 | $params = explode( '/', $subpage ); |
— | — | @@ -25,23 +25,23 @@ |
26 | 26 | $view = new CodeRevisionListView( $params[0] ); |
27 | 27 | break; |
28 | 28 | case 2: |
29 | | - if( $params[1] === 'tag' ) { |
| 29 | + if ( $params[1] === 'tag' ) { |
30 | 30 | $view = new CodeTagListView( $params[0] ); |
31 | 31 | break; |
32 | | - } elseif( $params[1] === 'author' ) { |
| 32 | + } elseif ( $params[1] === 'author' ) { |
33 | 33 | $view = new CodeAuthorListView( $params[0] ); |
34 | 34 | break; |
35 | | - } elseif( $params[1] === 'status' ) { |
| 35 | + } elseif ( $params[1] === 'status' ) { |
36 | 36 | $view = new CodeStatusListView( $params[0] ); |
37 | 37 | break; |
38 | | - } elseif( $params[1] === 'comments' ) { |
| 38 | + } elseif ( $params[1] === 'comments' ) { |
39 | 39 | $view = new CodeCommentsListView( $params[0] ); |
40 | 40 | break; |
41 | | - } elseif( $params[1] === 'releasenotes' ) { |
| 41 | + } elseif ( $params[1] === 'releasenotes' ) { |
42 | 42 | $view = new CodeReleaseNotes( $params[0] ); |
43 | 43 | 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 |
46 | 46 | $submit = new CodeRevisionCommitter( $params[0], $params[1] ); |
47 | 47 | $submit->execute(); |
48 | 48 | return; |
— | — | @@ -50,46 +50,46 @@ |
51 | 51 | break; |
52 | 52 | } |
53 | 53 | case 3: |
54 | | - if( $params[1] === 'tag' ) { |
| 54 | + if ( $params[1] === 'tag' ) { |
55 | 55 | $view = new CodeRevisionTagView( $params[0], $params[2] ); |
56 | 56 | break; |
57 | | - } elseif( $params[1] === 'author' ) { |
| 57 | + } elseif ( $params[1] === 'author' ) { |
58 | 58 | $view = new CodeRevisionAuthorView( $params[0], $params[2] ); |
59 | 59 | break; |
60 | | - } elseif( $params[1] === 'status' ) { |
| 60 | + } elseif ( $params[1] === 'status' ) { |
61 | 61 | $view = new CodeRevisionStatusView( $params[0], $params[2] ); |
62 | 62 | break; |
63 | | - } elseif( $params[1] === 'comments' ) { |
| 63 | + } elseif ( $params[1] === 'comments' ) { |
64 | 64 | $view = new CodeCommentsListView( $params[0] ); |
65 | 65 | break; |
66 | 66 | } else { |
67 | 67 | # Nonsense parameters, back out |
68 | | - if( empty($params[1]) ) |
| 68 | + if ( empty( $params[1] ) ) |
69 | 69 | $view = new CodeRevisionListView( $params[0] ); |
70 | 70 | else |
71 | 71 | $view = new CodeRevisionView( $params[0], $params[1] ); |
72 | 72 | break; |
73 | 73 | } |
74 | 74 | case 4: |
75 | | - if ( $params[1] == 'author' && $params[3] == 'link') { |
| 75 | + if ( $params[1] == 'author' && $params[3] == 'link' ) { |
76 | 76 | $view = new CodeRevisionAuthorLink( $params[0], $params[2] ); |
77 | 77 | break; |
78 | 78 | } |
79 | 79 | default: |
80 | | - if( $params[2] == 'reply' ) { |
| 80 | + if ( $params[2] == 'reply' ) { |
81 | 81 | $view = new CodeRevisionView( $params[0], $params[1], $params[3] ); |
82 | 82 | break; |
83 | 83 | } |
84 | | - $wgOut->addWikiText( wfMsg('nosuchactiontext') ); |
| 84 | + $wgOut->addWikiText( wfMsg( 'nosuchactiontext' ) ); |
85 | 85 | $wgOut->returnToMain( null, SpecialPage::getTitleFor( 'Code' ) ); |
86 | 86 | return; |
87 | 87 | } |
88 | 88 | } |
89 | 89 | $view->execute(); |
90 | | - |
| 90 | + |
91 | 91 | // Add subtitle for easy navigation |
92 | 92 | global $wgOut; |
93 | | - if( $view instanceof CodeView && ($repo = $view->getRepo()) ) { |
| 93 | + if ( $view instanceof CodeView && ( $repo = $view->getRepo() ) ) { |
94 | 94 | $wgOut->setSubtitle( wfMsgExt( 'codereview-subtitle', 'parse', CodeRepoListView::getNavItem( $repo->getName() ) ) ); |
95 | 95 | } |
96 | 96 | } |
— | — | @@ -105,17 +105,17 @@ |
106 | 106 | global $wgUser; |
107 | 107 | $this->mSkin = $wgUser->getSkin(); |
108 | 108 | } |
109 | | - |
| 109 | + |
110 | 110 | function validPost( $permission ) { |
111 | 111 | global $wgRequest, $wgUser; |
112 | 112 | return $wgRequest->wasPosted() |
113 | | - && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) |
| 113 | + && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) |
114 | 114 | && $wgUser->isAllowed( $permission ); |
115 | 115 | } |
116 | 116 | |
117 | 117 | abstract function execute(); |
118 | 118 | |
119 | | - /* |
| 119 | + /* |
120 | 120 | * returns a User object if $author has a wikiuser associated, |
121 | 121 | * of false |
122 | 122 | */ |
— | — | @@ -128,12 +128,12 @@ |
129 | 129 | $special = SpecialPage::getTitleFor( 'Code', "$repo/author/$author" ); |
130 | 130 | return $this->mSkin->link( $special, htmlspecialchars( $author ) ); |
131 | 131 | } |
132 | | - |
| 132 | + |
133 | 133 | function statusDesc( $status ) { |
134 | 134 | return wfMsg( "code-status-$status" ); |
135 | 135 | } |
136 | 136 | |
137 | | - function formatMessage( $text ){ |
| 137 | + function formatMessage( $text ) { |
138 | 138 | $text = nl2br( htmlspecialchars( $text ) ); |
139 | 139 | $linker = new CodeCommentLinkerHtml( $this->mRepo ); |
140 | 140 | return $linker->link( $text ); |
— | — | @@ -153,12 +153,12 @@ |
154 | 154 | */ |
155 | 155 | function formatMetaData( $fields ) { |
156 | 156 | $html = '<table class="mw-codereview-meta">'; |
157 | | - foreach( $fields as $label => $data ) { |
| 157 | + foreach ( $fields as $label => $data ) { |
158 | 158 | $html .= "<tr><td>" . wfMsgHtml( $label ) . "</td><td>$data</td></tr>\n"; |
159 | 159 | } |
160 | 160 | return $html . "</table>\n"; |
161 | 161 | } |
162 | | - |
| 162 | + |
163 | 163 | function getRepo() { |
164 | 164 | if ( $this->mRepo ) |
165 | 165 | return $this->mRepo; |
— | — | @@ -176,23 +176,23 @@ |
177 | 177 | function link( $text ) { |
178 | 178 | # Catch links like http://www.mediawiki.org/wiki/Special:Code/MediaWiki/44245#c829 |
179 | 179 | # 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 ); |
181 | 181 | $text = preg_replace_callback( '/\br(\d+)\b/', array( $this, 'messageRevLink' ), $text ); |
182 | 182 | $text = preg_replace_callback( '/\bbug #?(\d+)\b/i', array( $this, 'messageBugLink' ), $text ); |
183 | 183 | return $text; |
184 | 184 | } |
185 | | - |
| 185 | + |
186 | 186 | function generalLink( $arr ) { |
187 | 187 | $url = $arr[2] . $arr[3]; |
188 | 188 | // 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]; |
190 | 190 | } |
191 | 191 | |
192 | 192 | function messageBugLink( $arr ) { |
193 | 193 | $text = $arr[0]; |
194 | 194 | $bugNo = intval( $arr[1] ); |
195 | 195 | $url = $this->mRepo->getBugPath( $bugNo ); |
196 | | - if( $url ) { |
| 196 | + if ( $url ) { |
197 | 197 | return $this->makeExternalLink( $url, $text ); |
198 | 198 | } else { |
199 | 199 | return $text; |
Index: trunk/extensions/CodeReview/SpecialRepoAdmin.php |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | <?php |
3 | | -if (!defined('MEDIAWIKI')) die(); |
| 3 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
4 | 4 | |
5 | 5 | class SpecialRepoAdmin extends SpecialPage { |
6 | 6 | function __construct() { |
— | — | @@ -12,13 +12,13 @@ |
13 | 13 | wfLoadExtensionMessages( 'CodeReview' ); |
14 | 14 | $this->setHeaders(); |
15 | 15 | |
16 | | - if( !$this->userCanExecute( $wgUser ) ){ |
| 16 | + if ( !$this->userCanExecute( $wgUser ) ) { |
17 | 17 | $this->displayRestrictionError(); |
18 | 18 | return; |
19 | 19 | } |
20 | 20 | |
21 | 21 | $repo = $wgRequest->getVal( 'repo', $subpage ); |
22 | | - if( $repo == '' ) { |
| 22 | + if ( $repo == '' ) { |
23 | 23 | $view = new RepoAdminListView( $this ); |
24 | 24 | } else { |
25 | 25 | $view = new RepoAdminRepoView( $this, $repo ); |
— | — | @@ -48,11 +48,11 @@ |
49 | 49 | global $wgOut; |
50 | 50 | $wgOut->addHTML( $this->getForm() ); |
51 | 51 | $repos = CodeRepository::getRepoList(); |
52 | | - if( !count( $repos ) ){ |
| 52 | + if ( !count( $repos ) ) { |
53 | 53 | return; |
54 | 54 | } |
55 | 55 | $text = ''; |
56 | | - foreach( $repos as $repo ){ |
| 56 | + foreach ( $repos as $repo ) { |
57 | 57 | $name = $repo->getName(); |
58 | 58 | $text .= "* [[Special:RepoAdmin/$name|$name]]\n"; |
59 | 59 | } |
— | — | @@ -75,10 +75,10 @@ |
76 | 76 | $repoPath = $wgRequest->getVal( 'wpRepoPath', $repoExists ? $this->mRepo->mPath : '' ); |
77 | 77 | $bugPath = $wgRequest->getVal( 'wpBugPath', $repoExists ? $this->mRepo->mBugzilla : '' ); |
78 | 78 | $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 ) ) { |
80 | 80 | // @todo log |
81 | 81 | $dbw = wfGetDB( DB_MASTER ); |
82 | | - if( $repoExists ){ |
| 82 | + if ( $repoExists ) { |
83 | 83 | $dbw->update( |
84 | 84 | 'code_repo', |
85 | 85 | array( |
Index: trunk/extensions/CodeReview/CodeRevisionTagView.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | parent::__construct( $repoName ); |
7 | 7 | $this->mTag = $tag; |
8 | 8 | } |
9 | | - |
| 9 | + |
10 | 10 | function getPager() { |
11 | 11 | return new SvnRevTagTablePager( $this, $this->mTag ); |
12 | 12 | } |
— | — | @@ -16,7 +16,7 @@ |
17 | 17 | parent::__construct( $view ); |
18 | 18 | $this->mTag = $tag; |
19 | 19 | } |
20 | | - |
| 20 | + |
21 | 21 | function getQueryInfo() { |
22 | 22 | $info = parent::getQueryInfo(); |
23 | 23 | $info['tables'][] = 'code_tags'; |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | return $info; |
28 | 28 | } |
29 | 29 | |
30 | | - function getTitle(){ |
| 30 | + function getTitle() { |
31 | 31 | $repo = $this->mRepo->getName(); |
32 | 32 | return SpecialPage::getTitleFor( 'Code', "$repo/tag/$this->mTag" ); |
33 | 33 | } |
Index: trunk/extensions/CodeReview/codereview.js |
— | — | @@ -12,12 +12,12 @@ |
13 | 13 | injectSpinner(CodeReview.diffTarget(), 'codereview-diff'); |
14 | 14 | xmlhttp.open("GET", path, true); |
15 | 15 | xmlhttp.onreadystatechange=function(){ |
16 | | - if (xmlhttp.readyState==4) { |
| 16 | + if (xmlhttp.readyState==4) { |
17 | 17 | CodeReview.decodeAndShowDiff(xmlhttp.responseText); |
18 | 18 | removeSpinner('codereview-diff'); |
19 | 19 | } |
20 | 20 | }; |
21 | | - xmlhttp.send(null); |
| 21 | + xmlhttp.send(null); |
22 | 22 | } catch (e) { |
23 | 23 | if (window.location.hostname == "localhost") { |
24 | 24 | 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 @@ |
2 | 2 | <?php |
3 | | -if (!defined('MEDIAWIKI')) die(); |
| 3 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
4 | 4 | |
5 | 5 | class CodePropChange { |
6 | 6 | function __construct( $rev ) { |
7 | 7 | $this->rev = $rev; |
8 | 8 | } |
9 | | - |
| 9 | + |
10 | 10 | static function newFromRow( $rev, $row ) { |
11 | 11 | return self::newFromData( $rev, get_object_vars( $row ) ); |
12 | 12 | } |
13 | | - |
| 13 | + |
14 | 14 | static function newFromData( $rev, $data ) { |
15 | 15 | $change = new CodeComment( $rev ); |
16 | 16 | $change->attrib = $data['cpc_attrib']; |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | $change->added = $data['cpc_added']; |
19 | 19 | $change->user = $data['cpc_user']; |
20 | 20 | // 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']; |
22 | 22 | $change->timestamp = wfTimestamp( TS_MW, $data['cpc_timestamp'] ); |
23 | 23 | return $change; |
24 | 24 | } |
Index: trunk/extensions/CodeReview/CodeAuthorListView.php |
— | — | @@ -12,11 +12,10 @@ |
13 | 13 | $authors = $this->mRepo->getAuthorList(); |
14 | 14 | $name = $this->mRepo->getName(); |
15 | 15 | $text = wfMsg( 'code-authors-text' ) . "\n"; |
16 | | - foreach( $authors as $user ) { |
17 | | - if( $user ) |
| 16 | + foreach ( $authors as $user ) { |
| 17 | + if ( $user ) |
18 | 18 | $text .= "* [[Special:Code/$name/author/$user|$user]]\n"; |
19 | 19 | } |
20 | 20 | $wgOut->addWikiText( $text ); |
21 | 21 | } |
22 | 22 | } |
23 | | - |
Index: trunk/extensions/CodeReview/CodeReview.alias.php |
— | — | @@ -159,4 +159,3 @@ |
160 | 160 | 'Code' => array( 'Kodigo', 'Pagsusuri ng kodigo' ), |
161 | 161 | 'RepoAdmin' => array( 'Tagapangasiwa ng repositoryo' ), |
162 | 162 | ); |
163 | | - |
Index: trunk/extensions/CodeReview/DiffHighlighter.php |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | * Highlight a SVN diff for easier readibility |
6 | 6 | */ |
7 | 7 | class CodeDiffHighlighter { |
8 | | - |
| 8 | + |
9 | 9 | /** |
10 | 10 | * Main entry point. Given a diff text, highlight it |
11 | 11 | * and wrap it in a div |
— | — | @@ -16,7 +16,7 @@ |
17 | 17 | $this->splitLines( $text ) . |
18 | 18 | "</pre>\n"; |
19 | 19 | } |
20 | | - |
| 20 | + |
21 | 21 | /** |
22 | 22 | * Given a bunch of text, split it into individual |
23 | 23 | * lines, color them, then put it back into one big |
— | — | @@ -29,7 +29,7 @@ |
30 | 30 | array_map( array( $this, 'colorLine' ), |
31 | 31 | explode( "\n", $text ) ) ); |
32 | 32 | } |
33 | | - |
| 33 | + |
34 | 34 | /** |
35 | 35 | * Turn a diff line into a properly formatted string suitable |
36 | 36 | * for output |
— | — | @@ -40,7 +40,7 @@ |
41 | 41 | list( $element, $attribs ) = $this->tagForLine( $line ); |
42 | 42 | return Xml::element( $element, $attribs, $line ); |
43 | 43 | } |
44 | | - |
| 44 | + |
45 | 45 | /** |
46 | 46 | * Take a line of a diff and apply the appropriate stylings |
47 | 47 | * @param $line string Line to check |
— | — | @@ -55,10 +55,10 @@ |
56 | 56 | ' ' => array( 'span', array() ), |
57 | 57 | ); |
58 | 58 | $first = substr( $line, 0, 1 ); |
59 | | - if( isset( $tags[$first] ) ) |
| 59 | + if ( isset( $tags[$first] ) ) |
60 | 60 | return $tags[$first]; |
61 | 61 | else |
62 | 62 | return $default; |
63 | 63 | } |
64 | | - |
| 64 | + |
65 | 65 | } |
Index: trunk/extensions/CodeReview/CodeRevisionStatusView.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | parent::__construct( $repoName ); |
7 | 7 | $this->mStatus = $status; |
8 | 8 | } |
9 | | - |
| 9 | + |
10 | 10 | function getPager() { |
11 | 11 | return new SvnRevStatusTablePager( $this, $this->mStatus ); |
12 | 12 | } |
— | — | @@ -16,14 +16,14 @@ |
17 | 17 | parent::__construct( $view ); |
18 | 18 | $this->mStatus = $status; |
19 | 19 | } |
20 | | - |
| 20 | + |
21 | 21 | function getQueryInfo() { |
22 | 22 | $info = parent::getQueryInfo(); |
23 | | - $info['conds']['cr_status'] = $this->mStatus; // fixme: normalize input? |
| 23 | + $info['conds']['cr_status'] = $this->mStatus; // FIXME: normalize input? |
24 | 24 | return $info; |
25 | 25 | } |
26 | 26 | |
27 | | - function getTitle(){ |
| 27 | + function getTitle() { |
28 | 28 | $repo = $this->mRepo->getName(); |
29 | 29 | return SpecialPage::getTitleFor( 'Code', "$repo/status/$this->mStatus" ); |
30 | 30 | } |
Index: trunk/extensions/CodeReview/CodeTagListView.php |
— | — | @@ -12,10 +12,9 @@ |
13 | 13 | $tags = $this->mRepo->getTagList(); |
14 | 14 | $name = $this->mRepo->getName(); |
15 | 15 | $text = ''; |
16 | | - foreach( $tags as $tag ) { |
| 16 | + foreach ( $tags as $tag ) { |
17 | 17 | $text .= "* [[Special:Code/$name/tag/$tag|$tag]]\n"; |
18 | 18 | } |
19 | 19 | $wgOut->addWikiText( $text ); |
20 | 20 | } |
21 | 21 | } |
22 | | - |
Index: trunk/extensions/CodeReview/ApiCodeDiff.php |
— | — | @@ -4,36 +4,36 @@ |
5 | 5 | |
6 | 6 | public function execute() { |
7 | 7 | $params = $this->extractRequestParams(); |
8 | | - |
9 | | - if( !isset( $params['repo'] ) ) { |
| 8 | + |
| 9 | + if ( !isset( $params['repo'] ) ) { |
10 | 10 | $this->dieUsageMsg( array( 'missingparam', 'repo' ) ); |
11 | 11 | } |
12 | | - if( !isset( $params['rev'] ) ) { |
| 12 | + if ( !isset( $params['rev'] ) ) { |
13 | 13 | $this->dieUsageMsg( array( 'missingparam', 'rev' ) ); |
14 | 14 | } |
15 | | - |
| 15 | + |
16 | 16 | $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' ); |
19 | 19 | } |
20 | | - |
| 20 | + |
21 | 21 | $svn = SubversionAdaptor::newFromRepo( $repo->getPath() ); |
22 | 22 | $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' ); |
26 | 26 | } |
27 | | - |
| 27 | + |
28 | 28 | $diff = $repo->getDiff( $params['rev'] ); |
29 | | - |
30 | | - if( $diff ) { |
| 29 | + |
| 30 | + if ( $diff ) { |
31 | 31 | $hilite = new CodeDiffHighlighter(); |
32 | 32 | $html = $hilite->render( $diff ); |
33 | 33 | } else { |
34 | 34 | // FIXME: Are we sure we don't want to throw an error here? |
35 | 35 | $html = 'Failed to load diff.'; |
36 | 36 | } |
37 | | - |
| 37 | + |
38 | 38 | $data = array( |
39 | 39 | 'repo' => $params['repo'], |
40 | 40 | 'id' => $params['rev'], |
— | — | @@ -41,7 +41,7 @@ |
42 | 42 | ); |
43 | 43 | $this->getResult()->addValue( 'code', 'rev', $data ); |
44 | 44 | } |
45 | | - |
| 45 | + |
46 | 46 | public function getAllowedParams() { |
47 | 47 | return array( |
48 | 48 | 'repo' => null, |
— | — | @@ -51,24 +51,24 @@ |
52 | 52 | ) |
53 | 53 | ); |
54 | 54 | } |
55 | | - |
| 55 | + |
56 | 56 | public function getParamDescription() { |
57 | 57 | return array( |
58 | 58 | 'repo' => 'Name of repository to look at', |
59 | 59 | 'rev' => 'Revision ID to fetch diff of' ); |
60 | 60 | } |
61 | | - |
| 61 | + |
62 | 62 | public function getDescription() { |
63 | 63 | return array( |
64 | 64 | 'Fetch formatted diff from CodeReview\'s backing revision control system.' ); |
65 | 65 | } |
66 | | - |
| 66 | + |
67 | 67 | public function getExamples() { |
68 | 68 | return array( |
69 | 69 | 'api.php?action=codediff&repo=MediaWiki&rev=42080', |
70 | 70 | ); |
71 | 71 | } |
72 | | - |
| 72 | + |
73 | 73 | public function getVersion() { |
74 | 74 | return __CLASS__ . ': $Id$'; |
75 | 75 | } |
Index: trunk/extensions/CodeReview/svnImport.php |
— | — | @@ -1,18 +1,18 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | $IP = getenv( 'MW_INSTALL_PATH' ); |
5 | | -if( $IP === false ) |
6 | | - $IP = dirname( __FILE__ ). '/../..'; |
| 5 | +if ( $IP === false ) |
| 6 | + $IP = dirname( __FILE__ ) . '/../..'; |
7 | 7 | require "$IP/maintenance/commandLine.inc"; |
8 | 8 | |
9 | | -if( !isset( $args[0] ) ){ |
| 9 | +if ( !isset( $args[0] ) ) { |
10 | 10 | echo "Usage: php svnImport.php <repo> [<start>]\n"; |
11 | 11 | die; |
12 | 12 | } |
13 | 13 | |
14 | 14 | $repo = CodeRepository::newFromName( $args[0] ); |
15 | 15 | |
16 | | -if( !$repo ){ |
| 16 | +if ( !$repo ) { |
17 | 17 | echo "Invalid repo {$args[0]}\n"; |
18 | 18 | die; |
19 | 19 | } |
— | — | @@ -24,32 +24,32 @@ |
25 | 25 | |
26 | 26 | $startTime = microtime( true ); |
27 | 27 | $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 ) ) { |
30 | 30 | echo "Invalid starting point r{$start}\n"; |
31 | 31 | die; |
32 | 32 | } |
33 | 33 | |
34 | 34 | echo "Syncing repo {$args[0]} from r$start to HEAD...\n"; |
35 | | -while( true ) { |
| 35 | +while ( true ) { |
36 | 36 | $log = $svn->getLog( '', $start, $start + $chunkSize - 1 ); |
37 | | - if( empty($log) ) { |
| 37 | + if ( empty( $log ) ) { |
38 | 38 | # Repo seems to give a blank when max rev is invalid, which |
39 | 39 | # stops new revisions from being added. Try to avoid this |
40 | 40 | # by trying less at a time from the last point. |
41 | | - if( $chunkSize <= 1 ) { |
| 41 | + if ( $chunkSize <= 1 ) { |
42 | 42 | break; // done! |
43 | 43 | } |
44 | | - $chunkSize = max( 1, floor($chunkSize/4) ); |
| 44 | + $chunkSize = max( 1, floor( $chunkSize / 4 ) ); |
45 | 45 | continue; |
46 | 46 | } else { |
47 | 47 | $start += $chunkSize; |
48 | 48 | } |
49 | | - if( !is_array( $log ) ) { |
| 49 | + if ( !is_array( $log ) ) { |
50 | 50 | var_dump( $log ); |
51 | 51 | die( 'wtf' ); |
52 | 52 | } |
53 | | - foreach( $log as $data ) { |
| 53 | + foreach ( $log as $data ) { |
54 | 54 | $revCount++; |
55 | 55 | $delta = microtime( true ) - $startTime; |
56 | 56 | $revSpeed = $revCount / $delta; |
— | — | @@ -68,12 +68,12 @@ |
69 | 69 | |
70 | 70 | echo "Pre-caching the latest 50 diffs...\n"; |
71 | 71 | $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__, |
75 | 75 | array( 'ORDER BY' => 'cr_id DESC', 'LIMIT' => 50 ) |
76 | 76 | ); |
77 | | -while( $row = $dbw->fetchObject( $res ) ) { |
| 77 | +while ( $row = $dbw->fetchObject( $res ) ) { |
78 | 78 | $rev = $repo->getRevision( $row->cr_id ); |
79 | 79 | $diff = $repo->getDiff( $row->cr_id ); // trigger caching |
80 | 80 | echo "Diff r{$row->cr_id} done\n"; |