本文整理汇总了PHP中ParserOptions::setTimestamp方法的典型用法代码示例。如果您正苦于以下问题:PHP ParserOptions::setTimestamp方法的具体用法?PHP ParserOptions::setTimestamp怎么用?PHP ParserOptions::setTimestamp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParserOptions
的用法示例。
在下文中一共展示了ParserOptions::setTimestamp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: execute
function execute()
{
global $wgParser, $wgUser;
$wgUser = new PPFuzzUser();
$wgUser->mName = 'Fuzz';
$wgUser->mFrom = 'name';
$wgUser->ppfz_test = $this;
$options = new ParserOptions();
$options->setTemplateCallback(array($this, 'templateHook'));
$options->setTimestamp(wfTimestampNow());
$this->output = call_user_func(array($wgParser, $this->entryPoint), $this->mainText, $this->title->getPrefixedText(), $options);
return $this->output;
}