28        return $builder->buildDir($interchange, $dir);
 
   36    public function buildDir($interchange, $dir = 
null)
 
   39            $dir = HTMLPURIFIER_PREFIX . 
'/HTMLPurifier/ConfigSchema/schema';
 
   41        if (file_exists($dir . 
'/info.ini')) {
 
   42            $info = parse_ini_file($dir . 
'/info.ini');
 
   43            $interchange->name = 
$info[
'name'];
 
   48        while (
false !== ($file = readdir($dh))) {
 
   49            if (!$file || $file[0] == 
'.' || strrchr($file, 
'.') !== 
'.txt') {
 
   57        foreach (
$files as $file) {
 
   58            $this->
buildFile($interchange, $dir . 
'/' . $file);
 
   82    public function build($interchange, $hash)
 
   87        if (!isset($hash[
'ID'])) {
 
   90        if (strpos($hash[
'ID'], 
'.') === 
false) {
 
   91            if (count($hash) == 2 && isset($hash[
'DESCRIPTION'])) {
 
   92                $hash->offsetGet(
'DESCRIPTION'); 
 
  112        $directive->id = $this->
id($hash->offsetGet(
'ID'));
 
  113        $id = $directive->id->toString(); 
 
  115        if (isset($hash[
'TYPE'])) {
 
  116            $type = explode(
'/', $hash->offsetGet(
'TYPE'));
 
  117            if (isset(
$type[1])) {
 
  118                $directive->typeAllowsNull = 
true;
 
  120            $directive->type = 
$type[0];
 
  125        if (isset($hash[
'DEFAULT'])) {
 
  127                $directive->default = $this->varParser->parse(
 
  128                    $hash->offsetGet(
'DEFAULT'),
 
  130                    $directive->typeAllowsNull
 
  137        if (isset($hash[
'DESCRIPTION'])) {
 
  138            $directive->description = $hash->offsetGet(
'DESCRIPTION');
 
  141        if (isset($hash[
'ALLOWED'])) {
 
  142            $directive->allowed = $this->
lookup($this->
evalArray($hash->offsetGet(
'ALLOWED')));
 
  145        if (isset($hash[
'VALUE-ALIASES'])) {
 
  146            $directive->valueAliases = $this->
evalArray($hash->offsetGet(
'VALUE-ALIASES'));
 
  149        if (isset($hash[
'ALIASES'])) {
 
  150            $raw_aliases = trim($hash->offsetGet(
'ALIASES'));
 
  151            $aliases = preg_split(
'/\s*,\s*/', $raw_aliases);
 
  152            foreach ($aliases as $alias) {
 
  153                $directive->aliases[] = $this->
id($alias);
 
  157        if (isset($hash[
'VERSION'])) {
 
  158            $directive->version = $hash->offsetGet(
'VERSION');
 
  161        if (isset($hash[
'DEPRECATED-USE'])) {
 
  162            $directive->deprecatedUse = $this->
id($hash->offsetGet(
'DEPRECATED-USE'));
 
  165        if (isset($hash[
'DEPRECATED-VERSION'])) {
 
  166            $directive->deprecatedVersion = $hash->offsetGet(
'DEPRECATED-VERSION');
 
  169        if (isset($hash[
'EXTERNAL'])) {
 
  170            $directive->external = preg_split(
'/\s*,\s*/', trim($hash->offsetGet(
'EXTERNAL')));
 
  173        $interchange->addDirective($directive);
 
  182        return eval(
'return array(' . $contents . 
');');
 
  193        foreach ($array as $val) {
 
  217        $accessed = $hash->getAccessed();
 
  218        foreach ($hash as $k => $v) {
 
  219            if (!isset($accessed[$k])) {
 
  220                trigger_error(
"String hash key '$k' not used by builder", E_USER_NOTICE);
 
An exception for terminatinating execution or to throw for unit testing.
Exceptions related to configuration schema.
buildFile($interchange, $file)
build($interchange, $hash)
Builds an interchange object based on a hash.
evalArray($contents)
Evaluates an array PHP code string without array() wrapper.
id($id)
Convenience function that creates an HTMLPurifier_ConfigSchema_Interchange_Id object based on a strin...
buildDirective($interchange, $hash)
lookup($array)
Converts an array list into a lookup array.
buildDir($interchange, $dir=null)
_findUnused($hash)
Triggers errors for any unused keys passed in the hash; such keys may indicate typos,...
static buildFromDirectory($dir=null)
__construct($varParser=null)
$varParser
Used for processing DEFAULT, nothing else.
Interchange component class describing configuration directives.
Generic schema interchange format that can be converted to a runtime representation (HTMLPurifier_Con...
Parses string hash files.
This is in almost every respect equivalent to an array except that it keeps track of which keys were ...
Exception type for HTMLPurifier_VarParser.
This variable parser uses PHP's internal code engine.
if(!array_key_exists('StateId', $_REQUEST)) $id