/**
  * Main BBCode parser method. This takes plain jane content and
  * runs it through so many filters
  *
  * @return DBField
  */
 public function parse()
 {
     // Convert content to plain text
     $this->content = DBField::create_field('HTMLFragment', $this->content)->Plain();
     $p = new SSHTMLBBCodeParser();
     $this->content = $p->qparse($this->content);
     unset($p);
     if ($this->config()->allow_smilies) {
         $smilies = array('#(?<!\\w):D(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/grin.gif'> ", '#(?<!\\w):\\)(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/smile.gif'> ", '#(?<!\\w):-\\)(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/smile.gif'> ", '#(?<!\\w):\\((?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/sad.gif'> ", '#(?<!\\w):-\\((?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/sad.gif'> ", '#(?<!\\w):p(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/tongue.gif'> ", '#(?<!\\w)8-\\)(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/cool.gif'> ", '#(?<!\\w):\\^\\)(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/confused.gif'> ");
         $this->content = preg_replace(array_keys($smilies), array_values($smilies), $this->content);
     }
     // Ensure to return cast value
     return DBField::create_field('HTMLFragment', $this->content);
 }
Пример #2
0
 /**
  * Main BBCode parser method. This takes plain jane content and
  * runs it through so many filters 
  *
  * @return Text
  */
 public function parse()
 {
     $this->content = str_replace(array('&', '<', '>'), array('&amp;', '&lt;', '&gt;'), $this->content);
     $p = new SSHTMLBBCodeParser();
     $this->content = $p->qparse($this->content);
     unset($p);
     $this->content = "<p>" . $this->content . "</p>";
     $this->content = preg_replace('/(<p[^>]*>)\\s+/i', '\\1', $this->content);
     $this->content = preg_replace('/\\s+(<\\/p[^>]*>)/i', '\\1', $this->content);
     $this->content = preg_replace("/\n\\s*\n/", "</p><p>", $this->content);
     $this->content = str_replace("\n", "<br />", $this->content);
     if (BBCodeParser::smiliesAllowed()) {
         $smilies = array('#(?<!\\w):D(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/grin.gif'> ", '#(?<!\\w):\\)(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/smile.gif'> ", '#(?<!\\w):-\\)(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/smile.gif'> ", '#(?<!\\w):\\((?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/sad.gif'> ", '#(?<!\\w):-\\((?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/sad.gif'> ", '#(?<!\\w):p(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/tongue.gif'> ", '#(?<!\\w)8-\\)(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/cool.gif'> ", '#(?<!\\w):\\^\\)(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/confused.gif'> ");
         $this->content = preg_replace(array_keys($smilies), array_values($smilies), $this->content);
     }
     return $this->content;
 }
Пример #3
0
 /**
  * Quick static method to do setText(), parse() and getParsed at once
  *
  * @return   none
  * @access   public
  * @see      parse()
  * @see      $_text
  * @author   Stijn de Reede  <*****@*****.**>
  */
 function staticQparse($str)
 {
     $p = new SSHTMLBBCodeParser();
     $str = $p->qparse($str);
     unset($p);
     return $str;
 }