国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

45 lines
1.1KB

  1. <?php
  2. /**
  3. * Decorator which enables CSS properties to be disabled for specific elements.
  4. */
  5. class HTMLPurifier_AttrDef_CSS_DenyElementDecorator extends HTMLPurifier_AttrDef
  6. {
  7. /**
  8. * @type HTMLPurifier_AttrDef
  9. */
  10. public $def;
  11. /**
  12. * @type string
  13. */
  14. public $element;
  15. /**
  16. * @param HTMLPurifier_AttrDef $def Definition to wrap
  17. * @param string $element Element to deny
  18. */
  19. public function __construct($def, $element)
  20. {
  21. $this->def = $def;
  22. $this->element = $element;
  23. }
  24. /**
  25. * Checks if CurrentToken is set and equal to $this->element
  26. * @param string $string
  27. * @param HTMLPurifier_Config $config
  28. * @param HTMLPurifier_Context $context
  29. * @return bool|string
  30. */
  31. public function validate($string, $config, $context)
  32. {
  33. $token = $context->get('CurrentToken', true);
  34. if ($token && $token->name == $this->element) {
  35. return false;
  36. }
  37. return $this->def->validate($string, $config, $context);
  38. }
  39. }
  40. // vim: et sw=4 sts=4