ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules 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
$wrap
If a foreign element is found in this element, test if it is allowed by this sub-element; if it is...
Definition: ElementDef.php:117
mergeIn($def)
Merges the values of another element definition into this one.
Definition: ElementDef.php:141
$attr
Associative array of attribute name to HTMLPurifier_AttrDef.
Definition: ElementDef.php:31
$attr_transform_pre
List of tags HTMLPurifier_AttrTransform to be done before validation.
Definition: ElementDef.php:48
$content_model
Abstract string representation of internal ChildDef rules.
Definition: ElementDef.php:67
$descendants_are_inline
Does the element have a content model (#PCDATA | Inline)*? This is important for chameleon ins and de...
Definition: ElementDef.php:86
$required_attr
List of the names of required attributes this element has.
Definition: ElementDef.php:92
$child
HTMLPurifier_ChildDef of this tag.
Definition: ElementDef.php:58
Structure that stores an HTML element definition.
Definition: ElementDef.php:11
$standalone
Does the definition work by itself, or is it created solely for the purpose of merging into another d...
Definition: ElementDef.php:18
_mergeAssocArray(&$a1, $a2)
Merges one array into another, removes values which equal false.
Definition: ElementDef.php:183
$attr_transform_post
List of tags HTMLPurifier_AttrTransform to be done after validation.
Definition: ElementDef.php:53
$autoclose
This tag is explicitly auto-closed by the following tags.
Definition: ElementDef.php:110
$excludes
Lookup table of tags excluded from all descendants of this tag.
Definition: ElementDef.php:105
static create($content_model, $content_model_type, $attr)
Low-level factory constructor for creating new standalone element defs.
Definition: ElementDef.php:128
$formatting
Whether or not this is a formatting element affected by the "Active Formatting Elements" algorithm...
Definition: ElementDef.php:123
$content_model_type
Value of $child->type, used to determine which ChildDef to use, used in combination with $content_mod...
Definition: ElementDef.php:76