ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ConfigSchema.php
Go to the documentation of this file.
1 <?php
2 
7 
12  public $defaults = array();
13 
17  public $defaultPlist;
18 
48  public $info = array();
49 
53  static protected $singleton;
54 
55  public function __construct() {
56  $this->defaultPlist = new HTMLPurifier_PropertyList();
57  }
58 
62  public static function makeFromSerial() {
63  return unserialize(file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/ConfigSchema/schema.ser'));
64  }
65 
69  public static function instance($prototype = null) {
70  if ($prototype !== null) {
72  } elseif (HTMLPurifier_ConfigSchema::$singleton === null || $prototype === true) {
74  }
76  }
77 
90  public function add($key, $default, $type, $allow_null) {
91  $obj = new stdclass();
92  $obj->type = is_int($type) ? $type : HTMLPurifier_VarParser::$types[$type];
93  if ($allow_null) $obj->allow_null = true;
94  $this->info[$key] = $obj;
95  $this->defaults[$key] = $default;
96  $this->defaultPlist->set($key, $default);
97  }
98 
108  public function addValueAliases($key, $aliases) {
109  if (!isset($this->info[$key]->aliases)) {
110  $this->info[$key]->aliases = array();
111  }
112  foreach ($aliases as $alias => $real) {
113  $this->info[$key]->aliases[$alias] = $real;
114  }
115  }
116 
125  public function addAllowedValues($key, $allowed) {
126  $this->info[$key]->allowed = $allowed;
127  }
128 
136  public function addAlias($key, $new_key) {
137  $obj = new stdclass;
138  $obj->key = $new_key;
139  $obj->isAlias = true;
140  $this->info[$key] = $obj;
141  }
142 
146  public function postProcess() {
147  foreach ($this->info as $key => $v) {
148  if (count((array) $v) == 1) {
149  $this->info[$key] = $v->type;
150  } elseif (count((array) $v) == 2 && isset($v->allow_null)) {
151  $this->info[$key] = -$v->type;
152  }
153  }
154  }
155 
156 }
157 
158 // vim: et sw=4 sts=4