本文整理汇总了PHP中BBCode::AddRule方法的典型用法代码示例。如果您正苦于以下问题:PHP BBCode::AddRule方法的具体用法?PHP BBCode::AddRule怎么用?PHP BBCode::AddRule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BBCode
的用法示例。
在下文中一共展示了BBCode::AddRule方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: NBBC
/**
* @return BBCode;
*/
public function NBBC()
{
if ($this->_NBBC === NULL) {
require_once PATH_PLUGINS . '/HtmLawed/htmLawed/htmLawed.php';
$Plugin = new NBBCPlugin('BBCodeRelaxed');
$this->_NBBC = $Plugin->NBBC();
$this->_NBBC->ignore_newlines = TRUE;
$this->_NBBC->enable_smileys = FALSE;
$this->_NBBC->AddRule('attachment', array('mode' => BBCODE_MODE_CALLBACK, 'method' => array($this, "DoAttachment"), 'class' => 'image', 'allow_in' => array('listitem', 'block', 'columns', 'inline', 'link'), 'end_tag' => BBCODE_PROHIBIT, 'content' => BBCODE_PROHIBIT, 'plain_start' => "[image]", 'plain_content' => array()));
}
return $this->_NBBC;
}
示例2: parse
public static function parse($code)
{
$bbcode = new BBCode();
if (defined('SMILEY_DIR')) {
$bbcode->SetSmileyDir(substr(SMILEY_PATH, 0, -1));
$bbcode->SetSmileyURL(substr(SMILEY_DIR, 0, -1));
}
// A few backwards compatible issues
$code = str_replace('[img:right]', '[img align="right"]', $code);
/*
'quote' => Array(
'mode' => BBCODE_MODE_LIBRARY,
'method' => "DoQuote",
'allow_in' => Array('listitem', 'block', 'columns'),
'before_tag' => "sns",
'after_tag' => "sns",
'before_endtag' => "sns",
'after_endtag' => "sns",
'plain_start' => "\n<b>Quote:</b>\n",
'plain_end' => "\n",
),
*/
// Open tags
$bbcode->AddRule('open', array('mode' => BBCODE_MODE_CALLBACK, 'method' => array(__CLASS__, 'DoOpen'), 'class' => 'link', 'allow_in' => array('listitem', 'block', 'columns', 'inline'), 'content' => BBCODE_REQUIRED, 'plain_start' => "<a href=\"{\$link}\">", 'plain_end' => "</a>", 'plain_content' => array('_content', '_default'), 'plain_link' => array('_default', '_content')));
$bbcode->AddRule('colour', array('mode' => BBCODE_MODE_ENHANCED, 'allow' => array('_default' => '/^#?[a-zA-Z0-9._ -]+$/'), 'template' => '<span style="color:{$_default/tw}">{$_content/v}</span>', 'class' => 'inline', 'allow_in' => array('listitem', 'block', 'columns', 'inline', 'link')));
for ($i = 1; $i < 5; $i++) {
$bbcode->AddRule('h' . $i, array('simple_start' => "\n<h" . $i . ">\n", 'simple_end' => "\n</h" . $i . ">\n", 'allow_in' => array('listitem', 'block', 'columns'), 'before_tag' => "sns", 'after_tag' => "sns", 'before_endtag' => "sns", 'after_endtag' => "sns", 'plain_start' => "\n", 'plain_end' => "\n"));
}
$bbcode->AddRule('quote', array('mode' => BBCODE_MODE_CALLBACK, 'method' => array(__CLASS__, 'DoQuote'), 'allow_in' => array('listitem', 'block', 'columns'), 'before_tag' => "sns", 'after_tag' => "sns", 'before_endtag' => "sns", 'after_endtag' => "sns", 'plain_start' => "\n<b>Quote:</b>\n", 'plain_end' => "\n"));
$bbcode->AddRule('span', array('mode' => BBCODE_MODE_CALLBACK, 'method' => array(__CLASS__, 'DoSpan'), 'allow_in' => array('listitem', 'block', 'columns'), 'before_tag' => "sns", 'after_tag' => "sns", 'before_endtag' => "sns", 'after_endtag' => "sns", 'plain_start' => "\n<b>Quote:</b>\n", 'plain_end' => "\n"));
/*
'mode' => BBCODE_MODE_LIBRARY,
'method' => 'DoURL',
'class' => 'link',
'allow_in' => Array('listitem', 'block', 'columns', 'inline'),
'content' => BBCODE_REQUIRED,
'plain_start' => "<a href=\"{\$link}\">",
'plain_end' => "</a>",
'plain_content' => Array('_content', '_default'),
'plain_link' => Array('_default', '_content'),
*/
$bbcode->AddRule('action', array('mode' => BBCODE_MODE_CALLBACK, 'method' => array(__CLASS__, 'DoAction'), 'class' => 'link', 'allow_in' => array('listitem', 'block', 'columns', 'inline'), 'content' => BBCODE_REQUIRED, 'plain_start' => "<a href=\"{\$link}\">", 'plain_end' => "</a>", 'plain_content' => array('_content', '_default'), 'plain_link' => array('_default', '_content')));
return '<div class="text">' . @$bbcode->Parse($code) . '</div>';
}
示例3: BBCode
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Simple Tag Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<?php
require_once "../nbbc.php";
$input = "This text is [mono]monospaced![/mono]";
$bbcode = new BBCode();
$new_rule = array('simple_start' => '<tt>', 'simple_end' => '</tt>', 'class' => 'inline', 'allow_in' => array('listitem', 'block', 'columns', 'inline', 'link'));
$bbcode->AddRule('mono', $new_rule);
$output = $bbcode->Parse($input);
print "<div class='bbcode'>{$output}</div>";
?>
</body>
</html>
示例4: MyBorderFunction
<head>
<title>Enhanced Tag Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<?php
require_once "../nbbc.php";
$input = "[border color=red size=3]This text is in a medium red border![/border]\n" . "[border size=10]This text is in a fat blue border![/border]\n" . "[border color=green]This text is in a normal green border![/border]\n";
$bbcode = new BBCode();
function MyBorderFunction($bbcode, $action, $name, $default, $params, $content)
{
if ($action == BBCODE_CHECK) {
if (isset($params['color']) && !preg_match('/^#[0-9a-fA-F]+|[a-zA-Z]+$/', $params['color'])) {
return false;
}
if (isset($params['size']) && !preg_match('/^[1-9][0-9]*$/', $params['size'])) {
return false;
}
return true;
}
$color = isset($params['color']) ? $params['color'] : "blue";
$size = isset($params['size']) ? $params['size'] : 1;
return "<div style=\"border: {$size}px solid {$color}\">{$content}</div>";
}
$bbcode->AddRule('border', array('mode' => BBCODE_MODE_CALLBACK, 'method' => 'MyBorderFunction', 'class' => 'block', 'allow_in' => array('listitem', 'block', 'columns')));
$output = $bbcode->Parse($input);
print "<div class='bbcode'>{$output}</div>";
?>
</body>
</html>
示例5: BBCode
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Enhanced Tag Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<?php
require_once "../nbbc.php";
$input = "[border color=red size=3]This text is in a medium red border![/border]\n" . "[border size=10]This text is in a fat blue border![/border]\n" . "[border color=green]This text is in a normal green border![/border]\n";
$bbcode = new BBCode();
$bbcode->AddRule('border', array('mode' => BBCODE_MODE_ENHANCED, 'template' => '<div style="border: {$size}px solid {$color}">{$_content}</div>', 'allow' => array('color' => '/^#[0-9a-fA-F]+|[a-zA-Z]+$/', 'size' => '/^[1-9][0-9]*$/'), 'default' => array('color' => 'blue', 'size' => '1'), 'class' => 'block', 'allow_in' => array('listitem', 'block', 'columns')));
$output = $bbcode->Parse($input);
print "<div class='bbcode'>{$output}</div>";
?>
</body>
</html>