* performs brace substitution on MediaWiki messages
*
* Globals used:
- * objects: $wgLang
+ * objects: $wgLang, $wgContLang
*
* NOT $wgArticle, $wgUser or $wgTitle. Keep them away!
*
$this->replaceLinkHolders( $text );
- # the position of the convert() call should not be changed. it
+ # the position of the parserConvert() call should not be changed. it
# assumes that the links are all replaced and the only thing left
# is the <nowiki> mark.
- $text = $wgContLang->convert($text);
-
- # FIXME: Unexpected data flow
- # Set the title text in mOutput to a converted version of the global
- # title. The title is stored in $wgContLang from a previous call to
- # OutputPage::setPageTitle(). If no call has been made, this will be
- # blank, a condition which Parser callers are expected to ignore.
- $this->mOutput->setTitleText($wgContLang->getParsedTitle());
+ # Side-effects: this calls $this->mOutput->setTitleText()
+ $text = $wgContLang->parserConvert( $text, $this );
$text = $this->unstripNoWiki( $text, $this->mStripState );
var $mLang;
function fakeConverter($langobj) {$this->mLang = $langobj;}
function convert($t, $i) {return $t;}
+ function parserConvert($t, $p) {return $t;}
function getVariants() { return array( $this->mLang->getCode() ); }
function getPreferredVariant() {return $this->mLang->getCode(); }
function findVariantLink(&$l, &$n) {}
return $this->mConverter->convert($text, $isTitle);
}
+ # Convert text from within Parser
+ function parserConvert( $text, &$parser ) {
+ return $this->mConverter->parserConvert( $text, $parser );
+ }
+
/**
* Perform output conversion on a string, and encode for safe HTML output.
* @param string $text
return $ret;
}
+ /**
+ * Convert text using a parser object for context
+ */
+ function parserConvert( $text, &$parser ) {
+ global $wgDisableLangConversion;
+ /* don't do anything if this is the conversion table */
+ if ( $parser->mTitle->getNamespace() == NS_MEDIAWIKI &&
+ strpos($parser->mTitle->getText, "Conversiontable") !== false )
+ {
+ return $text;
+ }
+
+ if($wgDisableLangConversion)
+ return $text;
+
+ $text = $this->convert( $text );
+ $parser->mOutput->setTitleText( $this->mTitleDisplay );
+ return $text;
+ }
+
/**
* convert text to different variants of a language. the automatic
* conversion is done in autoConvert(). here we parse the text
* @access public
*/
function convert( $text , $isTitle=false) {
- global $wgDisableLangConversion;
- global $wgTitle;
-
- /* don't do anything if this is the conversion table */
- if($wgTitle->getNamespace() == NS_MEDIAWIKI &&
- strpos($wgTitle->getText(), "Conversiontable")!==false)
- return $text;
-
- if($wgDisableLangConversion)
- return $text;
-
$mw =& MagicWord::get( MAG_NOTITLECONVERT );
if( $mw->matchAndRemove( $text ) )
$this->mDoTitleConvert = false;