MediaWiki SVN Patch

From BlueM
Jump to: navigation, search

This no longer works with the current Wikimedia installation

Patch für die registrierung der magischen Wörter Bug (→ Bugzilla) und Rev oder Rev. (→ WebSVN) in der MediaWiki-Installation (Idee von hier).

Index: Parser.php
===================================================================
--- Parser.php	(revision 49595)
+++ Parser.php	(working copy)
@@ -1038,7 +1038,11 @@
 				    (?: 97[89] [\ \-]? )?   # optional 13-digit ISBN prefix
 				    (?: [0-9]  [\ \-]? ){9} # 9 digits with opt. delimiters
 				    [0-9Xx]                 # check digit
-				    \b)
+				    \b) |
+				Bug\s+(\d+) |				# m[6]: Bug numbers
+				Rev\.?\s+(\d+) |			# m[7]: Rev numbers
+				(?:doi|DOI):\s?
+				    ([a-zA-Z0-9\.,/\-\[\]\(\):;]+[a-zA-Z0-9]) 	# m[8]: DOI
 			)!x', array( &$this, 'magicLinkCallback' ), $text );
 		wfProfileOut( __METHOD__ );
 		return $text;
@@ -1054,16 +1058,28 @@
 		} elseif ( isset( $m[3] ) && strval( $m[3] ) !== '' ) {
 			# Free external link
 			return $this->makeFreeExternalLink( $m[0] );
-		} elseif ( isset( $m[4] ) && strval( $m[4] ) !== '' ) {
+		} elseif ( (isset( $m[4] ) && strval( $m[4] ) !== '') || in_array(substr($m[0], 0, 3), array('Bug', 'Rev', 'doi')) ) {
 			# RFC or PMID
 			if ( substr( $m[0], 0, 3 ) === 'RFC' ) {
-				$keyword = 'RFC';
+				$keyword = 'RFC ';
 				$urlmsg = 'rfcurl';
 				$id = $m[4];
 			} elseif ( substr( $m[0], 0, 4 ) === 'PMID' ) {
-				$keyword = 'PMID';
+				$keyword = 'PMID ';
 				$urlmsg = 'pubmedurl';
 				$id = $m[4];
+			} else if ( substr( $m[0], 0, 3 ) == 'Bug' ) {
+				$keyword = 'Bug ';
+				$urlmsg = 'bugurl';
+				$id = $m[6];
+			} else if ( substr( $m[0], 0, 3 ) == 'Rev' ) {
+				$keyword = 'Rev ';
+				$urlmsg = 'revurl';
+				$id = $m[7];
+			} elseif ( strtolower(substr( $m[0], 0, 3 )) == 'doi' ) {
+				$keyword = 'doi:';
+				$urlmsg = 'doiurl';
+				$id = $m[8];
 			} else {
 				throw new MWException( __METHOD__.': unrecognised match type "' .
 					substr($m[0], 0, 20 ) . '"' );
@@ -1071,7 +1087,7 @@
 			$url = wfMsg( $urlmsg, $id);
 			$sk = $this->mOptions->getSkin();
 			$la = $sk->getExternalLinkAttributes( $url, $keyword.$id );
-			return "<a href=\"{$url}\"{$la}>{$keyword} {$id}</a>";
+			return "<a href=\"{$url}\"{$la}>{$keyword}{$id}</a>";
 		} elseif ( isset( $m[5] ) && strval( $m[5] ) !== '' ) {
 			# ISBN
 			$isbn = $m[5];
</diff>

<diff>
Index: languages/messages/MessagesEn.php
===================================================================
--- languages/messages/MessagesEn.php	(revision 20837)
+++ languages/messages/MessagesEn.php	(working copy)
@@ -1544,6 +1544,8 @@
 
 'isbn'	=> 'ISBN',
 'rfcurl' =>  'http://www.ietf.org/rfc/rfc$1.txt',
+'bugurl' => '/bugzilla/show_bug.cgi?id=$1',
+'revurl' => '/websvn/listing.php?repname=BlueM&path=%2F&rev=$1&sc=1',
 'pubmedurl' =>  'http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=pubmed&dopt=Abstract&list_uids=$1',
 'alphaindexline' => "$1 to $2",
 'version'		=> 'Version',