HTMLPurifier 4.4.0
/home/ezyang/Dev/htmlpurifier/library/HTMLPurifier/AttrTransform/Length.php
Go to the documentation of this file.
00001 <?php
00002 
00006 class HTMLPurifier_AttrTransform_Length extends HTMLPurifier_AttrTransform
00007 {
00008 
00009     protected $name;
00010     protected $cssName;
00011 
00012     public function __construct($name, $css_name = null) {
00013         $this->name = $name;
00014         $this->cssName = $css_name ? $css_name : $name;
00015     }
00016 
00017     public function transform($attr, $config, $context) {
00018         if (!isset($attr[$this->name])) return $attr;
00019         $length = $this->confiscateAttr($attr, $this->name);
00020         if(ctype_digit($length)) $length .= 'px';
00021         $this->prependCSS($attr, $this->cssName . ":$length;");
00022         return $attr;
00023     }
00024 
00025 }
00026 
00027 // vim: et sw=4 sts=4