r62491 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62490‎ | r62491 | r62492 >
Date:03:59, 15 February 2010
Author:aaron
Status:ok
Tags:
Comment:
* Bug 22136: "Add link to show only own revisions in top menu"
* added wikiUserAuthor()
* authorWikiUser() fix
* truncateHtml() doc tweaks
Modified paths:
  • /trunk/extensions/CodeReview/CodeReview.i18n.php (modified) (history)
  • /trunk/extensions/CodeReview/backend/CodeCommentLinker.php (modified) (history)
  • /trunk/extensions/CodeReview/backend/CodeRepository.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/CodeRepoListView.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/SpecialCode.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/ui/CodeRepoListView.php
@@ -13,16 +13,23 @@
1414 $text = '';
1515 foreach ( $repos as $repo ) {
1616 $name = $repo->getName();
17 - $text .= "* " . self::getNavItem( $name ) . "\n";
 17+ $text .= "* " . self::getNavItem( $repo ) . "\n";
1818 }
1919 $wgOut->addWikiText( $text );
2020 }
2121
22 - public static function getNavItem( $name ) {
23 - global $wgLang;
 22+ public static function getNavItem( $repo ) {
 23+ global $wgLang, $wgUser;
 24+ $name = $repo->getName();
2425 $text = "'''[[Special:Code/$name|$name]]''' (";
2526 $links[] = "[[Special:Code/$name/comments|" . wfMsgHtml( 'code-notes' ) . "]]";
2627 $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+ }
2734 $links[] = "[[Special:Code/$name/tag|" . wfMsgHtml( 'code-tags' ) . "]]";
2835 $links[] = "[[Special:Code/$name/author|" . wfMsgHtml( 'code-authors' ) . "]]";
2936 $links[] = "[[Special:Code/$name/status|" . wfMsgHtml( 'code-status' ) . "]]";
Index: trunk/extensions/CodeReview/ui/SpecialCode.php
@@ -97,7 +97,9 @@
9898 // Add subtitle for easy navigation
9999 global $wgOut;
100100 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+ );
102104 }
103105 }
104106 }
Index: trunk/extensions/CodeReview/CodeReview.i18n.php
@@ -25,6 +25,7 @@
2626 'code-load-diff' => 'Loading diff…',
2727 'code-notes' => 'recent comments',
2828 'code-statuschanges' => 'status changes',
 29+ 'code-mycommits' => 'my commits',
2930 'code-authors' => 'authors',
3031 'code-status' => 'states',
3132 'code-tags' => 'tags',
Index: trunk/extensions/CodeReview/backend/CodeRepository.php
@@ -3,6 +3,7 @@
44
55 class CodeRepository {
66 static $userLinks = array();
 7+ static $authorLinks = array();
78
89 public static function newFromName( $name ) {
910 $dbw = wfGetDB( DB_MASTER );
@@ -371,12 +372,12 @@
372373 'ca_user_text',
373374 array(
374375 'ca_repo_id' => $this->getId(),
375 - 'ca_author' => $author,
 376+ 'ca_author' => $author,
376377 ),
377378 __METHOD__
378379 );
379380 $user = null;
380 - if ( $wikiUser )
 381+ if ( $wikiUser !== false )
381382 $user = User::newFromName( $wikiUser );
382383 if ( $user instanceof User )
383384 $res = $user;
@@ -384,4 +385,25 @@
385386 $res = false;
386387 return self::$userLinks[$author] = $res;
387388 }
 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+ }
388410 }
Index: trunk/extensions/CodeReview/backend/CodeCommentLinker.php
@@ -20,9 +20,15 @@
2121 return $text;
2222 }
2323
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+ */
2733 function truncateHtml( $text, $maxLen, $ellipsis = '...' ) {
2834 global $wgLang;
2935 if( strlen($text) <= $maxLen ) {

Status & tagging log