ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPCFileItem.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("flit");
46  }
47 
51  function newItemAfter($a_id, $a_location, $a_format)
52  {
53  $li =& $this->getNode();
54  $new_item =& $this->dom->create_element("FileItem");
55  if ($next_li =& $li->next_sibling())
56  {
57  $new_item =& $next_li->insert_before($new_item, $next_li);
58  }
59  else
60  {
61  $parent_list =& $li->parent_node();
62  $new_item =& $parent_list->append_child($new_item);
63  }
64 
65  // Identifier
66  $id_node =& $this->dom->create_element("Identifier");
67  $id_node =& $new_item->append_child($id_node);
68  $id_node->set_attribute("Catalog", "ILIAS");
69  $id_node->set_attribute("Entry", "il__file_".$a_id);
70 
71  // Location
72  $loc_node =& $this->dom->create_element("Location");
73  $loc_node =& $new_item->append_child($loc_node);
74  $loc_node->set_attribute("Type", "LocalFile");
75  $loc_node->set_content($a_location);
76 
77  // Format
78  $form_node =& $this->dom->create_element("Format");
79  $form_node =& $new_item->append_child($form_node);
80  $form_node->set_content($a_format);
81  }
82 
83 
87  function newItemBefore($a_id, $a_location, $a_format)
88  {
89  $li =& $this->getNode();
90  $new_item =& $this->dom->create_element("FileItem");
91  $new_item =& $li->insert_before($new_item, $li);
92 
93  // Identifier
94  $id_node =& $this->dom->create_element("Identifier");
95  $id_node =& $new_item->append_child($id_node);
96  $id_node->set_attribute("Catalog", "ILIAS");
97  $id_node->set_attribute("Entry", "il__file_".$a_id);
98 
99  // Location
100  $loc_node =& $this->dom->create_element("Location");
101  $loc_node =& $new_item->append_child($loc_node);
102  $loc_node->set_attribute("Type", "LocalFile");
103  $loc_node->set_content($a_location);
104 
105  // Format
106  $form_node =& $this->dom->create_element("Format");
107  $form_node =& $new_item->append_child($form_node);
108  $form_node->set_content($a_format);
109  }
110 
114  function deleteItem()
115  {
116  $li =& $this->getNode();
117  $li->unlink($li);
118  }
119 
123  function moveItemDown()
124  {
125  $li =& $this->getNode();
126  $next =& $li->next_sibling();
127  $next_copy = $next->clone_node(true);
128  $next_copy =& $li->insert_before($next_copy, $li);
129  $next->unlink($next);
130  }
131 
135  function moveItemUp()
136  {
137  $li =& $this->getNode();
138  $prev =& $li->previous_sibling();
139  $li_copy = $li->clone_node(true);
140  $li_copy =& $prev->insert_before($li_copy, $prev);
141  $li->unlink($li);
142  }
143 }
144 ?>