当前位置: 首页>>代码示例>>PHP>>正文


PHP BBCode::AddRule方法代码示例

本文整理汇总了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;
 }
开发者ID:nilsen,项目名称:addons,代码行数:15,代码来源:class.ipbformatter.plugin.php

示例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>';
 }
开发者ID:catlabinteractive,项目名称:dolumar-engine,代码行数:44,代码来源:Parser.php

示例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>
开发者ID:edgaraxe,项目名称:AnimeNetwork,代码行数:19,代码来源:tag_simple.php

示例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>
开发者ID:edgaraxe,项目名称:AnimeNetwork,代码行数:30,代码来源:tag_callback.php

示例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>
开发者ID:edgaraxe,项目名称:AnimeNetwork,代码行数:18,代码来源:tag_enhanced.php


注:本文中的BBCode::AddRule方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。