]>
Commit | Line | Data |
---|---|---|
d4949327 NL |
1 | <?php\r |
2 | \r | |
3 | /**\r | |
4 | * Class for handling width/height length attribute transformations to CSS\r | |
5 | */\r | |
6 | class HTMLPurifier_AttrTransform_Length extends HTMLPurifier_AttrTransform\r | |
7 | {\r | |
8 | \r | |
9 | /**\r | |
10 | * @type string\r | |
11 | */\r | |
12 | protected $name;\r | |
13 | \r | |
14 | /**\r | |
15 | * @type string\r | |
16 | */\r | |
17 | protected $cssName;\r | |
18 | \r | |
19 | public function __construct($name, $css_name = null)\r | |
20 | {\r | |
21 | $this->name = $name;\r | |
22 | $this->cssName = $css_name ? $css_name : $name;\r | |
23 | }\r | |
24 | \r | |
25 | /**\r | |
26 | * @param array $attr\r | |
27 | * @param HTMLPurifier_Config $config\r | |
28 | * @param HTMLPurifier_Context $context\r | |
29 | * @return array\r | |
30 | */\r | |
31 | public function transform($attr, $config, $context)\r | |
32 | {\r | |
33 | if (!isset($attr[$this->name])) {\r | |
34 | return $attr;\r | |
35 | }\r | |
36 | $length = $this->confiscateAttr($attr, $this->name);\r | |
37 | if (ctype_digit($length)) {\r | |
38 | $length .= 'px';\r | |
39 | }\r | |
40 | $this->prependCSS($attr, $this->cssName . ":$length;");\r | |
41 | return $attr;\r | |
42 | }\r | |
43 | }\r | |
44 | \r | |
45 | // vim: et sw=4 sts=4\r |