Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

46 rindas
984B

  1. <?php
  2. /**
  3. * Class for handling width/height length attribute transformations to CSS
  4. */
  5. class HTMLPurifier_AttrTransform_Length extends HTMLPurifier_AttrTransform
  6. {
  7. /**
  8. * @type string
  9. */
  10. protected $name;
  11. /**
  12. * @type string
  13. */
  14. protected $cssName;
  15. public function __construct($name, $css_name = null)
  16. {
  17. $this->name = $name;
  18. $this->cssName = $css_name ? $css_name : $name;
  19. }
  20. /**
  21. * @param array $attr
  22. * @param HTMLPurifier_Config $config
  23. * @param HTMLPurifier_Context $context
  24. * @return array
  25. */
  26. public function transform($attr, $config, $context)
  27. {
  28. if (!isset($attr[$this->name])) {
  29. return $attr;
  30. }
  31. $length = $this->confiscateAttr($attr, $this->name);
  32. if (ctype_digit($length)) {
  33. $length .= 'px';
  34. }
  35. $this->prependCSS($attr, $this->cssName . ":$length;");
  36. return $attr;
  37. }
  38. }
  39. // vim: et sw=4 sts=4