本文整理汇总了PHP中XenForo_BbCode_Parser::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_BbCode_Parser::parse方法的具体用法?PHP XenForo_BbCode_Parser::parse怎么用?PHP XenForo_BbCode_Parser::parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_BbCode_Parser
的用法示例。
在下文中一共展示了XenForo_BbCode_Parser::parse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __toString
/**
* Renders the text.
*
* @return string
*/
public function __toString()
{
try {
if (XenForo_Application::getOptions()->cacheBbCodeTree && !empty($this->_cache['contentType']) && !empty($this->_cache['contentId'])) {
$tree = null;
if (!empty($this->_cache['cache']) && !empty($this->_cache['cacheVersion']) && $this->_cache['cacheVersion'] == XenForo_Application::getOptions()->bbCodeCacheVersion) {
if (is_array($this->_cache['cache'])) {
$tree = $this->_cache['cache'];
} else {
$tree = @unserialize($this->_cache['cache']);
}
}
if (!$tree) {
try {
// need to update
$tree = $this->_parser->parse($this->_text);
$this->_cache['cache'] = $tree;
$this->_cache['cacheVersion'] = XenForo_Application::getOptions()->bbCodeCacheVersion;
$uniqueId = $this->_cache['contentType'] . '-' . $this->_cache['contentId'];
if (empty(self::$_cacheWritten[$uniqueId])) {
XenForo_Application::getDb()->query('
INSERT INTO xf_bb_code_parse_cache
(content_type, content_id, parse_tree, cache_version, cache_date)
VALUES (?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE parse_tree = VALUES(parse_tree),
cache_version = VALUES(cache_version),
cache_date = VALUES(cache_date)
', array($this->_cache['contentType'], $this->_cache['contentId'], serialize($tree), $this->_cache['cacheVersion'], XenForo_Application::$time));
self::$_cacheWritten[$uniqueId] = true;
}
} catch (Exception $e) {
return $this->_parser->render($this->_text, $this->_extraStates);
}
}
return $this->_parser->render($tree, $this->_extraStates);
} else {
return $this->_parser->render($this->_text, $this->_extraStates);
}
} catch (Exception $e) {
XenForo_Error::logException($e, false, "BB code to string error:");
return '';
}
}
示例2: renderGalleryComment
public static function renderGalleryComment(XenForo_BbCode_Parser $parser, &$message)
{
if (XenForo_Application::getOptions()->sonnbXG_extraBbcode) {
self::$_tags = array_merge(self::$_tags, array('img', 'media'));
}
$message = preg_replace(array('/(\\[url\\]\\[url\\])/i', '/(\\[\\/url\\]\\[\\/url\\])/i'), array('[url]', '[/url]'), $message);
$message = XenForo_Helper_String::censorString($message);
$message = self::linkTaggedPlainText($message);
$tags = $parser->parse($message);
if (!empty($tags)) {
$tags = self::_processTags($tags);
}
$extraStates = array('stopLineBreakConversion' => 1);
$message = new XenForo_BbCode_TextWrapper($tags, $parser, $extraStates);
return $message;
}