Dotclear 2.25
|
HTML code filter. More...
Public Member Functions | |
__construct (bool $keep_aria=false, bool $keep_data=false, bool $keep_js=false) | |
removeHosts (... $args) | |
removeTags (... $args) | |
removeAttributes (... $args) | |
removeArrayAttributes (array $attrs) | |
removePatternAttributes (... $args) | |
removeTagAttributes (string $tag,... $args) | |
setTags (array $tags) | |
apply (string $str, bool $tidy=true) | |
Data Fields | |
$content | |
HTML code filter.
This class removes all unwanted tags and attributes from an HTML string.
This was inspired by Ulf Harnhammar's Kses (http://sourceforge.net/projects/kses)
__construct | ( | bool | $keep_aria = false , |
bool | $keep_data = false , |
||
bool | $keep_js = false |
||
) |
Constructs a new instance.
bool | $keep_aria | Keep aria attributes |
bool | $keep_data | Keep data elements |
bool | $keep_js | Keep javascript elements |
References removeArrayAttributes(), removeAttributes(), removeHosts(), removePatternAttributes(), and removeTags().
removeHosts | ( | $args | ) |
Append hosts
Appends hosts to remove from URI. Each method argument is a host. Example:
<?php $filter = new htmlFilter(); $filter->removeHosts('javascript'); ?>
mixed | ...$args The arguments |
Referenced by __construct().
removeTags | ( | $args | ) |
Append tags
Appends tags to remove. Each method argument is a tag. Example:
<?php $filter = new htmlFilter(); $filter->removeTags('frame','script'); ?>
mixed | ...$args The arguments |
Referenced by __construct().
removeAttributes | ( | $args | ) |
Append attributes
Appends attributes to remove. Each method argument is an attribute. Example:
<?php $filter = new htmlFilter(); $filter->removeAttributes('onclick','onunload'); ?>
mixed | ...$args The arguments |
Referenced by __construct().
removeArrayAttributes | ( | array | $attrs | ) |
Append array of attributes
Appends attributes to remove. Example:
<?php $filter = new htmlFilter(); $filter->removeAttributes(['onload','onerror']); ?>
array | $attrs | The attributes |
Referenced by __construct().
removePatternAttributes | ( | $args | ) |
Append attribute patterns
Appends attribute patterns to remove. Each method argument is an attribute pattern. Example:
<?php $filter = new htmlFilter(); $filter->removeAttributes('data-.*'); ?>
mixed | ...$args The arguments |
Referenced by __construct().
removeTagAttributes | ( | string | $tag, |
$args | |||
) |
Append attributes for tags
Appends attributes to remove from specific tags. Each method argument is an array of tags with attributes. Example:
<?php $filter = new htmlFilter(); $filter->removeTagAttributes(['a' => ['src','title']]); ?>
string | $tag | The tag |
mixed | ...$args The arguments |
setTags | ( | array | $tags | ) |
Known tags
Creates a list of known tags.
array | $tags | Tags array |
apply | ( | string | $str, |
bool | $tidy = true |
||
) |
Apply filter
This method applies filter on given $str string. It will first try to use tidy extension if exists and then apply the filter.
string | $str | String to filter |
boolean | $tidy | Use tidy extension if present |
References $config, $content, and html\decodeEntities().
$content |
Referenced by apply().