From: Ævar Arnfjörð Bjarmason Date: Fri, 25 Nov 2005 06:53:20 +0000 (+0000) Subject: * (bug 3420) Allow extensions to specify new parser variables ({{VAR}}) X-Git-Tag: 1.6.0~1138 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=c67565e3dfcda94350650ee75f96092f30b55a40;p=lhc%2Fweb%2Fwiklou.git * (bug 3420) Allow extensions to specify new parser variables ({{VAR}}) --- diff --git a/includes/MagicWord.php b/includes/MagicWord.php index e038328653..696df1ec39 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -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. diff --git a/includes/Parser.php b/includes/Parser.php index bc39f9a5a2..f64faaf84f 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -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; } } diff --git a/includes/SpecialVersion.php b/includes/SpecialVersion.php index 5005f00f13..4f3a81aba6 100644 --- a/includes/SpecialVersion.php +++ b/includes/SpecialVersion.php @@ -84,6 +84,7 @@ class SpecialVersion { $extensionTypes = array( 'specialpage' => 'Special pages', 'parserhook' => 'Parser hooks', + 'variable' => 'Variables', 'other' => 'Other', ); wfRunHooks( 'SpecialVersionExtensionTypes', array( &$extensionTypes ) ); diff --git a/languages/Language.php b/languages/Language.php index b4c716d6ee..602b4e6c30 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -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();