ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilFileExporter.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
29{
33 public function init(): void
34 {
35 }
36
44 #[\Override]
45 public function getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids): array
46 {
47 $md_ids = [];
48 foreach ($a_ids as $file_id) {
49 $md_ids[] = $file_id . ":0:file";
50 }
51
52 return [
53 [
54 "component" => "components/ILIAS/MetaData",
55 "entity" => "md",
56 "ids" => $md_ids,
57 ],
58 [
59 "component" => "components/ILIAS/ILIASObject",
60 "entity" => "common",
61 "ids" => $a_ids
62 ]
63 ];
64 }
65
73 public function getXmlRepresentation(string $a_entity, string $a_schema_version, string $a_id): string
74 {
75 $xml = '';
76 if (ilObject::_lookupType((int) $a_id) === 'file') {
77 $file = new ilObjFile((int) $a_id, false);
78 $writer = new ilFileXMLWriter();
79 $writer->setFile($file);
80 $writer->setOmitHeader(true);
81 $writer->setAttachFileContents(ilFileXMLWriter::$CONTENT_ATTACH_COPY);
82 $this->prepareExportDirectories($writer);
83 $writer->start();
84 $xml = $writer->getXml();
85 }
86 return $xml;
87 }
88
89 protected function prepareExportDirectories(
90 ilFileXMLWriter $writer
91 ): void {
92 $path = str_replace('\\', '/', $this->exp->getExportDirInContainer());
93 $segments = explode('/', $path);
94 array_shift($segments);
95 $target_dir_relative = implode('/', $segments) . '/expDir_1';
96 $target_dir_absolute = rtrim($this->getAbsoluteExportDirectory(), '/') . '/' . $target_dir_relative;
97 ilFileUtils::makeDirParents($target_dir_absolute);
99 $target_dir_relative,
100 $target_dir_absolute
101 );
102 }
103
109 public function getValidSchemaVersions(string $a_entity): array
110 {
111 return [
112 "4.1.0" => [
113 "namespace" => "http://www.ilias.de/Modules/File/file/4_1",
114 "xsd_file" => "ilias_file_4_1.xsd",
115 "min" => "4.1.0",
116 "max" => ""
117 ]
118 ];
119 }
120}
Exporter class for files.
getValidSchemaVersions(string $a_entity)
Returns schema versions that the component can export to.
prepareExportDirectories(ilFileXMLWriter $writer)
getXmlRepresentation(string $a_entity, string $a_schema_version, string $a_id)
Get xml representation.
init()
Initialisation.
getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids)
Get tail dependencies.
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static int $CONTENT_ATTACH_COPY
setFileTargetDirectories(?string $a_rel, ?string $a_abs)
Set file target directories.
Class ilObjFile.
static _lookupType(int $id, bool $reference=false)
Xml Exporter class.
$path
Definition: ltiservices.php:30