1 : <?php
2 :
3 : /**
4 : * Pre-transform that changes converts a boolean attribute to fixed CSS
5 : */
6 1 : class HTMLPurifier_AttrTransform_BoolToCSS extends HTMLPurifier_AttrTransform {
7 :
8 : /**
9 : * Name of boolean attribute that is trigger
10 : */
11 : protected $attr;
12 :
13 : /**
14 : * CSS declarations to add to style, needs trailing semicolon
15 : */
16 : protected $css;
17 :
18 : /**
19 : * @param $attr string attribute name to convert from
20 : * @param $css string CSS declarations to add to style (needs semicolon)
21 : */
22 : public function __construct($attr, $css) {
23 1 : $this->attr = $attr;
24 1 : $this->css = $css;
25 1 : }
26 :
27 : public function transform($attr, $config, $context) {
28 0 : if (!isset($attr[$this->attr])) return $attr;
29 0 : unset($attr[$this->attr]);
30 0 : $this->prependCSS($attr, $this->css);
31 0 : return $attr;
32 : }
33 :
34 : }
35 :
|