File indexing completed on 2024-12-22 05:36:19
0001 <?php 0002 0003 /** 0004 * Pre-transform that changes proprietary background attribute to CSS. 0005 */ 0006 class HTMLPurifier_AttrTransform_Background extends HTMLPurifier_AttrTransform 0007 { 0008 /** 0009 * @param array $attr 0010 * @param HTMLPurifier_Config $config 0011 * @param HTMLPurifier_Context $context 0012 * @return array 0013 */ 0014 public function transform($attr, $config, $context) 0015 { 0016 if (!isset($attr['background'])) { 0017 return $attr; 0018 } 0019 0020 $background = $this->confiscateAttr($attr, 'background'); 0021 // some validation should happen here 0022 0023 $this->prependCSS($attr, "background-image:url($background);"); 0024 return $attr; 0025 } 0026 } 0027 0028 // vim: et sw=4 sts=4