You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Background.php 696B

12345678910111213141516171819202122232425262728
  1. <?php
  2. /**
  3. * Pre-transform that changes proprietary background attribute to CSS.
  4. */
  5. class HTMLPurifier_AttrTransform_Background extends HTMLPurifier_AttrTransform
  6. {
  7. /**
  8. * @param array $attr
  9. * @param HTMLPurifier_Config $config
  10. * @param HTMLPurifier_Context $context
  11. * @return array
  12. */
  13. public function transform($attr, $config, $context)
  14. {
  15. if (!isset($attr['background'])) {
  16. return $attr;
  17. }
  18. $background = $this->confiscateAttr($attr, 'background');
  19. // some validation should happen here
  20. $this->prependCSS($attr, "background-image:url($background);");
  21. return $attr;
  22. }
  23. }
  24. // vim: et sw=4 sts=4