function _htmlpurifier_process in HTML Purifier 6
Same name and namespace in other branches
- 6.2 htmlpurifier.module \_htmlpurifier_process()
- 7.2 htmlpurifier.module \_htmlpurifier_process()
- 7 htmlpurifier.module \_htmlpurifier_process()
Processes HTML according to a format and returns purified HTML. Makes a cache pass if possible.
@note We ignore $delta because the only difference it makes is in the configuration screen.
Parameters
string $text: Text to purify
int $format: Input format corresponding to HTML Purifier's configuration.
boolean $cache: Whether or not to check the cache.
2 calls to _htmlpurifier_process()
- htmlpurifier_filter in ./
htmlpurifier.module - Implementation of hook_filter().
- _htmlpurifier_settings in ./
htmlpurifier.module - Generates a settings form for configuring HTML Purifier.
File
- ./
htmlpurifier.module, line 135 - Implements HTML Purifier as a Drupal filter.
Code
function _htmlpurifier_process($text, $format, $cache = TRUE) {
if ($cache) {
$cid = $format . ':' . md5($text);
$old = cache_get($cid, 'cache_htmlpurifier');
if ($old) {
return $old->data;
}
}
_htmlpurifier_load();
$config = _htmlpurifier_get_config($format);
$purifier = new HTMLPurifier($config);
$ret = $purifier
->purify($text);
if ($cache) {
cache_set($cid, $ret, 'cache_htmlpurifier', CACHE_PERMANENT);
}
return $ret;
}