/** * GETS a message from the MediaWiki namespace */ protected function getMessage(&$key) { $source = wfMsgGetKey($key, true, true, false); if (wfEmptyMsg($key, $source)) { return null; } return $source; }
/** * @param $key * @param $useDB * @param $langCode * @param $transform * @return bool */ function wfFakeAnswersMessaging(&$key, &$useDB, &$langCode, &$transform) { $mask = "-answers2"; if (!preg_match("/{$mask}\$/", $key, $matches)) { $key2 = "{$key}{$mask}"; $msg2 = wfMsgGetKey($key2, $useDB, $langCode, $transform); if (!wfEmptyMsg($key2, $msg2)) { $key = $key2; } } return true; }
static function intFunction($parser, $part1 = '') { if (strval($part1) !== '') { $args = array_slice(func_get_args(), 2); $message = wfMsgGetKey($part1, true, false, false); $message = wfMsgReplaceArgs($message, $args); $message = $parser->replaceVariables($message); // like $wgMessageCache->transform() return $message; } else { return array('found' => false); } }
/** * getMessagesJs generates a javascript addMessages() calls for a given module and language * * @param String $moduleName the name of the module * @param String $langCode Name of scriptText module ( that hosts messages ) * @return string */ public static function getMessagesJs($moduleName, $language) { global $wgOut; // TODO this should be cached. Perhaps with Localisation Cache. global $wgExtensionMessagesFiles; // Empty out messages in the current scope $messages = array(); require $wgExtensionMessagesFiles[$moduleName]; // iterate over the default messages, and get this wiki's current messages // presumably this will include local overrides in MediaWiki: space $messagesForJs = array(); // 'en' is the default language, so it will be the most complete foreach (array_keys($messages['en']) as $key) { $messagesForJs[$key] = wfMsgGetKey($key, true, $language, false); } $messagesJson = FormatJson::encode($messagesForJs); return 'window.mediaWiki.addMessages(' . $messagesJson . ');'; }
private function getMessagesAndTests() { $messages = array(); $tests = array(); $wfMsgExtOptions = array('parsemag'); foreach (array('en', 'fr', 'ar', 'jp', 'zh') as $languageCode) { $wfMsgExtOptions['language'] = $languageCode; foreach (self::$keyToTestArgs as $key => $testArgs) { foreach ($testArgs as $args) { // get the raw template, without any transformations $template = wfMsgGetKey($key, true, $languageCode, false); // get the magic-parsed version with args $wfMsgExtArgs = array_merge(array($key, $wfMsgExtOptions), $args); $result = call_user_func_array('wfMsgExt', $wfMsgExtArgs); // record the template, args, language, and expected result // fake multiple languages by flattening them together $langKey = $languageCode . '_' . $key; $messages[$langKey] = $template; $tests[] = array('name' => $languageCode . " " . $key . " " . join(",", $args), 'key' => $langKey, 'args' => $args, 'result' => $result, 'lang' => $languageCode); } } } return array($messages, $tests); }
function __construct($msg, $width, $height) { $args = array_slice(func_get_args(), 3); $htmlArgs = array_map('htmlspecialchars', $args); $htmlArgs = array_map('nl2br', $htmlArgs); $this->htmlMsg = wfMsgReplaceArgs(htmlspecialchars(wfMsgGetKey($msg, true)), $htmlArgs); $this->textMsg = wfMsgReal($msg, $args); $this->width = intval($width); $this->height = intval($height); $this->url = false; $this->path = false; }
function getTimeZoneName() { if (!isset($this->timezoneName)) { $tzUser = $this->getTimeZone(); $tzName = $tzUser->getName(); if ($tzName == 'UTC') { $this->timezoneName = \wfMsgGetKey('utc', true, $this->languageCode); } else { $tzCityName = ' '; $tzRegionName = ' '; $tzInfo = explode('/', $tzName); $tzRegion = $tzInfo[0]; $tzCity = $tzInfo[1]; $tzRegionMsgCode = 'timezoneregion-' . strtolower($tzRegion); $tzRegionName = str_replace('_', ' ', \wfMsgGetKey($tzRegionMsgCode, true, $this->languageCode)); $tzCityName = str_replace('_', ' ', $tzCity); if ($this->mwLanguageObj->isRTL()) { $this->timezoneName = $tzCityName . '\\' . $tzRegionName; } else { $this->timezoneName = $tzRegionName . '/' . $tzCityName; } } } return $this->timezoneName; }
function reallyDoQuery($offset, $limit, $descending) { $result = new FakeResultWrapper(array()); $messageNames = $this->getAllMessages($descending); $statuses = $this->getCustomisedStatuses($messageNames); $count = 0; foreach ($messageNames as $key) { $customised = isset($statuses['pages'][$key]); if ($customised !== $this->custom && ($descending && ($key < $offset || !$offset) || !$descending && $key > $offset) && ($this->prefix && preg_match($this->prefix, $key) || $this->prefix === false)) { $result->result[] = array('am_title' => $key, 'am_actual' => wfMsgGetKey($key, true, $this->langcode, false), 'am_default' => wfMsgGetKey($key, false, $this->langcode, false), 'am_customised' => $customised, 'am_talk_exists' => isset($statuses['talks'][$key])); $count++; } if ($count == $limit) { break; } } return $result; }
/** * Convenience method for retrieving a wfMsgForContent() message. * Note: Any additional args not listed in the method signature are passed * forward to the msg resolution function. * @param String $msg The system message to use. */ function msg($msg) { $args = func_get_args(); array_shift($args); return wfMsgReplaceArgs(wfMsgGetKey($this->mMsgPrefix . $msg, true), $args); }
/** * Returns message in the requested format * * @deprecated since 1.18 * * @param string $key Key of the message * @param array $options Processing rules. * Can take the following options: * parse: parses wikitext to HTML * parseinline: parses wikitext to HTML and removes the surrounding * p's added by parser or tidy * escape: filters message through htmlspecialchars * escapenoentities: same, but allows entity references like   through * replaceafter: parameters are substituted after parsing or escaping * parsemag: transform the message using magic phrases * content: fetch message for content language instead of interface * Also can accept a single associative argument, of the form 'language' => 'xx': * language: Language object or language code to fetch message for * (overridden by content). * Behavior for conflicting options (e.g., parse+parseinline) is undefined. * * @return string */ function wfMsgExt($key, $options) { wfDeprecated(__METHOD__, '1.21'); $args = func_get_args(); array_shift($args); array_shift($args); $options = (array) $options; $validOptions = array('parse', 'parseinline', 'escape', 'escapenoentities', 'replaceafter', 'parsemag', 'content'); foreach ($options as $arrayKey => $option) { if (!preg_match('/^[0-9]+|language$/', $arrayKey)) { // An unknown index, neither numeric nor "language" wfWarn("wfMsgExt called with incorrect parameter key {$arrayKey}", 1, E_USER_WARNING); } elseif (preg_match('/^[0-9]+$/', $arrayKey) && !in_array($option, $validOptions)) { // A numeric index with unknown value wfWarn("wfMsgExt called with incorrect parameter {$option}", 1, E_USER_WARNING); } } if (in_array('content', $options, true)) { $forContent = true; $langCode = true; $langCodeObj = null; } elseif (array_key_exists('language', $options)) { $forContent = false; $langCode = wfGetLangObj($options['language']); $langCodeObj = $langCode; } else { $forContent = false; $langCode = false; $langCodeObj = null; } $string = wfMsgGetKey($key, true, $langCode, false); if (!in_array('replaceafter', $options, true)) { $string = wfMsgReplaceArgs($string, $args); } $messageCache = MessageCache::singleton(); $parseInline = in_array('parseinline', $options, true); if (in_array('parse', $options, true) || $parseInline) { $string = $messageCache->parse($string, null, true, !$forContent, $langCodeObj); if ($string instanceof ParserOutput) { $string = $string->getText(); } if ($parseInline) { $string = Parser::stripOuterParagraph($string); } } elseif (in_array('parsemag', $options, true)) { $string = $messageCache->transform($string, !$forContent, $langCodeObj); } if (in_array('escape', $options, true)) { $string = htmlspecialchars($string); } elseif (in_array('escapenoentities', $options, true)) { $string = Sanitizer::escapeHtmlAllowEntities($string); } if (in_array('replaceafter', $options, true)) { $string = wfMsgReplaceArgs($string, $args); } return $string; }
/** * Get messages for a given package as key => value structure * * Resolve messages list (entries matching "feature-*" pattern) * * @param string $name - name of the messages package * @param boolean $allowWildcards - can packages with wildcard be added? * @return array - key/value array of messages */ private static function getPackage($name, $allowWildcards = true) { wfProfileIn(__METHOD__); $ret = null; if (isset(self::$packages[$name])) { self::log(__METHOD__, $name); // get messages $messages = self::$packages[$name]; $ret = array(); foreach ($messages as $message) { // pattern to match messages (e.g. "feature-*") if (substr($message, -1) == '*') { // BugId:18482 if ($allowWildcards) { $msgs = self::resolveMessagesPattern($message); if (!empty($msgs)) { $ret = array_merge($ret, $msgs); } } else { Wikia::logBacktrace(__METHOD__); wfProfileOut(__METHOD__); trigger_error("JSMessages: '{$name}' package with wildcard matching can only be used in EXTERNAL mode", E_USER_ERROR); return; } } else { //@todo - this removes the {{PLURAL prefix, so plurals won't work in JS //on the other hand we cannot simply set $transform to true, as we want the wiki links to be parsed $msg = wfMsgGetKey($message, true); // check for not existing message if ($msg == htmlspecialchars("<{$message}>")) { $msg = false; } $ret[$message] = $msg; } } } wfProfileOut(__METHOD__); return $ret; }
/** * Updates an array of messages with the wfMsgGetKey value * * @param {Array} $jmsg Associative array of message key -> message value pairs * @param {String} $langCode Language code override */ public static function updateMessageValues(&$messegeArray, $langCode = false) { global $wgLang; // Check the langCode if (!$langCode && $wgLang) { $langCode = $wgLang->getCode(); } // Get the msg keys for the a json array foreach ($messegeArray as $msgKey => $na) { // Language codes use dash instead of underscore internally $msgLangCode = str_replace('_', '-', $langCode); $messegeArray[$msgKey] = wfMsgGetKey($msgKey, true, $msgLangCode, false); } }
function wfMsgReal($key, $args) { $message = wfMsgGetKey($key); $message = wfMsgReplaceArgs($message, $args); return $message; }
/** * Returns message in the requested format * @param string $key Key of the message * @param array $options Processing rules: * <i>parse<i>: parses wikitext to html * <i>parseinline<i>: parses wikitext to html and removes the surrounding p's added by parser or tidy * <i>escape<i>: filters message trough htmlspecialchars * <i>replaceafter<i>: parameters are substituted after parsing or escaping * <i>parsemag<i>: ?? */ function wfMsgExt($key, $options) { global $wgOut, $wgParser; $args = func_get_args(); array_shift($args); array_shift($args); if (!is_array($options)) { $options = array($options); } $string = wfMsgGetKey($key, true, false, false); if (!in_array('replaceafter', $options)) { $string = wfMsgReplaceArgs($string, $args); } if (in_array('parse', $options)) { $string = $wgOut->parse($string, true, true); } elseif (in_array('parseinline', $options)) { $string = $wgOut->parse($string, true, true); $m = array(); if (preg_match("~^<p>(.*)\n?</p>\$~", $string, $m)) { $string = $m[1]; } } elseif (in_array('parsemag', $options)) { global $wgMessageCache; if (isset($wgMessageCache)) { $string = $wgMessageCache->transform($string); } } if (in_array('escape', $options)) { $string = htmlspecialchars($string); } if (in_array('replaceafter', $options)) { $string = wfMsgReplaceArgs($string, $args); } return $string; }
/** * Returns message in the requested format after parsing wikitext to html * This is meant to be equivalent to wfMsgExt() with parse, parsemag and escape as available options but using the DPL2 local parser instead of the global one (bugfix). */ function msgExt($key, $options) { $args = func_get_args(); array_shift($args); array_shift($args); if (!is_array($options)) { $options = array($options); } $string = wfMsgGetKey($key, true, false, false); $string = wfMsgReplaceArgs($string, $args); if (in_array('parse', $options)) { $this->mParserOptions->setInterfaceMessage(true); $string = $this->mParser->recursiveTagParse($string); $this->mParserOptions->setInterfaceMessage(false); //$string = $parserOutput->getText(); } elseif (in_array('parsemag', $options)) { $parser = ParserPool::create(); # Wikia $parserOptions = new ParserOptions(); $parserOptions->setInterfaceMessage(true); $parser->startExternalParse($this->mParserTitle, $parserOptions, OT_MSG); $string = $parser->transformMsg($string, $parserOptions); } if (in_array('escape', $options)) { $string = htmlspecialchars($string); } return $string; }
/** * Returns message in the requested format * @param $key String: key of the message * @param $options Array: processing rules. Can take the following options: * <i>parse</i>: parses wikitext to HTML * <i>parseinline</i>: parses wikitext to HTML and removes the surrounding * p's added by parser or tidy * <i>escape</i>: filters message through htmlspecialchars * <i>escapenoentities</i>: same, but allows entity references like   through * <i>replaceafter</i>: parameters are substituted after parsing or escaping * <i>parsemag</i>: transform the message using magic phrases * <i>content</i>: fetch message for content language instead of interface * Also can accept a single associative argument, of the form 'language' => 'xx': * <i>language</i>: Language object or language code to fetch message for * (overriden by <i>content</i>). * Behavior for conflicting options (e.g., parse+parseinline) is undefined. * * @return String */ function wfMsgExt($key, $options) { $args = func_get_args(); array_shift($args); array_shift($args); $options = (array) $options; foreach ($options as $arrayKey => $option) { if (!preg_match('/^[0-9]+|language$/', $arrayKey)) { # An unknown index, neither numeric nor "language" wfWarn("wfMsgExt called with incorrect parameter key {$arrayKey}", 1, E_USER_WARNING); } elseif (preg_match('/^[0-9]+$/', $arrayKey) && !in_array($option, array('parse', 'parseinline', 'escape', 'escapenoentities', 'replaceafter', 'parsemag', 'content'))) { # A numeric index with unknown value wfWarn("wfMsgExt called with incorrect parameter {$option}", 1, E_USER_WARNING); } } if (in_array('content', $options, true)) { $forContent = true; $langCode = true; $langCodeObj = null; } elseif (array_key_exists('language', $options)) { $forContent = false; $langCode = wfGetLangObj($options['language']); $langCodeObj = $langCode; } else { $forContent = false; $langCode = false; $langCodeObj = null; } $string = wfMsgGetKey($key, true, $langCode, false); if (!in_array('replaceafter', $options, true)) { $string = wfMsgReplaceArgs($string, $args); } $messageCache = MessageCache::singleton(); if (in_array('parse', $options, true)) { $string = $messageCache->parse($string, null, true, !$forContent, $langCodeObj)->getText(); } elseif (in_array('parseinline', $options, true)) { $string = $messageCache->parse($string, null, true, !$forContent, $langCodeObj)->getText(); $m = array(); if (preg_match('/^<p>(.*)\\n?<\\/p>\\n?$/sU', $string, $m)) { $string = $m[1]; } } elseif (in_array('parsemag', $options, true)) { $string = $messageCache->transform($string, !$forContent, $langCodeObj); } if (in_array('escape', $options, true)) { $string = htmlspecialchars($string); } elseif (in_array('escapenoentities', $options, true)) { $string = Sanitizer::escapeHtmlAllowEntities($string); } if (in_array('replaceafter', $options, true)) { $string = wfMsgReplaceArgs($string, $args); } return $string; }
/** * Really get a message * @return $key String: key to get. * @return $args * @return $useDB Boolean * @return String: the requested message. */ function wfMsgReal($key, $args, $useDB = true, $forContent = false, $transform = true) { $fname = 'wfMsgReal'; $message = wfMsgGetKey($key, $useDB, $forContent, $transform); $message = wfMsgReplaceArgs($message, $args); return $message; }
/** * Return an HTML-escaped version of a message. * Parameter replacements, if any, are done *after* the HTML-escaping, * so parameters may contain HTML (eg links or form controls). Be sure * to pre-escape them if you really do want plaintext, or just wrap * the whole thing in htmlspecialchars(). * * @param string $key * @param string ... parameters * @return string */ function wfMsgHtml($key) { $args = func_get_args(); array_shift($args); return wfMsgReplaceArgs(htmlspecialchars(wfMsgGetKey($key, true)), $args); }
/** * Returns message in the requested format * @param string $key Key of the message * @param array $options Processing rules: * <i>parse<i>: parses wikitext to html * <i>parseinline<i>: parses wikitext to html and removes the surrounding p's added by parser or tidy * <i>escape<i>: filters message trough htmlspecialchars * <i>replaceafter<i>: parameters are substituted after parsing or escaping */ function wfMsgExt($key, $options) { global $wgOut, $wgMsgParserOptions, $wgParser; $args = func_get_args(); array_shift($args); array_shift($args); if (!is_array($options)) { $options = array($options); } $string = wfMsgGetKey($key, true, false, false); if (!in_array('replaceafter', $options)) { $string = wfMsgReplaceArgs($string, $args); } if (in_array('parse', $options)) { $string = $wgOut->parse($string, true, true); } elseif (in_array('parseinline', $options)) { $string = $wgOut->parse($string, true, true); $m = array(); if (preg_match("~^<p>(.*)\n?</p>\$~", $string, $m)) { $string = $m[1]; } } elseif (in_array('parsemag', $options)) { global $wgTitle; $parser = new Parser(); $parserOptions = new ParserOptions(); $parserOptions->setInterfaceMessage(true); $parser->startExternalParse($wgTitle, $parserOptions, OT_MSG); $string = $parser->transformMsg($string, $parserOptions); } if (in_array('escape', $options)) { $string = htmlspecialchars($string); } if (in_array('replaceafter', $options)) { $string = wfMsgReplaceArgs($string, $args); } return $string; }
/** * Note that getContent/loadContent do not follow redirects anymore. * If you need to fetch redirectable content easily, try * the shortcut in Article::followRedirect() * * This function has side effects! Do not use this function if you * only want the real revision text if any. * * @return Return the text of this revision */ public function getContent() { global $wgUser, $wgContLang, $wgMessageCache; wfProfileIn(__METHOD__); if ($this->getID() === 0) { # If this is a MediaWiki:x message, then load the messages # and return the message value for x. if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) { # If this is a system message, get the default text. list($message, $lang) = $wgMessageCache->figureMessage($wgContLang->lcfirst($this->mTitle->getText())); $text = wfMsgGetKey($message, false, $lang, false); if (wfEmptyMsg($message, $text)) { $text = ''; } } else { $text = wfMsgExt($wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon', 'parsemag'); } wfProfileOut(__METHOD__); return $text; } else { $this->loadContent(); wfProfileOut(__METHOD__); return $this->mContent; } }
/** * Fetch initial editing page content. * @private */ function getContent($def_text = '') { global $wgOut, $wgRequest, $wgParser, $wgContLang, $wgMessageCache; wfProfileIn(__METHOD__); # Get variables from query string :P $section = $wgRequest->getVal('section'); $preload = $wgRequest->getVal('preload'); $undoafter = $wgRequest->getVal('undoafter'); $undo = $wgRequest->getVal('undo'); $text = ''; // For message page not locally set, use the i18n message. // For other non-existent articles, use preload text if any. if (!$this->mTitle->exists()) { if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) { # If this is a system message, get the default text. list($message, $lang) = $wgMessageCache->figureMessage($wgContLang->lcfirst($this->mTitle->getText())); $wgMessageCache->loadAllMessages($lang); $text = wfMsgGetKey($message, false, $lang, false); if (wfEmptyMsg($message, $text)) { $text = ''; } } else { # If requested, preload some text. $text = $this->getPreloadedText($preload); } // For existing pages, get text based on "undo" or section parameters. } else { $text = $this->mArticle->getContent(); if ($undo > 0 && $undoafter > 0 && $undo < $undoafter) { # If they got undoafter and undo round the wrong way, switch them list($undo, $undoafter) = array($undoafter, $undo); } if ($undo > 0 && $undo > $undoafter) { # Undoing a specific edit overrides section editing; section-editing # doesn't work with undoing. if ($undoafter) { $undorev = Revision::newFromId($undo); $oldrev = Revision::newFromId($undoafter); } else { $undorev = Revision::newFromId($undo); $oldrev = $undorev ? $undorev->getPrevious() : null; } # Sanity check, make sure it's the right page, # the revisions exist and they were not deleted. # Otherwise, $text will be left as-is. if (!is_null($undorev) && !is_null($oldrev) && $undorev->getPage() == $oldrev->getPage() && $undorev->getPage() == $this->mArticle->getID() && !$undorev->isDeleted(Revision::DELETED_TEXT) && !$oldrev->isDeleted(Revision::DELETED_TEXT)) { $undotext = $this->mArticle->getUndoText($undorev, $oldrev); if ($undotext === false) { # Warn the user that something went wrong $this->editFormPageTop .= $wgOut->parse('<div class="error mw-undo-failure">' . wfMsgNoTrans('undo-failure') . '</div>'); } else { $text = $undotext; # Inform the user of our success and set an automatic edit summary $this->editFormPageTop .= $wgOut->parse('<div class="mw-undo-success">' . wfMsgNoTrans('undo-success') . '</div>'); $firstrev = $oldrev->getNext(); # If we just undid one rev, use an autosummary if ($firstrev->mId == $undo) { $this->summary = wfMsgForContent('undo-summary', $undo, $undorev->getUserText()); $this->undidRev = $undo; } $this->formtype = 'diff'; } } else { // Failed basic sanity checks. // Older revisions may have been removed since the link // was created, or we may simply have got bogus input. $this->editFormPageTop .= $wgOut->parse('<div class="error mw-undo-norev">' . wfMsgNoTrans('undo-norev') . '</div>'); } } else { if ($section != '') { if ($section == 'new') { $text = $this->getPreloadedText($preload); } else { $text = $wgParser->getSection($text, $section, $def_text); } } } } wfProfileOut(__METHOD__); return $text; }
public function execute() { $params = $this->extractRequestParams(); global $wgLang; $oldLang = null; if (!is_null($params['lang'])) { $oldLang = $wgLang; // Keep $wgLang for restore later $wgLang = Language::factory($params['lang']); } $prop = array_flip((array) $params['prop']); // Determine which messages should we print if (in_array('*', $params['messages'])) { $message_names = array_keys(Language::getMessagesFor('en')); sort($message_names); $messages_target = $message_names; } else { $messages_target = $params['messages']; } // Filter messages if (isset($params['filter'])) { $messages_filtered = array(); foreach ($messages_target as $message) { // !== is used because filter can be at the beginning of the string if (strpos($message, $params['filter']) !== false) { $messages_filtered[] = $message; } } $messages_target = $messages_filtered; } // Get all requested messages and print the result $skip = !is_null($params['from']); $useto = !is_null($params['to']); $result = $this->getResult(); foreach ($messages_target as $message) { // Skip all messages up to $params['from'] if ($skip && $message === $params['from']) { $skip = false; } if ($useto && $message > $params['to']) { break; } if (!$skip) { $a = array('name' => $message); $args = null; if (isset($params['args']) && count($params['args']) != 0) { $args = $params['args']; } // Check if the parser is enabled: if ($params['enableparser']) { $msg = wfMsgExt($message, array('parsemag'), $args); } elseif ($args) { $msgString = wfMsgGetKey($message, true, false, false); $msg = wfMsgReplaceArgs($msgString, $args); } else { $msg = wfMsgGetKey($message, true, false, false); } if (wfEmptyMsg($message, $msg)) { $a['missing'] = ''; } else { ApiResult::setContent($a, $msg); if (isset($prop['default'])) { $default = wfMsgGetKey($message, false, false, false); if ($default !== $msg) { if (wfEmptyMsg($message, $default)) { $a['defaultmissing'] = ''; } else { $a['default'] = $default; } } } } $fit = $result->addValue(array('query', $this->getModuleName()), null, $a); if (!$fit) { $this->setContinueEnumParameter('from', $message); break; } } } $result->setIndexedTagName_internal(array('query', $this->getModuleName()), 'message'); if (!is_null($oldLang)) { $wgLang = $oldLang; // Restore $oldLang } }
/** * Returns message in the requested format * @param string $key Key of the message * @param array $options Processing rules: * <i>parse</i>: parses wikitext to html * <i>parseinline</i>: parses wikitext to html and removes the surrounding p's added by parser or tidy * <i>escape</i>: filters message through htmlspecialchars * <i>escapenoentities</i>: same, but allows entity references like through * <i>replaceafter</i>: parameters are substituted after parsing or escaping * <i>parsemag</i>: transform the message using magic phrases * <i>content</i>: fetch message for content language instead of interface * Behavior for conflicting options (e.g., parse+parseinline) is undefined. */ function wfMsgExt($key, $options) { global $wgOut, $wgParser; $args = func_get_args(); array_shift($args); array_shift($args); if (!is_array($options)) { $options = array($options); } $forContent = false; if (in_array('content', $options)) { $forContent = true; } $string = wfMsgGetKey($key, true, $forContent, false); if (!in_array('replaceafter', $options)) { $string = wfMsgReplaceArgs($string, $args); } if (in_array('parse', $options)) { $string = $wgOut->parse($string, true, !$forContent); } elseif (in_array('parseinline', $options)) { $string = $wgOut->parse($string, true, !$forContent); $m = array(); if (preg_match('/^<p>(.*)\\n?<\\/p>\\n?$/sU', $string, $m)) { $string = $m[1]; } } elseif (in_array('parsemag', $options)) { global $wgMessageCache; if (isset($wgMessageCache)) { $string = $wgMessageCache->transform($string, !$forContent); } } if (in_array('escape', $options)) { $string = htmlspecialchars($string); } elseif (in_array('escapenoentities', $options)) { $string = htmlspecialchars($string); $string = str_replace('&', '&', $string); $string = Sanitizer::normalizeCharReferences($string); } if (in_array('replaceafter', $options)) { $string = wfMsgReplaceArgs($string, $args); } return $string; }