ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilPCFileItem.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 
6 require_once("./Services/COPage/classes/class.ilPageContent.php");
7 
19 {
23  public function init()
24  {
25  $this->setType("flit");
26  }
27 
31  public function newItemAfter($a_id, $a_location, $a_format)
32  {
33  $li = $this->getNode();
34  $new_item = $this->dom->create_element("FileItem");
35  if ($next_li = $li->next_sibling()) {
36  $new_item = $next_li->insert_before($new_item, $next_li);
37  } else {
38  $parent_list = $li->parent_node();
39  $new_item = $parent_list->append_child($new_item);
40  }
41 
42  // Identifier
43  $id_node = $this->dom->create_element("Identifier");
44  $id_node = $new_item->append_child($id_node);
45  $id_node->set_attribute("Catalog", "ILIAS");
46  $id_node->set_attribute("Entry", "il__file_" . $a_id);
47 
48  // Location
49  $loc_node = $this->dom->create_element("Location");
50  $loc_node = $new_item->append_child($loc_node);
51  $loc_node->set_attribute("Type", "LocalFile");
52  $loc_node->set_content($a_location);
53 
54  // Format
55  $form_node = $this->dom->create_element("Format");
56  $form_node = $new_item->append_child($form_node);
57  $form_node->set_content($a_format);
58  }
59 
60 
64  public function newItemBefore($a_id, $a_location, $a_format)
65  {
66  $li = $this->getNode();
67  $new_item = $this->dom->create_element("FileItem");
68  $new_item = $li->insert_before($new_item, $li);
69 
70  // Identifier
71  $id_node = $this->dom->create_element("Identifier");
72  $id_node = $new_item->append_child($id_node);
73  $id_node->set_attribute("Catalog", "ILIAS");
74  $id_node->set_attribute("Entry", "il__file_" . $a_id);
75 
76  // Location
77  $loc_node = $this->dom->create_element("Location");
78  $loc_node = $new_item->append_child($loc_node);
79  $loc_node->set_attribute("Type", "LocalFile");
80  $loc_node->set_content($a_location);
81 
82  // Format
83  $form_node = $this->dom->create_element("Format");
84  $form_node = $new_item->append_child($form_node);
85  $form_node->set_content($a_format);
86  }
87 
91  public function deleteItem()
92  {
93  $li = $this->getNode();
94  $li->unlink($li);
95  }
96 
100  public function moveItemDown()
101  {
102  $li = $this->getNode();
103  $next = $li->next_sibling();
104  $next_copy = $next->clone_node(true);
105  $next_copy = $li->insert_before($next_copy, $li);
106  $next->unlink($next);
107  }
108 
112  public function moveItemUp()
113  {
114  $li = $this->getNode();
115  $prev = $li->previous_sibling();
116  $li_copy = $li->clone_node(true);
117  $li_copy = $prev->insert_before($li_copy, $prev);
118  $li->unlink($li);
119  }
120 }
deleteItem()
Delete file item.
newItemAfter($a_id, $a_location, $a_format)
insert new list item after current one
& getNode()
Get xml node of page content.
setType($a_type)
Set Type.
Class ilPageContent.
$li
Definition: langwiz.php:233
moveItemDown()
move list item down
newItemBefore($a_id, $a_location, $a_format)
insert new list item before current one
moveItemUp()
move list item up
init()
Init page content component.
Class ilPCFileItem.