2007-03-29 23:48:54 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once 'HTMLPurifier/AttrTransform.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class for handling width/height length attribute transformations to CSS
|
|
|
|
*/
|
|
|
|
class HTMLPurifier_AttrTransform_Length extends HTMLPurifier_AttrTransform
|
|
|
|
{
|
|
|
|
|
2007-11-25 02:24:39 +00:00
|
|
|
protected $name;
|
|
|
|
protected $cssName;
|
2007-03-29 23:48:54 +00:00
|
|
|
|
2007-11-29 04:29:51 +00:00
|
|
|
public function __construct($name, $css_name = null) {
|
2007-03-29 23:48:54 +00:00
|
|
|
$this->name = $name;
|
|
|
|
$this->cssName = $css_name ? $css_name : $name;
|
|
|
|
}
|
|
|
|
|
2008-01-05 00:10:43 +00:00
|
|
|
public function transform($attr, $config, $context) {
|
2007-03-29 23:48:54 +00:00
|
|
|
if (!isset($attr[$this->name])) return $attr;
|
2007-05-05 02:25:55 +00:00
|
|
|
$length = $this->confiscateAttr($attr, $this->name);
|
2007-03-29 23:48:54 +00:00
|
|
|
if(ctype_digit($length)) $length .= 'px';
|
2007-05-05 02:25:55 +00:00
|
|
|
$this->prependCSS($attr, $this->cssName . ":$length;");
|
2007-03-29 23:48:54 +00:00
|
|
|
return $attr;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|