ILIAS  release_4-4 Revision
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. More...
 
 performInclusions (&$attr)
 Takes a reference to an attribute associative array and performs all inclusions specified by the zero index. More...
 
 expandIdentifiers (&$attr, $attr_types)
 Expands all string identifiers in an attribute array by replacing them with the appropriate values inside HTMLPurifier_AttrTypes. More...
 

Data Fields

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

Detailed Description

Defines common attribute collections that modules reference.

Definition at line 7 of file AttrCollections.php.

Constructor & Destructor Documentation

◆ __construct()

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 expandIdentifiers(), and performInclusions().

22  {
23  // load extensions from the modules
24  foreach ($modules as $module) {
25  foreach ($module->attr_collections as $coll_i => $coll) {
26  if (!isset($this->info[$coll_i])) {
27  $this->info[$coll_i] = array();
28  }
29  foreach ($coll as $attr_i => $attr) {
30  if ($attr_i === 0 && isset($this->info[$coll_i][$attr_i])) {
31  // merge in includes
32  $this->info[$coll_i][$attr_i] = array_merge(
33  $this->info[$coll_i][$attr_i], $attr);
34  continue;
35  }
36  $this->info[$coll_i][$attr_i] = $attr;
37  }
38  }
39  }
40  // perform internal expansions and inclusions
41  foreach ($this->info as $name => $attr) {
42  // merge attribute collections that include others
43  $this->performInclusions($this->info[$name]);
44  // replace string identifiers with actual attribute objects
45  $this->expandIdentifiers($this->info[$name], $attr_types);
46  }
47  }
performInclusions(&$attr)
Takes a reference to an attribute associative array and performs all inclusions specified by the zero...
expandIdentifiers(&$attr, $attr_types)
Expands all string identifiers in an attribute array by replacing them with the appropriate values in...
+ Here is the call graph for this function:

Member Function Documentation

◆ expandIdentifiers()

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

82  {
83 
84  // because foreach will process new elements we add, make sure we
85  // skip duplicates
86  $processed = array();
87 
88  foreach ($attr as $def_i => $def) {
89  // skip inclusions
90  if ($def_i === 0) continue;
91 
92  if (isset($processed[$def_i])) continue;
93 
94  // determine whether or not attribute is required
95  if ($required = (strpos($def_i, '*') !== false)) {
96  // rename the definition
97  unset($attr[$def_i]);
98  $def_i = trim($def_i, '*');
99  $attr[$def_i] = $def;
100  }
101 
102  $processed[$def_i] = true;
103 
104  // if we've already got a literal object, move on
105  if (is_object($def)) {
106  // preserve previous required
107  $attr[$def_i]->required = ($required || $attr[$def_i]->required);
108  continue;
109  }
110 
111  if ($def === false) {
112  unset($attr[$def_i]);
113  continue;
114  }
115 
116  if ($t = $attr_types->get($def)) {
117  $attr[$def_i] = $t;
118  $attr[$def_i]->required = $required;
119  } else {
120  unset($attr[$def_i]);
121  }
122  }
123 
124  }
+ Here is the caller graph for this function:

◆ performInclusions()

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.

Referenced by __construct().

54  {
55  if (!isset($attr[0])) return;
56  $merge = $attr[0];
57  $seen = array(); // recursion guard
58  // loop through all the inclusions
59  for ($i = 0; isset($merge[$i]); $i++) {
60  if (isset($seen[$merge[$i]])) continue;
61  $seen[$merge[$i]] = true;
62  // foreach attribute of the inclusion, copy it over
63  if (!isset($this->info[$merge[$i]])) continue;
64  foreach ($this->info[$merge[$i]] as $key => $value) {
65  if (isset($attr[$key])) continue; // also catches more inclusions
66  $attr[$key] = $value;
67  }
68  if (isset($this->info[$merge[$i]][0])) {
69  // recursion
70  $merge = array_merge($merge, $this->info[$merge[$i]][0]);
71  }
72  }
73  unset($attr[0]);
74  }
+ Here is the caller graph for this function:

Field Documentation

◆ $info

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: