Ejemplo n.º 1
0
 /**
  * Get the parsed content of this post
  * @return string The parsed content of the post
  */
 public function getContent()
 {
     $message = $this->get('message');
     /* Check custom content parser setting */
     if ($this->xpdo->getOption('discuss.use_custom_post_parser', null, false)) {
         /* Load custom parser */
         $parsed = $this->xpdo->invokeEvent('OnDiscussPostCustomParser', array('content' => &$message));
         if (is_array($parsed)) {
             foreach ($parsed as $msg) {
                 if (!empty($msg)) {
                     $message = $msg;
                 }
             }
         } else {
             if (!empty($parsed)) {
                 $message = $parsed;
             }
         }
     } else {
         if (true) {
             $this->loadParser();
             $message = $this->parser->parse($message);
         }
     }
     /* Allow for plugin to change content of posts after it has been parsed */
     $rs = $this->xpdo->invokeEvent('OnDiscussPostFetchContent', array('content' => &$message));
     if (is_array($rs)) {
         foreach ($rs as $msg) {
             if (!empty($msg)) {
                 $message = $msg;
             }
         }
     } else {
         if (!empty($rs)) {
             $message = $rs;
         }
     }
     $message = $this->stripBBCode($message);
     return $message;
 }
Ejemplo n.º 2
0
 /**
  * Parse BBCode in post and return proper HTML. Supports SMF/Vanilla formats.
  *
  * @param $message The string to parse
  * @return string The parsed string with HTML instead of BBCode, and all code stripped
  */
 public function parseBBCode($message)
 {
     $parserClass = $this->xpdo->getOption('discuss.parser_class', null, 'disBBCodeParser');
     $parserClassPath = $this->xpdo->getOption('discuss.parser_class_path');
     if (empty($this->parser)) {
         if (empty($parserClassPath)) {
             $parserClassPath = $this->xpdo->discuss->config['modelPath'] . 'discuss/parser/';
         }
         $this->parser = $this->xpdo->getService('disParser', $parserClass, $parserClassPath);
     }
     if (empty($this->parser)) {
         /* If we can't find the parser, log an error and return an empty message. */
         $this->xpdo->log(modX::LOG_LEVEL_ERROR, 'Error loading signature parser ' . $parserClass . ' from ' . $parserClassPath);
         return '';
     }
     $allowedBBCodes = $this->xpdo->getOption('discuss.signatures.allowed_bbcodes', null, 'b,i,u,s,url,quote,pre,ul,ol,list,smileys,rtl,hr,color,size');
     $allowedBBCodes = explode(',', $allowedBBCodes);
     $message = $this->parser->parse($message, $allowedBBCodes);
     $message = str_replace(''', '’', $message);
     $message = $this->stripBBCode($message);
     return $message;
 }