r5339 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r5338‎ | r5339 | r5340 >
Date:00:38, 21 September 2004
Author:kateturner
Status:old
Tags:
Comment:
backport hashar's fix for allowing [[RFC xxxx]] links. (MFC Parser.php 1.278)
Modified paths:
  • /branches/REL1_3/phase3/RELEASE-NOTES (modified) (history)
  • /branches/REL1_3/phase3/includes/Parser.php (modified) (history)

Diff [purge]

Index: branches/REL1_3/phase3/RELEASE-NOTES
@@ -23,6 +23,7 @@
2424 * Fixed problem where pages which were created as a redirect following
2525 a move never showed on Special:Randompage.
2626 * Fixed line spacing on printed table of contents
 27+* Allow links to pages with names of the form [[RFC 1234]]
2728
2829
2930 == Version 1.3.3, 2004-09-09 ==
Index: branches/REL1_3/phase3/includes/Parser.php
@@ -2239,35 +2239,65 @@
22402240 return $text;
22412241 }
22422242
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 ) {
22452249 global $wgLang;
 2250+
 2251+ $valid = '0123456789';
 2252+ $internal = false;
22462253
22472254 $a = split( 'RFC ', ' '.$text );
22482255 if ( count ( $a ) < 2 ) return $text;
22492256 $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; }
22512263
22522264 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+
22532271 $rfc = $blank = '' ;
2254 - while ( ' ' == $x{0} ) {
 2272+
 2273+ /** remove and save whitespaces in $blank */
 2274+ while ( $x{0} == ' ' ) {
22552275 $blank .= ' ';
22562276 $x = substr( $x, 1 );
22572277 }
 2278+
 2279+ /** remove and save the rfc number in $rfc */
22582280 while ( strstr( $valid, $x{0} ) != false ) {
22592281 $rfc .= $x{0};
22602282 $x = substr( $x, 1 );
22612283 }
22622284
2263 - if ( '' == $rfc ) {
 2285+ if ( $rfc == '') {
 2286+ /* call back stripped spaces*/
22642287 $text .= "RFC $blank$x";
 2288+ } elseif( $internal) {
 2289+ /* normal link */
 2290+ $text .= "RFC $rfc$x";
22652291 } else {
 2292+ /* build the external link*/
22662293 $url = wfmsg( 'rfcurl' );
22672294 $url = str_replace( '$1', $rfc, $url);
22682295 $sk =& $this->mOptions->getSkin();
22692296 $la = $sk->getExternalLinkAttributes( $url, "RFC {$rfc}" );
22702297 $text .= "<a href='{$url}'{$la}>RFC {$rfc}</a>{$x}";
22712298 }
 2299+
 2300+ /* Check if the next RFC keyword is preceed by [[ */
 2301+ $internal = (substr($x,-2) == '[[');
22722302 }
22732303 return $text;
22742304 }

Status & tagging log