本文整理汇总了PHP中ParserOptions::setUserLang方法的典型用法代码示例。如果您正苦于以下问题:PHP ParserOptions::setUserLang方法的具体用法?PHP ParserOptions::setUserLang怎么用?PHP ParserOptions::setUserLang使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParserOptions
的用法示例。
在下文中一共展示了ParserOptions::setUserLang方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFeedItem
/**
*
* @param int $date
* @return FeaturedFeedItem
*/
public function getFeedItem($date)
{
self::$parserOptions->setTimestamp($date);
self::$parserOptions->setUserLang($this->language);
$titleText = self::$parser->transformMsg($this->page, self::$parserOptions);
$title = Title::newFromText($titleText);
if (!$title) {
return false;
}
$rev = Revision::newFromTitle($title);
if (!$rev) {
return false;
// page does not exist
}
$text = $rev->getText();
if (!$text) {
return false;
}
$text = self::$parser->parse($text, $title, self::$parserOptions)->getText();
$url = SpecialPage::getTitleFor('FeedItem', $this->name . '/' . wfTimestamp(TS_MW, $date) . '/' . $this->language->getCode())->getFullURL();
return new FeaturedFeedItem(self::$parser->transformMsg($this->entryName, self::$parserOptions), wfExpandUrl($url), $text, $date);
}
示例2: setParserLanguage
/**
* ParserOptions are constructed before we determined the language, so fix it
*
* @param $lang Language
*/
public function setParserLanguage($lang)
{
$this->parserOptions->setTargetLanguage($lang);
$this->parserOptions->setUserLang($lang);
}
示例3: getParserOptions
/**
* Get parser options suitable for rendering the primary article wikitext
* @param $canonical boolean Determines that the generated options must not depend on user preferences (see bug 14404)
* @return mixed ParserOptions object or boolean false
*/
public function getParserOptions($canonical = false)
{
global $wgUser, $wgLanguageCode;
if (!$this->mParserOptions || $canonical) {
$user = !$canonical ? $wgUser : new User();
$parserOptions = new ParserOptions($user);
$parserOptions->setTidy(true);
$parserOptions->enableLimitReport();
if ($canonical) {
$parserOptions->setUserLang($wgLanguageCode);
# Must be set explicitely
return $parserOptions;
}
$this->mParserOptions = $parserOptions;
}
// Clone to allow modifications of the return value without affecting cache
return clone $this->mParserOptions;
}