Index: trunk/extensions/CodeReview/CodeRevision.php |
— | — | @@ -76,12 +76,12 @@ |
77 | 77 | __METHOD__ |
78 | 78 | ); |
79 | 79 | } |
80 | | - |
| 80 | + |
81 | 81 | function saveComment( $text, $review, $parent=null ) { |
82 | 82 | global $wgUser; |
83 | 83 | $ts = wfTimestamp( TS_MW ); |
84 | 84 | $sortkey = $this->threadedSortkey( $parent, $ts ); |
85 | | - |
| 85 | + |
86 | 86 | $dbw = wfGetDB( DB_SLAVE ); |
87 | 87 | $dbw->insert( 'code_comment', |
88 | 88 | array( |
— | — | @@ -96,7 +96,7 @@ |
97 | 97 | 'cc_sortkey' => $sortkey ), |
98 | 98 | __METHOD__ ); |
99 | 99 | } |
100 | | - |
| 100 | + |
101 | 101 | protected function threadedSortKey( $parent, $ts ) { |
102 | 102 | if( $parent ) { |
103 | 103 | // We construct a threaded sort key by concatenating the timestamps |
— | — | @@ -116,7 +116,7 @@ |
117 | 117 | return $ts; |
118 | 118 | } |
119 | 119 | } |
120 | | - |
| 120 | + |
121 | 121 | function getComments() { |
122 | 122 | $dbr = wfGetDB( DB_SLAVE ); |
123 | 123 | $result = $dbr->select( 'code_comment', |
— | — | @@ -134,7 +134,7 @@ |
135 | 135 | __METHOD__, |
136 | 136 | array( |
137 | 137 | 'ORDER BY' => 'cc_sortkey' ) ); |
138 | | - |
| 138 | + |
139 | 139 | $comments = array(); |
140 | 140 | foreach( $result as $row ) { |
141 | 141 | $comments[] = new CodeComment( $this, $row ); |
Index: trunk/extensions/CodeReview/CodeRepository.php |
— | — | @@ -100,22 +100,22 @@ |
101 | 101 | throw new MWException( 'barf' ); |
102 | 102 | return CodeRevision::newFromRow( $row ); |
103 | 103 | } |
104 | | - |
| 104 | + |
105 | 105 | function getDiff( $rev ) { |
106 | 106 | global $wgMemc; |
107 | | - |
| 107 | + |
108 | 108 | $rev1 = $rev - 1; |
109 | 109 | $rev2 = $rev; |
110 | | - |
| 110 | + |
111 | 111 | $key = wfMemcKey( 'svn', md5( $this->mPath ), 'diff', $rev1, $rev2 ); |
112 | 112 | $data = $wgMemc->get( $key ); |
113 | | - |
| 113 | + |
114 | 114 | if( !$data ) { |
115 | 115 | $svn = SubversionAdaptor::newFromRepo( $this->mPath ); |
116 | 116 | $data = $svn->getDiff( '', $rev1, $rev2 ); |
117 | 117 | $wgMemc->add( $key, $data, 86400 ); |
118 | 118 | } |
119 | | - |
| 119 | + |
120 | 120 | return $data; |
121 | 121 | } |
122 | 122 | } |
Index: trunk/extensions/CodeReview/CodeReview.i18n.php |
— | — | @@ -10,6 +10,7 @@ |
11 | 11 | |
12 | 12 | $messages['en'] = array( |
13 | 13 | 'code' => 'Code Review', |
| 14 | + 'code-desc' => 'This tells you what I do on Special:Version. Provide links to special page(s) if possible', |
14 | 15 | 'code-no-repo' => 'No repository configured!', |
15 | 16 | 'code-field-id' => 'Revision', |
16 | 17 | 'code-field-author' => 'Author', |
Index: trunk/extensions/CodeReview/SpecialCode.php |
— | — | @@ -43,7 +43,7 @@ |
44 | 44 | global $wgUser; |
45 | 45 | $this->mSkin = $wgUser->getSkin(); |
46 | 46 | } |
47 | | - |
| 47 | + |
48 | 48 | abstract function execute(); |
49 | 49 | |
50 | 50 | function authorLink( $author ) { |
— | — | @@ -93,7 +93,7 @@ |
94 | 94 | $this->mSkin = $wgUser->getSkin(); |
95 | 95 | $this->mRepo = $repo; |
96 | 96 | } |
97 | | - |
| 97 | + |
98 | 98 | function link( $text ) { |
99 | 99 | $text = preg_replace_callback( '/\br(\d+)\b/', array( $this, 'messageRevLink' ), $text ); |
100 | 100 | $text = preg_replace_callback( '/\bbug #?(\d+)\b/i', array( $this, 'messageBugLink' ), $text ); |
— | — | @@ -104,17 +104,17 @@ |
105 | 105 | $text = $arr[0]; |
106 | 106 | $bugNo = intval( $arr[1] ); |
107 | 107 | $url = $this->mRepo->getBugPath( $bugNo ); |
108 | | - |
| 108 | + |
109 | 109 | return $this->makeExternalLink( $url, $text ); |
110 | 110 | } |
111 | | - |
| 111 | + |
112 | 112 | function messageRevLink( $matches ) { |
113 | 113 | $text = $matches[0]; |
114 | 114 | $rev = intval( $matches[1] ); |
115 | | - |
| 115 | + |
116 | 116 | $repo = $this->mRepo->getName(); |
117 | 117 | $title = SpecialPage::getTitleFor( 'Code', "$repo/$rev" ); |
118 | | - |
| 118 | + |
119 | 119 | return $this->makeInternalLink( $title, $text ); |
120 | 120 | } |
121 | 121 | |
— | — | @@ -124,7 +124,7 @@ |
125 | 125 | function makeExternalLink( $url, $text ) { |
126 | 126 | return $this->mSkin->makeExternalLink( $url, $text ); |
127 | 127 | } |
128 | | - |
| 128 | + |
129 | 129 | function makeInternalLink( $title, $text ) { |
130 | 130 | return $this->mSkin->link( $title, $text ); |
131 | 131 | } |
— | — | @@ -134,7 +134,7 @@ |
135 | 135 | function makeExternalLink( $url, $text ) { |
136 | 136 | return "[$url $text]"; |
137 | 137 | } |
138 | | - |
| 138 | + |
139 | 139 | function makeInternalLink( $title, $text ) { |
140 | 140 | return "[[" . $title->getPrefixedText() . "|$text]]"; |
141 | 141 | } |
— | — | @@ -216,7 +216,7 @@ |
217 | 217 | switch( $name ){ |
218 | 218 | case 'cr_id': |
219 | 219 | global $wgUser; |
220 | | - return $wgUser->getSkin()->link( |
| 220 | + return $wgUser->getSkin()->link( |
221 | 221 | SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/' . $value ), htmlspecialchars( $value ) |
222 | 222 | ); |
223 | 223 | case 'cr_author': |
— | — | @@ -250,10 +250,10 @@ |
251 | 251 | $view->execute(); |
252 | 252 | return; |
253 | 253 | } |
254 | | - |
| 254 | + |
255 | 255 | $this->checkPostings(); |
256 | | - |
257 | | - $repoLink = $wgUser->getSkin()->link( SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() ), |
| 256 | + |
| 257 | + $repoLink = $wgUser->getSkin()->link( SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() ), |
258 | 258 | htmlspecialchars( $this->mRepo->getName() ) ); |
259 | 259 | $rev = $this->mRev->getId(); |
260 | 260 | $revText = htmlspecialchars( $rev ); |
— | — | @@ -283,13 +283,13 @@ |
284 | 284 | "<div class='mw-codereview-diff'>" . |
285 | 285 | $this->formatDiff() . |
286 | 286 | "</div>"; |
287 | | - |
| 287 | + |
288 | 288 | $html .= |
289 | 289 | "<h2>Comments</h2>" . |
290 | 290 | $this->formatComments(); |
291 | 291 | $wgOut->addHtml( $html ); |
292 | 292 | } |
293 | | - |
| 293 | + |
294 | 294 | function checkPostings() { |
295 | 295 | global $wgRequest, $wgUser; |
296 | 296 | if( $wgRequest->wasPosted() |
— | — | @@ -307,7 +307,7 @@ |
308 | 308 | } |
309 | 309 | } |
310 | 310 | } |
311 | | - |
| 311 | + |
312 | 312 | function formatPathLine( $path, $action ) { |
313 | 313 | $desc = wfMsgHtml( 'code-rev-modified-'.strtolower( $action ) ); |
314 | 314 | $encPath = htmlspecialchars( $path ); |
— | — | @@ -323,12 +323,12 @@ |
324 | 324 | } |
325 | 325 | return "<li>$link ($desc)</li>\n"; |
326 | 326 | } |
327 | | - |
| 327 | + |
328 | 328 | function formatDiff() { |
329 | 329 | $diff = $this->mRepo->getDiff( $this->mRev->getId() ); |
330 | 330 | return "<pre>" . htmlspecialchars( $diff ) . "</pre>"; |
331 | 331 | } |
332 | | - |
| 332 | + |
333 | 333 | function formatComments() { |
334 | 334 | return "<div class='mw-codereview-comments'>" . |
335 | 335 | implode( "\n", |
— | — | @@ -338,7 +338,7 @@ |
339 | 339 | $this->postCommentForm() . |
340 | 340 | "</div>"; |
341 | 341 | } |
342 | | - |
| 342 | + |
343 | 343 | function formatComment( $comment ) { |
344 | 344 | global $wgOut, $wgLang; |
345 | 345 | $linker = new CodeCommentLinkerWiki( $this->mRepo ); |
— | — | @@ -355,7 +355,7 @@ |
356 | 356 | '</div>' . |
357 | 357 | '</div>'; |
358 | 358 | } |
359 | | - |
| 359 | + |
360 | 360 | function postCommentForm( $parent=null ) { |
361 | 361 | global $wgUser; |
362 | 362 | return '<div class="mw-codereview-post-comment">' . |
— | — | @@ -378,4 +378,4 @@ |
379 | 379 | '</div>' . |
380 | 380 | '</form>'; |
381 | 381 | } |
382 | | -} |
\ No newline at end of file |
| 382 | +} |
Index: trunk/extensions/CodeReview/CodeReview.php |
— | — | @@ -1,11 +1,18 @@ |
2 | 2 | <?php |
3 | 3 | if (!defined('MEDIAWIKI')) die(); |
4 | 4 | /** |
5 | | - * Copyright (c) 2008 Brion Vibber <brion@pobox.com> |
6 | | - * GPLv2 |
| 5 | + * |
| 6 | + * @author Brion Vibber |
| 7 | + * @author Aaron Schulz |
| 8 | + * @author Alexandre Emsenhuber |
| 9 | + * @author Chad Horohoe |
| 10 | + * @copyright Copyright � 2008 Brion Vibber <brion@pobox.com> |
| 11 | + * @copyright Copyright � 2008 Chad Horohoe <innocentkiller@gmail.com> |
| 12 | + * @copyright Copyright � 2008 Aaron Schulz <JSchulz_4587@msn.com> |
| 13 | + * @copyright Copyright � 2008 Alexandre Emsenhuber <alex.emsenhuber@bluewin.ch> |
| 14 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
7 | 15 | */ |
8 | 16 | |
9 | | - |
10 | 17 | /* |
11 | 18 | |
12 | 19 | What do I need out of SVN? |
— | — | @@ -20,6 +27,15 @@ |
21 | 28 | |
22 | 29 | */ |
23 | 30 | |
| 31 | +$wgExtensionCredits['other'][] = array( |
| 32 | + 'name' => 'CodeReview', |
| 33 | + 'svn-date' => '$LastChangedDate$', |
| 34 | + 'svn-revision' => '$LastChangedRevision$', |
| 35 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:CodeReview', |
| 36 | + 'author' => array( 'Brion Vibber', 'Aaron Schulz', 'Alexandre Emsenhuber', 'Chad Horohoe' ), |
| 37 | + 'descriptionmsg' => 'code-desc', |
| 38 | +); |
| 39 | + |
24 | 40 | $dir = dirname(__FILE__) . '/'; |
25 | 41 | |
26 | 42 | $wgAutoloadClasses['CodeRepository'] = $dir . 'CodeRepository.php'; |
Property changes on: trunk/extensions/CodeReview/CodeReview.php |
___________________________________________________________________ |
Added: svn:keywords |
27 | 43 | + LastChangedDate LastChangedRevision |
Index: trunk/extensions/CodeReview/CodeComment.php |
— | — | @@ -1,4 +1,5 @@ |
2 | 2 | <?php |
| 3 | +if (!defined('MEDIAWIKI')) die(); |
3 | 4 | |
4 | 5 | class CodeComment { |
5 | 6 | function __construct( $repo, $row ) { |
— | — | @@ -10,4 +11,4 @@ |
11 | 12 | $this->timestamp = wfTimestamp( TS_MW, $row->cc_timestamp ); |
12 | 13 | $this->review = $row->cc_review; |
13 | 14 | } |
14 | | -} |
\ No newline at end of file |
| 15 | +} |
Index: trunk/extensions/CodeReview/svnImport.php |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | while( $start <= $lastRev ) { |
33 | 33 | $log = $svn->getLog( '', $start, $start + $chunkSize - 1 ); |
34 | 34 | if( empty($log) ) { |
35 | | - # Repo seems to give a blank when max rev is invalid, which |
| 35 | + # Repo seems to give a blank when max rev is invalid, which |
36 | 36 | # stops new revisions from being added. Try to avoid this |
37 | 37 | # by trying less at a time from the last point. |
38 | 38 | if( $chunkSize <= 1 ) { |
Index: trunk/extensions/CodeReview/CodeReview.alias.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * Aliases for Special:AdvancedRandom |
| 4 | + * Aliases for extension CodeReview |
5 | 5 | * |
6 | 6 | * @addtogroup Extensions |
7 | 7 | */ |