ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
5 require_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 }
moveItemUp()
move list item up
& getNode()
Get xml node of page content.
newItemAfter()
insert new list item after current one
setType($a_type)
Set Type.
Class ilPageContent.
$li
Definition: langwiz.php:233
init()
Init page content component.
newItemBefore()
insert new list item before current one
Class ilPCListItem.
moveItemDown()
move list item down
deleteItem()
delete row of cell