ILIAS  release_8 Revision v8.25
class.ilPCFileItem.php
Go to the documentation of this file.
1<?php
2
26{
27 public function init(): void
28 {
29 $this->setType("flit");
30 }
31
32 public function newItemAfter(
33 int $a_id,
34 string $a_location,
35 string $a_format
36 ): void {
37 $li = $this->getNode();
38 $new_item = $this->dom->create_element("FileItem");
39 if ($next_li = $li->next_sibling()) {
40 $new_item = $next_li->insert_before($new_item, $next_li);
41 } else {
42 $parent_list = $li->parent_node();
43 $new_item = $parent_list->append_child($new_item);
44 }
45
46 // Identifier
47 $id_node = $this->dom->create_element("Identifier");
48 $id_node = $new_item->append_child($id_node);
49 $id_node->set_attribute("Catalog", "ILIAS");
50 $id_node->set_attribute("Entry", "il__file_" . $a_id);
51
52 // Location
53 $loc_node = $this->dom->create_element("Location");
54 $loc_node = $new_item->append_child($loc_node);
55 $loc_node->set_attribute("Type", "LocalFile");
56 $loc_node->set_content($a_location);
57
58 // Format
59 $form_node = $this->dom->create_element("Format");
60 $form_node = $new_item->append_child($form_node);
61 $form_node->set_content($a_format);
62 }
63
64
68 public function newItemBefore(
69 int $a_id,
70 string $a_location,
71 string $a_format
72 ): void {
73 $li = $this->getNode();
74 $new_item = $this->dom->create_element("FileItem");
75 $new_item = $li->insert_before($new_item, $li);
76
77 // Identifier
78 $id_node = $this->dom->create_element("Identifier");
79 $id_node = $new_item->append_child($id_node);
80 $id_node->set_attribute("Catalog", "ILIAS");
81 $id_node->set_attribute("Entry", "il__file_" . $a_id);
82
83 // Location
84 $loc_node = $this->dom->create_element("Location");
85 $loc_node = $new_item->append_child($loc_node);
86 $loc_node->set_attribute("Type", "LocalFile");
87 $loc_node->set_content($a_location);
88
89 // Format
90 $form_node = $this->dom->create_element("Format");
91 $form_node = $new_item->append_child($form_node);
92 $form_node->set_content($a_format);
93 }
94
98 public function deleteItem(): void
99 {
100 $li = $this->getNode();
101 $li->unlink($li);
102 }
103
107 public function moveItemDown(): void
108 {
109 $li = $this->getNode();
110 $next = $li->next_sibling();
111 $next_copy = $next->clone_node(true);
112 $next_copy = $li->insert_before($next_copy, $li);
113 $next->unlink($next);
114 }
115
119 public function moveItemUp(): void
120 {
121 $li = $this->getNode();
122 $prev = $li->previous_sibling();
123 $li_copy = $li->clone_node(true);
124 $li_copy = $prev->insert_before($li_copy, $prev);
125 $li->unlink($li);
126 }
127}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
moveItemUp()
move list item up
deleteItem()
Delete file item.
moveItemDown()
move list item down
newItemAfter(int $a_id, string $a_location, string $a_format)
newItemBefore(int $a_id, string $a_location, string $a_format)
insert new list item before current one
init()
Init object.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setType(string $a_type)
Set Type.