示例#1
0
 /**
  * @param string $text
  * @param array $allowedTags
  * @return string
  */
 public function filterTags($text, $allowedTags = array())
 {
     $allowedTags = array_merge_recursive($this->allowedTags, $allowedTags);
     // filter tags
     $tags = '<' . implode('><', array_keys($allowedTags)) . '>';
     $text = strip_tags($text, $tags);
     // filter attributes
     $sa = new StripAttributes();
     $sa->exceptions = $allowedTags;
     $text = $sa->strip($text);
     return $text;
 }
示例#2
0
 /**
  * @param string $text
  * @return string
  */
 protected function filterContent($text)
 {
     // filter tags
     $tags = '<' . implode('><', array_keys($this->allowedTags)) . '>';
     $text = strip_tags($text, $tags);
     // filter attributes
     $sa = new StripAttributes();
     $sa->exceptions = $this->allowedTags;
     $text = $sa->strip($text);
     return $text;
 }