ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  {
37  return false;
38  }
39 
40  include_once("./Services/Export/classes/class.ilManifestParser.php");
41  $parser = new ilManifestParser($manifest_file);
42 
43 
44  // begin-patch optes_lok_export
45 
46  // Handling single containers without subitems
47 
48  // @todo: check if this is required
49  // all container have container export sets
50  $all_importers = array();
51 
52  if(!$parser->getExportSets())
53  {
54  $this->createDummy($type);
55  $import_info = parent::doImportObject($dir,$type);
56 
57  $all_importers = array_merge($all_importers, $import_info['importers']);
58  return $import_info;
59  //return $import_info['new_id'];
60  }
61 
62  // Handling containers with subitems
63  $first = true;
64  foreach($parser->getExportSets() as $set)
65  {
66  $import_info = parent::doImportObject($dir.DIRECTORY_SEPARATOR.$set['path'],$set['type']);
67 
68  $all_importers = array_merge($all_importers, $import_info['importers']);
69  if($first)
70  {
71  $ret = $import_info;
72  //$ret = $import_info['new_id'];
73  $first = false;
74  }
75  }
76  // after container import is finished, call all importers to perform a final processing
77  foreach((array) $all_importers as $importer)
78  {
79  $importer->afterContainerImportProcessing($this->getMapping());
80  }
81  // end-patch optes_lok_export
82 
83  return $ret;
84  }
85 
91  protected function createDummy($a_type)
92  {
93  global $objDefinition;
94 
95  $class_name = "ilObj".$objDefinition->getClassName($a_type);
96  $location = $objDefinition->getLocation($a_type);
97 
98  include_once($location."/class.".$class_name.".php");
99  $new = new $class_name();
100  $new->setTitle('Import');
101  $new->create(true);
102  $new->createReference();
103  $new->putInTree($this->getMapping()->getTargetId());
104  $new->setPermissions($this->getMapping()->getTargetId());
105 
106  $this->getMapping()->addMapping('Services/Container','objs', 0, $new->getId());
107  $this->getMapping()->addMapping('Services/Container','refs', 0,$new->getRefId());
108 
109  return $new;
110 
111  }
112 }
113 ?>
createDummy($a_type)
Create dummy object.
$location
Definition: buildRTE.php:44
getMapping()
Get mapping object.
Import class.
$a_type
Definition: workflow.php:93
__construct($a_target_id)
Constructor.
Create styles array
The data for the language used.
Manifest parser for ILIAS standard export files.
$parser
Definition: BPMN2Parser.php:24
$ret
Definition: parser.php:6
doImportObject($dir, $type, $a_component="", $a_tmpdir="")
Import a container.