Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / lib / htmlpurifier / HTMLPurifier / ChildDef / Chameleon.php
blobb338354d3812cae08fa089206378e633a33ffa9f
1 <?php
3 require_once 'HTMLPurifier/ChildDef.php';
5 /**
6 * Definition that uses different definitions depending on context.
7 *
8 * The del and ins tags are notable because they allow different types of
9 * elements depending on whether or not they're in a block or inline context.
10 * Chameleon allows this behavior to happen by using two different
11 * definitions depending on context. While this somewhat generalized,
12 * it is specifically intended for those two tags.
14 class HTMLPurifier_ChildDef_Chameleon extends HTMLPurifier_ChildDef
17 /**
18 * Instance of the definition object to use when inline. Usually stricter.
19 * @public
21 var $inline;
23 /**
24 * Instance of the definition object to use when block.
25 * @public
27 var $block;
29 var $type = 'chameleon';
31 /**
32 * @param $inline List of elements to allow when inline.
33 * @param $block List of elements to allow when block.
35 function HTMLPurifier_ChildDef_Chameleon($inline, $block) {
36 $this->inline = new HTMLPurifier_ChildDef_Optional($inline);
37 $this->block = new HTMLPurifier_ChildDef_Optional($block);
38 $this->elements = $this->block->elements;
41 function validateChildren($tokens_of_children, $config, &$context) {
42 if ($context->get('IsInline') === false) {
43 return $this->block->validateChildren(
44 $tokens_of_children, $config, $context);
45 } else {
46 return $this->inline->validateChildren(
47 $tokens_of_children, $config, $context);