ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPCListItem.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once("./Services/COPage/classes/class.ilPageContent.php");
25 
37 {
38  var $dom;
39 
43  function init()
44  {
45  $this->setType("li");
46  }
47 
51  function newItemAfter()
52  {
53  $li =& $this->getNode();
54  $new_li =& $this->dom->create_element("ListItem");
55  if ($next_li =& $li->next_sibling())
56  {
57  $new_li =& $next_li->insert_before($new_li, $next_li);
58  }
59  else
60  {
61  $parent_list =& $li->parent_node();
62  $new_li =& $parent_list->append_child($new_li);
63  }
64  }
65 
66 
70  function newItemBefore()
71  {
72  $li =& $this->getNode();
73  $new_li =& $this->dom->create_element("ListItem");
74  $new_li =& $li->insert_before($new_li, $li);
75  }
76 
77 
81  function deleteItem()
82  {
83  $parent_node = $this->getNode()->parent_node();
84  $cnt = count($parent_node->child_nodes());
85  if ($cnt == 1)
86  {
87  // if list item is the last one -> delete whole list
88  $grandma = $parent_node->parent_node();
89  $grandma->unlink($grandma);
90  }
91  else
92  {
93  $li =& $this->getNode();
94  $li->unlink($li);
95  }
96  }
97 
101  function moveItemDown()
102  {
103  $li =& $this->getNode();
104  $next =& $li->next_sibling();
105  $next_copy = $next->clone_node(true);
106  $next_copy =& $li->insert_before($next_copy, $li);
107  $next->unlink($next);
108  }
109 
113  function moveItemUp()
114  {
115  $li =& $this->getNode();
116  $prev =& $li->previous_sibling();
117  $li_copy = $li->clone_node(true);
118  $li_copy =& $prev->insert_before($li_copy, $prev);
119  $li->unlink($li);
120  }
121 
122 }
123 ?>