Index: trunk/extensions/CodeReview/SpecialCode.php |
— | — | @@ -38,10 +38,14 @@ |
39 | 39 | abstract class CodeView { |
40 | 40 | var $mRepo; |
41 | 41 | |
| 42 | + function __construct() { |
| 43 | + global $wgUser; |
| 44 | + $this->mSkin = $wgUser->getSkin(); |
| 45 | + } |
| 46 | + |
42 | 47 | abstract function execute(); |
43 | 48 | |
44 | 49 | function authorLink( $author ) { |
45 | | - global $wgUser; |
46 | 50 | static $userLinks = array(); |
47 | 51 | if( isset( $userLinks[$author] ) ) |
48 | 52 | return $userLinks[$author]; |
— | — | @@ -60,7 +64,7 @@ |
61 | 65 | if( $wikiUser ) |
62 | 66 | $user = User::newFromName( $wikiUser ); |
63 | 67 | if( $user instanceof User ) |
64 | | - $link = $author . ' (' . $wgUser->getSkin()->userLink( $user->getId(), $user->getName() ) . ')'; |
| 68 | + $link = $author . ' (' . $this->mSkin->userLink( $user->getId(), $user->getName() ) . ')'; |
65 | 69 | else |
66 | 70 | $link = htmlspecialchars( $author ); |
67 | 71 | return $userLinks[$author] = $link; |
— | — | @@ -68,15 +72,26 @@ |
69 | 73 | |
70 | 74 | function formatMessage( $value ){ |
71 | 75 | $value = nl2br( htmlspecialchars( $value ) ); |
| 76 | + $value = preg_replace_callback( '/\br(\d+)\b/', array( $this, 'messageRevLink' ), $value ); |
72 | 77 | $value = preg_replace_callback( '/\bbug (\d+)\b/', array( $this, 'messageBugLink' ), $value ); |
73 | 78 | return "<code>$value</code>"; |
74 | 79 | } |
75 | 80 | |
76 | 81 | function messageBugLink( $arr ){ |
77 | | - $bugNo = $arr[1]; |
| 82 | + $bugNo = intval( $arr[1] ); |
78 | 83 | $url = $this->mRepo->getBugPath( $bugNo ); |
79 | | - return "<a href=\"$url\" title=\"bug $bugNo\">bug $bugNo</a>"; |
| 84 | + return $this->mSkin->makeExternalLink( $url, "bug $bugNo" ); |
80 | 85 | } |
| 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 | + } |
81 | 96 | |
82 | 97 | function messageFragment( $value ) { |
83 | 98 | global $wgLang; |
— | — | @@ -91,8 +106,6 @@ |
92 | 107 | // Special:Code |
93 | 108 | class CodeRepoListView { |
94 | 109 | |
95 | | - function __construct() {} |
96 | | - |
97 | 110 | function execute() { |
98 | 111 | global $wgOut; |
99 | 112 | $repos = CodeRepository::getRepoList(); |
— | — | @@ -112,6 +125,7 @@ |
113 | 126 | // Special:Code/MediaWiki |
114 | 127 | class CodeRevisionListView extends CodeView { |
115 | 128 | function __construct( $repoName ) { |
| 129 | + parent::__construct(); |
116 | 130 | $this->mRepo = CodeRepository::newFromName( $repoName ); |
117 | 131 | } |
118 | 132 | |
— | — | @@ -180,6 +194,7 @@ |
181 | 195 | class CodeRevisionView extends CodeView { |
182 | 196 | |
183 | 197 | function __construct( $repoName, $rev ){ |
| 198 | + parent::__construct(); |
184 | 199 | $this->mRepo = CodeRepository::newFromName( $repoName ); |
185 | 200 | $this->mRev = $this->mRepo->getRevision( intval( $rev ) ); |
186 | 201 | } |