ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPCListItem.php
Go to the documentation of this file.
1<?php
2
25{
26 public function init(): void
27 {
28 $this->setType("li");
29 }
30
34 public function newItemAfter(): void
35 {
36 $li = $this->getDomNode();
37 $new_li = $this->dom_doc->createElement("ListItem");
38 if ($next_li = $li->nextSibling) {
39 $new_li = $next_li->parentNode->insertBefore($new_li, $next_li);
40 } else {
41 $parent_list = $li->parentNode;
42 $new_li = $parent_list->appendChild($new_li);
43 }
44 }
45
46
50 public function newItemBefore(): void
51 {
52 $li = $this->getDomNode();
53 $new_li = $this->dom_doc->createElement("ListItem");
54 $new_li = $li->parentNode->insertBefore($new_li, $li);
55 }
56
57
61 public function deleteItem(): void
62 {
63 $parent_node = $this->getDomNode()->parentNode;
64 $cnt = count($parent_node->childNodes);
65 if ($cnt == 1) {
66 // if list item is the last one -> delete whole list
67 $grandma = $parent_node->parentNode;
68 $grandma->parentNode->removeChild($grandma);
69 } else {
70 $li = $this->getDomNode();
71 $li->parentNode->removeChild($li);
72 }
73 }
74
78 public function moveItemDown(): void
79 {
80 $li = $this->getDomNode();
81 $next = $li->nextSibling;
82 $next_copy = $next->cloneNode(true);
83 $next_copy = $li->parentNode->insertBefore($next_copy, $li);
84 $next->parentNode->removeChild($next);
85 }
86
90 public function moveItemUp(): void
91 {
92 $li = $this->getDomNode();
93 $prev = $li->previousSibling;
94 $li_copy = $li->cloneNode(true);
95 $li_copy = $prev->parentNode->insertBefore($li_copy, $prev);
96 $li->parentNode->removeChild($li);
97 }
98}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
moveItemUp()
move list item up
deleteItem()
delete row of cell
moveItemDown()
move list item down
newItemBefore()
insert new list item before current one
init()
Init object.
newItemAfter()
insert new list item after current one
Content object of ilPageObject (see ILIAS DTD).
setType(string $a_type)
Set Type.