ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjFileUnzipRecursiveDelegate.php
Go to the documentation of this file.
1 <?php
2 
4 
10 {
11  protected function getPossibleContainer(int $parent_id) : ilObject
12  {
13  if (!$this->isInWorkspace()) {
14  $type = ilObject::_lookupType($parent_id, true);
15  } else {
16  $type = ilObject::_lookupType($this->tree->lookupObjectId($parent_id), false);
17  }
18 
19  switch ($type) {
20  // workspace structure
21  case 'wfld':
22  case 'wsrt':
23  return new ilObjWorkspaceFolder();
24  case 'cat':
25  case 'root':
26  return new ilObjCategory();
27  case 'fold':
28  case 'crs':
29  default:
30  return new ilObjFolder();
31  }
32  }
33 
34  public function handle(
35  int $parent_id,
36  array $post_data,
38  ilObjFileGUI $gui
40  $this->initZip($result);
41 
42  $base_node_id = $parent_id;
43 
44  // Create Base Container if needed
45  if ($this->create_base_container_for_multiple_root_entries && $this->hasMultipleRootEntriesInZip()) {
46  $base_node_id = $this->createSurroundingContainer($result, $parent_id);
47  }
48 
49  $this->path_map['./'] = $base_node_id;
50 
51  foreach ($this->getNextPath() as $original_path) {
52  $dir_name = dirname($original_path) . '/';
53  $parent_id_of_iteration = (int) ($this->path_map[$dir_name] ?? $parent_id);
54  $is_dir = substr($original_path, -1) === DIRECTORY_SEPARATOR;
55 
56  if ($is_dir) {
57  $obj = $this->createContainer($original_path, $parent_id_of_iteration);
58  $i = $this->isInWorkspace() ? $obj->getRefId() : $obj->getRefId();
59  $this->path_map[$original_path] = (int) $i;
60  } else {
61  $this->createFile($original_path, $parent_id_of_iteration);
62  }
63  }
64 
65  $this->tearDown();
66 
68  $response->error = null;
69  return $response;
70  }
71 }
Class ilObjFolder.
$result
$type
Class ilObjFileUnzipRecursiveDelegate.
Class ilObjFileAbstractZipDelegate.
Class ilObjFileUploadResponse.
createContainer(string $original_path, int $parent_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
Class ilObjCategory.
Class ilObjWorkspaceFolder.
createSurroundingContainer(UploadResult $result, int $parent_id)
createFile(string $original_path, int $parent_id)
GUI class for file objects.
$response
$i
Definition: metadata.php:24
handle(int $parent_id, array $post_data, UploadResult $result, ilObjFileGUI $gui)