ILIAS  Release_3_10_x_branch Revision 61812
 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 
111 
115  function deleteItem()
116  {
117  $li =& $this->getNode();
118  $li->unlink($li);
119  }
120 
124  function moveItemDown()
125  {
126  $li =& $this->getNode();
127  $next =& $li->next_sibling();
128  $next_copy = $next->clone_node(true);
129  $next_copy =& $li->insert_before($next_copy, $li);
130  $next->unlink($next);
131  }
132 
136  function moveItemUp()
137  {
138  $li =& $this->getNode();
139  $prev =& $li->previous_sibling();
140  $li_copy = $li->clone_node(true);
141  $li_copy =& $prev->insert_before($li_copy, $prev);
142  $li->unlink($li);
143  }
144 }
145 ?>