ILIAS  Release_4_4_x_branch Revision 61816
 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 
33  // XXX: Design note: currently, it's not possible to override
34  // previously defined AttrTransforms without messing around with
35  // the final generated config. This is by design; a previous version
36  // used an associated list of attr_transform, but it was extremely
37  // easy to accidentally override other attribute transforms by
38  // forgetting to specify an index (and just using 0.) While we
39  // could check this by checking the index number and complaining,
40  // there is a second problem which is that it is not at all easy to
41  // tell when something is getting overridden. Combine this with a
42  // codebase where this isn't really being used, and it's perfect for
43  // nuking.
44 
48  public $attr_transform_pre = array();
49 
53  public $attr_transform_post = array();
54 
58  public $child;
59 
68 
77 
78 
79 
86  public $descendants_are_inline = false;
87 
92  public $required_attr = array();
93 
105  public $excludes = array();
106 
110  public $autoclose = array();
111 
117  public $wrap;
118 
123  public $formatting;
124 
128  public static function create($content_model, $content_model_type, $attr) {
129  $def = new HTMLPurifier_ElementDef();
130  $def->content_model = $content_model;
131  $def->content_model_type = $content_model_type;
132  $def->attr = $attr;
133  return $def;
134  }
135 
141  public function mergeIn($def) {
142 
143  // later keys takes precedence
144  foreach($def->attr as $k => $v) {
145  if ($k === 0) {
146  // merge in the includes
147  // sorry, no way to override an include
148  foreach ($v as $v2) {
149  $this->attr[0][] = $v2;
150  }
151  continue;
152  }
153  if ($v === false) {
154  if (isset($this->attr[$k])) unset($this->attr[$k]);
155  continue;
156  }
157  $this->attr[$k] = $v;
158  }
159  $this->_mergeAssocArray($this->excludes, $def->excludes);
160  $this->attr_transform_pre = array_merge($this->attr_transform_pre, $def->attr_transform_pre);
161  $this->attr_transform_post = array_merge($this->attr_transform_post, $def->attr_transform_post);
162 
163  if(!empty($def->content_model)) {
164  $this->content_model =
165  str_replace("#SUPER", $this->content_model, $def->content_model);
166  $this->child = false;
167  }
168  if(!empty($def->content_model_type)) {
169  $this->content_model_type = $def->content_model_type;
170  $this->child = false;
171  }
172  if(!is_null($def->child)) $this->child = $def->child;
173  if(!is_null($def->formatting)) $this->formatting = $def->formatting;
174  if($def->descendants_are_inline) $this->descendants_are_inline = $def->descendants_are_inline;
175 
176  }
177 
183  private function _mergeAssocArray(&$a1, $a2) {
184  foreach ($a2 as $k => $v) {
185  if ($v === false) {
186  if (isset($a1[$k])) unset($a1[$k]);
187  continue;
188  }
189  $a1[$k] = $v;
190  }
191  }
192 
193 }
194 
195 // vim: et sw=4 sts=4