ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
List.php
Go to the documentation of this file.
1 <?php
2 
13 {
17  public $type = 'list';
21  // lying a little bit, so that we can handle ul and ol ourselves
22  // XXX: This whole business with 'wrap' is all a bit unsatisfactory
23  public $elements = array('li' => true, 'ul' => true, 'ol' => true);
24 
31  public function validateChildren($children, $config, $context)
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  // the new set of children
42  $result = array();
43 
44  // a little sanity check to make sure it's not ALL whitespace
45  $all_whitespace = true;
46 
47  $current_li = false;
48 
49  foreach ($children as $node) {
50  if (!empty($node->is_whitespace)) {
51  $result[] = $node;
52  continue;
53  }
54  $all_whitespace = false; // phew, we're not talking about whitespace
55 
56  if ($node->name === 'li') {
57  // good
58  $current_li = $node;
59  $result[] = $node;
60  } else {
61  // we want to tuck this into the previous li
62  // Invariant: we expect the node to be ol/ul
63  // ToDo: Make this more robust in the case of not ol/ul
64  // by distinguishing between existing li and li created
65  // to handle non-list elements; non-list elements should
66  // not be appended to an existing li; only li created
67  // for non-list. This distinction is not currently made.
68  if ($current_li === false) {
69  $current_li = new HTMLPurifier_Node_Element('li');
70  $result[] = $current_li;
71  }
72  $current_li->children[] = $node;
73  $current_li->empty = false; // XXX fascinating! Check for this error elsewhere ToDo
74  }
75  }
76  if (empty($result)) {
77  return false;
78  }
79  if ($all_whitespace) {
80  return false;
81  }
82  return $result;
83  }
84 }
85 
86 // vim: et sw=4 sts=4
Definition for list containers ul and ol.
Definition: List.php:12
Concrete element node class.
Definition: Element.php:6
$result
validateChildren($children, $config, $context)
Definition: List.php:31
Defines allowed child nodes and validates nodes against it.
Definition: ChildDef.php:6