[3.0.0] Convert all $context calls away from references
[htmlpurifier.git] / library / HTMLPurifier / AttrTransform / Length.php
blob3cff5de32fd04887a111ed705afb3ea3fbbf2249
1 <?php
3 require_once 'HTMLPurifier/AttrTransform.php';
5 /**
6 * Class for handling width/height length attribute transformations to CSS
7 */
8 class HTMLPurifier_AttrTransform_Length extends HTMLPurifier_AttrTransform
11 protected $name;
12 protected $cssName;
14 public function __construct($name, $css_name = null) {
15 $this->name = $name;
16 $this->cssName = $css_name ? $css_name : $name;
19 public function transform($attr, $config, $context) {
20 if (!isset($attr[$this->name])) return $attr;
21 $length = $this->confiscateAttr($attr, $this->name);
22 if(ctype_digit($length)) $length .= 'px';
23 $this->prependCSS($attr, $this->cssName . ":$length;");
24 return $attr;