ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ElementDef.php
Go to the documentation of this file.
1<?php
2
12{
18 public $standalone = true;
19
32 public $attr = array();
33
34 // XXX: Design note: currently, it's not possible to override
35 // previously defined AttrTransforms without messing around with
36 // the final generated config. This is by design; a previous version
37 // used an associated list of attr_transform, but it was extremely
38 // easy to accidentally override other attribute transforms by
39 // forgetting to specify an index (and just using 0.) While we
40 // could check this by checking the index number and complaining,
41 // there is a second problem which is that it is not at all easy to
42 // tell when something is getting overridden. Combine this with a
43 // codebase where this isn't really being used, and it's perfect for
44 // nuking.
45
50 public $attr_transform_pre = array();
51
56 public $attr_transform_post = array();
57
62 public $child;
63
73
83
92
98 public $required_attr = array();
99
112 public $excludes = array();
113
118 public $autoclose = array();
119
126 public $wrap;
127
134
139 {
140 $def = new HTMLPurifier_ElementDef();
141 $def->content_model = $content_model;
142 $def->content_model_type = $content_model_type;
143 $def->attr = $attr;
144 return $def;
145 }
146
153 public function mergeIn($def)
154 {
155 // later keys takes precedence
156 foreach ($def->attr as $k => $v) {
157 if ($k === 0) {
158 // merge in the includes
159 // sorry, no way to override an include
160 foreach ($v as $v2) {
161 $this->attr[0][] = $v2;
162 }
163 continue;
164 }
165 if ($v === false) {
166 if (isset($this->attr[$k])) {
167 unset($this->attr[$k]);
168 }
169 continue;
170 }
171 $this->attr[$k] = $v;
172 }
173 $this->_mergeAssocArray($this->excludes, $def->excludes);
174 $this->attr_transform_pre = array_merge($this->attr_transform_pre, $def->attr_transform_pre);
175 $this->attr_transform_post = array_merge($this->attr_transform_post, $def->attr_transform_post);
176
177 if (!empty($def->content_model)) {
178 $this->content_model =
179 str_replace("#SUPER", $this->content_model, $def->content_model);
180 $this->child = false;
181 }
182 if (!empty($def->content_model_type)) {
183 $this->content_model_type = $def->content_model_type;
184 $this->child = false;
185 }
186 if (!is_null($def->child)) {
187 $this->child = $def->child;
188 }
189 if (!is_null($def->formatting)) {
190 $this->formatting = $def->formatting;
191 }
192 if ($def->descendants_are_inline) {
193 $this->descendants_are_inline = $def->descendants_are_inline;
194 }
195 }
196
202 private function _mergeAssocArray(&$a1, $a2)
203 {
204 foreach ($a2 as $k => $v) {
205 if ($v === false) {
206 if (isset($a1[$k])) {
207 unset($a1[$k]);
208 }
209 continue;
210 }
211 $a1[$k] = $v;
212 }
213 }
214}
215
216// vim: et sw=4 sts=4
Structure that stores an HTML element definition.
Definition: ElementDef.php:12
$content_model_type
Value of $child->type, used to determine which ChildDef to use, used in combination with $content_mod...
Definition: ElementDef.php:82
$autoclose
This tag is explicitly auto-closed by the following tags.
Definition: ElementDef.php:118
mergeIn($def)
Merges the values of another element definition into this one.
Definition: ElementDef.php:153
$attr
Associative array of attribute name to HTMLPurifier_AttrDef.
Definition: ElementDef.php:32
$attr_transform_post
List of tags HTMLPurifier_AttrTransform to be done after validation.
Definition: ElementDef.php:56
$standalone
Does the definition work by itself, or is it created solely for the purpose of merging into another d...
Definition: ElementDef.php:18
$required_attr
List of the names of required attributes this element has.
Definition: ElementDef.php:98
$content_model
Abstract string representation of internal ChildDef rules.
Definition: ElementDef.php:72
$attr_transform_pre
List of tags HTMLPurifier_AttrTransform to be done before validation.
Definition: ElementDef.php:50
$excludes
Lookup table of tags excluded from all descendants of this tag.
Definition: ElementDef.php:112
$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:126
$descendants_are_inline
Does the element have a content model (#PCDATA | Inline)*? This is important for chameleon ins and de...
Definition: ElementDef.php:91
$child
HTMLPurifier_ChildDef of this tag.
Definition: ElementDef.php:62
$formatting
Whether or not this is a formatting element affected by the "Active Formatting Elements" algorithm.
Definition: ElementDef.php:133
_mergeAssocArray(&$a1, $a2)
Merges one array into another, removes values which equal false.
Definition: ElementDef.php:202
static create($content_model, $content_model_type, $attr)
Low-level factory constructor for creating new standalone element defs.
Definition: ElementDef.php:138