28 public function init(): void
35 parent::setNode($a_node);
46 $this->list_node = $this->dom->create_element(
"FileList");
47 $this->list_node = $this->node->append_child($this->list_node);
56 $new_item = $this->dom->create_element(
"FileItem");
57 $new_item = $this->list_node->append_child($new_item);
60 $id_node = $this->dom->create_element(
"Identifier");
61 $id_node = $new_item->append_child($id_node);
62 $id_node->set_attribute(
"Catalog",
"ILIAS");
63 $id_node->set_attribute(
"Entry",
"il__file_" . $a_id);
66 $loc_node = $this->dom->create_element(
"Location");
67 $loc_node = $new_item->append_child($loc_node);
68 $loc_node->set_attribute(
"Type",
"LocalFile");
69 $loc_node->set_content($a_location);
72 $form_node = $this->dom->create_element(
"Format");
73 $form_node = $new_item->append_child($form_node);
74 $form_node->set_content($a_format);
87 array(
"Language" => $a_language)
93 $chlds = $this->list_node->child_nodes();
94 for (
$i = 0;
$i < count($chlds);
$i++) {
95 if ($chlds[
$i]->node_name() ==
"Title") {
96 return $chlds[
$i]->get_content();
104 $chlds = $this->list_node->child_nodes();
105 for (
$i = 0;
$i < count($chlds);
$i++) {
106 if ($chlds[
$i]->node_name() ==
"Title") {
107 return $chlds[
$i]->get_attribute(
"Language");
121 $childs = $this->list_node->child_nodes();
122 for (
$i = 0;
$i < count($childs);
$i++) {
123 if ($childs[
$i]->node_name() ==
"FileItem") {
125 $pc_id = $childs[
$i]->get_attribute(
"PCID");
126 $hier_id = $childs[
$i]->get_attribute(
"HierId");
127 $class = $childs[
$i]->get_attribute(
"Class");
130 $id_node = $childs[
$i]->first_child();
131 if ($id_node->node_name() ==
"Identifier") {
132 $entry = $id_node->get_attribute(
"Entry");
133 if (substr($entry, 0, 9) ==
"il__file_") {
134 $id = substr($entry, 9);
137 $files[] = array(
"entry" => $entry,
"id" =>
$id,
138 "pc_id" => $pc_id,
"hier_id" =>
$hier_id,
152 $childs = $this->list_node->child_nodes();
154 for (
$i = 0;
$i < count($childs);
$i++) {
155 if ($childs[
$i]->node_name() ==
"FileItem") {
157 $pc_id = $childs[
$i]->get_attribute(
"PCID");
158 $hier_id = $childs[
$i]->get_attribute(
"HierId");
160 if (in_array(
$hier_id .
":" . $pc_id, $a_ids)) {
161 $childs[
$i]->unlink($childs[
$i]);
175 $childs = $this->list_node->child_nodes();
177 for (
$i = 0;
$i < count($childs);
$i++) {
178 if ($childs[
$i]->node_name() ==
"FileItem") {
179 $pc_id = $childs[
$i]->get_attribute(
"PCID");
180 $hier_id = $childs[
$i]->get_attribute(
"HierId");
181 $nodes[
$hier_id .
":" . $pc_id] = $childs[
$i];
182 $childs[
$i]->unlink($childs[
$i]);
186 foreach ($a_pos as $k => $v) {
187 if (is_object($nodes[$k])) {
188 $nodes[$k] = $this->list_node->append_child($nodes[$k]);
201 $childs = $this->list_node->child_nodes();
203 for (
$i = 0;
$i < count($childs);
$i++) {
204 if ($childs[
$i]->node_name() ==
"FileItem") {
205 $classes[$childs[
$i]->get_attribute(
"HierId") .
":" .
206 $childs[
$i]->get_attribute(
"PCID")] = $childs[
$i]->get_attribute(
"Class");
219 $childs = $this->list_node->child_nodes();
220 for (
$i = 0;
$i < count($childs);
$i++) {
221 if ($childs[
$i]->node_name() ==
"FileItem") {
222 $childs[
$i]->set_attribute(
224 $a_class[$childs[
$i]->get_attribute(
"HierId") .
":" .
225 $childs[
$i]->get_attribute(
"PCID")]
237 return array(
"ed_edit_files",
"ed_insert_filelist",
"pc_flist");
251 $file_ids = ilObjFile::_getFilesOfObject(
257 self::saveFileUsage($a_page, $a_domdoc);
259 foreach ($file_ids as $file) {
262 $usages = $file_obj->getUsages();
263 if (count($usages) == 0) {
264 if ($file_obj->getMode() ==
"filelist") {
279 $files = self::collectFileItems($a_page, $a_page->getDomDoc());
282 ilObjFile::_deleteAllUsages(
289 foreach ($files as $file_id) {
291 $file_obj =
new ilObjFile($file_id,
false);
306 self::saveFileUsage($a_page, $a_old_domdoc, $a_old_nr);
317 $file_ids = self::collectFileItems($a_page, $a_domdoc);
319 foreach ($file_ids as $file_id) {
320 ilObjFile::_saveUsage(
338 $nodes = $xpath->query(
'//FileItem/Identifier');
340 foreach ($nodes as
$node) {
341 $id_arr = explode(
"_", $node->getAttribute(
"Entry"));
342 $file_id = $id_arr[count($id_arr) - 1];
343 if ($file_id > 0 && ($id_arr[1] ==
"" || $id_arr[1] ==
IL_INST_ID || $id_arr[1] == 0)) {
344 $file_ids[$file_id] = $file_id;
349 $nodes = $xpath->query(
"//IntLink[@Type='File']");
350 foreach ($nodes as $node) {
351 $t = $node->getAttribute(
"Target");
352 if (substr($t, 0, 9) ==
"il__dfile") {
353 $id_arr = explode(
"_", $t);
354 $file_id = $id_arr[count($id_arr) - 1];
355 $file_ids[$file_id] = $file_id;
365 int $delete_lower_than_nr
367 $file_ids = self::_deleteHistoryUsagesLowerEqualThan(
370 $delete_lower_than_nr,
374 foreach ($file_ids as $file_id) {
377 $usages = $file->getUsages();
378 if (count($usages) == 0) {
388 int $a_usage_hist_nr,
393 $hist_repo = $DIC->copage()->internal()->repo()->history();
396 foreach ($hist_repo->getHistoryNumbersOlderEqualThanNr(
402 foreach (ilObjFile::_getFilesOfObject($parent_type .
":pg", $a_id, $old_nr, $a_lang) as $file_id) {
403 $file_ids[$file_id] = $file_id;
405 ilObjFile::_deleteAllUsages($parent_type .
":pg", $a_id, $old_nr, $a_lang);
setType(string $a_type)
Set Type.
getAllClasses()
Get all style classes.
static setFirstOptionalElement(php4DOMDocument $doc, php4DOMElement $parent_node, string $a_node_name, array $a_successors, string $a_content, array $a_attributes, bool $a_remove_childs=true)
searches for an element $a_node_name within the childs of $parent_node if no node is found...
static getLangVars()
Get lang vars needed for editing.
php4DOMElement $list_node
appendItem(int $a_id, string $a_location, string $a_format)
setNode(php4DOMElement $a_node)
static _deleteHistoryUsagesLowerEqualThan(string $parent_type, int $a_id, int $a_usage_hist_nr, string $a_lang="-")
static afterPageHistoryEntry(ilPageObject $a_page, DOMDocument $a_old_domdoc, string $a_old_xml, int $a_old_nr)
After page history entry has been created.
create(ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
getFileList()
Get list of files.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static deleteHistoryLowerEqualThan(string $parent_type, int $page_id, string $lang, int $delete_lower_than_nr)
saveStyleClasses(array $a_class)
Save style classes of file items.
static collectFileItems(ilPageObject $a_page, DOMDocument $a_domdoc)
Get all file items that are used within the page.
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
insertContent(ilPageContent $a_cont_obj, string $a_pos, int $a_mode=IL_INSERT_AFTER, string $a_pcid="", bool $remove_placeholder=true)
insert a content node before/after a sibling or as first child of a parent
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
deleteFileItems(array $a_ids)
Delete file items.
createPageContentNode(bool $a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
static saveFileUsage(ilPageObject $a_page, DOMDocument $a_domdoc, int $a_old_nr=0)
Save file usages.
setListTitle(string $a_title, string $a_language)
savePositions(array $a_pos)
Save positions of file items.
static beforePageDelete(ilPageObject $a_page)
Before page is being deleted.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static afterPageUpdate(ilPageObject $a_page, DOMDocument $a_domdoc, string $a_xml, bool $a_creation)
After page has been updated (or created)
static _lookupType(int $id, bool $reference=false)