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
|
|
|
|
{
|
|
|
|
|
|
|
|
var $name;
|
|
|
|
var $cssName;
|
|
|
|
|
|
|
|
function HTMLPurifier_AttrTransform_Length($name, $css_name = null) {
|
|
|
|
$this->name = $name;
|
|
|
|
$this->cssName = $css_name ? $css_name : $name;
|
|
|
|
}
|
|
|
|
|
|
|
|
function transform($attr, $config, &$context) {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|