function BBCodeParser($text = null) { $parser = new \SBBCodeParser\Node_Container_Document(); if ($text == null) { return $parser; } $parser->add_emoticons(array(':)' => asset('plugins/sceditor/emoticons/smile.png'), ':angel:' => asset('plugins/sceditor/emoticons/angel.png'), ':angry:' => asset('plugins/sceditor/emoticons/angry.png'), '8-)' => asset('plugins/sceditor/emoticons/cool.png'), ':'(' => asset('plugins/sceditor/emoticons/cwy.png'), ':ermm:' => asset('plugins/sceditor/emoticons/ermm.png'), ':D' => asset('plugins/sceditor/emoticons/grin.png'), '<3' => asset('plugins/sceditor/emoticons/heart.png'), ':(' => asset('plugins/sceditor/emoticons/sad.png'), ':O' => asset('plugins/sceditor/emoticons/shocked.png'), ':P' => asset('plugins/sceditor/emoticons/tongue.png'), ';)' => asset('plugins/sceditor/emoticons/wink.png'), ':alien:' => asset('plugins/sceditor/emoticons/alien.png'), ':blink:' => asset('plugins/sceditor/emoticons/blink.png'), ':blush:' => asset('plugins/sceditor/emoticons/blush.png'), ':cheerful:' => asset('plugins/sceditorplugins/sceditor/emoticons/cheerful.png'), ':devil:' => asset('plugins/sceditor/emoticons/devil.png'), ':dizzy:' => asset('plugins/sceditor/emoticons/dizzy.png'), ':getlost:' => asset('plugins/sceditor/emoticons/getlost.png'), ':happy:' => asset('plugins/sceditor/emoticons/happy.png'), ':kissing:' => asset('plugins/sceditor/emoticons/kissing.png'), ':ninja:' => asset('plugins/sceditor/emoticons/ninja.png'), ':pinch:' => asset('plugins/sceditor/emoticons/pinch.png'), ':pouty:' => asset('plugins/sceditor/emoticons/pouty.png'), ':sick:' => asset('plugins/sceditor/emoticons/sick.png'), ':sideways:' => asset('plugins/sceditor/emoticons/sideways.png'), ':silly:' => asset('plugins/sceditor/emoticons/silly.png'), ':sleeping:' => asset('plugins/sceditor/emoticons/sleeping.png'), ':unsure:' => asset('plugins/sceditor/emoticons/unsure.png'), ':woot:' => asset('plugins/sceditor/emoticons/w00t.png'), ':wassat:' => asset('plugins/sceditor/emoticons/wassat.png'), ':whistling:' => asset('plugins/sceditor/emoticons/whistling.png'), ':love:' => asset('plugins/sceditor/emoticons/wub.png'))); return $parser->parse($text)->detect_links()->detect_emails()->detect_emoticons()->get_html(); }
static function ParseBBCode($text, $message = null, $strip_inline_imgs = false, $no_div = false, $foruser = false) { if (substr($text, 0, 9) == "{RAWHTML}" && FSS_Settings::get('allow_raw_html_messages')) { $text = substr($text, 9); $text = self::filterText($text); return $text; } if ($strip_inline_imgs) { $text = preg_replace("/\\[img\\]data(.*)\\[\\/img\\]/i", "", $text); } require_once JPATH_SITE . DS . 'components' . DS . 'com_fss' . DS . 'helper' . DS . 'third' . DS . 'sbbcodeparser' . DS . 'sbbcodeparser.php'; $parser = new \SBBCodeParser\Node_Container_Document(true, false); if (FSS_Settings::get('sceditor_emoticons')) { $parser->add_emoticons(array(":)" => JURI::root() . "components/com_fss/assets/emoticons/smile.png", ":angel:" => JURI::root() . "components/com_fss/assets/emoticons/angel.png", ":angry:" => JURI::root() . "components/com_fss/assets/emoticons/angry.png", "8-)" => JURI::root() . "components/com_fss/assets/emoticons/cool.png", ":'(" => JURI::root() . "components/com_fss/assets/emoticons/cwy.png", ":ermm:" => JURI::root() . "components/com_fss/assets/emoticons/ermm.png", ":D" => JURI::root() . "components/com_fss/assets/emoticons/grin.png", "<3" => JURI::root() . "components/com_fss/assets/emoticons/heart.png", ":(" => JURI::root() . "components/com_fss/assets/emoticons/sad.png", ":O" => JURI::root() . "components/com_fss/assets/emoticons/shocked.png", ":P" => JURI::root() . "components/com_fss/assets/emoticons/tongue.png", ";)" => JURI::root() . "components/com_fss/assets/emoticons/wink.png", ":alien:" => JURI::root() . "components/com_fss/assets/emoticons/alien.png", ":blink:" => JURI::root() . "components/com_fss/assets/emoticons/blink.png", ":blush:" => JURI::root() . "components/com_fss/assets/emoticons/blush.png", ":cheerful:" => JURI::root() . "components/com_fss/assets/emoticons/cheerful.png", ":devil:" => JURI::root() . "components/com_fss/assets/emoticons/devil.png", ":dizzy:" => JURI::root() . "components/com_fss/assets/emoticons/dizzy.png", ":getlost:" => JURI::root() . "components/com_fss/assets/emoticons/getlost.png", ":happy:" => JURI::root() . "components/com_fss/assets/emoticons/happy.png", ":kissing:" => JURI::root() . "components/com_fss/assets/emoticons/kissing.png", ":ninja:" => JURI::root() . "components/com_fss/assets/emoticons/ninja.png", ":pinch:" => JURI::root() . "components/com_fss/assets/emoticons/pinch.png", ":pouty:" => JURI::root() . "components/com_fss/assets/emoticons/pouty.png", ":sick:" => JURI::root() . "components/com_fss/assets/emoticons/sick.png", ":sideways:" => JURI::root() . "components/com_fss/assets/emoticons/sideways.png", ":silly:" => JURI::root() . "components/com_fss/assets/emoticons/silly.png", ":sleeping:" => JURI::root() . "components/com_fss/assets/emoticons/sleeping.png", ":unsure:" => JURI::root() . "components/com_fss/assets/emoticons/unsure.png", ":woot:" => JURI::root() . "components/com_fss/assets/emoticons/w00t.png", ":wassat:" => JURI::root() . "components/com_fss/assets/emoticons/wassat.png", ":whistling:" => JURI::root() . "components/com_fss/assets/emoticons/whistling.png", ":love:" => JURI::root() . "components/com_fss/assets/emoticons/wub.png")); } $text = str_replace("\r\n", "\n", $text); $links = array(); $linkno = 1; while (stripos($text, "[url=") !== false) { $before = substr($text, 0, stripos($text, "[url=")); $rest = substr($text, stripos($text, "[url=") + 5); if (stripos($rest, "[/url]") !== false) { $end = substr($rest, stripos($rest, "[/url]") + 6); $link = substr($rest, 0, stripos($rest, "[/url]")); $url = substr($link, 0, strpos($link, "]")); $desc = substr($link, strpos($link, "]") + 1); // add http:// to www starting urls if (strpos($url, 'www') === 0) { $url = 'http://' . $url; } // add the base url to any urls not starting with http or ftp as they must be relative if (substr($url, 0, 4) !== 'http' && substr($url, 0, 3) !== 'ftp') { $url = JURI::root() . $url; } $linkid = "XXZZXX" . $linkno++ . "XXZZXX"; $target = FSS_Settings::get('ticket_link_target') ? '_blank' : ''; $sp = new \SBBCodeParser\Node_Container_Document(true, false); $desc = $sp->parse($desc)->get_html(false); $links[$linkid] = "<a href='{$url}' target='{$target}'>{$desc}</a>"; $text = $before . $linkid . $end; } else { break; } } // all inline images get replaced with this, so convert into proper image links depending on where we are in the system at the moment while (strpos($text, "[img attachment=") !== false) { $start = strpos($text, "[img attachment="); $end = strpos($text, "[/img]", $start); $content = substr($text, $start + 5, $end - $start - 6); list($temp, $attachid) = explode("=", $content); $replace = $attachid; if (is_object($foruser)) { $link = $foruser($attachid); } else { if ($foruser) { $link = JRoute::_('index.php?option=com_fss&view=ticket&ticketid=' . JRequest::getVar('ticketid') . '&fileid=' . $attachid, false); } else { $link = JRoute::_('index.php?option=com_fss&view=admin_support&task=attach.view&ticketid=' . JRequest::getVar('ticketid') . '&fileid=' . $attachid, false); } } $replace = '[img]' . $link . '[/img]'; $text = substr($text, 0, $start) . $replace . substr($text, $end + 6); } $text = str_replace("|", "|", $text); $output = $parser->parse($text)->detect_links()->detect_emails()->detect_emoticons()->get_html(false); $output = str_replace("&#124;", "|", $output); $output = str_replace("|", "|", $output); foreach ($links as $find => $replace) { $output = str_replace($find, $replace, $output); } //$parsed = str_replace("\n", "\\n", $output); //$parsed = str_replace("\r", "\\r", $parsed); $output = str_replace(array("\r\n", "\r", "\n"), "<br />", $output); $output = str_replace("&#91;", "[", $output); $output = str_replace("&#93;", "]", $output); //return "<pre>" . $up . "</pre>"."<pre>" . $parsed . "</pre>"."<div class='bbcode'>$output</div>"; if ($no_div) { return $output; } return "<div class='bbcode'>{$output}</div>"; }
<?php include 'classes/functions.php'; include 'classes/SBBCodeParser.php'; $functions = new accDBFunctions(); $parser = new \SBBCodeParser\Node_Container_Document(); // So now we update the steam account $functions->UpdateMessage($_POST['title'], $parser->parse($_POST['message'])->get_html()); header("refresh:0; url=index.php");
public function getNewParser() { $parser = new \SBBCodeParser\Node_Container_Document(); $bbcode = new \SBBCodeParser\BBCode('title', function ($content, $attribs) { $tag = trim(htmlspecialchars($content)); $att = $attribs['default']; if ($att == 'h1') { SBBCodeParser::$tree[] = array(1, $content, $tag); return "<h1 class=\"uk-h2\" id=\"{$tag}\">" . $content . "</h1>"; } else { if ($att == 'h2') { SBBCodeParser::$tree[] = array(2, $content, $tag); return "<h2 class=\"uk-h3\" id=\"{$tag}\">" . $content . "</h2>"; } else { if ($att == 'h3') { SBBCodeParser::$tree[] = array(3, $content, $tag); return "<h3 class=\"uk-h4\" id=\"{$tag}\">" . $content . "</h2>"; } else { if ($att == 'h4') { SBBCodeParser::$tree[] = array(4, $content, $tag); return "<h4 class=\"uk-h5\" id=\"{$tag}\">" . $content . "</h4>"; } else { if ($att == 'h5') { SBBCodeParser::$tree[] = array(5, $content, $tag); return "<h5 class=\"uk-h6\" id=\"{$tag}\">" . $content . "</h5>"; } } } } } }, \SBBCodeParser\BBCode::BLOCK_TAG, false, array(), array('text_node'), \SBBCodeParser\BBCode::AUTO_DETECT_EXCLUDE_ALL); $parser->add_bbcode($bbcode); $bbcode = new \SBBCodeParser\BBCode('codes', function ($content, $attribs) { if (isset($attribs['default']) && !empty($attribs['default'])) { $att = strtolower($attribs['default']); } else { $att = 'text'; } $brushes = array(); $brushes['actionscript3'] = 'shBrushAS3.js'; $brushes['as3,actionscript3'] = 'shBrushAS3.js'; $brushes['bash'] = 'shBrushBash.js'; $brushes['shell'] = 'shBrushBash.js'; $brushes['cf,coldfusion'] = 'shBrushColdFusion.js'; $brushes['cf'] = 'shBrushColdFusion.js'; $brushes['csharp'] = 'shBrushCSharp.js'; $brushes['c-sharp'] = 'shBrushCSharp.js'; $brushes['cpp'] = 'shBrushCpp.js'; $brushes['c'] = 'shBrushCpp.js'; $brushes['css'] = 'shBrushCss.js'; $brushes['delphi'] = 'shBrushDelphi.js'; $brushes['pas'] = '******'; $brushes['pascal'] = 'shBrushDelphi.js'; $brushes['patch'] = 'shBrushDiff.js'; $brushes['diff'] = 'shBrushDiff.js'; $brushes['erlang'] = 'shBrushErlang.js'; $brushes['erl'] = 'shBrushErlang.js'; $brushes['groovy'] = 'shBrushGroovy.js'; $brushes['js'] = 'shBrushJScript.js'; $brushes['jscript,'] = 'shBrushJScript.js'; $brushes['javascript'] = 'shBrushJScript.js'; $brushes['java'] = 'shBrushJava.js'; $brushes['javafx'] = 'shBrushJavaFX.js'; $brushes['jfx'] = 'shBrushJavaFX.js'; $brushes['pl'] = 'shBrushPerl.js'; $brushes['perl'] = 'shBrushPerl.js'; $brushes['php'] = 'shBrushPhp.js'; $brushes['text'] = 'shBrushPlain.js'; $brushes['plain'] = 'shBrushPlain.js'; $brushes['ps'] = 'shBrushPowerShell.js'; $brushes['powershell'] = 'shBrushPowerShell.js'; $brushes['py'] = 'shBrushPython.js'; $brushes['python'] = 'shBrushPython.js'; $brushes['rails'] = 'shBrushRuby.js'; $brushes['ror'] = 'shBrushRuby.js'; $brushes['ruby'] = 'shBrushRuby.js'; $brushes['scala'] = 'shBrushScala.js'; $brushes['sql'] = 'shBrushSql.js'; $brushes['vb'] = 'shBrushVb.js'; $brushes['vbnet'] = 'shBrushVb.js'; $brushes['xml'] = 'shBrushXml.js'; $brushes['xhtml'] = 'shBrushXml.js'; $brushes['xslt'] = 'shBrushXml.js'; $brushes['html'] = 'shBrushXml.js'; $brushes['xhtml'] = 'shBrushXml.js'; if (isset($brushes[$att])) { $js = $brushes[$att]; } else { $att = 'plain'; $js = $brushes['plain']; } $headers = \OWeb\manage\Headers::getInstance(); $headers->addHeader('syntaxHighlighter/shCore.js', \OWeb\manage\Headers::javascript); $headers->addHeader('syntaxHighlighter/' . $js, \OWeb\manage\Headers::js); $headers->addHeader('syntaxHighlighter/shCoreDefault.css', \OWeb\manage\Headers::css); \OWeb\utils\js\jquery\HeaderOnReadyManager::getInstance()->add("SyntaxHighlighter.config.bloggerMode = true;\n\t\t\t\t\t\t\tSyntaxHighlighter.defaults['toolbar'] = true;\n\t\t\t\t\t\t\tSyntaxHighlighter.all();"); $content = str_replace("<br />", "", $content); return '<pre class="brush: ' . $att . ';">' . $content . '</pre>'; }, \SBBCodeParser\BBCode::BLOCK_TAG, false, array(), array(), \SBBCodeParser\BBCode::AUTO_DETECT_EXCLUDE_ALL); $parser->add_bbcode($bbcode); $parser->add_emoticons(array(':D' => OWEB_HTML_URL_IMG . '/icons/01.png', 'OD' => OWEB_HTML_URL_IMG . '/icons/02.png', ':)' => OWEB_HTML_URL_IMG . '/icons/03.png', ';)' => OWEB_HTML_URL_IMG . '/icons/04.png', '8)' => OWEB_HTML_URL_IMG . '/icons/05.png')); return $parser; }