ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
HTMLPurifier_ChildDef_List Class Reference

Definition for list containers ul and ol. More...

+ Inheritance diagram for HTMLPurifier_ChildDef_List:
+ Collaboration diagram for HTMLPurifier_ChildDef_List:

Public Member Functions

 validateChildren ($children, $config, $context)
 
- Public Member Functions inherited from HTMLPurifier_ChildDef
 getAllowedElements ($config)
 Get lookup of tag names that should not close this element automatically. More...
 
 validateChildren ($children, $config, $context)
 Validates nodes according to definition and returns modification. More...
 

Data Fields

 $type = 'list'
 string More...
 
 $elements = array('li' => true, 'ul' => true, 'ol' => true)
 array More...
 
- Data Fields inherited from HTMLPurifier_ChildDef
 $type
 Type of child definition, usually right-most part of class name lowercase. More...
 
 $allow_empty
 Indicates whether or not an empty array of children is okay. More...
 
 $elements = array()
 Lookup array of all elements that this definition could possibly allow. More...
 

Detailed Description

Definition for list containers ul and ol.

What does this do? The big thing is to handle ol/ul at the top level of list nodes, which should be handled specially by /folding/ them into the previous list node. We generally shouldn't ever see other disallowed elements, because the autoclose behavior in MakeWellFormed handles it.

Definition at line 12 of file List.php.

Member Function Documentation

◆ validateChildren()

HTMLPurifier_ChildDef_List::validateChildren (   $children,
  $config,
  $context 
)
Parameters
array$children
HTMLPurifier_Config$config
HTMLPurifier_Context$context
Returns
array

Definition at line 31 of file List.php.

References $config, $result, and array.

32  {
33  // Flag for subclasses
34  $this->whitespace = false;
35 
36  // if there are no tokens, delete parent node
37  if (empty($children)) {
38  return false;
39  }
40 
41  // if li is not allowed, delete parent node
42  if (!isset($config->getHTMLDefinition()->info['li'])) {
43  trigger_error("Cannot allow ul/ol without allowing li", E_USER_WARNING);
44  return false;
45  }
46 
47  // the new set of children
48  $result = array();
49 
50  // a little sanity check to make sure it's not ALL whitespace
51  $all_whitespace = true;
52 
53  $current_li = false;
54 
55  foreach ($children as $node) {
56  if (!empty($node->is_whitespace)) {
57  $result[] = $node;
58  continue;
59  }
60  $all_whitespace = false; // phew, we're not talking about whitespace
61 
62  if ($node->name === 'li') {
63  // good
64  $current_li = $node;
65  $result[] = $node;
66  } else {
67  // we want to tuck this into the previous li
68  // Invariant: we expect the node to be ol/ul
69  // ToDo: Make this more robust in the case of not ol/ul
70  // by distinguishing between existing li and li created
71  // to handle non-list elements; non-list elements should
72  // not be appended to an existing li; only li created
73  // for non-list. This distinction is not currently made.
74  if ($current_li === false) {
75  $current_li = new HTMLPurifier_Node_Element('li');
76  $result[] = $current_li;
77  }
78  $current_li->children[] = $node;
79  $current_li->empty = false; // XXX fascinating! Check for this error elsewhere ToDo
80  }
81  }
82  if (empty($result)) {
83  return false;
84  }
85  if ($all_whitespace) {
86  return false;
87  }
88  return $result;
89  }
Concrete element node class.
Definition: Element.php:6
$result
Create styles array
The data for the language used.

Field Documentation

◆ $elements

HTMLPurifier_ChildDef_List::$elements = array('li' => true, 'ul' => true, 'ol' => true)

array

Definition at line 23 of file List.php.

◆ $type

HTMLPurifier_ChildDef_List::$type = 'list'

string

Definition at line 17 of file List.php.


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