Now should set the parser functions as magic words via the appropriate hooks (MagicWo...
authorRotem Liss <rotem@users.mediawiki.org>
Sat, 24 Jun 2006 14:40:25 +0000 (14:40 +0000)
committerRotem Liss <rotem@users.mediawiki.org>
Sat, 24 Jun 2006 14:40:25 +0000 (14:40 +0000)
includes/Parser.php

index e6ebb46..cf692c9 100644 (file)
@@ -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;
        }