* (bug 3420) Allow extensions to specify new parser variables ({{VAR}})
authorÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Fri, 25 Nov 2005 06:53:20 +0000 (06:53 +0000)
committerÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Fri, 25 Nov 2005 06:53:20 +0000 (06:53 +0000)
includes/MagicWord.php
includes/Parser.php
includes/SpecialVersion.php
languages/Language.php

index e038328..696df1e 100644 (file)
@@ -69,6 +69,7 @@ $magicWords = array(
        'MAG_FULLPAGENAME',
        'MAG_FULLPAGENAMEE',
 );
+wfRunHooks( 'MagicWordMagicWords', array( &$magicWords ) );
 
 for ( $i = 0; $i < count( $magicWords ); ++$i )
        define( $magicWords[$i], $i );
@@ -98,6 +99,7 @@ $wgVariableIDs = array(
        MAG_CURRENTDOW,
        MAG_REVISIONID,
 );
+wfRunHooks( 'MagicWordwgVariableIDs', array( &$wgVariableIDs ) );
 
 /**
  * This class encapsulates "magic words" such as #redirect, __NOTOC__, etc.
index bc39f9a..f64faaf 100644 (file)
@@ -1939,7 +1939,11 @@ class Parser
                        case MAG_SCRIPTPATH:
                                return $wgScriptPath;
                        default:
-                               return NULL;
+                               $ret = null;
+                               if ( wfRunHooks( 'ParserGetVariableValueSwitch', array( &$this, &$varCache, &$index, &$ret ) ) )
+                                       return $ret;
+                               else
+                                       return null;
                }
        }
 
index 5005f00..4f3a81a 100644 (file)
@@ -84,6 +84,7 @@ class SpecialVersion {
                $extensionTypes = array(
                        'specialpage' => 'Special pages',
                        'parserhook' => 'Parser hooks',
+                       'variable' => 'Variables',
                        'other' => 'Other',
                );
                wfRunHooks( 'SpecialVersionExtensionTypes', array( &$extensionTypes ) );
index b4c716d..602b4e6 100644 (file)
@@ -2779,6 +2779,9 @@ class Language {
        # Fill a MagicWord object with data from here
        function getMagic( &$mw ) {
                $raw = $this->getMagicWords();
+
+               wfRunHooks( 'LanguageGetMagic', array( &$raw ) );
+               
                if( !isset( $raw[$mw->mId] ) ) {
                        # Fall back to English if local list is incomplete
                        $raw =& Language::getMagicWords();