r40870 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40869‎ | r40870 | r40871 >
Date:19:18, 15 September 2008
Author:brion
Status:old
Tags:
Comment:
* Add internal links for revision references in comments
* Tweak to bugzilla URLs
Modified paths:
  • /trunk/extensions/CodeReview/SpecialCode.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/SpecialCode.php
@@ -38,10 +38,14 @@
3939 abstract class CodeView {
4040 var $mRepo;
4141
 42+ function __construct() {
 43+ global $wgUser;
 44+ $this->mSkin = $wgUser->getSkin();
 45+ }
 46+
4247 abstract function execute();
4348
4449 function authorLink( $author ) {
45 - global $wgUser;
4650 static $userLinks = array();
4751 if( isset( $userLinks[$author] ) )
4852 return $userLinks[$author];
@@ -60,7 +64,7 @@
6165 if( $wikiUser )
6266 $user = User::newFromName( $wikiUser );
6367 if( $user instanceof User )
64 - $link = $author . ' (' . $wgUser->getSkin()->userLink( $user->getId(), $user->getName() ) . ')';
 68+ $link = $author . ' (' . $this->mSkin->userLink( $user->getId(), $user->getName() ) . ')';
6569 else
6670 $link = htmlspecialchars( $author );
6771 return $userLinks[$author] = $link;
@@ -68,15 +72,26 @@
6973
7074 function formatMessage( $value ){
7175 $value = nl2br( htmlspecialchars( $value ) );
 76+ $value = preg_replace_callback( '/\br(\d+)\b/', array( $this, 'messageRevLink' ), $value );
7277 $value = preg_replace_callback( '/\bbug (\d+)\b/', array( $this, 'messageBugLink' ), $value );
7378 return "<code>$value</code>";
7479 }
7580
7681 function messageBugLink( $arr ){
77 - $bugNo = $arr[1];
 82+ $bugNo = intval( $arr[1] );
7883 $url = $this->mRepo->getBugPath( $bugNo );
79 - return "<a href=\"$url\" title=\"bug $bugNo\">bug $bugNo</a>";
 84+ return $this->mSkin->makeExternalLink( $url, "bug $bugNo" );
8085 }
 86+
 87+ function messageRevLink( $matches ) {
 88+ $text = $matches[0];
 89+ $rev = intval( $matches[1] );
 90+
 91+ $repo = $this->mRepo->getName();
 92+ $title = SpecialPage::getTitleFor( 'Code', "$repo/$rev" );
 93+
 94+ return $this->mSkin->link( $title, $text );
 95+ }
8196
8297 function messageFragment( $value ) {
8398 global $wgLang;
@@ -91,8 +106,6 @@
92107 // Special:Code
93108 class CodeRepoListView {
94109
95 - function __construct() {}
96 -
97110 function execute() {
98111 global $wgOut;
99112 $repos = CodeRepository::getRepoList();
@@ -112,6 +125,7 @@
113126 // Special:Code/MediaWiki
114127 class CodeRevisionListView extends CodeView {
115128 function __construct( $repoName ) {
 129+ parent::__construct();
116130 $this->mRepo = CodeRepository::newFromName( $repoName );
117131 }
118132
@@ -180,6 +194,7 @@
181195 class CodeRevisionView extends CodeView {
182196
183197 function __construct( $repoName, $rev ){
 198+ parent::__construct();
184199 $this->mRepo = CodeRepository::newFromName( $repoName );
185200 $this->mRev = $this->mRepo->getRevision( intval( $rev ) );
186201 }

Status & tagging log