]> git.immae.eu Git - github/wallabag/wallabag.git/blame - inc/3rdparty/htmlpurifier/HTMLPurifier/ChildDef/Chameleon.php
remove autoload section in composer.json
[github/wallabag/wallabag.git] / inc / 3rdparty / htmlpurifier / HTMLPurifier / ChildDef / Chameleon.php
CommitLineData
d4949327
NL
1<?php\r
2\r
3/**\r
4 * Definition that uses different definitions depending on context.\r
5 *\r
6 * The del and ins tags are notable because they allow different types of\r
7 * elements depending on whether or not they're in a block or inline context.\r
8 * Chameleon allows this behavior to happen by using two different\r
9 * definitions depending on context. While this somewhat generalized,\r
10 * it is specifically intended for those two tags.\r
11 */\r
12class HTMLPurifier_ChildDef_Chameleon extends HTMLPurifier_ChildDef\r
13{\r
14\r
15 /**\r
16 * Instance of the definition object to use when inline. Usually stricter.\r
17 * @type HTMLPurifier_ChildDef_Optional\r
18 */\r
19 public $inline;\r
20\r
21 /**\r
22 * Instance of the definition object to use when block.\r
23 * @type HTMLPurifier_ChildDef_Optional\r
24 */\r
25 public $block;\r
26\r
27 /**\r
28 * @type string\r
29 */\r
30 public $type = 'chameleon';\r
31\r
32 /**\r
33 * @param array $inline List of elements to allow when inline.\r
34 * @param array $block List of elements to allow when block.\r
35 */\r
36 public function __construct($inline, $block)\r
37 {\r
38 $this->inline = new HTMLPurifier_ChildDef_Optional($inline);\r
39 $this->block = new HTMLPurifier_ChildDef_Optional($block);\r
40 $this->elements = $this->block->elements;\r
41 }\r
42\r
43 /**\r
44 * @param HTMLPurifier_Node[] $children\r
45 * @param HTMLPurifier_Config $config\r
46 * @param HTMLPurifier_Context $context\r
47 * @return bool\r
48 */\r
49 public function validateChildren($children, $config, $context)\r
50 {\r
51 if ($context->get('IsInline') === false) {\r
52 return $this->block->validateChildren(\r
53 $children,\r
54 $config,\r
55 $context\r
56 );\r
57 } else {\r
58 return $this->inline->validateChildren(\r
59 $children,\r
60 $config,\r
61 $context\r
62 );\r
63 }\r
64 }\r
65}\r
66\r
67// vim: et sw=4 sts=4\r