4 * Definition that uses different definitions depending on context.
6 * The del and ins tags are notable because they allow different types of
7 * elements depending on whether or not they're in a block or inline context.
8 * Chameleon allows this behavior to happen by using two different
9 * definitions depending on context. While this somewhat generalized,
10 * it is specifically intended for those two tags.
12 class HTMLPurifier_ChildDef_Chameleon
extends HTMLPurifier_ChildDef
16 * Instance of the definition object to use when inline. Usually stricter.
21 * Instance of the definition object to use when block.
25 public $type = 'chameleon';
28 * @param $inline List of elements to allow when inline.
29 * @param $block List of elements to allow when block.
31 public function __construct($inline, $block) {
32 $this->inline
= new HTMLPurifier_ChildDef_Optional($inline);
33 $this->block
= new HTMLPurifier_ChildDef_Optional($block);
34 $this->elements
= $this->block
->elements
;
37 public function validateChildren($tokens_of_children, $config, $context) {
38 if ($context->get('IsInline') === false) {
39 return $this->block
->validateChildren(
40 $tokens_of_children, $config, $context);
42 return $this->inline
->validateChildren(
43 $tokens_of_children, $config, $context);