本文整理汇总了PHP中BBCode::addCode方法的典型用法代码示例。如果您正苦于以下问题:PHP BBCode::addCode方法的具体用法?PHP BBCode::addCode怎么用?PHP BBCode::addCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BBCode
的用法示例。
在下文中一共展示了BBCode::addCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bbcode
/**
_ \_/ |\ | /¯¯\ \ / /\ |¯¯) |_¯ \ / /¯¯\ | | |´¯|¯` | /¯¯\ |\ |5
¯ /¯\ | \| \__/ \/ /--\ |¯¯\ |__ \/ \__/ |__ \_/ | | \__/ | \|Core.
* @author: Copyright (C) 2011 by Brayan Narvaez (Prinick) developer of xNova Revolution
* @link: http://www.xnovarevolution.con.ar
* @package 2Moons
* @author Slaver <slaver7@gmail.com>
* @copyright 2009 Lucky <douglas@crockford.com> (XGProyecto)
* @copyright 2011 Slaver <slaver7@gmail.com> (Fork/2Moons)
* @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
* @version 1.3 (2011-01-21)
* @link http://code.google.com/p/2moons/
* Please do not remove the credits
*/
function bbcode($text)
{
require_once ROOT_PATH . 'includes/classes/class.BBCode.php';
$bbcode = new BBCode();
$bbcode->addParser('list', 'bbcode_stripcontents');
//Block-Elements
$bbcode->addCode("quote", "callback_replace", "bbcode_quote", array(), "block", array("block"), array('inline', 'link', 'list'));
$bbcode->addCode("align", "callback_replace", "bbcode_align", array(), "block", array("block"), array('inline', 'link', 'list'));
$bbcode->addCode("spoiler", "simple_replace", null, array('start_tag' => '<div class="bbcode_spoiler"><p><b>Spoiler:</b></p><div>', 'end_tag' => '</div></div>'), "block", array("block"), array('inline', 'link', 'list'));
$bbcode->addCode("bg", "usecontent?", "bbcode_background", array('usecontent_param' => 'default'), 'link', array('block', 'inline', 'listitem'), array('link'));
$bbcode->addCode("bgcolor", "callback_replace", "bbcode_bgcolor", array(), 'inline', array('block', 'inline', 'link', 'listitem'), array());
//Inline-Elements
$bbcode->addCode("b", "simple_replace", null, array('start_tag' => '<b>', 'end_tag' => '</b>'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
$bbcode->addCode("i", "simple_replace", null, array('start_tag' => '<i>', 'end_tag' => '</i>'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
$bbcode->addCode("u", "simple_replace", null, array('start_tag' => '<u>', 'end_tag' => '</u>'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
$bbcode->addCode("s", "simple_replace", null, array('start_tag' => '<s>', 'end_tag' => '</s>'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
$bbcode->addCode("size", "callback_replace", "bbcode_size", array(), 'inline', array('block', 'inline', 'link', 'listitem'), array());
$bbcode->addCode("color", "callback_replace", "bbcode_color", array(), 'inline', array('block', 'inline', 'link', 'listitem'), array());
//Link-Elements
$bbcode->addCode("url", "usecontent?", "bbcode_url", array('usecontent_param' => 'default'), 'link', array('block', 'inline', 'listitem'), array('link'));
$bbcode->addCode("link", "usecontent?", "bbcode_url", array('usecontent_param' => 'default'), 'link', array('block', 'inline', 'listitem'), array('link'));
$bbcode->addCode("mailto", "usecontent?", "bbcode_mailto", array('usecontent_param' => 'default'), 'link', array('block', 'inline', 'listitem'), array('link'));
$bbcode->addCode("email", "usecontent?", "bbcode_mailto", array('usecontent_param' => 'default'), 'link', array('block', 'inline', 'listitem'), array('link'));
$bbcode->addCode("mail", "usecontent?", "bbcode_mailto", array('usecontent_param' => 'default'), 'link', array('block', 'inline', 'listitem'), array('link'));
//Code-Elements
$bbcode->addCode("code", "usecontent", "bbcode_code", array('php' => false), 'code', array('block'), array('inline', 'link', 'list'));
$bbcode->addCode("php", "usecontent", "bbcode_code", array('php' => true), 'code', array('block'), array('inline', 'link', 'list'));
//List-Elements
$bbcode->addCode("list", "callback_replace", "bbcode_list", array(), "list", array('block', 'listitem'), array('inline', 'link'));
$bbcode->addCode("*", "simple_replace", null, array('start_tag' => '<li>', 'end_tag' => '</li>'), "listitem", array('list'), array());
//Image-Element
$bbcode->addCode("img", "usecontent", "bbcode_img", array(), "image", array('block', 'inline', 'link', 'listitem'), array());
//Flags
$bbcode->setCodeFlag('*', 'closetag', BBCODE_CLOSETAG_OPTIONAL);
$bbcode->setGlobalCaseSensitive(false);
//New-Line-Drops
$bbcode->setCodeFlag('*', 'closetag.before.newline', BBCODE_NEWLINE_DROP);
$bbcode->setCodeFlag('list', 'opentag.before.newline', BBCODE_NEWLINE_DROP);
$bbcode->setCodeFlag('list', 'closetag.before.newline', BBCODE_NEWLINE_DROP);
$codes = array('code', 'php', 'quote', 'spoiler');
$flags = array('opentag.before.newline', 'opentag.after.newline', 'closetag.before.newline', 'closetag.after.newline');
foreach ($codes as $code) {
foreach ($flags as $flag) {
$bbcode->setCodeFlag($code, $flag, BBCODE_NEWLINE_DROP);
}
}
return makebr($bbcode->parse($text));
}