Esempio n. 1
0
 /**
  * Get the state of the entry as either text or numerical value
  *
  * @param   string  $as      Format to return state in [text, number]
  * @param   integer $shorten Number of characters to shorten text to
  * @return  mixed   String or Integer
  */
 public function content($as = 'parsed', $shorten = 0)
 {
     $as = strtolower($as);
     $options = array();
     switch ($as) {
         case 'parsed':
             $content = $this->get('content.parsed', null);
             if ($content === null) {
                 $config = array('option' => 'com_forum', 'scope' => 'forum', 'pagename' => 'forum', 'pageid' => $this->get('thread'), 'filepath' => '', 'domain' => $this->get('thread'));
                 $attach = new Tables\Attachment($this->_db);
                 $content = (string) stripslashes($this->get('comment', ''));
                 $this->importPlugin('content')->trigger('onContentPrepare', array($this->_context, &$this, &$config));
                 $this->set('content.parsed', (string) $this->get('comment', ''));
                 $this->set('content.parsed', $this->get('content.parsed') . $attach->getAttachment($this->get('id'), $this->link('download'), $this->_config));
                 $this->set('comment', $content);
                 return $this->content($as, $shorten);
             }
             $options['html'] = true;
             break;
         case 'clean':
             $content = strip_tags($this->content('parsed'));
             break;
         case 'raw':
         default:
             $content = $this->get('comment');
             $content = preg_replace('/^(<!-- \\{FORMAT:.*\\} -->)/i', '', $content);
             break;
     }
     if ($shorten) {
         $content = String::truncate($content, $shorten, $options);
     }
     return $content;
 }