Index: trunk/extensions/CodeReview/ui/CodeRepoListView.php |
— | — | @@ -13,16 +13,23 @@ |
14 | 14 | $text = ''; |
15 | 15 | foreach ( $repos as $repo ) { |
16 | 16 | $name = $repo->getName(); |
17 | | - $text .= "* " . self::getNavItem( $name ) . "\n"; |
| 17 | + $text .= "* " . self::getNavItem( $repo ) . "\n"; |
18 | 18 | } |
19 | 19 | $wgOut->addWikiText( $text ); |
20 | 20 | } |
21 | 21 | |
22 | | - public static function getNavItem( $name ) { |
23 | | - global $wgLang; |
| 22 | + public static function getNavItem( $repo ) { |
| 23 | + global $wgLang, $wgUser; |
| 24 | + $name = $repo->getName(); |
24 | 25 | $text = "'''[[Special:Code/$name|$name]]''' ("; |
25 | 26 | $links[] = "[[Special:Code/$name/comments|" . wfMsgHtml( 'code-notes' ) . "]]"; |
26 | 27 | $links[] = "[[Special:Code/$name/statuschanges|" . wfMsgHtml( 'code-statuschanges' ) . "]]"; |
| 28 | + if( $wgUser->getId() ) { |
| 29 | + $author = $repo->wikiUserAuthor( $wgUser->getName() ); |
| 30 | + if( $author !== false ) { |
| 31 | + $links[] = "[[Special:Code/$name/author/$author|" . wfMsgHtml( 'code-mycommits' ) . "]]"; |
| 32 | + } |
| 33 | + } |
27 | 34 | $links[] = "[[Special:Code/$name/tag|" . wfMsgHtml( 'code-tags' ) . "]]"; |
28 | 35 | $links[] = "[[Special:Code/$name/author|" . wfMsgHtml( 'code-authors' ) . "]]"; |
29 | 36 | $links[] = "[[Special:Code/$name/status|" . wfMsgHtml( 'code-status' ) . "]]"; |
Index: trunk/extensions/CodeReview/ui/SpecialCode.php |
— | — | @@ -97,7 +97,9 @@ |
98 | 98 | // Add subtitle for easy navigation |
99 | 99 | global $wgOut; |
100 | 100 | if ( $view instanceof CodeView && ( $repo = $view->getRepo() ) ) { |
101 | | - $wgOut->setSubtitle( wfMsgExt( 'codereview-subtitle', 'parse', CodeRepoListView::getNavItem( $repo->getName() ) ) ); |
| 101 | + $wgOut->setSubtitle( |
| 102 | + wfMsgExt( 'codereview-subtitle', 'parse', CodeRepoListView::getNavItem( $repo ) ) |
| 103 | + ); |
102 | 104 | } |
103 | 105 | } |
104 | 106 | } |
Index: trunk/extensions/CodeReview/CodeReview.i18n.php |
— | — | @@ -25,6 +25,7 @@ |
26 | 26 | 'code-load-diff' => 'Loading diff…', |
27 | 27 | 'code-notes' => 'recent comments', |
28 | 28 | 'code-statuschanges' => 'status changes', |
| 29 | + 'code-mycommits' => 'my commits', |
29 | 30 | 'code-authors' => 'authors', |
30 | 31 | 'code-status' => 'states', |
31 | 32 | 'code-tags' => 'tags', |
Index: trunk/extensions/CodeReview/backend/CodeRepository.php |
— | — | @@ -3,6 +3,7 @@ |
4 | 4 | |
5 | 5 | class CodeRepository { |
6 | 6 | static $userLinks = array(); |
| 7 | + static $authorLinks = array(); |
7 | 8 | |
8 | 9 | public static function newFromName( $name ) { |
9 | 10 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -371,12 +372,12 @@ |
372 | 373 | 'ca_user_text', |
373 | 374 | array( |
374 | 375 | 'ca_repo_id' => $this->getId(), |
375 | | - 'ca_author' => $author, |
| 376 | + 'ca_author' => $author, |
376 | 377 | ), |
377 | 378 | __METHOD__ |
378 | 379 | ); |
379 | 380 | $user = null; |
380 | | - if ( $wikiUser ) |
| 381 | + if ( $wikiUser !== false ) |
381 | 382 | $user = User::newFromName( $wikiUser ); |
382 | 383 | if ( $user instanceof User ) |
383 | 384 | $res = $user; |
— | — | @@ -384,4 +385,25 @@ |
385 | 386 | $res = false; |
386 | 387 | return self::$userLinks[$author] = $res; |
387 | 388 | } |
| 389 | + |
| 390 | + /* |
| 391 | + * returns an author name if $name wikiuser has an author associated, |
| 392 | + * or false |
| 393 | + */ |
| 394 | + public function wikiUserAuthor( $name ) { |
| 395 | + if ( isset( self::$authorLinks[$name] ) ) |
| 396 | + return self::$authorLinks[$name]; |
| 397 | + |
| 398 | + $dbr = wfGetDB( DB_SLAVE ); |
| 399 | + $res = $dbr->selectField( |
| 400 | + 'code_authors', |
| 401 | + 'ca_author', |
| 402 | + array( |
| 403 | + 'ca_repo_id' => $this->getId(), |
| 404 | + 'ca_user_text' => $name, |
| 405 | + ), |
| 406 | + __METHOD__ |
| 407 | + ); |
| 408 | + return self::$authorLinks[$name] = $res; |
| 409 | + } |
388 | 410 | } |
Index: trunk/extensions/CodeReview/backend/CodeCommentLinker.php |
— | — | @@ -20,9 +20,15 @@ |
21 | 21 | return $text; |
22 | 22 | } |
23 | 23 | |
24 | | - // truncate() for valid HTML with self-contained tags only |
25 | | - // Note: tries to fix broken HTML with MWTidy |
26 | | - // @TODO: cleanup and move to language.php |
| 24 | + /* |
| 25 | + * Truncate a valid HTML string with self-contained tags only |
| 26 | + * Note: tries to fix broken HTML with MWTidy |
| 27 | + * @TODO: cleanup and move to language.php |
| 28 | + * @param string $text |
| 29 | + * @param int $maxLen, (greater than zero) |
| 30 | + * @param string $ellipsis |
| 31 | + * @returns string |
| 32 | + */ |
27 | 33 | function truncateHtml( $text, $maxLen, $ellipsis = '...' ) { |
28 | 34 | global $wgLang; |
29 | 35 | if( strlen($text) <= $maxLen ) { |