ILIAS  release_8 Revision v8.23
ilObjFileUnzipRecursiveProcessor Class Reference

Class ilObjFileUnzipRecursiveProcessor. More...

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

Public Member Functions

 process (ResourceIdentification $rid, array $options=[])
 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, $tree)
 
- Public Member Functions inherited from ilObjFileAbstractProcessor
 __construct (ResourceStakeholder $stakeholder, ilObjFileGUI $gui_object, Services $storage, ilFileServicesSettings $settings)
 
 getInvalidFileNames ()
 

Private Attributes

array $path_map = []
 

Additional Inherited Members

- Data Fields inherited from ilObjFileProcessorInterface
const OPTION_FILENAME = 'title'
 
const OPTION_DESCRIPTION = 'description'
 
const OPTIONS
 
- Protected Member Functions inherited from ilObjFileAbstractZipProcessor
 createSurroundingContainer (ResourceIdentification $rid)
 
 createContainerObj (string $dir_name, int $parent_id, array $options=[])
 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, array $options=[], bool $create_reference=false)
 Creates an ilObjFile instance for the provided information. More...
 
 applyOptions (ilObject $obj, array $options)
 Apply provided options to the given object. More...
 
- Protected Attributes inherited from ilObjFileAbstractZipProcessor
bool $create_base_container_for_multiple_root_entries = false
 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
 
ilFileServicesSettings $settings
 
ilCountPDFPages $page_counter
 
Services $storage
 
ResourceStakeholder $stakeholder
 
ilObjFileGUI $gui_object
 
array $invalid_file_names = []
 

Detailed Description

Member Function Documentation

◆ process()

ilObjFileUnzipRecursiveProcessor::process ( ResourceIdentification  $rid,
array  $options = [] 
)

Processes a given resource for the given arguments.

Parameters
array<string,mixed>$options
See also
ilObjFileProcessorInterface::OPTIONS

Implements ilObjFileProcessorInterface.

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

References ilObjFileAbstractZipProcessor\closeZip(), ilObjFileAbstractZipProcessor\createContainerObj(), ilObjFileAbstractProcessor\createFileObj(), ilObjFileAbstractZipProcessor\createSurroundingContainer(), ilObjFileAbstractZipProcessor\getZipDirectories(), ilObjFileAbstractZipProcessor\getZipFiles(), ilObjFileAbstractZipProcessor\hasMultipleRootEntriesInZip(), ILIAS\Repository\int(), ilObjFileAbstractZipProcessor\openZip(), and ilObjFileAbstractZipProcessor\storeZippedFile().

35  : 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  }
createContainerObj(string $dir_name, int $parent_id, array $options=[])
Creates a container object depending on the parent&#39;s node type and returns it.
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.
createFileObj(ResourceIdentification $rid, int $parent_id, array $options=[], bool $create_reference=false)
Creates an ilObjFile instance for the provided information.
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.
+ 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: