ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
HTMLPurifier.kses.php
Go to the documentation of this file.
1<?php
2
8require_once dirname(__FILE__) . '/HTMLPurifier.auto.php';
9
10function kses($string, $allowed_html, $allowed_protocols = null)
11{
13 $allowed_elements = array();
14 $allowed_attributes = array();
15 foreach ($allowed_html as $element => $attributes) {
16 $allowed_elements[$element] = true;
17 foreach ($attributes as $attribute => $x) {
18 $allowed_attributes["$element.$attribute"] = true;
19 }
20 }
21 $config->set('HTML.AllowedElements', $allowed_elements);
22 $config->set('HTML.AllowedAttributes', $allowed_attributes);
23 if ($allowed_protocols !== null) {
24 $config->set('URI.AllowedSchemes', $allowed_protocols);
25 }
26 $purifier = new HTMLPurifier($config);
27 return $purifier->purify($string);
28}
29
30// vim: et sw=4 sts=4
HTMLPurifier($html, $config=null)
Purify HTML.
kses($string, $allowed_html, $allowed_protocols=null)
static createDefault()
Convenience constructor that creates a default configuration object.
Definition: Config.php:154
$x
Definition: example_009.php:98