From 7adb982f57d8d34ff590b5c233bb6fc32dc37cef Mon Sep 17 00:00:00 2001 From: Steve Sanbeg Date: Mon, 11 Dec 2006 23:50:41 +0000 Subject: [PATCH] refactor template arg parsing into static method; this may prevent a future fork of it, since it could be useful for parserfunctions, too. --- includes/Parser.php | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/includes/Parser.php b/includes/Parser.php index ad39cbd46e..e87fa9497a 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -2841,6 +2841,30 @@ class Parser return $text; } + + /// Clean up argument array - refactored in 1.9 so parserfunctions can use it, too. + static function createAssocArgs( $args ) { + $assocArgs = array(); + $index = 1; + foreach( $args as $arg ) { + $eqpos = strpos( $arg, '=' ); + if ( $eqpos === false ) { + $assocArgs[$index++] = $arg; + } else { + $name = trim( substr( $arg, 0, $eqpos ) ); + $value = trim( substr( $arg, $eqpos+1 ) ); + if ( $value === false ) { + $value = ''; + } + if ( $name !== false ) { + $assocArgs[$name] = $value; + } + } + } + + return $assocArgs; + } + /** * Return the text of a template, after recursively * replacing any variables or templates within the template. @@ -3088,24 +3112,7 @@ class Parser $assocArgs = array(); } else { # Clean up argument array - $assocArgs = array(); - $index = 1; - foreach( $args as $arg ) { - $eqpos = strpos( $arg, '=' ); - if ( $eqpos === false ) { - $assocArgs[$index++] = $arg; - } else { - $name = trim( substr( $arg, 0, $eqpos ) ); - $value = trim( substr( $arg, $eqpos+1 ) ); - if ( $value === false ) { - $value = ''; - } - if ( $name !== false ) { - $assocArgs[$name] = $value; - } - } - } - + $assocArgs = $this->createAssocArgs($args); # Add a new element to the templace recursion path $this->mTemplatePath[$part1] = 1; } -- 2.20.1