71 $this->access_handler = $access_checker;
79 $info =
new SplFileInfo(
$result->getName());
80 $base_path = $info->getBasename(
"." . $info->getExtension());
83 return (
int) $base_container->getRefId();
98 $this->zip =
new ZipArchive();
99 $this->zip->open(
$result->getPath());
116 $obj = $this->getPossibleContainer($parent_id);
117 $obj->setTitle(basename($original_path));
121 $obj->createReference();
122 $obj->putInTree($parent_id);
123 $obj->setPermissions($parent_id);
125 $node_id = $this->tree->insertObject($parent_id, $obj->getId());
126 $this->access_handler->setPermissions($parent_id, $node_id);
127 $obj->setRefId($node_id);
130 if ($obj->getType() ===
"cat") {
134 $obj->addTranslation(basename($original_path),
"",
$lng->getLangKey(),
$lng->getLangKey());
149 $obj->setTitle(basename($original_path));
152 $obj->appendStream(Streams::ofString($this->zip->getFromName($original_path)), basename($original_path));
155 $obj->createReference();
156 $obj->putInTree($parent_id);
157 $obj->setPermissions($parent_id);
159 $node_id = $this->tree->insertObject($parent_id, $obj->getId());
160 $this->access_handler->setPermissions($parent_id, $node_id);
161 $obj->setRefId($node_id);
164 $this->uploaded_suffixes[] = $obj->getFileExtension();
176 for (
$i = 0;
$i < $this->zip->numFiles;
$i++) {
177 $original_path = $this->zip->getNameIndex(
$i, ZipArchive::FL_UNCHANGED);
178 if (strpos($original_path,
'__MACOSX') !==
false || strpos($original_path,
'.DS_') !==
false) {
181 $paths[] = $original_path;
184 $path_with_root_folders = [];
186 foreach ($paths as $path) {
187 $parent = dirname($path) .
'/';
188 if ($parent !==
'./' && !in_array($parent, $paths)) {
189 $path_with_root_folders[] = $parent;
191 $path_with_root_folders[] = $path;
194 $path_with_root_folders = array_unique($path_with_root_folders);
195 sort($path_with_root_folders);
197 yield from $path_with_root_folders;
204 $dirname = dirname($zip_directory);
205 if ($dirname ===
'.') {
217 return array_map(
'strtolower', $this->uploaded_suffixes);
An exception for terminatinating execution or to throw for unit testing.
Class Streams Stream factory which enables the user to create streams without the knowledge of the co...
Interface Identification.
Class ilObjFileAbstractZipDelegate.
__construct(object $access_checker, int $node_type, ilTree $tree)
ilObjFileAbstractZipDelegate constructor.
initZip(UploadResult $result)
hasMultipleRootEntriesInZip()
createSurroundingContainer(UploadResult $result, int $parent_id)
createContainer(string $original_path, int $parent_id)
createFile(string $original_path, int $parent_id)
$create_base_container_for_multiple_root_entries
@description Unzip on operating systems may behave differently when unzipping if there are only one o...
Class ilObject Basic functions for all objects.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
Interface ilObjUploadDelegateInterface.