本文整理汇总了PHP中BBCode::setCodeFlag方法的典型用法代码示例。如果您正苦于以下问题:PHP BBCode::setCodeFlag方法的具体用法?PHP BBCode::setCodeFlag怎么用?PHP BBCode::setCodeFlag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BBCode
的用法示例。
在下文中一共展示了BBCode::setCodeFlag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bbcode
/**
* 2Moons
* Copyright (C) 2012 Jan Kröpke
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package 2Moons
* @author Jan Kröpke <info@2moons.cc>
* @copyright 2012 Jan Kröpke <info@2moons.cc>
* @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
* @version 1.7.3 (2013-05-19)
* @info $Id: BBCode.php 2640 2013-03-23 19:23:26Z slaver7 $
* @link http://2moons.cc/
*/
function bbcode($text)
{
require_once '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());
$bbcode->addCode("rouge", "callback_replace", "bbcode_rouge", array('start_tag' => '[rouge]', 'end_tag' => '[/rouge]'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
$bbcode->addCode("orange", "callback_replace", "bbcode_orange", array('start_tag' => '[orange]', 'end_tag' => '[/orange]'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
$bbcode->addCode("jaune", "callback_replace", "bbcode_jaune", array('start_tag' => '[jaune]', 'end_tag' => '[/jaune]'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
$bbcode->addCode("chartreuse", "callback_replace", "bbcode_chartreuse", array('start_tag' => '[chartreuse]', 'end_tag' => '[/chartreuse]'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
$bbcode->addCode("vert", "callback_replace", "bbcode_vert", array('start_tag' => '[vert]', 'end_tag' => '[/vert]'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
$bbcode->addCode("cyan", "callback_replace", "bbcode_cyan", array('start_tag' => '[cyan]', 'end_tag' => '[/cyan]'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
$bbcode->addCode("bleu", "callback_replace", "bbcode_bleu", array('start_tag' => '[bleu]', 'end_tag' => '[/bleu]'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
$bbcode->addCode("violet", "callback_replace", "bbcode_violet", array('start_tag' => '[violet]', 'end_tag' => '[/violet]'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
$bbcode->addCode("rose", "callback_replace", "bbcode_rose", array('start_tag' => '[rose]', 'end_tag' => '[/rose]'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
$bbcode->addCode("gris", "callback_replace", "bbcode_gris", array('start_tag' => '[gris]', 'end_tag' => '[/gris]'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
$bbcode->addCode("blanc", "callback_replace", "bbcode_blanc", array('start_tag' => '[blanc]', 'end_tag' => '[/blanc]'), '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 str_replace('&amp;', '&', makebr($bbcode->parse($text)));
}
示例2: bbcode
function bbcode($text)
{
require_once ROOT_PATH . 'includes/classes/class.BBCode.' . PHP_EXT;
$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));
}