4 * Structure that stores an HTML element definition. Used by
5 * HTMLPurifier_HTMLDefinition and HTMLPurifier_HTMLModule.
7 class HTMLPurifier_ElementDef
11 * Does the definition work by itself, or is it created solely
12 * for the purpose of merging into another definition?
14 var $standalone = true;
17 * Associative array of attribute name to HTMLPurifier_AttrDef
18 * @note Before being processed by HTMLPurifier_AttrCollections
19 * when modules are finalized during
20 * HTMLPurifier_HTMLDefinition->setup(), this array may also
21 * contain an array at index 0 that indicates which attribute
22 * collections to load into the full array. It may also
23 * contain string indentifiers in lieu of HTMLPurifier_AttrDef,
24 * see HTMLPurifier_AttrTypes on how they are expanded during
25 * HTMLPurifier_HTMLDefinition->setup() processing.
31 * Indexed list of tag's HTMLPurifier_AttrTransform to be done before validation
34 var $attr_transform_pre = array();
37 * Indexed list of tag's HTMLPurifier_AttrTransform to be done after validation
40 var $attr_transform_post = array();
45 * HTMLPurifier_ChildDef of this tag.
51 * Abstract string representation of internal ChildDef rules. See
52 * HTMLPurifier_ContentSets for how this is parsed and then transformed
53 * into an HTMLPurifier_ChildDef.
59 * Value of $child->type, used to determine which ChildDef to use,
60 * used in combination with $content_model.
63 var $content_model_type;
68 * Lookup table of tags that close this tag. Used during parsing
69 * to make sure we don't attempt to nest unclosed tags.
72 var $auto_close = array();
75 * Does the element have a content model (#PCDATA | Inline)*? This
76 * is important for chameleon ins and del processing in
77 * HTMLPurifier_ChildDef_Chameleon. Dynamically set: modules don't
78 * have to worry about this one.
81 var $descendants_are_inline;
84 * Lookup table of tags excluded from all descendants of this tag.
87 var $excludes = array();
90 * Merges the values of another element definition into this one.
91 * Values from the new element def take precedence if a value is
94 function mergeIn($def) {
96 // later keys takes precedence
97 foreach($def->attr
as $k => $v) {
99 // merge in the includes
100 // sorry, no way to override an include
101 foreach ($v as $v2) {
102 $def->attr
[0][] = $v2;
106 $this->attr
[$k] = $v;
108 foreach($def->attr_transform_pre
as $k => $v) $this->attr_transform_pre
[$k] = $v;
109 foreach($def->attr_transform_post
as $k => $v) $this->attr_transform_post
[$k] = $v;
110 foreach($def->auto_close
as $k => $v) $this->auto_close
[$k] = $v;
111 foreach($def->excludes
as $k => $v) $this->excludes
[$k] = $v;
113 if(!is_null($def->child
)) $this->child
= $def->child
;
114 if(!empty($def->content_model
)) $this->content_model
.= ' | ' . $def->content_model
;
115 if(!empty($def->content_model_type
)) $this->content_model_type
= $def->content_model_type
;
116 if(!is_null($def->descendants_are_inline
)) $this->descendants_are_inline
= $def->descendants_are_inline
;