Release 1.6.0, merged in r875-930.
[htmlpurifier.git] / library / HTMLPurifier / AttrTransform / BgColor.php
blobabfd03427d4bf3c5cc2cdaa09364f3a3c505a878
1 <?php
3 require_once 'HTMLPurifier/AttrTransform.php';
5 /**
6 * Pre-transform that changes deprecated bgcolor attribute to CSS.
7 */
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'];
22 return $attr;