本文整理汇总了PHP中bbcode类的典型用法代码示例。如果您正苦于以下问题:PHP bbcode类的具体用法?PHP bbcode怎么用?PHP bbcode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了bbcode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getstr
function getstr($string, $length, $in_slashes = 0, $out_slashes = 0, $bbcode = 0, $html = 0)
{
global $_G;
$string = trim($string);
$sppos = strpos($string, chr(0) . chr(0) . chr(0));
if ($sppos !== false) {
$string = substr($string, 0, $sppos);
}
if ($in_slashes) {
$string = dstripslashes($string);
}
$string = preg_replace("/\\[hide=?\\d*\\](.*?)\\[\\/hide\\]/is", '', $string);
if ($html < 0) {
$string = preg_replace("/(\\<[^\\<]*\\>|\r|\n|\\s|\\[.+?\\])/is", ' ', $string);
} elseif ($html == 0) {
$string = dhtmlspecialchars($string);
}
if ($length) {
$string = cutstr($string, $length);
}
if ($bbcode) {
require_once DISCUZ_ROOT . './source/class/class_bbcode.php';
$bb =& bbcode::instance();
$string = $bb->bbcode2html($string, $bbcode);
}
if ($out_slashes) {
$string = daddslashes($string);
}
return trim($string);
}
示例2: generate_text_for_display
/**
* For display of custom parsed text on user-facing pages
* Expects $text to be the value directly from the database (stored value)
*/
function generate_text_for_display($text, $only_smileys = false, $censor = true, $acro_autolinks = false, $forum_id = '999999')
{
global $bbcode, $config, $user;
if (empty($text)) {
return '';
}
if (defined('IS_ICYPHOENIX') && $censor) {
$text = censor_text($text);
}
if (!class_exists('bbcode') || empty($bbcode)) {
include_once IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT;
}
if (empty($bbcode)) {
$bbcode = new bbcode();
if (!$user->data['session_logged_in']) {
$user->data['user_allowhtml'] = $config['allow_html'] ? true : false;
$user->data['user_allowbbcode'] = $config['allow_bbcode'] ? true : false;
$user->data['user_allowsmile'] = $config['allow_smilies'] ? true : false;
}
$bbcode->allow_html = $user->data['user_allowhtml'] && $config['allow_html'] ? true : false;
$bbcode->allow_bbcode = $user->data['user_allowbbcode'] && $config['allow_bbcode'] ? true : false;
$bbcode->allow_smilies = $user->data['user_allowsmile'] && $config['allow_smilies'] ? true : false;
}
if ($only_smileys) {
$text = $bbcode->parse_only_smilies($text);
} else {
$text = $bbcode->parse($text);
if ($acro_autolinks) {
$text = $bbcode->acronym_pass($text);
$text = $bbcode->autolink_text($text, $forum_id);
}
}
return $text;
}
示例3: render_message
/**
* Render BBCode in a message
*
* @param string $message Message to render -- should already be parsed using message parser. Using some modified code from $bbcode->bbcode_cache_init() in phpBB's bbcode.php.
* @param string $uid BBCode uid
* @param string $bitfield BBCode bitfield
* @return string Demo HTML
*/
public function render_message($message, $uid, $bitfield)
{
if (empty($this->bbcode_data)) {
return $message;
}
if (!is_object($this->bbcode)) {
if (!class_exists('\\bbcode')) {
require $this->phpbb_root_path . 'includes/bbcode.' . $this->php_ext;
}
$this->bbcode = new \bbcode();
}
// We define bbcode_bitfield here instead of when instantiating the class to prevent bbcode_cache_init() from running
$this->bbcode->bbcode_bitfield = $bitfield;
$bbcode_tpl = !empty($this->bbcode_data['second_pass_replace']) ? $this->bbcode_data['second_pass_replace'] : $this->bbcode_data['bbcode_tpl'];
// Handle language variables
$bbcode_tpl = preg_replace('/{L_([A-Z_]+)}/e', "(!empty(phpbb::\$user->lang['\$1'])) ? phpbb::\$user->lang['\$1'] : ucwords(strtolower(str_replace('_', ' ', '\$1')))", $bbcode_tpl);
if ($this->bbcode_data['second_pass_replace']) {
$this->bbcode->bbcode_cache[$this->contrib_id] = array('preg' => array($this->bbcode_data['second_pass_match'] => $bbcode_tpl));
} else {
$this->bbcode->bbcode_cache[$this->contrib_id] = array('str' => array($this->bbcode_data['second_pass_match'] => $bbcode_tpl));
}
$this->bbcode->bbcode_uid = $uid;
$this->bbcode->bbcode_second_pass($message);
return bbcode_nl2br($message);
}
示例4: get_html
function get_html($tree = null)
{
$str = '';
foreach ($this->tree as $item) {
if ('item' == $item['type']) {
continue;
}
$str .= $item['str'];
}
$bb = new bbcode();
$bb->tags = $this->tags;
$bb->mnemonics = $this->mnemonics;
$bb->autolinks = $this->autolinks;
$bb->parse($str);
return '<code class="bb_code">' . $bb->highlight() . '</code>';
}
示例5: getstr
function getstr($string, $length, $in_slashes = 0, $out_slashes = 0, $censor = 0, $bbcode = 0, $html = 0)
{
global $_G;
$string = trim($string);
if ($in_slashes) {
$string = dstripslashes($string);
}
if ($html < 0) {
$string = preg_replace("/(\\<[^\\<]*\\>|\r|\n|\\s|\\[.+?\\])/is", ' ', $string);
} elseif ($html == 0) {
$string = dhtmlspecialchars($string);
}
if ($censor) {
if (!class_exists('discuz_censor')) {
include libfile('class/censor');
}
$censor = discuz_censor::instance();
$censor->check($string);
if ($censor->modbanned() || $censor->modmoderated()) {
showmessage('word_banned');
}
}
if ($length) {
$string = cutstr($string, $length);
}
if ($bbcode) {
require_once DISCUZ_ROOT . './source/class/class_bbcode.php';
$bb =& bbcode::instance();
$string = $bb->bbcode2html($string, $bbcode);
}
if ($out_slashes) {
$string = daddslashes($string);
}
return trim($string);
}
示例6: modify_case_img
/**
* Changes the regex replacement for second pass
*
* @param object $event
* @return null
* @access public
*/
public function modify_case_img($event)
{
$bbcode_id = 4;
// [img] has bbcode_id 4 hardcoded
$bbcode_cache = $event['bbcode_cache'];
if (!isset($bbcode_cache[$bbcode_id]) || !$this->user->optionget('viewimg')) {
return;
}
$this->template->set_filenames(array('bbcode.html' => 'bbcode.html'));
$bbcode = new \bbcode();
// We need these otherwise we cannot use $bbcode->bbcode_tpl()
$bbcode->template_bitfield = new \bitfield($this->user->style['bbcode_bitfield']);
$bbcode->template_filename = $this->template->get_source_file_for_handle('bbcode.html');
$extimgaslink_boardurl = generate_board_url() . '/';
$bbcode_cache[$bbcode_id] = array('preg' => array('#\\[img:$uid\\](' . preg_quote($extimgaslink_boardurl, '#') . '.*?)\\[/img:$uid\\]#s' => $bbcode->bbcode_tpl('img', $bbcode_id), '#\\[img:$uid\\](.*?)\\[/img:$uid\\]#s' => str_replace('$2', $this->user->lang('EXTIMGLINK'), $bbcode->bbcode_tpl('url', $bbcode_id, true))));
$event['bbcode_cache'] = $bbcode_cache;
}
示例7: mail_read
function mail_read()
{
global $smarty;
$mail_id = (int) $_REQUEST['mail_id'];
$db_query = "\n\t\t\tSELECT \n\t\t\t\t`players`.`name` as 'from', \n\t\t\t\t`mail`.`mail_id`, \n\t\t\t\t`mail`.`from_player_id`, \n\t\t\t\t`mail`.`body`, \n\t\t\t\t`mail`.`subject`, \n\t\t\t\t`mail`.`time`, \n\t\t\t\t`mail`.`status` \n\t\t\tFROM `mail` \n\t\t\tLEFT JOIN `players` ON `players`.`player_id` = `mail`.`from_player_id` \n\t\t\tWHERE \n\t\t\t\t`mail`.`round_id` = '" . $_SESSION['round_id'] . "' AND \n\t\t\t\t`mail`.`mail_id` = '" . $mail_id . "' AND \n\t\t\t\t`mail`.`to_player_id` = '" . $_SESSION['player_id'] . "' AND \n\t\t\t\t`mail`.`status` != '" . MAILSTATUS_DELETED . "'\n\t\t\tORDER BY `time` ASC \n\t\t\tLIMIT 30";
$db_result = mysql_query($db_query);
if (mysql_num_rows($db_result) == 0) {
$status[] = 'That mail does not exist or you do not have permission to view it.';
$smarty->append('status', $status);
mail_list();
exit;
}
$mail = mysql_fetch_array($db_result, MYSQL_ASSOC);
$mail['time'] = format_timestamp($mail['time'] + 3600 * $_SESSION['preferences']['timezone']);
$mail['subject'] = htmlentities($mail['subject']);
$mail['body'] = nl2br(htmlentities($mail['body']));
if ($mail['from_player_id'] == 0) {
$mail['from'] = 'Administration';
}
$bbtags = array('b' => array('Name' => 'b', 'HtmlBegin' => '<span style="font-weight: bold;">', 'HtmlEnd' => '</span>'), 'i' => array('Name' => 'i', 'HtmlBegin' => '<span style="font-style: italic;">', 'HtmlEnd' => '</span>'), 'u' => array('Name' => 'u', 'HtmlBegin' => '<span style="text-decoration: underline;">', 'HtmlEnd' => '</span>'), 's' => array('Name' => 's', 'HtmlBegin' => '<span style="text-decoration: line-through;">', 'HtmlEnd' => '</span>'), 'quote' => array('Name' => 'quote', 'HasParam' => true, 'HtmlBegin' => '<b>Quote %%P%%:</b><div class="mailquote">', 'HtmlEnd' => '</div>'));
require_once dirname(__FILE__) . '/includes/bbcode.php';
$bbcode = new bbcode();
$bbcode->add_tag($bbtags['b']);
$bbcode->add_tag($bbtags['i']);
$bbcode->add_tag($bbtags['u']);
$bbcode->add_tag($bbtags['s']);
$bbcode->add_tag($bbtags['quote']);
$mail['body'] = $bbcode->parse_bbcode($mail['body']);
if ($mail['status'] == 1) {
$db_query = "UPDATE `mail` SET `status` = '2' WHERE `mail_id` = '" . $mail_id . "' LIMIT 1";
$db_result = mysql_query($db_query);
}
$smarty->assign('mail', $mail);
$smarty->display('mail_read.tpl');
}
示例8: bbcode_cache_init_end
/**
* Changes the regex replacement for second pass
*
* Based on phpBB.de - External Image as Link from Christian Schnegelberger<blackhawk87@phpbb.de> and Oliver Schramm <elsensee@phpbb.de>
*
* @param object $event
* @return null
* @access public
*/
public function bbcode_cache_init_end($event)
{
$bbcode_id = 4;
// [img] has bbcode_id 4 hardcoded
$bbcode_cache = $event['bbcode_cache'];
if (!isset($bbcode_cache[$bbcode_id]) || !$this->user->optionget('viewimg')) {
return;
}
$this->template->set_filenames(array('bbcode.html' => 'bbcode.html'));
$bbcode = new \bbcode();
// We need these otherwise we cannot use $bbcode->bbcode_tpl()
$bbcode->template_bitfield = new \bitfield($this->user->style['bbcode_bitfield']);
$bbcode->template_filename = $this->template->get_source_file_for_handle('bbcode.html');
$extimgaslink_boardurl = generate_board_url() . '/';
$url = $this->helper->route('tas2580_imageproxy_main', array());
$bbcode_cache[$bbcode_id] = array('preg' => array('#\\[img:$uid\\](' . preg_quote($extimgaslink_boardurl, '#') . '.*?)\\[/img:$uid\\]#s' => $bbcode->bbcode_tpl('img', $bbcode_id), '#\\[img:$uid\\](.*?)\\[/img:$uid\\]#s' => str_replace('$1', $url . '?img=$1', $bbcode->bbcode_tpl('img', $bbcode_id, true))));
$event['bbcode_cache'] = $bbcode_cache;
}
示例9: tohtml
public static function tohtml($text, $advanced = TRUE, $charset = 'utf8')
{
$basic_bbcode = array('[b]', '[/b]', '[i]', '[/i]', '[u]', '[/u]', '[s]', '[/s]', '[ul]', '[/ul]', '[li]', '[/li]', '[ol]', '[/ol]', '[center]', '[/center]', '[left]', '[/left]', '[right]', '[/right]');
$basic_html = array('<b>', '</b>', '<i>', '</i>', '<u>', '</u>', '<s>', '</s>', '<ul>', '</ul>', '<li>', '</li>', '<ol>', '</ol>', '<div style="text-align: center;">', '</div>', '<div style="text-align: left;">', '</div>', '<div style="text-align: right;">', '</div>');
$text = str_replace($basic_bbcode, $basic_html, $text);
if ($advanced) {
$advanced_bbcode = array('#\\[color=([a-zA-Z]*|\\#?[0-9a-fA-F]{6})](.+)\\[/color\\]#Usi', '#\\[size=([0-9][0-9]?)](.+)\\[/size\\]#Usi', '#\\[quote](\\r\\n)?(.+?)\\[/quote]#si', '#\\[quote=(.*?)](\\r\\n)?(.+?)\\[/quote]#si', '#\\[url](.+)\\[/url]#Usi', '#\\[url=(.+)](.+)\\[/url\\]#Usi', '#\\[email]([\\w\\.\\-]+@[a-zA-Z0-9\\-]+\\.?[a-zA-Z0-9\\-]*\\.\\w{1,4})\\[/email]#Usi', '#\\[email=([\\w\\.\\-]+@[a-zA-Z0-9\\-]+\\.?[a-zA-Z0-9\\-]*\\.\\w{1,4})](.+)\\[/email]#Usi', '#\\[img](.+)\\[/img]#Usi', '#\\[img=(.+)](.+)\\[/img]#Usi', '#\\[code](\\r\\n)?(.+?)(\\r\\n)?\\[/code]#si', '#\\[youtube]http://[a-z]{0,3}.youtube.com/watch\\?v=([0-9a-zA-Z]{1,11})\\[/youtube]#Usi', '#\\[youtube]([0-9a-zA-Z]{1,11})\\[/youtube]#Usi');
$advanced_html = array('<span style="color: $1">$2</span>', '<span style="font-size: $1px">$2</span>', "<div class=\"quote\"><span class=\"quoteby\">Disse:</span>\r\n\$2</div>", "<div class=\"quote\"><span class=\"quoteby\">Disse <b>\$1</b>:</span>\r\n\$3</div>", '<a rel="nofollow" target="_blank" href="$1">$1</a>', '<a rel="nofollow" target="_blank" href="$1">$2</a>', '<a href="mailto: $1">$1</a>', '<a href="mailto: $1">$2</a>', '<img src="$1" alt="$1" />', '<img src="$1" alt="$2" />', '<div class="codeblock"><code>$2</code></div>', '<object type="application/x-shockwave-flash" style="width: 450px; height: 366px;" data="http://www.youtube.com/v/$1"><param name="movie" value="http://www.youtube.com/v/$1" /><param name="wmode" value="transparent" /></object>', '<object type="application/x-shockwave-flash" style="width: 450px; height: 366px;" data="http://www.youtube.com/v/$1"><param name="movie" value="http://www.youtube.com/v/$1" /><param name="wmode" value="transparent" /></object>');
$text = preg_replace($advanced_bbcode, $advanced_html, $text);
}
return bbcode::nl2br($text);
}
示例10: isset
function get_html($tree = null)
{
$attr = ' class="bb"';
$width = isset($this->attrib['width']) ? $this->attrib['width'] : '';
if ($width) {
$attr .= ' width="' . htmlspecialchars($width) . '"';
}
$height = isset($this->attrib['height']) ? $this->attrib['height'] : '';
if ($height) {
$attr .= ' height="' . htmlspecialchars($height) . '"';
}
$align = isset($this->attrib['align']) ? $this->attrib['align'] : '';
if ($align) {
$attr .= ' align="' . htmlspecialchars($align) . '"';
}
$valign = isset($this->attrib['valign']) ? $this->attrib['valign'] : '';
if ($valign) {
$attr .= ' valign="' . htmlspecialchars($valign) . '"';
}
if (isset($this->attrib['colspan'])) {
$colspan = (int) $this->attrib['colspan'];
if ($colspan) {
$attr .= ' colspan="' . $colspan . '"';
}
}
if (isset($this->attrib['rowspan'])) {
$rowspan = (int) $this->attrib['rowspan'];
if ($rowspan) {
$attr .= ' rowspan="' . $rowspan . '"';
}
}
return '<th' . $attr . '>' . parent::get_html($this->tree) . '</th>';
}
示例11: isset
function get_html($tree = null)
{
$attr = ' class="bb"';
$border = isset($this->attrib['border']) ? (int) $this->attrib['border'] : null;
if (null !== $border) {
$attr .= ' border="' . $border . '"';
}
$width = isset($this->attrib['width']) ? $this->attrib['width'] : '';
if ($width) {
$attr .= ' width="' . htmlspecialchars($width) . '"';
}
$cellspacing = isset($this->attrib['cellspacing']) ? (int) $this->attrib['cellspacing'] : null;
if (null !== $cellspacing) {
$attr .= ' cellspacing="' . $cellspacing . '"';
}
$cellpadding = isset($this->attrib['cellpadding']) ? (int) $this->attrib['cellpadding'] : null;
if (null !== $cellpadding) {
$attr .= ' cellpadding="' . $cellpadding . '"';
}
$align = isset($this->attrib['align']) ? $this->attrib['align'] : '';
if ($align) {
$attr .= ' align="' . htmlspecialchars($align) . '"';
}
$str = '<table' . $attr . '>';
foreach ($this->tree as $key => $item) {
if ('text' == $item['type']) {
unset($this->tree[$key]);
}
}
$str .= parent::get_html($this->tree) . '</table>';
return $str;
}
示例12: switch
function get_html($tree = null)
{
$align = '';
if (isset($this->attrib['justify'])) {
$align = 'justify';
}
if (isset($this->attrib['left'])) {
$align = 'left';
}
if (isset($this->attrib['right'])) {
$align = 'right';
}
if (isset($this->attrib['center'])) {
$align = 'center';
}
if (!$align && isset($this->attrib['align'])) {
switch (strtolower($this->attrib['align'])) {
case 'left':
$align = 'left';
break;
case 'right':
$align = 'right';
break;
case 'center':
$align = 'center';
break;
case 'justify':
$align = 'justify';
break;
}
}
return '<div class="bb" align="' . $align . '">' . parent::get_html($this->tree) . '</div>';
}
示例13:
function get_html($tree = null)
{
$sign = '';
if (strlen($this->attrib['size'])) {
$sign = $this->attrib['size'][0];
}
if ('+' != $sign) {
$sign = '';
}
$size = (int) $this->attrib['size'];
if ($size >= 50 && $size <= 200) {
return '<font style="font-size:' . $size . '%">' . parent::get_html($this->tree) . '</font>';
}
if (7 < $size) {
$size = 7;
$sign = '';
}
if (-6 > $size) {
$size = '-6';
$sign = '';
}
if (0 == $size) {
$size = 3;
}
$size = $sign . $size;
return '<font size="' . $size . '">' . parent::get_html($this->tree) . '</font>';
}
示例14: switch
function get_html($tree = null)
{
$tag_name = 'ul';
$type = '';
switch ($this->tag) {
case 'ol':
$tag_name = 'ol';
$type = strtolower($this->attrib['ol']);
break;
case 'list':
if ($this->attrib['list']) {
$tag_name = 'ol';
}
$type = strtolower($this->attrib['list']);
$this->tag = 'del';
}
$attr = ' class="bb"';
if ('1' == $type) {
$attr .= ' type="1"';
} elseif ($type) {
$attr .= ' type="a"';
}
$str = '<' . $tag_name . $attr . '>' . parent::get_html() . '</' . $tag_name . '>';
return $str;
}
示例15: htmlspecialchars
function get_html($tree = null)
{
$attrib = 'class="bb"';
if ($this->attrib['abbr']) {
$attrib .= ' title="' . htmlspecialchars($this->attrib['abbr']) . '"';
}
return '<abbr ' . $attrib . '>' . parent::get_html($this->tree) . '</abbr>';
}