ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
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? bool. 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 202 of file ElementDef.php.

Referenced by mergeIn().

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  }
+ 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 138 of file ElementDef.php.

References $attr, $content_model, and $content_model_type.

Referenced by HTMLPurifier_HTMLModule\addElement().

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  }
$attr
Associative array of attribute name to HTMLPurifier_AttrDef.
Definition: ElementDef.php:32
$content_model
Abstract string representation of internal ChildDef rules.
Definition: ElementDef.php:72
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:82
+ 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.

Parameters
HTMLPurifier_ElementDef$def

Definition at line 153 of file ElementDef.php.

References _mergeAssocArray().

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

Field Documentation

◆ $attr

HTMLPurifier_ElementDef::$attr = array()

Associative array of attribute name to HTMLPurifier_AttrDef.

array

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 32 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.

array

Definition at line 56 of file ElementDef.php.

◆ $attr_transform_pre

HTMLPurifier_ElementDef::$attr_transform_pre = array()

List of tags HTMLPurifier_AttrTransform to be done before validation.

array

Definition at line 50 of file ElementDef.php.

◆ $autoclose

HTMLPurifier_ElementDef::$autoclose = array()

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

array

Definition at line 118 of file ElementDef.php.

◆ $child

HTMLPurifier_ElementDef::$child

HTMLPurifier_ChildDef of this tag.

HTMLPurifier_ChildDef

Definition at line 62 of file ElementDef.php.

◆ $content_model

HTMLPurifier_ElementDef::$content_model

Abstract string representation of internal ChildDef rules.

See also
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 string

Definition at line 72 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 string

Definition at line 82 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. bool

Definition at line 91 of file ElementDef.php.

◆ $excludes

HTMLPurifier_ElementDef::$excludes = array()

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

array

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 112 of file ElementDef.php.

◆ $formatting

HTMLPurifier_ElementDef::$formatting

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

bool

Definition at line 133 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() array

Definition at line 98 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? bool.

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.

string

Definition at line 126 of file ElementDef.php.


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