ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilImportContainer.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once './Services/Export/classes/class.ilImport.php';
5 
14 {
20  public function __construct($a_target_id)
21  {
22  parent::__construct($a_target_id);
23  }
24 
25 
32  protected function doImportObject($dir, $type, $a_component = "", $a_tmpdir = "")
33  {
34  $manifest_file = $dir . "/manifest.xml";
35  if (!file_exists($manifest_file)) {
36  return false;
37  }
38 
39  include_once("./Services/Export/classes/class.ilManifestParser.php");
40  $parser = new ilManifestParser($manifest_file);
41 
42 
43  // begin-patch optes_lok_export
44 
45  // Handling single containers without subitems
46 
47  // @todo: check if this is required
48  // all container have container export sets
49  $all_importers = array();
50 
51  if (!$parser->getExportSets()) {
52  $this->createDummy($type);
53  $import_info = parent::doImportObject($dir, $type);
54 
55  $all_importers = array_merge($all_importers, $import_info['importers']);
56  return $import_info;
57  //return $import_info['new_id'];
58  }
59 
60  // Handling containers with subitems
61  $first = true;
62  foreach ($parser->getExportSets() as $set) {
63  $import_info = parent::doImportObject($dir . DIRECTORY_SEPARATOR . $set['path'], $set['type']);
64 
65  $all_importers = array_merge($all_importers, $import_info['importers']);
66  if ($first) {
67  $ret = $import_info;
68  //$ret = $import_info['new_id'];
69  $first = false;
70  }
71  }
72  // after container import is finished, call all importers to perform a final processing
73  foreach ((array) $all_importers as $importer) {
74  $importer->afterContainerImportProcessing($this->getMapping());
75  }
76  // end-patch optes_lok_export
77 
78  return $ret;
79  }
80 
86  protected function createDummy($a_type)
87  {
88  global $DIC;
89 
90  $objDefinition = $DIC['objDefinition'];
91 
92  $class_name = "ilObj" . $objDefinition->getClassName($a_type);
93  $location = $objDefinition->getLocation($a_type);
94 
95  include_once($location . "/class." . $class_name . ".php");
96  $new = new $class_name();
97  $new->setTitle('Import');
98  $new->create(true);
99  $new->createReference();
100  $new->putInTree($this->getMapping()->getTargetId());
101  $new->setPermissions($this->getMapping()->getTargetId());
102 
103  $this->getMapping()->addMapping('Services/Container', 'objs', 0, $new->getId());
104  $this->getMapping()->addMapping('Services/Container', 'refs', 0, $new->getRefId());
105 
106  return $new;
107  }
108 }
createDummy($a_type)
Create dummy object.
$type
global $DIC
Definition: saml.php:7
$location
Definition: buildRTE.php:44
getMapping()
Get mapping object.
Import class.
$a_type
Definition: workflow.php:92
__construct($a_target_id)
Constructor.
Manifest parser for ILIAS standard export files.
$parser
Definition: BPMN2Parser.php:23
$ret
Definition: parser.php:6
doImportObject($dir, $type, $a_component="", $a_tmpdir="")
Import a container.