3 require_once 'HTMLPurifier/AttrTransform.php';
6 * Pre-transform that changes deprecated bgcolor attribute to CSS.
8 class HTMLPurifier_AttrTransform_BgColor
9 extends HTMLPurifier_AttrTransform
{
11 function transform($attr, $config, &$context) {
13 if (!isset($attr['bgcolor'])) return $attr;
15 $bgcolor = $attr['bgcolor'];
16 unset($attr['bgcolor']);
17 // some validation should happen here
19 $attr['style'] = isset($attr['style']) ?
$attr['style'] : '';
20 $attr['style'] = "background-color:$bgcolor;" . $attr['style'];