Page MenuHomePhabricator

ISSNpatch

Authored By
bzimport
Nov 21 2014, 8:52 PM
Size
1 KB
Referenced Files
None
Subscribers
None

ISSNpatch

--- ../../temp/mediawiki-1.5beta4/includes/Parser.php 2005-07-30 16:03:34.000000000 -0400
+++ Parser.php 2005-12-03 10:50:12.000000000 -0500
@@ -788,7 +788,7 @@
}
/**
- * Replace special strings like "ISBN xxx" and "RFC xxx" with
+ * Replace special strings like "#ISBN xxx" and "RFC xxx" with
* magic external links.
*
* @access private
@@ -2691,15 +2691,27 @@
$fname = 'Parser::magicISBN';
wfProfileIn( $fname );
- $a = split( 'ISBN ', ' '.$text );
+ $a = preg_split( '/IS(B|S)N/ ', ' '.$text, -1, PREG_SPLIT_DELIM_CAPTURE );
if ( count ( $a ) < 2 ) {
wfProfileOut( $fname );
return $text;
}
- $text = substr( array_shift( $a ), 1);
- $valid = '0123456789-Xx';
+ $text = substr( array_shift( $a ), 1);
foreach ( $a as $x ) {
+ if ( preg_match( '/IS(S|B)N/', $x )){
+ continue;
+ }
+ if ($x == 'S' or $x == 'B' ){
+ $stype = $x;
+ if ( $stype == 'B'){
+ $valid = '0123456789-Xx';
+ }
+ else {
+ $valid = '0123456789-123456789';
+ }
+ continue;
+ }
$isbn = $blank = '' ;
while ( ' ' == $x{0} ) {
$blank .= ' ';
@@ -2718,12 +2730,13 @@
$num = str_replace( 'x', 'X', $num );
if ( '' == $num ) {
- $text .= "ISBN $blank$x";
- } else {
+ $text .= "IS".$stype."N $blank$x";
+ }
+ else {
$titleObj = Title::makeTitle( NS_SPECIAL, 'Booksources' );
$text .= '<a href="' .
- $titleObj->escapeLocalUrl( 'isbn='.$num ) .
- "\" class=\"internal\">ISBN $isbn</a>";
+ $titleObj->escapeLocalUrl( 'is'.strtolower($stype).'n='.$num ) .
+ "\" class=\"internal\">IS".$stype."N ".$isbn."</a>";
$text .= $x;
}
}

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1954
Default Alt Text
ISSNpatch (1 KB)

Event Timeline