Ejemplo n.º 1
0
 private static function parseInternal(vB5_Template_BbCode $parser, $text, $options = array(), $attachments = array())
 {
     if (!isset($options['allowhtml'])) {
         $options['allowhtml'] = false;
     }
     if (!isset($options['allowsmilies'])) {
         $options['allowsmilies'] = true;
     }
     if (!isset($options['allowbbcode'])) {
         $options['allowbbcode'] = true;
     }
     if (!isset($options['allowimagebbcode'])) {
         $options['allowimagebbcode'] = true;
     }
     if (isset($options['userid'])) {
         $parser->setParseUserinfo($options['userid']);
     }
     $parser->setAttachments($attachments);
     /*
      * If we have new attachments, we need to know whether it's an image or not so we can choose the correct
      * tag (img or a). We need to grab & check the file extension for that, which is saved in the filedata table.
      * Let's prefetch all of them so we don't have to hit the DB one at a time.
      */
     preg_match_all('#\\[attach(?:=(right|left|config))?\\]temp_(\\d+)_(\\d+)_(\\d+)\\[/attach\\]#i', $text, $matches);
     if (!empty($matches[2])) {
         $filedataids = array();
         foreach ($matches[2] as $filedataid) {
             $filedataids[$filedataid] = $filedataid;
         }
         $parser->prefetchFiledata($filedataids);
     }
     // Parse the bbcode
     $result = $parser->doParse($text, $options['allowhtml'], $options['allowsmilies'], $options['allowbbcode'], $options['allowimagebbcode']);
     return $result;
 }