ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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->getDomNode();
38 $new_item = $this->dom_doc->createElement("FileItem");
39 if ($next_li = $li->nextSibling) {
40 $new_item = $next_li->parentNode->insertBefore($new_item, $next_li);
41 } else {
42 $parent_list = $li->parentNode;
43 $new_item = $parent_list->appendChild($new_item);
44 }
45
46 // Identifier
47 $id_node = $this->dom_doc->createElement("Identifier");
48 $id_node = $new_item->appendChild($id_node);
49 $id_node->setAttribute("Catalog", "ILIAS");
50 $id_node->setAttribute("Entry", "il__file_" . $a_id);
51
52 // Location
53 $loc_node = $this->dom_doc->createElement("Location");
54 $loc_node = $new_item->appendChild($loc_node);
55 $loc_node->setAttribute("Type", "LocalFile");
56 $this->dom_util->setContent($loc_node, $a_location);
57
58 // Format
59 $form_node = $this->dom_doc->createElement("Format");
60 $form_node = $new_item->appendChild($form_node);
61 $this->dom_util->setContent($form_node, $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->getDomNode();
74 $new_item = $this->dom_doc->createElement("FileItem");
75 $new_item = $li->parentNode->insertBefore($new_item, $li);
76
77 // Identifier
78 $id_node = $this->dom_doc->createElement("Identifier");
79 $id_node = $new_item->appendChild($id_node);
80 $id_node->setAttribute("Catalog", "ILIAS");
81 $id_node->setAttribute("Entry", "il__file_" . $a_id);
82
83 // Location
84 $loc_node = $this->dom_doc->createElement("Location");
85 $loc_node = $new_item->appendChild($loc_node);
86 $loc_node->setAttribute("Type", "LocalFile");
87 $this->dom_util->setContent($loc_node, $a_location);
88
89 // Format
90 $form_node = $this->dom_doc->createElement("Format");
91 $form_node = $new_item->appendChild($form_node);
92 $this->dom_util->setContent($form_node, $a_format);
93 }
94
98 public function deleteItem(): void
99 {
100 $li = $this->getDomNode();
101 $li->parentNode->removeChild($li);
102 }
103
107 public function moveItemDown(): void
108 {
109 $li = $this->getDomNode();
110 $next = $li->nextSibling;
111 $next_copy = $next->cloneNode(true);
112 $next_copy = $li->parentNode->insertBefore($next_copy, $li);
113 $next->parentNode->removeChild($next);
114 }
115
119 public function moveItemUp(): void
120 {
121 $li = $this->getDomNode();
122 $prev = $li->previousSibling;
123 $li_copy = $li->cloneNode(true);
124 $li_copy = $prev->parentNode->insertBefore($li_copy, $prev);
125 $li->parentNode->removeChild($li);
126 }
127
128 public function getListPCId(): string
129 {
130 $list = $this->getDomNode()->parentNode->parentNode;
131 return $list->getAttribute("PCID");
132 }
133}
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.
Content object of ilPageObject (see ILIAS DTD).
setType(string $a_type)
Set Type.