From bca1ed3db9b08bc7592f8e58dd7b00806c829389 Mon Sep 17 00:00:00 2001 From: Rotem Liss Date: Sun, 25 Jun 2006 21:24:14 +0000 Subject: [PATCH] ParserFunctions are now set using magic words; backwards compatibility is retained. --- includes/Parser.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/includes/Parser.php b/includes/Parser.php index e6ebb460c4..cf692c98c8 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -2845,6 +2845,17 @@ class Parser $colonPos = strpos( $part1, ':' ); if ( $colonPos !== false ) { $function = strtolower( substr( $part1, 1, $colonPos - 1 ) ); + if ( !isset( $this->mFunctionHooks[$function] ) ) { + foreach ($this->mFunctionHooks as $key => $value) { + if( is_int( $key ) ) { + $mwExtension =& MagicWord::get( $key ); + if( $mwExtension->matchVariableStartToEnd( $function ) ) { + $function = $key; + break; + } + } + } + } if ( isset( $this->mFunctionHooks[$function] ) ) { $funcArgs = array_map( 'trim', $args ); $funcArgs = array_merge( array( &$this, trim( substr( $part1, $colonPos + 1 ) ) ), $funcArgs ); @@ -3883,15 +3894,17 @@ class Parser * * @public * - * @param string $name The function name. Function names are case-insensitive. + * @param mixed $id The magic word ID, or (deprecated) the function name. Function names are case-insensitive. * @param mixed $callback The callback function (and object) to use * * @return The old callback function for this name, if any */ - function setFunctionHook( $name, $callback ) { - $name = strtolower( $name ); - $oldVal = @$this->mFunctionHooks[$name]; - $this->mFunctionHooks[$name] = $callback; + function setFunctionHook( $id, $callback ) { + if( is_string( $id ) ) { + $id = strtolower( $id ); + } + $oldVal = @$this->mFunctionHooks[$id]; + $this->mFunctionHooks[$id] = $callback; return $oldVal; } -- 2.20.1