Bool.php 560 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. /**
  3. * Validates a boolean attribute
  4. */
  5. class HTMLPurifier_AttrDef_HTML_Bool extends HTMLPurifier_AttrDef
  6. {
  7. protected $name;
  8. public $minimized = true;
  9. public function __construct($name = false) {$this->name = $name;}
  10. public function validate($string, $config, $context) {
  11. if (empty($string)) return false;
  12. return $this->name;
  13. }
  14. /**
  15. * @param $string Name of attribute
  16. */
  17. public function make($string) {
  18. return new HTMLPurifier_AttrDef_HTML_Bool($string);
  19. }
  20. }
  21. // vim: et sw=4 sts=4