19 declare(strict_types=1);
46 class Handler implements ilExportHandlerManagerInterface
55 ilExportHandlerFactoryInterface $export_handler,
59 ilExportHandlerDataFactoryWrapperInterface $data_factory_wrapper
71 $obj_id = $export_object->
getId();
72 $type = $export_object->
getType();
73 $class = ilImportExportFactory::getExporterClass($type);
74 $comp = ilImportExportFactory::getComponentForExport($type);
76 $target_release = $v[0] .
"." . $v[1] .
".0";
77 return $this->export_handler->target()->handler()
78 ->withTargetRelease($target_release)
80 ->withObjectIds([$obj_id])
81 ->withClassname($class)
82 ->withComponent($comp);
87 ): ilExportHandlerTargetInterface {
88 $obj_id = $object_id->
toInt();
90 $class = ilImportExportFactory::getExporterClass($type);
91 $comp = ilImportExportFactory::getComponentForExport($type);
93 $target_release = $v[0] .
"." . $v[1] .
".0";
94 return $this->export_handler->target()->handler()
95 ->withTargetRelease($target_release)
97 ->withObjectIds([$obj_id])
98 ->withClassname($class)
99 ->withComponent($comp);
103 string $path_in_container,
104 ilExportHandlerExportInfo $export_info,
105 ilExportHandlerRepositoryElementInterface $element
107 $export_info = $export_info->withCurrentElement($element);
108 $manifest = $this->export_handler->part()->manifest()->handler()
109 ->withInfo($export_info);
110 $element->getIRSS()->write(
112 $path_in_container . DIRECTORY_SEPARATOR . $export_info->getExportFolderName() . DIRECTORY_SEPARATOR .
"manifest.xml" 114 foreach ($export_info->getComponentInfos() as $component_info) {
115 $component = $this->export_handler->part()->component()->handler()
116 ->withExportInfo($export_info)
117 ->withComponentInfo($component_info);
118 $element->getIRSS()->write(
120 $path_in_container . DIRECTORY_SEPARATOR . $component_info->getExportFilePathInContainer()
127 ilExportHandlerContainerExportInfoInterface $container_export_info,
128 ): ilExportHandlerRepositoryElementInterface {
129 $main_export_info = $container_export_info->getMainEntityExportInfo();
133 "set_" . $main_export_info->getSetNumber()
135 $repository = $this->export_handler->repository();
136 foreach ($container_export_info->getExportInfos() as $export_info) {
138 $keys = $repository->key()->collection()
139 ->withElement($repository->key()->handler()->withObjectId($export_info->getTargetObjectId()));
140 $element = $export_info->getReuseExport()
141 ? $this->export_handler->repository()->handler()->getElements($keys)->newest()
143 $element = $element->getIRSS()->isContainerExport()
146 $stream = $element->getIRSSInfo()->getStream();
148 $zip_structure = $zip_reader->getStructure();
149 foreach ($zip_structure as $path_inside_zip => $item) {
150 if ($item[
'is_dir']) {
156 $stream = $zip_reader->getItem($path_inside_zip, $zip_structure)[0];
157 # Contents of the stream $stream are lost later (possible incompatible stream object), therefore a new 158 # stream with the content of $stream is created and passed on. 159 $main_element->getIRSS()->write(
161 "set_" . $export_info->getSetNumber() . DIRECTORY_SEPARATOR . $path_inside_zip
165 $container = $this->export_handler->part()->container()->handler()
166 ->withExportInfos($container_export_info->getExportInfos()->withElementAtHead($main_export_info))
167 ->withMainEntityExportInfo($main_export_info);
168 $main_element->getIRSS()->write(
172 return $main_element;
177 ilExportHandlerExportInfoInterface $export_info,
178 string $path_in_container
179 ): ilExportHandlerRepositoryElementInterface {
180 # make legacy export run dir 181 # tmp solution, remove later if no longer needed 184 $stakeholder = $this->export_handler->repository()->stakeholder()->handler()->withOwnerId($user_id);
185 $object_id = $this->data_factory_wrapper->objId($export_info->getTarget()->getObjectIds()[0]);
186 $element = $this->export_handler->repository()->handler()->createElement(
191 $this->
writeToElement($path_in_container, $export_info, $element);
193 # write files from legacy export run dir to irss 194 # tmp solution, remove later if no longer needed 195 $writer = $this->export_handler->consumer()->handler()->exportWriter($element);
196 $writer->writeDirectoryRecursive(
197 $export_info->getLegacyExportRunDir(),
198 $export_info->getExportFolderName()
201 # delete legacy export run dir 202 # tmp solution, remove if no longer needed 210 ExportConfigCollectionInterface $export_configs
227 ExportConfigCollectionInterface $export_configs
228 ): ilExportHandlerExportInfoInterface {
229 return $this->export_handler->info()->export()->handler()
231 ->withExportConfigs($export_configs);
237 ExportConfigCollectionInterface $export_configs
238 ): ilExportHandlerExportInfoInterface {
239 return $this->export_handler->info()->export()->handler()
241 ->withExportConfigs($export_configs);
246 ilExportHandlerContainerExportInfoObjectIdCollectionInterface $object_ids,
247 ExportConfigCollectionInterface $export_configs
248 ): ilExportHandlerContainerExportInfoInterface {
249 return $this->export_handler->info()->export()->container()->handler()
250 ->withMainExportEntity($main_entity_object_id)
251 ->withObjectIds($object_ids)
252 ->withTimestamp(time())
253 ->withExportConfigs($export_configs);
258 return $this->export_handler->info()->export()->container()->objectId()->collectionBuilder();
263 bool $public_access =
false 264 ): ilExportHandlerContainerExportInfoObjectIdCollectionBuilderInterface {
265 $id_collection_builder = $this->export_handler->info()->export()->container()->objectId()->collectionBuilder();
266 $tree_nodes = $this->tree->getSubTree($this->tree->getNodeData($container_reference_id->
toInt()));
267 foreach ($tree_nodes as $node) {
269 $node[
'type'] ==
'rolf' or
270 !$this->obj_definition->allowExport($node[
'type']) or
272 !$this->
access->checkAccess(
'write',
'', (
int) $node[
'ref_id'])
276 $reference_id =
new ReferenceId((
int) $node[
'ref_id']);
277 $object_id = $reference_id->toObjectId();
278 $keys = $this->export_handler->repository()->key()->collection()->withElement(
279 $this->export_handler->repository()->key()->handler()->withObjectId($object_id)
281 $elements = $this->export_handler->repository()->handler()->getElements($keys);
282 $create_new_export = (
283 ($public_access and !$this->export_handler->publicAccess()->handler()->hasPublicAccessFile($object_id)) or
284 !$public_access and $elements->count() == 0
286 $id_collection_builder = $id_collection_builder->addObjectId($object_id, $create_new_export);
288 return $id_collection_builder;
getContainerExportInfo(ObjectId $main_entity_object_id, ilExportHandlerContainerExportInfoObjectIdCollectionInterface $object_ids, ExportConfigCollectionInterface $export_configs)
getExportInfoWithObject(ilObject $export_object, int $time_stamp, ExportConfigCollectionInterface $export_configs)
getExportTargetWithObject(ilObject $export_object)
writeToElement(string $path_in_container, ilExportHandlerExportInfo $export_info, ilExportHandlerRepositoryElementInterface $element)
static _isFileHidden(string $a_file_name)
Returns true, if a file with the specified name, is usually hidden from the user. ...
createExportOfObject(ilObject $export_object, int $user_id, ExportConfigCollectionInterface $export_configs)
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
createContainerExport(int $user_id, ilExportHandlerContainerExportInfoInterface $container_export_info)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
const ILIAS_VERSION_NUMERIC
__construct(ilExportHandlerFactoryInterface $export_handler, ilObjectDefinition $obj_definition, ilTree $tree, ilAccessHandler $access, ilExportHandlerDataFactoryWrapperInterface $data_factory_wrapper)
ilExportHandlerFactoryInterface $export_handler
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
ilObjectDefinition $obj_definition
static ofString(string $string)
Creates a new stream with an initial value.
getObjectIdCollectioBuilder()
getExportInfo(ObjectId $object_id, int $time_stamp, ExportConfigCollectionInterface $export_configs)
ilExportHandlerDataFactoryWrapperInterface $data_factory_wrapper
getExportTarget(ObjectId $object_id)
createExport(int $user_id, ilExportHandlerExportInfoInterface $export_info, string $path_in_container)
static _lookupType(int $id, bool $reference=false)
getObjectIdCollectionBuilderFrom(ReferenceId $container_reference_id, bool $public_access=false)