ILIAS  release_8 Revision v8.24
class.ilObjFileUnzipRecursiveProcessor.php
Go to the documentation of this file.
1<?php
2
20
27{
31 private array $path_map = [];
32
33
34
35 public function process(ResourceIdentification $rid, array $options = []): void
36 {
37 $this->openZip($rid);
38 $base_node = $this->gui_object->getParentId();
39
40 // Create Base Container if needed
41 if ($this->create_base_container_for_multiple_root_entries && $this->hasMultipleRootEntriesInZip()) {
42 $base_node = $this->createSurroundingContainer($rid);
43 }
44
45 $this->path_map['./'] = $base_node;
46
47 // Create Containers first to have proper path mapping after,
48 // differences between macOS and windows are already handled in getZipDirectories()
49 foreach ($this->getZipDirectories() as $directory) {
50 $dir_name = dirname($directory) . '/';
51 $parent_id_of_iteration = (int) ($this->path_map[$dir_name] ?? $base_node);
52
53 $obj = $this->createContainerObj(basename($directory), $parent_id_of_iteration);
54 $this->path_map[$directory] = (int) $obj->getRefId();
55 }
56
57
58 // Create Files
59 foreach ($this->getZipFiles() as $file_path) {
60 $dir_name = dirname($file_path) . '/';
61 $parent_id_of_iteration = (int) ($this->path_map[$dir_name] ?? $base_node);
62
63 $this->createFileObj($this->storeZippedFile($file_path), $parent_id_of_iteration, [], true);
64 }
65
66 $this->closeZip();
67 }
68}
createFileObj(ResourceIdentification $rid, int $parent_id, array $options=[], bool $create_reference=false)
Creates an ilObjFile instance for the provided information.
Class ilObjFileAbstractZipProcessor.
createSurroundingContainer(ResourceIdentification $rid)
closeZip()
Closes the currently open zip-archive.
getZipDirectories()
Yields the directory-paths of the currently open zip-archive.
getZipFiles()
Yields the file-paths of the currently open zip-archive.
storeZippedFile(string $file_path)
Creates an IRSS resource from the given filepath.
openZip(ResourceIdentification $rid)
Opens the zip archive of the given resource.
createContainerObj(string $dir_name, int $parent_id, array $options=[])
Creates a container object depending on the parent's node type and returns it.
process(ResourceIdentification $rid, array $options=[])
Processes a given resource for the given arguments.