本文整理匯總了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;
}