]>
Commit | Line | Data |
---|---|---|
d4949327 NL |
1 | <?php\r |
2 | \r | |
3 | /**\r | |
4 | * Pre-transform that changes converts a boolean attribute to fixed CSS\r | |
5 | */\r | |
6 | class HTMLPurifier_AttrTransform_BoolToCSS extends HTMLPurifier_AttrTransform\r | |
7 | {\r | |
8 | /**\r | |
9 | * Name of boolean attribute that is trigger.\r | |
10 | * @type string\r | |
11 | */\r | |
12 | protected $attr;\r | |
13 | \r | |
14 | /**\r | |
15 | * CSS declarations to add to style, needs trailing semicolon.\r | |
16 | * @type string\r | |
17 | */\r | |
18 | protected $css;\r | |
19 | \r | |
20 | /**\r | |
21 | * @param string $attr attribute name to convert from\r | |
22 | * @param string $css CSS declarations to add to style (needs semicolon)\r | |
23 | */\r | |
24 | public function __construct($attr, $css)\r | |
25 | {\r | |
26 | $this->attr = $attr;\r | |
27 | $this->css = $css;\r | |
28 | }\r | |
29 | \r | |
30 | /**\r | |
31 | * @param array $attr\r | |
32 | * @param HTMLPurifier_Config $config\r | |
33 | * @param HTMLPurifier_Context $context\r | |
34 | * @return array\r | |
35 | */\r | |
36 | public function transform($attr, $config, $context)\r | |
37 | {\r | |
38 | if (!isset($attr[$this->attr])) {\r | |
39 | return $attr;\r | |
40 | }\r | |
41 | unset($attr[$this->attr]);\r | |
42 | $this->prependCSS($attr, $this->css);\r | |
43 | return $attr;\r | |
44 | }\r | |
45 | }\r | |
46 | \r | |
47 | // vim: et sw=4 sts=4\r |