ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilObjFileUnzipRecursiveProcessor.php
Go to the documentation of this file.
1 <?php
2 
20 
27 {
31  private array $path_map = [];
32 
33  public function process(
35  ?string $title = null,
36  ?string $description = null,
37  ?string $copyright_id = null
38  ): void {
39  $this->openZip($rid);
40  $base_node = $this->gui_object->getParentId();
41 
42  // Create Base Container if needed
43  if ($this->create_base_container_for_multiple_root_entries && $this->hasMultipleRootEntriesInZip()) {
44  $base_node = $this->createSurroundingContainer($rid);
45  }
46 
47  $this->path_map['./'] = $base_node;
48 
49  // Create Containers first to have proper path mapping after,
50  // differences between macOS and windows are already handled in getZipDirectories()
51  foreach ($this->getZipDirectories() as $directory) {
52  $dir_name = dirname($directory) . '/';
53  $parent_id_of_iteration = (int) ($this->path_map[$dir_name] ?? $base_node);
54 
55  $obj = $this->createContainerObj(basename($directory), $parent_id_of_iteration);
56  $this->path_map[$directory] = (int) $obj->getRefId();
57  }
58 
59  // Create Files
60  foreach ($this->getZipFiles() as $file_path) {
61  $dir_name = dirname($file_path) . '/';
62  $parent_id_of_iteration = (int) ($this->path_map[$dir_name] ?? $base_node);
63  $rid_of_iteration = $this->storeZippedFile($file_path);
64 
65  $file_obj = $this->createFileObj(
66  $rid_of_iteration,
67  $parent_id_of_iteration,
68  null,
69  null,
70  $copyright_id,
71  true
72  );
73  }
74 
75  $this->closeZip();
76  }
77 }
getZipFiles()
Yields the file-paths of the currently open zip-archive.
createSurroundingContainer(ResourceIdentification $rid)
getZipDirectories()
Yields the directory-paths of the currently open zip-archive.
Class ilObjFileAbstractZipProcessor.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
storeZippedFile(string $file_path)
Creates an IRSS resource from the given filepath.
closeZip()
Closes the currently open zip-archive.
openZip(ResourceIdentification $rid)
Opens the zip archive of the given resource.
createFileObj(ResourceIdentification $rid, int $parent_id, ?string $title=null, ?string $description=null, ?string $copyright_id=null, bool $create_reference=false)
Creates an ilObjFile instance for the provided information.
Class ilObjFileUnzipRecursiveProcessor.
createContainerObj(string $dir_name, int $parent_id)
Creates a container object depending on the parent&#39;s node type and returns it.
process(ResourceIdentification $rid, ?string $title=null, ?string $description=null, ?string $copyright_id=null)
Processes a given resource for the given arguments.