ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilPCListItem.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5require_once("./Services/COPage/classes/class.ilPageContent.php");
6
18{
19 public $dom;
20
24 public function init()
25 {
26 $this->setType("li");
27 }
28
32 public function newItemAfter()
33 {
34 $li = $this->getNode();
35 $new_li = $this->dom->create_element("ListItem");
36 if ($next_li = $li->next_sibling()) {
37 $new_li = $next_li->insert_before($new_li, $next_li);
38 } else {
39 $parent_list = $li->parent_node();
40 $new_li = $parent_list->append_child($new_li);
41 }
42 }
43
44
48 public function newItemBefore()
49 {
50 $li = $this->getNode();
51 $new_li = $this->dom->create_element("ListItem");
52 $new_li = $li->insert_before($new_li, $li);
53 }
54
55
59 public function deleteItem()
60 {
61 $parent_node = $this->getNode()->parent_node();
62 $cnt = count($parent_node->child_nodes());
63 if ($cnt == 1) {
64 // if list item is the last one -> delete whole list
65 $grandma = $parent_node->parent_node();
66 $grandma->unlink($grandma);
67 } else {
68 $li = $this->getNode();
69 $li->unlink($li);
70 }
71 }
72
76 public function moveItemDown()
77 {
78 $li = $this->getNode();
79 $next = $li->next_sibling();
80 $next_copy = $next->clone_node(true);
81 $next_copy = $li->insert_before($next_copy, $li);
82 $next->unlink($next);
83 }
84
88 public function moveItemUp()
89 {
90 $li = $this->getNode();
91 $prev = $li->previous_sibling();
92 $li_copy = $li->clone_node(true);
93 $li_copy = $prev->insert_before($li_copy, $prev);
94 $li->unlink($li);
95 }
96}
An exception for terminatinating execution or to throw for unit testing.
Class ilPCListItem.
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 page content component.
newItemAfter()
insert new list item after current one
Class ilPageContent.
& getNode()
Get xml node of page content.
setType($a_type)
Set Type.