ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ElementDef.php
Go to the documentation of this file.
1 <?php
2 
12 {
13 
18  public $standalone = true;
19 
31  public $attr = array();
32 
36  public $attr_transform_pre = array();
37 
41  public $attr_transform_post = array();
42 
46  public $child;
47 
56 
65 
66 
67 
74  public $descendants_are_inline = false;
75 
80  public $required_attr = array();
81 
93  public $excludes = array();
94 
98  public $autoclose = array();
99 
104  public $formatting;
105 
109  public static function create($content_model, $content_model_type, $attr) {
110  $def = new HTMLPurifier_ElementDef();
111  $def->content_model = $content_model;
112  $def->content_model_type = $content_model_type;
113  $def->attr = $attr;
114  return $def;
115  }
116 
122  public function mergeIn($def) {
123 
124  // later keys takes precedence
125  foreach($def->attr as $k => $v) {
126  if ($k === 0) {
127  // merge in the includes
128  // sorry, no way to override an include
129  foreach ($v as $v2) {
130  $this->attr[0][] = $v2;
131  }
132  continue;
133  }
134  if ($v === false) {
135  if (isset($this->attr[$k])) unset($this->attr[$k]);
136  continue;
137  }
138  $this->attr[$k] = $v;
139  }
140  $this->_mergeAssocArray($this->attr_transform_pre, $def->attr_transform_pre);
141  $this->_mergeAssocArray($this->attr_transform_post, $def->attr_transform_post);
142  $this->_mergeAssocArray($this->excludes, $def->excludes);
143 
144  if(!empty($def->content_model)) {
145  $this->content_model =
146  str_replace("#SUPER", $this->content_model, $def->content_model);
147  $this->child = false;
148  }
149  if(!empty($def->content_model_type)) {
150  $this->content_model_type = $def->content_model_type;
151  $this->child = false;
152  }
153  if(!is_null($def->child)) $this->child = $def->child;
154  if(!is_null($def->formatting)) $this->formatting = $def->formatting;
155  if($def->descendants_are_inline) $this->descendants_are_inline = $def->descendants_are_inline;
156 
157  }
158 
164  private function _mergeAssocArray(&$a1, $a2) {
165  foreach ($a2 as $k => $v) {
166  if ($v === false) {
167  if (isset($a1[$k])) unset($a1[$k]);
168  continue;
169  }
170  $a1[$k] = $v;
171  }
172  }
173 
174 }
175 
176 // vim: et sw=4 sts=4