ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
HTMLPurifier_AttrCollections Class Reference

Defines common attribute collections that modules reference. More...

+ Collaboration diagram for HTMLPurifier_AttrCollections:

Public Member Functions

 __construct ($attr_types, $modules)
 Performs all expansions on internal data for use by other inclusions It also collects all attribute collection extensions from modules.
 performInclusions (&$attr)
 Takes a reference to an attribute associative array and performs all inclusions specified by the zero index.
 expandIdentifiers (&$attr, $attr_types)
 Expands all string identifiers in an attribute array by replacing them with the appropriate values inside HTMLPurifier_AttrTypes.

Data Fields

 $info = array()
 Associative array of attribute collections, indexed by name.

Detailed Description

Defines common attribute collections that modules reference.

Definition at line 7 of file AttrCollections.php.

Constructor & Destructor Documentation

HTMLPurifier_AttrCollections::__construct (   $attr_types,
  $modules 
)

Performs all expansions on internal data for use by other inclusions It also collects all attribute collection extensions from modules.

Parameters
$attr_typesHTMLPurifier_AttrTypes instance
$modulesHash array of HTMLPurifier_HTMLModule members

Definition at line 22 of file AttrCollections.php.

References $name, expandIdentifiers(), and performInclusions().

{
// load extensions from the modules
foreach ($modules as $module) {
foreach ($module->attr_collections as $coll_i => $coll) {
if (!isset($this->info[$coll_i])) {
$this->info[$coll_i] = array();
}
foreach ($coll as $attr_i => $attr) {
if ($attr_i === 0 && isset($this->info[$coll_i][$attr_i])) {
// merge in includes
$this->info[$coll_i][$attr_i] = array_merge(
$this->info[$coll_i][$attr_i], $attr);
continue;
}
$this->info[$coll_i][$attr_i] = $attr;
}
}
}
// perform internal expansions and inclusions
foreach ($this->info as $name => $attr) {
// merge attribute collections that include others
$this->performInclusions($this->info[$name]);
// replace string identifiers with actual attribute objects
$this->expandIdentifiers($this->info[$name], $attr_types);
}
}

+ Here is the call graph for this function:

Member Function Documentation

HTMLPurifier_AttrCollections::expandIdentifiers ( $attr,
  $attr_types 
)

Expands all string identifiers in an attribute array by replacing them with the appropriate values inside HTMLPurifier_AttrTypes.

Parameters
&$attrReference to attribute array
$attr_typesHTMLPurifier_AttrTypes instance

Definition at line 82 of file AttrCollections.php.

References $t.

Referenced by __construct().

{
// because foreach will process new elements we add, make sure we
// skip duplicates
$processed = array();
foreach ($attr as $def_i => $def) {
// skip inclusions
if ($def_i === 0) continue;
if (isset($processed[$def_i])) continue;
// determine whether or not attribute is required
if ($required = (strpos($def_i, '*') !== false)) {
// rename the definition
unset($attr[$def_i]);
$def_i = trim($def_i, '*');
$attr[$def_i] = $def;
}
$processed[$def_i] = true;
// if we've already got a literal object, move on
if (is_object($def)) {
// preserve previous required
$attr[$def_i]->required = ($required || $attr[$def_i]->required);
continue;
}
if ($def === false) {
unset($attr[$def_i]);
continue;
}
if ($t = $attr_types->get($def)) {
$attr[$def_i] = $t;
$attr[$def_i]->required = $required;
} else {
unset($attr[$def_i]);
}
}
}

+ Here is the caller graph for this function:

HTMLPurifier_AttrCollections::performInclusions ( $attr)

Takes a reference to an attribute associative array and performs all inclusions specified by the zero index.

Parameters
&$attrReference to attribute array

Definition at line 54 of file AttrCollections.php.

References $key.

Referenced by __construct().

{
if (!isset($attr[0])) return;
$merge = $attr[0];
$seen = array(); // recursion guard
// loop through all the inclusions
for ($i = 0; isset($merge[$i]); $i++) {
if (isset($seen[$merge[$i]])) continue;
$seen[$merge[$i]] = true;
// foreach attribute of the inclusion, copy it over
if (!isset($this->info[$merge[$i]])) continue;
foreach ($this->info[$merge[$i]] as $key => $value) {
if (isset($attr[$key])) continue; // also catches more inclusions
$attr[$key] = $value;
}
if (isset($this->info[$merge[$i]][0])) {
// recursion
$merge = array_merge($merge, $this->info[$merge[$i]][0]);
}
}
unset($attr[0]);
}

+ Here is the caller graph for this function:

Field Documentation

HTMLPurifier_AttrCollections::$info = array()

Associative array of attribute collections, indexed by name.

Definition at line 13 of file AttrCollections.php.


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