* @return string
*/
function wfMsgWikiHtml( $key ) {
- global $wgMessageCache;
+ global $wgOut;
$args = func_get_args();
array_shift( $args );
- return wfMsgReplaceArgs(
- $wgMessageCache->parse( wfMsgGetKey( $key, true ), null, /* can't be set to false */ true ),
- $args );
+ return wfMsgReplaceArgs( $wgOut->parse( wfMsgGetKey( $key, true ), /* can't be set to false */ true ), $args );
}
/**
* Behavior for conflicting options (e.g., parse+parseinline) is undefined.
*/
function wfMsgExt( $key, $options ) {
- global $wgMessageCache;
+ global $wgOut;
$args = func_get_args();
array_shift( $args );
}
if( in_array( 'parse', $options, true ) ) {
- $string = $wgMessageCache->parse( $string, null, true, !$forContent, $langCodeObj );
+ $string = $wgOut->parse( $string, true, !$forContent, $langCodeObj );
} elseif ( in_array( 'parseinline', $options, true ) ) {
- $string = $wgMessageCache->parse( $string, null, true, !$forContent, $langCodeObj );
+ $string = $wgOut->parse( $string, true, !$forContent, $langCodeObj );
$m = array();
if( preg_match( '/^<p>(.*)\n?<\/p>\n?$/sU', $string, $m ) ) {
$string = $m[1];
/**
* ParserOptions is lazy initialised.
- *
- * @return ParserOptions
*/
function getParserOptions() {
if ( !$this->mParserOptions ) {
/**
* Set the cache to $cache, if it is valid. Otherwise set the cache to false.
- *
- * @return bool
*/
function setCache( $cache, $code ) {
if ( isset( $cache['VERSION'] ) && $cache['VERSION'] == MSG_CACHE_VERSION ) {
return $message;
}
- $parser = $this->getParser();
- if ( $parser ) {
- $popts = $this->getParserOptions();
- $popts->setInterfaceMessage( $interface );
- $popts->setTargetLanguage( $language );
- $popts->setUserLang( $language );
- $message = $parser->transformMsg( $message, $popts, $title );
- }
- return $message;
- }
-
- /**
- * @return Parser
- */
- function getParser() {
global $wgParser, $wgParserConf;
if ( !$this->mParser && isset( $wgParser ) ) {
# Do some initialisation so that we don't have to do it twice
} else {
$this->mParser = clone $wgParser;
}
+ #wfDebug( __METHOD__ . ": following contents triggered transform: $message\n" );
}
- return $this->mParser;
- }
-
- /**
- * @param $text string
- * @param $title
- * @param $linestart bool
- * @return ParserOutput
- */
- public function parse( $text, $title = null, $linestart = true, $interface = false, $language = null ) {
- $parser = $this->getParser();
- $popts = $this->getParserOptions();
-
- if ( $interface ) {
- $popts->setInterfaceMessage( true );
- }
- if ( $language !== null ) {
+ if ( $this->mParser ) {
+ $popts = $this->getParserOptions();
+ $popts->setInterfaceMessage( $interface );
$popts->setTargetLanguage( $language );
+ $popts->setUserLang( $language );
+ $message = $this->mParser->transformMsg( $message, $popts, $title );
}
-
- return $parser->parse( $text, $title, $popts, $linestart );
+ return $message;
}
function disable() {