# PHP global rebinding syntax is a bit weird, need to use the GLOBALS array
$GLOBALS['wgCurParser'] =& $this;
+ # Variable substitution
+ $text = preg_replace_callback( "/{{([$titleChars]*?)}}/", 'wfVariableSubstitution', $text );
+
if ( $this->mOutputType == OT_HTML ) {
# Argument substitution
$text = preg_replace_callback( "/{{{([$titleChars]*?)}}}/", 'wfArgSubstitution', $text );
return $text;
}
+ /**
+ * Replace magic variables
+ * @access private
+ */
+ function variableSubstitution( $matches ) {
+ if ( !$this->mVariables ) {
+ $this->initialiseVariables();
+ }
+ $skip = false;
+ if ( $this->mOutputType == OT_WIKI ) {
+ # Do only magic variables prefixed by SUBST
+ $mwSubst =& MagicWord::get( MAG_SUBST );
+ if (!$mwSubst->matchStartAndRemove( $matches[1] ))
+ $skip = true;
+ # Note that if we don't substitute the variable below,
+ # we don't remove the {{subst:}} magic word, in case
+ # it is a template rather than a magic variable.
+ }
+ if ( !$skip && array_key_exists( $matches[1], $this->mVariables ) ) {
+ $text = $this->mVariables[$matches[1]];
+ $this->mOutput->mContainsOldMagic = true;
+ } else {
+ $text = $matches[0];
+ }
+ return $text;
+ }
+
# Split template arguments
function getTemplateArgs( $argsString ) {
if ( $argsString === '' ) {
}
}
- # Internal variables
- if ( !$this->mVariables ) {
- $this->initialiseVariables();
- }
- if ( !$found && array_key_exists( $part1, $this->mVariables ) ) {
- $text = $this->mVariables[$part1];
- $found = true;
- $this->mOutput->mContainsOldMagic = true;
- }
-
# GRAMMAR
if ( !$found && $argc == 1 ) {
$mwGrammar =& MagicWord::get( MAG_GRAMMAR );
return $wgCurParser->argSubstitution( $matches );
}
+function wfVariableSubstitution( $matches ) {
+ global $wgCurParser;
+ return $wgCurParser->variableSubstitution( $matches );
+}
+
/**
* Return the total number of articles
*/