Perforce Chronicle 2012.2/486814
API Documentation
|
Extended Zend_Filter_StripTags to preset default-allowed tags/attributes. More...
Public Member Functions | |
__construct ($options=null) | |
Overwrite parent constructor to set default allowed tags and attributes. | |
removeAttributes ($attributes) | |
Remove specified attribute(s) from allowed attributes list. | |
removeTags ($tags) | |
Remove specified tag(s) from allowed tags list. | |
Protected Member Functions | |
_removeTagAttribute ($attribute, $tag=null) | |
Removes attribute from (optionaly) given tag. | |
Protected Attributes | |
$_defaultAttributesAllowed | |
$_defaultTagsAllowed |
Extended Zend_Filter_StripTags to preset default-allowed tags/attributes.
P4Cms_Filter_DefaultStripTags::__construct | ( | $ | options = null | ) |
Overwrite parent constructor to set default allowed tags and attributes.
array | null | $options | Filter options (see parent for details). |
{ // set default allowed tags/attributes $this->setTagsAllowed($this->_defaultTagsAllowed); $this->setAttributesAllowed($this->_defaultAttributesAllowed); parent::__construct($options); }
P4Cms_Filter_DefaultStripTags::_removeTagAttribute | ( | $ | attribute, |
$ | tag = null |
||
) | [protected] |
Removes attribute from (optionaly) given tag.
If tag is not specified, removes attribute from all currently allowed tags.
string | $attribute | Attribute to remove (from given tag). |
string | null | $tag | Tag to remove attribute from. |
{ if ($tag) { unset($this->_tagsAllowed[$tag][$attribute]); return; } foreach ($this->_tagsAllowed as $tag => $value) { unset($this->_tagsAllowed[$tag][$attribute]); } }
P4Cms_Filter_DefaultStripTags::removeAttributes | ( | $ | attributes | ) |
Remove specified attribute(s) from allowed attributes list.
Function supports also an option to remove attributes only for certain tags, see examples below.
Examples of parameter values and their meaning:
'attr' removes 'attr' attribute array('attr1', 'attr2') removes 'attr1' and 'attr2' attributes array('tag' => 'attr') removes 'attr' attribute only for 'tag' tag array('tag' => array('attr1', 'attr2') removes 'attr1' and 'attr2' attributes only for 'tag' tag
string | array | $attributes | List with attributes to remove from allowed attributes. |
{ if (!is_array($attributes)) { $attributes = array($attributes); } foreach ($attributes as $index => $element) { // if attributes were provided without tag, remove them from // allowed attributes and also from all allowed tag attributes if (is_int($index)) { // normalize attribute name $attrinuteName = strtolower($element); unset($this->_attributesAllowed[$attrinuteName]); $this->_removeTagAttribute($attrinuteName); } else { if (!is_array($element)) { $element = array($element); } foreach ($element as $attribute) { // normalize attribute/tag names $attributeName = strtolower($attribute); $tagName = strtolower($index); $this->_removeTagAttribute($attributeName, $tagName); } } } }
P4Cms_Filter_DefaultStripTags::removeTags | ( | $ | tags | ) |
Remove specified tag(s) from allowed tags list.
string | array | $tags | List of tags to remove from allowed tags. |
{ if (!is_array($tags)) { $tags = array($tags); } foreach ($tags as $tag) { // normalize tag name $tagName = strtolower($tag); unset($this->_tagsAllowed[$tagName]); } }
P4Cms_Filter_DefaultStripTags::$_defaultAttributesAllowed [protected] |
array( 'align', 'bgcolor', 'class', 'height', 'id', 'style', 'width' )
P4Cms_Filter_DefaultStripTags::$_defaultTagsAllowed [protected] |