ILIAS  release_8 Revision v8.24
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->getNode();
37 $new_li = $this->dom->create_element("ListItem");
38 if ($next_li = $li->next_sibling()) {
39 $new_li = $next_li->insert_before($new_li, $next_li);
40 } else {
41 $parent_list = $li->parent_node();
42 $new_li = $parent_list->append_child($new_li);
43 }
44 }
45
46
50 public function newItemBefore(): void
51 {
52 $li = $this->getNode();
53 $new_li = $this->dom->create_element("ListItem");
54 $new_li = $li->insert_before($new_li, $li);
55 }
56
57
61 public function deleteItem(): void
62 {
63 $parent_node = $this->getNode()->parent_node();
64 $cnt = count($parent_node->child_nodes());
65 if ($cnt == 1) {
66 // if list item is the last one -> delete whole list
67 $grandma = $parent_node->parent_node();
68 $grandma->unlink($grandma);
69 } else {
70 $li = $this->getNode();
71 $li->unlink($li);
72 }
73 }
74
78 public function moveItemDown(): void
79 {
80 $li = $this->getNode();
81 $next = $li->next_sibling();
82 $next_copy = $next->clone_node(true);
83 $next_copy = $li->insert_before($next_copy, $li);
84 $next->unlink($next);
85 }
86
90 public function moveItemUp(): void
91 {
92 $li = $this->getNode();
93 $prev = $li->previous_sibling();
94 $li_copy = $li->clone_node(true);
95 $li_copy = $prev->insert_before($li_copy, $prev);
96 $li->unlink($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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setType(string $a_type)
Set Type.