Tags which are allowed * 'allowAttribs' => Attributes which are allowed * 'allowComments' => Are comments allowed ? * * @param string|array|Zend_Config $options * @return void */ public function __construct($options = null) { if ($options instanceof Zend_Config) { $options = $options->toArray(); } else if ((!is_array($options)) || (is_array($options) && !array_key_exists('allowTags', $options) && !array_key_exists('allowAttribs', $options) && !array_key_exists('allowComments', $options))) { $options = func_get_args(); $temp['allowTags'] = array_shift($options); if (!empty($options)) { $temp['allowAttribs'] = array_shift($options); } if (!empty($options)) { $temp['allowComments'] = array_shift($options); } $options = $temp; } if (array_key_exists('allowTags', $options)) { $this->setTagsAllowed($options['allowTags']); } if (array_key_exists('allowAttribs', $options)) { $this->setAttributesAllowed($options['allowAttribs']); } if (array_key_exists('allowComments', $options)) { $this->setCommentsAllowed($options['allowComments']); } } /** * Returns the commentsAllowed option * * This setting is now deprecated and ignored internally. * * @deprecated * @return bool */ public function getCommentsAllowed() { return $this->commentsAllowed; } /** * Sets the commentsAllowed option * * This setting is now deprecated and ignored internally. * * @deprecated * @param boolean $commentsAllowed * @return Zend_Filter_StripTags Provides a fluent interface */ public function setCommentsAllowed($commentsAllowed) { $this->commentsAllowed = (boolean) $commentsAllowed; return $this; } /** * Returns the tagsAllowed option * * @return array */ public function getTagsAllowed() { return $this->_tagsAllowed; } /** * Sets the tagsAllowed option * * @param array|string $tagsAllowed * @return Zend_Filter_StripTags Provides a fluent interface */ public function setTagsAllowed($tagsAllowed) { if (!is_array($tagsAllowed)) { $tagsAllowed = array($tagsAllowed); } foreach ($tagsAllowed as $index => $element) { // If the tag was provided without attributes if (is_int($index) && is_string($element)) { // Canonicalize the tag name $tagName = strtolower($element); // Store the tag as allowed with no attributes $this->_tagsAllowed[$tagName] = array(); } // Otherwise, if a tag was provided with attributes else if (is_string($index) && (is_array($element) || is_string($element))) { // Canonicalize the tag name $tagName = strtolower($index); // Canonicalize the attributes if (is_string($element)) { $element = array($element); } // Store the tag as allowed with the provided attributes $this->_tagsAllowed[$tagName] = array(); foreach ($element as $attribute) { if (is_string($attribute)) { // Canonicalize the attribute name $attributeName = strtolower($attribute); $this->_tagsAllowed[$tagName][$attributeName] = null; } } } } return $this; } /** * Returns the attributesAllowed option * * @return array */ public function getAttributesAllowed() { return $this->_attributesAllowed; } /** * Sets the attributesAllowed option * * @param array|string $attributesAllowed * @return Zend_Filter_StripTags Provides a fluent interface */ public function setAttributesAllowed($attributesAllowed) { if (!is_array($attributesAllowed)) { $attributesAllowed = array($attributesAllowed); } // Store each attribute as allowed foreach ($attributesAllowed as $attribute) { if (is_string($attribute)) { // Canonicalize the attribute name $attributeName = strtolower($attribute); $this->_attributesAllowed[$attributeName] = null; } } return $this; } /** * Defined by Zend_Filter_Interface * * @todo improve docblock descriptions * * @param string $value * @return string */ public function filter($value) { $value = (string) $value; // Strip HTML comments first while (strpos($value, '