Exemplo n.º 1
0
 /**
  * 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;
 }
Exemplo n.º 2
0
 /**
  * Gets a DecodaPhpEngine.
  *
  * @return DecodaPhpEngine
  */
 private function getPhpEngine()
 {
     if (null === $this->phpEngine) {
         $this->phpEngine = new PhpEngine();
         foreach ($this->options['templates'] as $template) {
             // Use bundle hierachy
             $paths = $this->locator->locate($template['path'], null, false);
             foreach ($paths as $path) {
                 $this->phpEngine->addPath($path);
             }
         }
         $decoda = new Decoda();
         $defaultPaths = $decoda->getEngine()->getPaths();
         foreach ($defaultPaths as $path) {
             $this->phpEngine->addPath($path);
         }
     }
     return $this->phpEngine;
 }
Exemplo n.º 3
0
 /**
  * Sets the path to the tag templates.
  *
  * @access public
  * @param  string $path
  * @return \Decoda\Engine|\FM\BbcodeBundle\Decoda\DecodaPhpEngine
  */
 public function setPath($path)
 {
     parent::setPath($path);
     return $this->addPath($path);
 }