/** * Process bbcode inside a string * @since Version 3.10.0 * @param string|DOMDocument $string The HTML or text block to process * @return DOMDocument */ public static function Process($string, $doBbcode = true) { if (!$doBbcode) { return $string; } $timer = Debug::getTimer(); /** * Pre-process the string before we send it through the BBCode parser */ $string = self::preProcessBBCodeUIDs($string); $parser = new Decoda($string); $parser->addPath(__DIR__ . DIRECTORY_SEPARATOR . 'BbcodeEtc' . DIRECTORY_SEPARATOR); $emoticonConfig = ['path' => '//static.railpage.com.au/images/smiles/', 'extension' => 'gif']; $engine = new DecodaPhpEngine(); $engine->addPath(__DIR__ . DIRECTORY_SEPARATOR . 'BbcodeEtc' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR); $parser->setEngine($engine); $parser->defaults(); $parser->setStrict(false); $parser->setLineBreaks(false); $parser->removeHook('Emoticon'); $parser->addFilter(new RailpageImageFilter()); $string = $parser->parse(); $string = html_entity_decode($string); // Fix: if I set escapeHtml in the Decoda options, it fails to auto linkify links //$string = wpautop($string); Debug::LogEvent(__METHOD__, $timer); return $string; }
public function __invoke($request) { $url = $this->view->basePath(); $bbcode = new Decoda($request); $bbcode->defaults(); $bbcode->addHook(new EmoticonHook(array('path' => $url . '/images/emoticons/'))); return $bbcode->parse(); }
public function Parse($string) { $code = new Decoda($string); $code->defaults(); $code->addFilter(new \Decoda\Filter\CodeFilter()); $code->addHook(new \Decoda\Hook\EmoticonHook()); $code->addHook(new \Decoda\Hook\CensorHook()); return $code->parse(); }
public function textToBBcode($text) { $whitelist = explode(",", Settings::get('whitelist_tags')); $code = new Decoda\Decoda($text, array('xhtmlOutput' => true, 'strictMode' => false, 'escapeHtml' => false)); $code->addFilter(new \Decoda\Filter\ImageFilter()); $code->addHook(new \Decoda\Hook\EmoticonHook(array('path' => URL::to('plugins/shahiemseymor/bbcode/emoticons') . '/'))); $code->whitelist($whitelist)->addFilter(new \Decoda\Filter\DefaultFilter()); if (trim(Settings::get('language')) != '') { $code->setLocale(Settings::get('language')); } if (Settings::get('shorthand') == TRUE) { $code->addFilter(new \Decoda\Filter\EmailFilter())->addFilter(new \Decoda\Filter\UrlFilter())->setShorthand($text); } $code->defaults(); return $code->parse(); }