Index: branches/REL1_3/phase3/RELEASE-NOTES |
— | — | @@ -23,6 +23,7 @@ |
24 | 24 | * Fixed problem where pages which were created as a redirect following |
25 | 25 | a move never showed on Special:Randompage. |
26 | 26 | * Fixed line spacing on printed table of contents |
| 27 | +* Allow links to pages with names of the form [[RFC 1234]] |
27 | 28 | |
28 | 29 | |
29 | 30 | == Version 1.3.3, 2004-09-09 == |
Index: branches/REL1_3/phase3/includes/Parser.php |
— | — | @@ -2239,35 +2239,65 @@ |
2240 | 2240 | return $text; |
2241 | 2241 | } |
2242 | 2242 | |
2243 | | - # Return an HTML link for the "RFC 1234" text |
2244 | | - /* private */ function magicRFC( $text ) { |
| 2243 | + /** |
| 2244 | + * Return an HTML link for the "RFC 1234" text |
| 2245 | + * @access private |
| 2246 | + * @param string $text text to be processed |
| 2247 | + */ |
| 2248 | + function magicRFC( $text ) { |
2245 | 2249 | global $wgLang; |
| 2250 | + |
| 2251 | + $valid = '0123456789'; |
| 2252 | + $internal = false; |
2246 | 2253 | |
2247 | 2254 | $a = split( 'RFC ', ' '.$text ); |
2248 | 2255 | if ( count ( $a ) < 2 ) return $text; |
2249 | 2256 | $text = substr( array_shift( $a ), 1); |
2250 | | - $valid = '0123456789'; |
| 2257 | + |
| 2258 | + /* Check if RFC keyword is preceed by [[. |
| 2259 | + * This test is made here cause of the array_shift above |
| 2260 | + * that prevent the test to be done in the foreach. |
| 2261 | + */ |
| 2262 | + if(substr($text, -2) == '[[') { $internal = true; } |
2251 | 2263 | |
2252 | 2264 | foreach ( $a as $x ) { |
| 2265 | + /* token might be empty if we have RFC RFC 1234 */ |
| 2266 | + if($x=='') { |
| 2267 | + $text.='RFC '; |
| 2268 | + continue; |
| 2269 | + } |
| 2270 | + |
2253 | 2271 | $rfc = $blank = '' ; |
2254 | | - while ( ' ' == $x{0} ) { |
| 2272 | + |
| 2273 | + /** remove and save whitespaces in $blank */ |
| 2274 | + while ( $x{0} == ' ' ) { |
2255 | 2275 | $blank .= ' '; |
2256 | 2276 | $x = substr( $x, 1 ); |
2257 | 2277 | } |
| 2278 | + |
| 2279 | + /** remove and save the rfc number in $rfc */ |
2258 | 2280 | while ( strstr( $valid, $x{0} ) != false ) { |
2259 | 2281 | $rfc .= $x{0}; |
2260 | 2282 | $x = substr( $x, 1 ); |
2261 | 2283 | } |
2262 | 2284 | |
2263 | | - if ( '' == $rfc ) { |
| 2285 | + if ( $rfc == '') { |
| 2286 | + /* call back stripped spaces*/ |
2264 | 2287 | $text .= "RFC $blank$x"; |
| 2288 | + } elseif( $internal) { |
| 2289 | + /* normal link */ |
| 2290 | + $text .= "RFC $rfc$x"; |
2265 | 2291 | } else { |
| 2292 | + /* build the external link*/ |
2266 | 2293 | $url = wfmsg( 'rfcurl' ); |
2267 | 2294 | $url = str_replace( '$1', $rfc, $url); |
2268 | 2295 | $sk =& $this->mOptions->getSkin(); |
2269 | 2296 | $la = $sk->getExternalLinkAttributes( $url, "RFC {$rfc}" ); |
2270 | 2297 | $text .= "<a href='{$url}'{$la}>RFC {$rfc}</a>{$x}"; |
2271 | 2298 | } |
| 2299 | + |
| 2300 | + /* Check if the next RFC keyword is preceed by [[ */ |
| 2301 | + $internal = (substr($x,-2) == '[['); |
2272 | 2302 | } |
2273 | 2303 | return $text; |
2274 | 2304 | } |