2006-07-30 00:54:38 +00:00
|
|
|
<?php
|
|
|
|
|
2006-08-16 15:12:48 +00:00
|
|
|
require_once 'HTMLPurifier/AttrDef.php';
|
|
|
|
|
2006-07-30 00:54:38 +00:00
|
|
|
// Enum = Enumerated
|
|
|
|
class HTMLPurifier_AttrDef_Enum extends HTMLPurifier_AttrDef
|
|
|
|
{
|
|
|
|
|
|
|
|
var $valid_values = array();
|
|
|
|
var $case_sensitive = false; // values according to W3C spec
|
|
|
|
|
|
|
|
function HTMLPurifier_AttrDef_Enum(
|
2006-07-30 15:29:22 +00:00
|
|
|
$valid_values = array(), $case_sensitive = false) {
|
|
|
|
|
2006-07-30 00:54:38 +00:00
|
|
|
$this->valid_values = array_flip($valid_values);
|
|
|
|
$this->case_sensitive = $case_sensitive;
|
|
|
|
}
|
|
|
|
|
2006-08-12 16:04:40 +00:00
|
|
|
function validate($string, $config, &$context) {
|
2006-08-05 00:30:31 +00:00
|
|
|
$string = trim($string);
|
2006-07-30 00:54:38 +00:00
|
|
|
if (!$this->case_sensitive) {
|
|
|
|
$string = ctype_lower($string) ? $string : strtolower($string);
|
|
|
|
}
|
2006-08-04 00:11:54 +00:00
|
|
|
$result = isset($this->valid_values[$string]);
|
|
|
|
|
2006-08-05 00:30:31 +00:00
|
|
|
return $result ? $string : false;
|
2006-07-30 00:54:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|