65 $this->id_type = $gui_object->
getIdType();
72 $zip_name = $this->storage->manage()->getCurrentRevision($rid)->getInformation()->getTitle();
74 $base_path = $info->getBasename(
"." . $info->getExtension());
75 $base_container = $this->
createContainerObj($base_path, $this->gui_object->getParentId());
77 return (
int) $base_container->getRefId();
86 $container_obj->setTitle($dir_name);
88 if (!empty($options)) {
92 $container_obj->create();
93 $container_obj->createReference();
95 $this->gui_object->putObjectInTree($container_obj, $parent_id);
97 return $container_obj;
105 if (null !== $this->archive) {
106 throw new LogicException(
"openZip() can only be called once, yet it was called again.");
109 $file_uri = $this->storage->consume()->stream($rid)->getStream()->getMetadata(self::IRSS_FILEPATH_KEY);
110 $this->archive =
new ZipArchive();
111 $this->archive->open($file_uri);
120 if (null === $this->archive) {
121 throw new LogicException(
"cannot read content of unopened zip archive");
124 for (
$i = 0, $i_max = $this->archive->count();
$i < $i_max;
$i++) {
125 $path = $this->archive->getNameIndex(
$i, ZipArchive::FL_UNCHANGED);
126 if (strpos(
$path,
'__MACOSX') !==
false || strpos(
$path,
'.DS_') !==
false) {
141 if (substr($path, -1) !==
"/" && substr($path, -1) !==
"\\") {
151 $dirname = dirname($zip_directory);
152 if ($dirname ===
'.') {
160 $dirname = dirname($zip_file);
161 if ($dirname ===
'.') {
180 if (substr($path, -1) ===
"/" || substr($path, -1) ===
"\\") {
181 $directories[] =
$path;
185 $directories_with_parents = [];
187 foreach ($directories as $directory) {
188 $parent = dirname($directory) .
'/';
189 if ($parent !==
'./' && !in_array($parent, $directories)) {
190 $directories_with_parents[] = $parent;
192 $directories_with_parents[] = $directory;
195 $directories_with_parents = array_unique($directories_with_parents);
196 sort($directories_with_parents);
197 yield from $directories_with_parents;
206 if (null === $this->archive) {
207 throw new LogicException(
"No archive has been opened yet, call openZip() first in order to read files.");
210 return $this->storage->manage()->stream(
211 Streams::ofString($this->archive->getFromName($file_path)),
222 if ($this->archive !== null) {
223 $this->archive->close();
ilFileServicesSettings $settings
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
applyOptions(ilObject $obj, array $options)
Apply provided options to the given object.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ResourceStakeholder $stakeholder, ilObjFileGUI $gui_object, Services $storage, ilFileServicesSettings $settings, $tree)
createContainerObj(string $dir_name, int $parent_id, array $options=[])
Creates a container object depending on the parent's node type and returns it.
isWorkspace()
Returns whether the current context is workspace.
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ResourceStakeholder $stakeholder
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ResourceIdentification.
storeZippedFile(string $file_path)
Creates an IRSS resource from the given filepath.
hasMultipleRootEntriesInZip()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getPossibleContainerObj(int $parent_id)
Returns a container object that is possible for the given parent.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
closeZip()
Closes the currently open zip-archive.
getZipPaths()
Yields all paths of the currently open zip-archive (without some macos stuff).
Class ilObjFileAbstractProcessorInterface.
bool $create_base_container_for_multiple_root_entries
Unzip on operating systems may behave differently when unzipping if there are only one or more root n...
__construct(Container $dic, ilPlugin $plugin)
GUI class for file objects.
openZip(ResourceIdentification $rid)
Opens the zip archive of the given resource.
Interface ResourceStakeholder.
static _lookupType(int $id, bool $reference=false)