ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
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.

Static Public Member Functions

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

Data Fields

 $standalone = true
 Does the definition work by itself, or is it created solely for the purpose of merging into another definition?
 $attr = array()
 Associative array of attribute name to HTMLPurifier_AttrDef.
 $attr_transform_pre = array()
 Indexed list of tag's HTMLPurifier_AttrTransform to be done before validation.
 $attr_transform_post = array()
 Indexed list of tag's HTMLPurifier_AttrTransform to be done after validation.
 $child
 HTMLPurifier_ChildDef of this tag.
 $content_model
 Abstract string representation of internal ChildDef rules.
 $content_model_type
 Value of $child->type, used to determine which ChildDef to use, used in combination with $content_model.
 $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.
 $required_attr = array()
 List of the names of required attributes this element has.
 $excludes = array()
 Lookup table of tags excluded from all descendants of this tag.
 $autoclose = array()
 This tag is explicitly auto-closed by the following tags.
 $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.
 $formatting
 Whether or not this is a formatting element affected by the "Active Formatting Elements" algorithm.

Private Member Functions

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

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

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

Referenced by mergeIn().

{
foreach ($a2 as $k => $v) {
if ($v === false) {
if (isset($a1[$k])) unset($a1[$k]);
continue;
}
$a1[$k] = $v;
}
}

+ Here is the caller graph for this function:

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

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

Definition at line 116 of file ElementDef.php.

References $attr, $content_model, and $content_model_type.

Referenced by HTMLPurifier_HTMLModule\addElement().

{
$def->content_model = $content_model;
$def->content_model_type = $content_model_type;
$def->attr = $attr;
return $def;
}

+ Here is the caller graph for this function:

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

References _mergeAssocArray().

{
// later keys takes precedence
foreach($def->attr as $k => $v) {
if ($k === 0) {
// merge in the includes
// sorry, no way to override an include
foreach ($v as $v2) {
$this->attr[0][] = $v2;
}
continue;
}
if ($v === false) {
if (isset($this->attr[$k])) unset($this->attr[$k]);
continue;
}
$this->attr[$k] = $v;
}
$this->_mergeAssocArray($this->attr_transform_pre, $def->attr_transform_pre);
$this->_mergeAssocArray($this->attr_transform_post, $def->attr_transform_post);
$this->_mergeAssocArray($this->excludes, $def->excludes);
if(!empty($def->content_model)) {
$this->content_model =
str_replace("#SUPER", $this->content_model, $def->content_model);
$this->child = false;
}
if(!empty($def->content_model_type)) {
$this->content_model_type = $def->content_model_type;
$this->child = false;
}
if(!is_null($def->child)) $this->child = $def->child;
if(!is_null($def->formatting)) $this->formatting = $def->formatting;
if($def->descendants_are_inline) $this->descendants_are_inline = $def->descendants_are_inline;
}

+ Here is the call graph for this function:

Field Documentation

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().

HTMLPurifier_ElementDef::$attr_transform_post = array()

Indexed list of tag's HTMLPurifier_AttrTransform to be done after validation.

Definition at line 41 of file ElementDef.php.

HTMLPurifier_ElementDef::$attr_transform_pre = array()

Indexed list of tag's HTMLPurifier_AttrTransform to be done before validation.

Definition at line 36 of file ElementDef.php.

HTMLPurifier_ElementDef::$autoclose = array()

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

Definition at line 98 of file ElementDef.php.

HTMLPurifier_ElementDef::$child

HTMLPurifier_ChildDef of this tag.

Definition at line 46 of file ElementDef.php.

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

Referenced by create().

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

Referenced by create().

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

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

HTMLPurifier_ElementDef::$formatting

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

Definition at line 111 of file ElementDef.php.

HTMLPurifier_ElementDef::$required_attr = array()

List of the names of required attributes this element has.

Dynamically populated by HTMLPurifier_HTMLDefinition::getElement

Definition at line 80 of file ElementDef.php.

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.

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


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