本文整理汇总了PHP中BBCode类的典型用法代码示例。如果您正苦于以下问题:PHP BBCode类的具体用法?PHP BBCode怎么用?PHP BBCode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BBCode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: strip
private function strip($in)
{
$bb = new BBCode();
$tfe = new TextFormattingEvent($in);
$bb->receive_event($tfe);
return $tfe->stripped;
}
示例2: nbbc
/**
* @return BBCode;
*/
public function nbbc()
{
if ($this->_NBBC === null) {
$plugin = new BBCode();
$this->_NBBC = $plugin->nbbc();
$this->_NBBC->setIgnoreNewlines(true);
$this->_NBBC->addRule('attachment', array('mode' => Nbbc\BBCode::BBCODE_MODE_CALLBACK, 'method' => array($this, "DoAttachment"), 'class' => 'image', 'allow_in' => array('listitem', 'block', 'columns', 'inline', 'link'), 'end_tag' => Nbbc\BBCode::BBCODE_PROHIBIT, 'content' => Nbbc\BBCode::BBCODE_PROHIBIT, 'plain_start' => "[image]", 'plain_content' => array()));
}
return $this->_NBBC;
}
示例3: 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;
}
示例4: Parse
function Parse($string)
{
global $config;
require_once dirname(__FILE__) . '/nbbc/nbbc.php';
$setup = new BBCode();
if (!isset($config)) {
// old compatibility mode
$setup->SetSmileyURL(baseaddress() . 'smileys');
} else {
$setup->SetSmileyURL($config->getValue('baseaddress') . 'smileys');
}
// $setup->SetEnableSmileys(false);
$setup->SetAllowAmpersand(true);
// escape (x)html entities
return $setup->Parse(htmlent($string));
}
示例5: __construct
/**
* Create new BBCode object and initialize our own settings
*
* @param string $text
*/
public function __construct($text = null)
{
parent::BBCode();
$this->text = $text;
// Automagically print hrefs
$this->SetDetectURLs(true);
// We have our own smileys
$config = Kohana::$config->load('site.smiley');
if (!empty($config)) {
$this->ClearSmileys();
$this->SetSmileyURL(URL::base() . $config['dir']);
foreach ($config['smileys'] as $name => $smiley) {
$this->AddSmiley($name, $smiley['src']);
}
} else {
$this->SetEnableSmileys(false);
}
// We handle newlines with Kohana
//$this->SetIgnoreNewlines(true);
$this->SetPreTrim('a');
$this->SetPostTrim('a');
// User our own quote
$this->AddRule('quote', array('mode' => BBCODE_MODE_CALLBACK, 'method' => array($this, 'bbcode_quote'), 'class' => 'block', 'allow_in' => array('listitem', 'block', 'columns'), 'content' => BBCODE_REQUIRED));
// Media tags
$this->AddRule('audio', array('mode' => BBCODE_MODE_CALLBACK, 'method' => array($this, 'bbcode_media'), 'class' => 'block', 'allow_in' => array('listitem', 'block', 'columns', 'inline'), 'allow' => array('align' => '/^left|center|right$/'), 'default' => array('align' => 'left'), 'content' => BBCODE_REQUIRED, 'plain_content' => array('')));
$this->AddRule('video', array('mode' => BBCODE_MODE_CALLBACK, 'method' => array($this, 'bbcode_media'), 'class' => 'block', 'allow_in' => array('listitem', 'block', 'columns', 'inline'), 'allow' => array('align' => '/^left|center|right$/'), 'default' => array('align' => 'left'), 'content' => BBCODE_REQUIRED, 'plain_content' => array('')));
}
示例6: ShowSendMessagesPage
function ShowSendMessagesPage()
{
global $USER, $LNG;
$ACTION = HTTP::_GP('action', '');
if ($ACTION == 'send') {
switch ($USER['authlevel']) {
case AUTH_MOD:
$class = 'mod';
break;
case AUTH_OPS:
$class = 'ops';
break;
case AUTH_ADM:
$class = 'admin';
break;
default:
$class = '';
break;
}
$Subject = HTTP::_GP('subject', '', true);
$Message = HTTP::_GP('text', '', true);
$Mode = HTTP::_GP('mode', 0);
$Lang = HTTP::_GP('lang', '');
if (!empty($Message) && !empty($Subject)) {
require 'includes/classes/BBCode.class.php';
if ($Mode == 0 || $Mode == 2) {
$From = '<span class="' . $class . '">' . $LNG['user_level'][$USER['authlevel']] . ' ' . $USER['username'] . '</span>';
$pmSubject = '<span class="' . $class . '">' . $Subject . '</span>';
$pmMessage = '<span class="' . $class . '">' . BBCode::parse($Message) . '</span>';
$USERS = $GLOBALS['DATABASE']->query("SELECT `id`, `username` FROM " . USERS . " WHERE `universe` = '" . Universe::getEmulated() . "'" . (!empty($Lang) ? " AND `lang` = '" . $GLOBALS['DATABASE']->sql_escape($Lang) . "'" : "") . ";");
while ($UserData = $GLOBALS['DATABASE']->fetch_array($USERS)) {
$sendMessage = str_replace('{USERNAME}', $UserData['username'], $pmMessage);
PlayerUtil::sendMessage($UserData['id'], $USER['id'], $From, 50, $pmSubject, $sendMessage, TIMESTAMP, NULL, 1, Universe::getEmulated());
}
}
if ($Mode == 1 || $Mode == 2) {
require 'includes/classes/Mail.class.php';
$userList = array();
$USERS = $GLOBALS['DATABASE']->query("SELECT `email`, `username` FROM " . USERS . " WHERE `universe` = '" . Universe::getEmulated() . "'" . (!empty($Lang) ? " AND `lang` = '" . $GLOBALS['DATABASE']->sql_escape($Lang) . "'" : "") . ";");
while ($UserData = $GLOBALS['DATABASE']->fetch_array($USERS)) {
$userList[$UserData['email']] = array('username' => $UserData['username'], 'body' => BBCode::parse(str_replace('{USERNAME}', $UserData['username'], $Message)));
}
Mail::multiSend($userList, strip_tags($Subject));
}
exit($LNG['ma_message_sended']);
} else {
exit($LNG['ma_subject_needed']);
}
}
$sendModes = $LNG['ma_modes'];
if (Config::get()->mail_active == 0) {
unset($sendModes[1]);
unset($sendModes[2]);
}
$template = new template();
$template->assign_vars(array('langSelector' => array_merge(array('' => $LNG['ma_all']), $LNG->getAllowedLangs(false)), 'modes' => $sendModes));
$template->show('SendMessagesPage.tpl');
}
示例7: 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>';
}
示例8: __construct
/**
* Object Constructor
*
* @param
* @return void
* @since 1.0
*/
function __construct() {
parent::__construct ();
$this->defaults = new KunenaBBCodeLibrary;
$this->tag_rules = $this->defaults->default_tag_rules;
$this->smileys = $this->defaults->default_smileys;
if (empty($this->smileys)) $this->SetEnableSmileys(false);
$this->SetSmileyDir ( JPATH_ROOT .'/'. KPATH_COMPONENT_RELATIVE );
$this->SetSmileyURL ( JURI::root(true) . '/' . KPATH_COMPONENT_RELATIVE );
$this->SetDetectURLs ( true );
}
示例9: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$sujet = ForumSubjects::where("id", $id)->first();
$categorie = ForumCategories::find($sujet->category);
foreach ($sujet->messages as $message) {
Date::setLocale('fr');
$date = new Date($message->created);
$message->when = $date->format('j F Y');
$message->message = $this::text_humanized($message->message);
$message->message = BBCode::parse($message->message);
}
return view('forum.sujets.show', ['categorie' => $categorie, "sujet" => $sujet]);
}
示例10: __construct
/**
* Create new BBCode object and initialize our own settings
*
*/
public function __construct($text = null)
{
parent::BBCode();
$this->text = $text;
// Automagically print hrefs
$this->SetDetectURLs(true);
// We have our own smileys
$config = Kohana::config('site.smiley');
if (!empty($config)) {
$this->ClearSmileys();
$this->SetSmileyURL(url::base() . $config['dir']);
foreach ($config['smileys'] as $name => $smiley) {
$this->AddSmiley($name, $smiley['src']);
}
} else {
$this->SetEnableSmileys(false);
}
// We handle newlines with Kohana
$this->SetIgnoreNewlines(true);
$this->SetPreTrim('a');
$this->SetPostTrim('a');
// User our own quote
$this->AddRule('quote', array('mode' => BBCODE_MODE_CALLBACK, 'method' => array($this, 'bbcode_quote'), 'class' => 'block', 'allow_in' => array('listitem', 'block', 'columns'), 'content' => BBCODE_REQUIRED));
}
示例11: foreach
<?php
if (!$published || !empty($revision) || !empty($preview)) {
?>
<br /><br />
<blockquote>
<strong>Description:</strong><br />
<?php
echo $description;
?>
</blockquote>
<?php
}
?>
<p><?php
echo BBCode::parse($body);
?>
</p>
<?php
if (!empty($mlt)) {
?>
<p><h4>More Like This:</h4>
<?php
foreach ($mlt as $fetched) {
echo '<a href="' . Url::format('article/view/' . Id::create($fetched, 'news')) . '">' . $fetched['title'] . '</a><br />';
}
?>
</p>
<?php
}
示例12: callback_html
/**
* This callback processes any custom BBCodes with parser.php
*/
protected function callback_html($field)
{
// Strips Invision custom HTML first from $field before parsing $field to parser.php
$invision_markup = $field;
$invision_markup = html_entity_decode($invision_markup);
// Replace '[html]' with '<pre><code>'
$invision_markup = preg_replace('/\\[html\\]/', '<pre><code>', $invision_markup);
// Replace '[/html]' with '</code></pre>'
$invision_markup = preg_replace('/\\[\\/html\\]/', '</code></pre>', $invision_markup);
// Replace '[sql]' with '<pre><code>'
$invision_markup = preg_replace('/\\[sql\\]/', '<pre><code>', $invision_markup);
// Replace '[/sql]' with '</code></pre>'
$invision_markup = preg_replace('/\\[\\/sql\\]/', '</code></pre>', $invision_markup);
// Replace '[php]' with '<pre><code>'
$invision_markup = preg_replace('/\\[php\\]/', '<pre><code>', $invision_markup);
// Replace '[/php]' with '</code></pre>'
$invision_markup = preg_replace('/\\[\\/php\\]/', '</code></pre>', $invision_markup);
// Replace '[xml]' with '<pre><code>'
$invision_markup = preg_replace('/\\[xml\\]/', '<pre><code>', $invision_markup);
// Replace '[/xml]' with '</code></pre>'
$invision_markup = preg_replace('/\\[\\/xml\\]/', '</code></pre>', $invision_markup);
// Replace '[CODE]' with '<pre><code>'
$invision_markup = preg_replace('/\\[CODE\\]/', '<pre><code>', $invision_markup);
// Replace '[/CODE]' with '</code></pre>'
$invision_markup = preg_replace('/\\[\\/CODE\\]/', '</code></pre>', $invision_markup);
// Replace '[quote:XXXXXXX]' with '<blockquote>'
$invision_markup = preg_replace('/\\[quote:(.*?)\\]/', '<blockquote>', $invision_markup);
// Replace '[quote="$1"]' with '<em>@$1 wrote:</em><blockquote>'
$invision_markup = preg_replace('/\\[quote="(.*?)":(.*?)\\]/', '<em>@$1 wrote:</em><blockquote>', $invision_markup);
// Replace '[/quote:XXXXXXX]' with '</blockquote>'
$invision_markup = preg_replace('/\\[\\/quote:(.*?)\\]/', '</blockquote>', $invision_markup);
// Replace '[twitter]$1[/twitter]' with '<a href="https://twitter.com/$1">@$1</a>"
$invision_markup = preg_replace('/\\[twitter\\](.*?)\\[\\/twitter\\]/', '<a href="https://twitter.com/$1">@$1</a>', $invision_markup);
// Replace '[member='username']' with '@username"
$invision_markup = preg_replace('/\\[member=\'(.*?)\'\\]/', '@$1 ', $invision_markup);
// Replace '[media]' with ''
$invision_markup = preg_replace('/\\[media\\]/', '', $invision_markup);
// Replace '[/media]' with ''
$invision_markup = preg_replace('/\\[\\/media\\]/', '', $invision_markup);
// Replace '[list:XXXXXXX]' with '<ul>'
$invision_markup = preg_replace('/\\[list\\]/', '<ul>', $invision_markup);
// Replace '[list=1:XXXXXXX]' with '<ul>'
$invision_markup = preg_replace('/\\[list=1\\]/', '<ul>', $invision_markup);
// Replace '[*:XXXXXXX]' with '<li>'
$invision_markup = preg_replace('/\\[\\*\\](.*?)\\<br \\/\\>/', '<li>$1</li>', $invision_markup);
// Replace '[/list:u:XXXXXXX]' with '</ul>'
$invision_markup = preg_replace('/\\[\\/list\\]/', '</ul>', $invision_markup);
// Replace '[hr]' with '<hr>"
$invision_markup = preg_replace('/\\[hr\\]/', '<hr>', $invision_markup);
// Replace '[font=XXXXXXX]' with ''
$invision_markup = preg_replace('/\\[font=(.*?)\\]/', '', $invision_markup);
// Replace '[/font]' with ''
$invision_markup = preg_replace('/\\[\\/font\\]/', '', $invision_markup);
// Replace any Invision smilies from path '/sp-resources/forum-smileys/sf-smily.gif' with the equivelant WordPress Smilie
$invision_markup = preg_replace('/\\<img src=(.*?)EMO\\_DIR(.*?)bbc_emoticon(.*?)alt=\'(.*?)\' \\/\\>/', '$4', $invision_markup);
$invision_markup = preg_replace('/\\:angry\\:/', ':mad:', $invision_markup);
$invision_markup = preg_replace('/\\:mellow\\:/', ':neutral:', $invision_markup);
$invision_markup = preg_replace('/\\:blink\\:/', ':eek:', $invision_markup);
$invision_markup = preg_replace('/B\\)/', ':cool:', $invision_markup);
$invision_markup = preg_replace('/\\:rolleyes\\:/', ':roll:', $invision_markup);
$invision_markup = preg_replace('/\\:unsure\\:/', ':???:', $invision_markup);
// Now that Invision custom HTML has been stripped put the cleaned HTML back in $field
$field = $invision_markup;
require_once bbpress()->admin->admin_dir . 'parser.php';
$bbcode = BBCode::getInstance();
$bbcode->enable_smileys = false;
$bbcode->smiley_regex = false;
return html_entity_decode($bbcode->Parse($field));
}
示例13: saveInfo
/**
* This is save info function, use it whatever saving or updating
*
* @param string $lowerItem
* @param array $fields
* @param array $systemFields
* @param string $actionType
* @return array
*/
public function saveInfo($lowerItem, $fields, $systemFields, $actionType, $compatible = false)
{
$item = ucfirst($lowerItem);
$modelName = $item . 'InfoView';
$model = new $modelName();
$basicInfoFields = array_keys($model->attributes);
$basicInfoFields[] = 'action_note';
$basicInfo = array();
$customInfo = array();
$isNeedBBCodeTransfer = true;
if (isset($fields['no_bbcode_transfer']) && !empty($fields['no_bbcode_transfer'])) {
$isNeedBBCodeTransfer = false;
}
foreach ($fields as $key => $field) {
if (in_array($key, $systemFields)) {
continue;
}
if ($compatible) {
if ('AssignedTo' == $key || 'ScriptedBy' == $key) {
$field = $this->getRealNameByName($field);
} else {
if ('MailTo' == $key) {
$field = $this->getRealNamesByMailTo($field);
}
}
$key = $this->fieldOld2New($key, $lowerItem);
}
if ($isNeedBBCodeTransfer && in_array($key, array('action_note', 'repeat_step', 'case_step', 'result_step'))) {
$field = BBCode::bbcode2html($field);
}
if ('no_bbcode_transfer' != $key && !in_array($key, $basicInfoFields)) {
$customInfo[$key] = $field;
continue;
}
$basicInfo[$key] = $field;
}
if (Info::ACTION_OPEN == $actionType && isset($basicInfo['id'])) {
unset($basicInfo['id']);
}
if (Info::ACTION_OPEN_EDIT == $actionType && 'bug' == $lowerItem && isset($basicInfo['id'])) {
$bug = BugInfo::model()->findByPk($basicInfo['id']);
if (!isset($basicInfo['bug_status'])) {
$basicInfo['bug_status'] = $bug->bug_status;
}
if (null !== $bug) {
switch ($basicInfo['bug_status']) {
case BugInfo::STATUS_ACTIVE:
if (BugInfo::STATUS_ACTIVE !== $bug->bug_status) {
$actionType = BugInfo::ACTION_ACTIVATE;
} else {
$actionType = BugInfo::ACTION_OPEN_EDIT;
}
break;
case BugInfo::STATUS_RESOLVED:
if (BugInfo::STATUS_RESOLVED !== $bug->bug_status) {
$actionType = BugInfo::ACTION_RESOLVE;
} else {
$actionType = BugInfo::ACTION_RESOLVE_EDIT;
}
break;
case BugInfo::STATUS_CLOSED:
if (BugInfo::STATUS_CLOSED !== $bug->bug_status) {
$actionType = BugInfo::ACTION_CLOSE;
} else {
$actionType = BugInfo::ACTION_CLOSE_EDIT;
}
break;
default:
break;
}
}
}
$code = API::ERROR_NONE;
$attachmentFile = CUploadedFile::getInstancesByName('attachment_file');
$result = InfoService::saveInfo($lowerItem, $actionType, $basicInfo, $customInfo, $attachmentFile);
$info = $result['detail'];
if (CommonService::$ApiResult['FAIL'] === $result['status']) {
$code = API::ERROR_SAVE_INFO;
}
return array($code, $info);
}
示例14: view
function view()
{
global $USER, $LNG;
require 'includes/classes/BBCode.class.php';
$db = Database::get();
$ticketID = HTTP::_GP('id', 0);
$sql = "SELECT a.*, t.categoryID, t.status FROM %%TICKETS_ANSWER%% a INNER JOIN %%TICKETS%% t USING(ticketID) WHERE a.ticketID = :ticketID ORDER BY a.answerID;";
$answerResult = $db->select($sql, array(':ticketID' => $ticketID));
$answerList = array();
if (empty($answerResult)) {
$this->printMessage(sprintf($LNG['ti_not_exist'], $ticketID), array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=ticket')));
}
$ticket_status = 0;
foreach ($answerResult as $answerRow) {
$answerRow['time'] = _date($LNG['php_tdformat'], $answerRow['time'], $USER['timezone']);
$answerRow['message'] = BBCode::parse($answerRow['message']);
$answerList[$answerRow['answerID']] = $answerRow;
if (empty($ticket_status)) {
$ticket_status = $answerRow['status'];
}
}
$categoryList = $this->ticketObj->getCategoryList();
$this->assign(array('ticketID' => $ticketID, 'categoryList' => $categoryList, 'answerList' => $answerList, 'status' => $ticket_status));
$this->display('page.ticket.view.tpl');
}
示例15: login_session_refresh
<?php
require '../include/mellivora.inc.php';
login_session_refresh();
head('Home');
if (cache_start('home', CONFIG_CACHE_TIME_HOME)) {
require CONFIG_PATH_THIRDPARTY . 'nbbc/nbbc.php';
$bbc = new BBCode();
$bbc->SetEnableSmileys(false);
$news = db_query_fetch_all('SELECT * FROM news ORDER BY added DESC');
foreach ($news as $item) {
echo '
<div class="news-container">';
section_head($item['title']);
echo '
<div class="news-body">
', $bbc->parse($item['body']), '
</div>
</div>
';
}
cache_end('home');
}
foot();