ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilObjFileUnzipRecursiveProcessor Class Reference

Class ilObjFileUnzipRecursiveProcessor. More...

+ Inheritance diagram for ilObjFileUnzipRecursiveProcessor:
+ Collaboration diagram for ilObjFileUnzipRecursiveProcessor:

Public Member Functions

 process (ResourceIdentification $rid, ?string $title=null, ?string $description=null, ?string $copyright_id=null)
 Processes a given resource for the given arguments. More...
 
- Public Member Functions inherited from ilObjFileAbstractZipProcessor
 __construct (ResourceStakeholder $stakeholder, ilObjFileGUI $gui_object, Services $storage, ilFileServicesSettings $settings, private $tree)
 
- Public Member Functions inherited from ilObjFileAbstractProcessor
 __construct (protected ResourceStakeholder $stakeholder, protected ilObjFileGUI $gui_object, protected Services $storage, protected ilFileServicesSettings $settings)
 
 getInvalidFileNames ()
 
 process (ResourceIdentification $rid, ?string $title=null, ?string $description=null, ?string $copyright_id=null)
 Processes a given resource for the given arguments. More...
 

Private Attributes

array $path_map = []
 

Additional Inherited Members

- Protected Member Functions inherited from ilObjFileAbstractZipProcessor
 createSurroundingContainer (ResourceIdentification $rid)
 
 createContainerObj (string $dir_name, int $parent_id)
 Creates a container object depending on the parent's node type and returns it. More...
 
 openZip (ResourceIdentification $rid)
 Opens the zip archive of the given resource. More...
 
 getZipFiles ()
 Yields the file-paths of the currently open zip-archive. More...
 
 hasMultipleRootEntriesInZip ()
 
 getZipDirectories ()
 Yields the directory-paths of the currently open zip-archive. More...
 
 storeZippedFile (string $file_path)
 Creates an IRSS resource from the given filepath. More...
 
 closeZip ()
 Closes the currently open zip-archive. More...
 
 isWorkspace ()
 Returns whether the current context is workspace. More...
 
- Protected Member Functions inherited from ilObjFileAbstractProcessor
 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. More...
 
- Protected Attributes inherited from ilObjFileAbstractZipProcessor
bool $create_base_container_for_multiple_root_entries = false
 @description Unzip on operating systems may behave differently when unzipping if there are only one or more root nodes in the zip. More...
 
- Protected Attributes inherited from ilObjFileAbstractProcessor
ilFileServicesPolicy $policy
 
ilCountPDFPages $page_counter
 
array $invalid_file_names = []
 

Detailed Description

Member Function Documentation

◆ process()

ilObjFileUnzipRecursiveProcessor::process ( ResourceIdentification  $rid,
?string  $title = null,
?string  $description = null,
?string  $copyright_id = null 
)

Processes a given resource for the given arguments.

Implements ilObjFileProcessorInterface.

Definition at line 33 of file class.ilObjFileUnzipRecursiveProcessor.php.

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 }
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.
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.
createContainerObj(string $dir_name, int $parent_id)
Creates a container object depending on the parent's node type and returns it.
storeZippedFile(string $file_path)
Creates an IRSS resource from the given filepath.
openZip(ResourceIdentification $rid)
Opens the zip archive of the given resource.

References ilObjFileAbstractZipProcessor\createSurroundingContainer().

+ Here is the call graph for this function:

Field Documentation

◆ $path_map

array ilObjFileUnzipRecursiveProcessor::$path_map = []
private

Definition at line 31 of file class.ilObjFileUnzipRecursiveProcessor.php.


The documentation for this class was generated from the following file: