ILIAS  release_4-4 Revision
HTMLPurifier_ElementDef Class Reference

Structure that stores an HTML element definition. More...

+ Collaboration diagram for HTMLPurifier_ElementDef:

Public Member Functions

 mergeIn ($def)
 Merges the values of another element definition into this one. More...
 

Static Public Member Functions

static create ($content_model, $content_model_type, $attr)
 Low-level factory constructor for creating new standalone element defs. More...
 

Data Fields

 $standalone = true
 Does the definition work by itself, or is it created solely for the purpose of merging into another definition? More...
 
 $attr = array()
 Associative array of attribute name to HTMLPurifier_AttrDef. More...
 
 $attr_transform_pre = array()
 List of tags HTMLPurifier_AttrTransform to be done before validation. More...
 
 $attr_transform_post = array()
 List of tags HTMLPurifier_AttrTransform to be done after validation. More...
 
 $child
 HTMLPurifier_ChildDef of this tag. More...
 
 $content_model
 Abstract string representation of internal ChildDef rules. More...
 
 $content_model_type
 Value of $child->type, used to determine which ChildDef to use, used in combination with $content_model. More...
 
 $descendants_are_inline = false
 Does the element have a content model (#PCDATA | Inline)*? This is important for chameleon ins and del processing in HTMLPurifier_ChildDef_Chameleon. More...
 
 $required_attr = array()
 List of the names of required attributes this element has. More...
 
 $excludes = array()
 Lookup table of tags excluded from all descendants of this tag. More...
 
 $autoclose = array()
 This tag is explicitly auto-closed by the following tags. More...
 
 $wrap
 If a foreign element is found in this element, test if it is allowed by this sub-element; if it is, instead of closing the current element, place it inside this element. More...
 
 $formatting
 Whether or not this is a formatting element affected by the "Active Formatting Elements" algorithm. More...
 

Private Member Functions

 _mergeAssocArray (&$a1, $a2)
 Merges one array into another, removes values which equal false. More...
 

Detailed Description

Structure that stores an HTML element definition.

Used by HTMLPurifier_HTMLDefinition and HTMLPurifier_HTMLModule.

Note
This class is inspected by HTMLPurifier_Printer_HTMLDefinition. Please update that class too.
Warning
If you add new properties to this class, you MUST update the mergeIn() method.

Definition at line 11 of file ElementDef.php.

Member Function Documentation

◆ _mergeAssocArray()

HTMLPurifier_ElementDef::_mergeAssocArray ( $a1,
  $a2 
)
private

Merges one array into another, removes values which equal false.

Parameters
$a1Array by reference that is merged into
$a2Array that merges into $a1

Definition at line 183 of file ElementDef.php.

Referenced by mergeIn().

183  {
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  }
+ Here is the caller graph for this function:

◆ create()

static HTMLPurifier_ElementDef::create (   $content_model,
  $content_model_type,
  $attr 
)
static

Low-level factory constructor for creating new standalone element defs.

Definition at line 128 of file ElementDef.php.

References $attr, $content_model, and $content_model_type.

Referenced by HTMLPurifier_HTMLModule\addElement().

128  {
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  }
$attr
Associative array of attribute name to HTMLPurifier_AttrDef.
Definition: ElementDef.php:31
$content_model
Abstract string representation of internal ChildDef rules.
Definition: ElementDef.php:67
Structure that stores an HTML element definition.
Definition: ElementDef.php:11
$content_model_type
Value of $child->type, used to determine which ChildDef to use, used in combination with $content_mod...
Definition: ElementDef.php:76
+ Here is the caller graph for this function:

◆ mergeIn()

HTMLPurifier_ElementDef::mergeIn (   $def)

Merges the values of another element definition into this one.

Values from the new element def take precedence if a value is not mergeable.

Definition at line 141 of file ElementDef.php.

References _mergeAssocArray().

141  {
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  }
_mergeAssocArray(&$a1, $a2)
Merges one array into another, removes values which equal false.
Definition: ElementDef.php:183
+ Here is the call graph for this function:

Field Documentation

◆ $attr

HTMLPurifier_ElementDef::$attr = array()

Associative array of attribute name to HTMLPurifier_AttrDef.

Note
Before being processed by HTMLPurifier_AttrCollections when modules are finalized during HTMLPurifier_HTMLDefinition->setup(), this array may also contain an array at index 0 that indicates which attribute collections to load into the full array. It may also contain string indentifiers in lieu of HTMLPurifier_AttrDef, see HTMLPurifier_AttrTypes on how they are expanded during HTMLPurifier_HTMLDefinition->setup() processing.

Definition at line 31 of file ElementDef.php.

Referenced by create().

◆ $attr_transform_post

HTMLPurifier_ElementDef::$attr_transform_post = array()

List of tags HTMLPurifier_AttrTransform to be done after validation.

Definition at line 53 of file ElementDef.php.

◆ $attr_transform_pre

HTMLPurifier_ElementDef::$attr_transform_pre = array()

List of tags HTMLPurifier_AttrTransform to be done before validation.

Definition at line 48 of file ElementDef.php.

◆ $autoclose

HTMLPurifier_ElementDef::$autoclose = array()

This tag is explicitly auto-closed by the following tags.

Definition at line 110 of file ElementDef.php.

◆ $child

HTMLPurifier_ElementDef::$child

HTMLPurifier_ChildDef of this tag.

Definition at line 58 of file ElementDef.php.

◆ $content_model

HTMLPurifier_ElementDef::$content_model

Abstract string representation of internal ChildDef rules.

See HTMLPurifier_ContentSets for how this is parsed and then transformed into an HTMLPurifier_ChildDef.

Warning
This is a temporary variable that is not available after being processed by HTMLDefinition

Definition at line 67 of file ElementDef.php.

Referenced by create().

◆ $content_model_type

HTMLPurifier_ElementDef::$content_model_type

Value of $child->type, used to determine which ChildDef to use, used in combination with $content_model.

Warning
This must be lowercase
This is a temporary variable that is not available after being processed by HTMLDefinition

Definition at line 76 of file ElementDef.php.

Referenced by create().

◆ $descendants_are_inline

HTMLPurifier_ElementDef::$descendants_are_inline = false

Does the element have a content model (#PCDATA | Inline)*? This is important for chameleon ins and del processing in HTMLPurifier_ChildDef_Chameleon.

Dynamically set: modules don't have to worry about this one.

Definition at line 86 of file ElementDef.php.

◆ $excludes

HTMLPurifier_ElementDef::$excludes = array()

Lookup table of tags excluded from all descendants of this tag.

Note
SGML permits exclusions for all descendants, but this is not possible with DTDs or XML Schemas. W3C has elected to use complicated compositions of content_models to simulate exclusion for children, but we go the simpler, SGML-style route of flat-out exclusions, which correctly apply to all descendants and not just children. Note that the XHTML Modularization Abstract Modules are blithely unaware of such distinctions.

Definition at line 105 of file ElementDef.php.

◆ $formatting

HTMLPurifier_ElementDef::$formatting

Whether or not this is a formatting element affected by the "Active Formatting Elements" algorithm.

Definition at line 123 of file ElementDef.php.

◆ $required_attr

HTMLPurifier_ElementDef::$required_attr = array()

List of the names of required attributes this element has.

Dynamically populated by HTMLPurifier_HTMLDefinition::getElement

Definition at line 92 of file ElementDef.php.

◆ $standalone

HTMLPurifier_ElementDef::$standalone = true

Does the definition work by itself, or is it created solely for the purpose of merging into another definition?

Definition at line 18 of file ElementDef.php.

◆ $wrap

HTMLPurifier_ElementDef::$wrap

If a foreign element is found in this element, test if it is allowed by this sub-element; if it is, instead of closing the current element, place it inside this element.

Definition at line 117 of file ElementDef.php.


The documentation for this class was generated from the following file: