]>
Commit | Line | Data |
---|---|---|
d4949327 NL |
1 | <?php\r |
2 | \r | |
3 | /**\r | |
4 | * Allows multiple validators to attempt to validate attribute.\r | |
5 | *\r | |
6 | * Composite is just what it sounds like: a composite of many validators.\r | |
7 | * This means that multiple HTMLPurifier_AttrDef objects will have a whack\r | |
8 | * at the string. If one of them passes, that's what is returned. This is\r | |
9 | * especially useful for CSS values, which often are a choice between\r | |
10 | * an enumerated set of predefined values or a flexible data type.\r | |
11 | */\r | |
12 | class HTMLPurifier_AttrDef_CSS_Composite extends HTMLPurifier_AttrDef\r | |
13 | {\r | |
14 | \r | |
15 | /**\r | |
16 | * List of objects that may process strings.\r | |
17 | * @type HTMLPurifier_AttrDef[]\r | |
18 | * @todo Make protected\r | |
19 | */\r | |
20 | public $defs;\r | |
21 | \r | |
22 | /**\r | |
23 | * @param HTMLPurifier_AttrDef[] $defs List of HTMLPurifier_AttrDef objects\r | |
24 | */\r | |
25 | public function __construct($defs)\r | |
26 | {\r | |
27 | $this->defs = $defs;\r | |
28 | }\r | |
29 | \r | |
30 | /**\r | |
31 | * @param string $string\r | |
32 | * @param HTMLPurifier_Config $config\r | |
33 | * @param HTMLPurifier_Context $context\r | |
34 | * @return bool|string\r | |
35 | */\r | |
36 | public function validate($string, $config, $context)\r | |
37 | {\r | |
38 | foreach ($this->defs as $i => $def) {\r | |
39 | $result = $this->defs[$i]->validate($string, $config, $context);\r | |
40 | if ($result !== false) {\r | |
41 | return $result;\r | |
42 | }\r | |
43 | }\r | |
44 | return false;\r | |
45 | }\r | |
46 | }\r | |
47 | \r | |
48 | // vim: et sw=4 sts=4\r |