예제 #1
0
 /**
  * @desc Parses the parser content from BBCode to XHTML.
  * @return void You will find the result by using the get_content method
  */
 public function parse()
 {
     $this->content = TextHelper::html_entity_decode($this->content);
     //On supprime d'abord toutes les occurences de balises CODE que nous réinjecterons à la fin pour ne pas y toucher
     if (!in_array('code', $this->forbidden_tags)) {
         $this->pick_up_tag('code', '=[A-Za-z0-9#+-]+(?:,[01]){0,2}');
     }
     //On prélève tout le code HTML afin de ne pas l'altérer
     if (!in_array('html', $this->forbidden_tags) && AppContext::get_current_user()->check_auth($this->html_auth, 1)) {
         $this->pick_up_tag('html');
     }
     //Ajout des espaces pour éviter l'absence de parsage lorsqu'un séparateur de mot est éxigé
     $this->content = ' ' . $this->content . ' ';
     //Traitement du code HTML
     $this->protect_content();
     //Traitement des smilies
     $this->parse_smilies();
     //Interprétation des sauts de ligne
     $this->content = nl2br($this->content);
     // BBCode simple tags
     $this->parse_simple_tags();
     //Tableaux
     if (!in_array('table', $this->forbidden_tags) && strpos($this->content, '[table') !== false) {
         $this->parse_table();
     }
     //Listes
     if (!in_array('list', $this->forbidden_tags) && strpos($this->content, '[list') !== false) {
         $this->parse_list();
     }
     //On remet le code HTML mis de côté
     if (!empty($this->array_tags['html'])) {
         $this->array_tags['html'] = array_map(create_function('$string', 'return str_replace("[html]", "<!-- START HTML -->\\n", str_replace("[/html]", "\\n<!-- END HTML -->", $string));'), $this->array_tags['html']);
         $this->reimplant_tag('html');
     }
     parent::parse();
     //On réinsère les fragments de code qui ont été prévelevés pour ne pas les considérer
     if (!empty($this->array_tags['code'])) {
         $this->array_tags['code'] = array_map(create_function('$string', 'return preg_replace(\'`^\\[code(=.+)?\\](.+)\\[/code\\]$`isU\', \'[[CODE$1]]$2[[/CODE]]\', TextHelper::htmlspecialchars($string, ENT_NOQUOTES));'), $this->array_tags['code']);
         $this->reimplant_tag('code');
     }
 }
예제 #2
0
 /**
  * @desc Parses the content of the parser.
  * Translates the whole content from the TinyMCE syntax to the PHPBoost one.
  */
 public function parse()
 {
     $this->content = TextHelper::html_entity_decode($this->content);
     //On supprime d'abord toutes les occurences de balises CODE que nous réinjecterons à la fin pour ne pas y toucher
     if (!in_array('code', $this->forbidden_tags)) {
         $this->pick_up_tag('code', '=[A-Za-z0-9#+-]+(?:,[01]){0,2}');
     }
     //On prélève tout le code HTML afin de ne pas l'altérer
     if (!in_array('html', $this->forbidden_tags) && AppContext::get_current_user()->check_auth($this->html_auth, 1)) {
         $this->pick_up_tag('html');
     }
     //Prepare the content (HTML modifications such as entities treatment)
     $this->prepare_content();
     //Parse the HTML code generated by TinyMCE
     $this->parse_tinymce_formatting();
     //Parse the HTML tables generated by TinyMCE
     if (!in_array('table', $this->forbidden_tags)) {
         $this->parse_tables();
     }
     //Replace smilies code by smilies images
     $this->parse_smilies();
     //Parse the tags which are not supported by TinyMCE but expected in BBCode
     $this->parse_bbcode_tags();
     $this->correct();
     //On remet le code HTML mis de côté
     if (!empty($this->array_tags['html'])) {
         $this->array_tags['html'] = array_map(create_function('$string', 'return str_replace("[html]", "<!-- START HTML -->\\n", str_replace("[/html]", "\\n<!-- END HTML -->", $string));'), $this->array_tags['html']);
         //If we don't protect the HTML code inserted into the tags code and HTML TinyMCE will parse it!
         $this->array_tags['html'] = array_map(array('TinyMCEParser', 'clear_html_and_code_tag'), $this->array_tags['html']);
         $this->reimplant_tag('html');
     }
     parent::parse();
     //On réinsère les fragments de code qui ont été prélevés pour ne pas les considérer
     if (!empty($this->array_tags['code'])) {
         $this->array_tags['code'] = array_map(create_function('$string', 'return preg_replace(\'`^\\[code(=.+)?\\](.+)\\[/code\\]$`isU\', \'[[CODE$1]]$2[[/CODE]]\', TextHelper::htmlspecialchars($string, ENT_NOQUOTES));'), $this->array_tags['code']);
         //If we don't protect the HTML code inserted into the tags code and HTML TinyMCE will parse it!
         $this->array_tags['code'] = array_map(array($this, 'clear_html_and_code_tag'), $this->array_tags['code']);
         $this->reimplant_tag('code');
     }
 }
예제 #3
0
 public function parse()
 {
     $this->content = str_replace(array("\r\n", "\r"), "\n", $this->content);
     $this->content = "\n" . $this->content . "\n";
     $this->content = TextHelper::html_entity_decode($this->content);
     foreach (static::$parsers as $parser) {
         $this->content = $parser->parse_save_tags($this->content);
     }
     $this->protect_content();
     foreach (static::$parsers as $parser) {
         $this->content = $parser->parse($this->content);
     }
     $this->parse_paragraphs();
     foreach (static::$parsers as $parser) {
         $this->content = $parser->restaure_tags($this->content);
     }
     foreach (static::$parsers as $parser) {
         if (method_exists($parser, "after_parse")) {
             $this->content = $parser->after_parse($this->content);
         }
     }
     parent::parse();
 }