Source for file ElementDef.php
Documentation is available at ElementDef.php
* 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.
* Does the definition work by itself, or is it created solely
* for the purpose of merging into another definition?
* 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.
* Indexed list of tag's HTMLPurifier_AttrTransform to be done before validation
* Indexed list of tag's HTMLPurifier_AttrTransform to be done after validation
* HTMLPurifier_ChildDef of this tag.
* 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
* Value of $child->type, used to determine which ChildDef to use,
* used in combination with $content_model.
* @warning This must be lowercase
* @warning This is a temporary variable that is not available after
* being processed by HTMLDefinition
* 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.
* List of the names of required attributes this element has. Dynamically
* populated by HTMLPurifier_HTMLDefinition::getElement
* 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
* Low-level factory constructor for creating new standalone element defs
public static function create($content_model, $content_model_type, $attr) {
$def->content_model =
$content_model;
$def->content_model_type =
$content_model_type;
* Merges the values of another element definition into this one.
* Values from the new element def take precedence if a value is
// later keys takes precedence
foreach($def->attr as $k =>
$v) {
// sorry, no way to override an include
if (isset
($this->attr[$k])) unset
($this->attr[$k]);
$this->_mergeAssocArray($this->excludes, $def->excludes);
if(!empty($def->content_model)) {
if(!empty($def->content_model_type)) {
* Merges one array into another, removes values which equal false
* @param $a1 Array by reference that is merged into
* @param $a2 Array that merges into $a1
private function _mergeAssocArray(&$a1, $a2) {
foreach ($a2 as $k =>
$v) {
if (isset
($a1[$k])) unset
($a1[$k]);
Documentation generated on Thu, 19 Jun 2008 18:49:06 -0400 by phpDocumentor 1.4.2