18 return $builder->buildDir($interchange,
$dir);
22 if (!
$dir)
$dir = HTMLPURIFIER_PREFIX .
'/HTMLPurifier/ConfigSchema/schema';
23 if (file_exists(
$dir .
'/info.ini')) {
24 $info = parse_ini_file(
$dir .
'/info.ini');
25 $interchange->name = $info[
'name'];
30 while (
false !== (
$file = readdir($dh))) {
39 foreach ($files as
$file) {
59 public function build($interchange, $hash) {
61 $hash =
new HTMLPurifier_StringHash($hash);
63 if (!isset($hash[
'ID'])) {
66 if (strpos($hash[
'ID'],
'.') ===
false) {
67 if (count($hash) == 2 && isset($hash[
'DESCRIPTION'])) {
68 $hash->offsetGet(
'DESCRIPTION');
82 $directive->id = $this->
id($hash->offsetGet(
'ID'));
83 $id = $directive->id->toString();
85 if (isset($hash[
'TYPE'])) {
86 $type = explode(
'/', $hash->offsetGet(
'TYPE'));
87 if (isset(
$type[1])) $directive->typeAllowsNull =
true;
88 $directive->type =
$type[0];
93 if (isset($hash[
'DEFAULT'])) {
95 $directive->default = $this->varParser->parse($hash->offsetGet(
'DEFAULT'), $directive->type, $directive->typeAllowsNull);
101 if (isset($hash[
'DESCRIPTION'])) {
102 $directive->description = $hash->offsetGet(
'DESCRIPTION');
105 if (isset($hash[
'ALLOWED'])) {
106 $directive->allowed = $this->
lookup($this->
evalArray($hash->offsetGet(
'ALLOWED')));
109 if (isset($hash[
'VALUE-ALIASES'])) {
110 $directive->valueAliases = $this->
evalArray($hash->offsetGet(
'VALUE-ALIASES'));
113 if (isset($hash[
'ALIASES'])) {
114 $raw_aliases = trim($hash->offsetGet(
'ALIASES'));
115 $aliases = preg_split(
'/\s*,\s*/', $raw_aliases);
116 foreach ($aliases as $alias) {
117 $directive->aliases[] = $this->
id($alias);
121 if (isset($hash[
'VERSION'])) {
122 $directive->version = $hash->offsetGet(
'VERSION');
125 if (isset($hash[
'DEPRECATED-USE'])) {
126 $directive->deprecatedUse = $this->
id($hash->offsetGet(
'DEPRECATED-USE'));
129 if (isset($hash[
'DEPRECATED-VERSION'])) {
130 $directive->deprecatedVersion = $hash->offsetGet(
'DEPRECATED-VERSION');
133 if (isset($hash[
'EXTERNAL'])) {
134 $directive->external = preg_split(
'/\s*,\s*/', trim($hash->offsetGet(
'EXTERNAL')));
137 $interchange->addDirective($directive);
144 return eval(
'return array('. $contents .
');');
152 foreach ($array as $val)
$ret[$val] =
true;
160 protected function id($id) {
170 $accessed = $hash->getAccessed();
171 foreach ($hash as $k => $v) {
172 if (!isset($accessed[$k])) {
173 trigger_error(
"String hash key '$k' not used by builder", E_USER_NOTICE);