Beispiel #1
0
 /**
  * Parse le content et retourne du HTML valide
  *
  */
 public function getContentHtml()
 {
     $code = new Decoda\Decoda($this->content);
     $code->defaults();
     $code->setXhtml(false);
     $code->setStrict(false);
     $code->setLineBreaks(true);
     return $code->parse();
 }
Beispiel #2
0
 /**
  * Affiche le contenue 
  *
  * @access public
  * @return HTML
  */
 public function getPreview()
 {
     $code = new Decoda\Decoda(Input::get('content'));
     $code->defaults();
     $code->setXhtml(false);
     $code->setStrict(false);
     $code->setLineBreaks(true);
     return $code->parse();
 }
Beispiel #3
0
 public function filter($text)
 {
     $config = array('escapeHtml' => false);
     $decoda = new Decoda\Decoda($text, $config);
     $decoda->setStrict(false);
     // $decoda->defaults();
     $decoda->addFilter(new \Decoda\Filter\DefaultFilter());
     $decoda->addFilter(new \Decoda\Filter\EmailFilter());
     $decoda->addFilter(new \Decoda\Filter\ImageFilter());
     $decoda->addFilter(new \Decoda\Filter\UrlFilter());
     $decoda->addFilter(new \Decoda\Filter\TextFilter());
     $decoda->addFilter(new \Decoda\Filter\VideoFilter());
     $decoda->addFilter(new \Decoda\Filter\CodeFilter());
     $decoda->addFilter(new \Decoda\Filter\QuoteFilter());
     $decoda->addFilter(new \Decoda\Filter\ListFilter());
     $decoda->addFilter(new \Decoda\Filter\TableFilter());
     $decoda->addFilter(new ComForumsBlock());
     $decoda->addHook(new \Decoda\Hook\ClickableHook());
     $parsed = $decoda->parse();
     $html = str_replace('<br />', '', $parsed);
     $nesting = array();
     $closing = array();
     $scope = array();
     $errors = array();
     foreach ($decoda->getErrors() as $error) {
         switch ($error['type']) {
             case Decoda\Decoda::ERROR_NESTING:
                 $nesting[] = $error['tag'];
                 break;
             case Decoda\Decoda::ERROR_CLOSING:
                 $closing[] = $error['tag'];
                 break;
             case Decoda\Decoda::ERROR_SCOPE:
                 $scope[] = $error['child'] . ' in ' . $error['parent'];
                 break;
         }
     }
     if (!empty($nesting)) {
         $errors[] = sprintf('The following tags have been nested in the wrong order: %s', implode(', ', $nesting));
     }
     if (!empty($closing)) {
         $errors[] = sprintf('The following tags have no closing tag: %s', implode(', ', $closing));
     }
     if (!empty($scope)) {
         $errors[] = sprintf('The following tags can not be placed within a specific tag: %s', implode(', ', $scope));
     }
     foreach ($errors as $error) {
         $string = '<div class="alert alert-error">';
         $string .= $error;
         $string .= '</div>';
         echo $string;
     }
     return $html;
 }
Beispiel #4
0
 public function bbcode($text)
 {
     $decoda = new Decoda\Decoda($text);
     $decoda->defaults();
     $decoda->setStrict(false);
     // $decoda->removeFilter('Video');
     $decoda->removeHook('Censor');
     //$decoda->removeFilter('Url');
     $html = $decoda->parse();
     // $errors = $decoda->getErrors();
     // foreach($errors as $error) {
     //     $string = "";
     //     foreach($error as $key => $value) {
     //         $string = $key . ":" . $value . ", ";
     //     }
     //     error_log($string);
     // }
     // print_r($errors);
     $nesting = array();
     $closing = array();
     $scope = array();
     $errors = array();
     foreach ($decoda->getErrors() as $error) {
         switch ($error['type']) {
             case Decoda\Decoda::ERROR_NESTING:
                 $nesting[] = $error['tag'];
                 break;
             case Decoda\Decoda::ERROR_CLOSING:
                 $closing[] = $error['tag'];
                 break;
             case Decoda\Decoda::ERROR_SCOPE:
                 $scope[] = $error['child'] . ' in ' . $error['parent'];
                 break;
         }
     }
     if (!empty($nesting)) {
         $errors[] = sprintf('The following tags have been nested in the wrong order: %s', implode(', ', $nesting));
     }
     if (!empty($closing)) {
         $errors[] = sprintf('The following tags have no closing tag: %s', implode(', ', $closing));
     }
     if (!empty($scope)) {
         $errors[] = sprintf('The following tags can not be placed within a specific tag: %s', implode(', ', $scope));
     }
     foreach ($errors as $error) {
         $string = '<div class="alert alert-error">';
         $string .= $error;
         $string .= '</div>';
         echo $string;
     }
     return $html;
     // return $decoda->parse();
     // return $text;
 }