28 include_once(
"./Services/Export/classes/class.ilImportMapping.php");
30 $this->mapping->setTagetId($a_target_id);
49 $this->entity_types = $a_val;
59 return $this->entity_types;
70 $this->skip_entity[$a_component][$a_entity] = $skip;
80 $this->current_dataset = $a_val;
91 return $this->current_dataset;
117 $a_entity, $a_component, $a_copy_file =
false)
119 $this->
importObject(null, $a_tmp_file, $a_filename, $a_entity, $a_component, $a_copy_file);
128 final public function importObject($a_new_obj, $a_tmp_file, $a_filename, $a_type,
129 $a_comp =
"", $a_copy_file =
false)
136 copy($a_tmp_file, $tmpdir.
"/".$a_filename);
143 $dir = $tmpdir.
"/".substr($a_filename, 0, strlen($a_filename) - 4);
145 $GLOBALS[
'ilLog']->write(__METHOD__.
': do import with dir '.$dir);
160 protected function doImportObject($dir, $a_type, $a_component =
"", $a_tmpdir =
"")
162 global $objDefinition,
$tpl;
164 if ($a_component ==
"")
166 $comp = $objDefinition->getComponentForType($a_type);
167 $class = $objDefinition->getClassName($a_type);
171 $comp = $a_component;
172 $c = explode(
"/", $comp);
173 $class = $c[count($c) - 1];
182 include_once(
"./Services/Export/classes/class.ilManifestParser.php");
183 if (!is_file($dir.
"/manifest.xml"))
185 include_once(
"./Services/Export/exceptions/class.ilManifestFileNotFoundImportException.php");
187 $e->setManifestDir($dir);
188 $e->setTmpDir($a_tmpdir);
192 $this->mapping->setInstallUrl($parser->getInstallUrl());
193 $this->mapping->setInstallId($parser->getInstallId());
196 $expfiles = $parser->getExportFiles();
198 include_once(
"./Services/Export/classes/class.ilExportFileParser.php");
199 $all_importers = array();
200 foreach ($expfiles as $expfile)
202 $comp = $expfile[
"component"];
203 $comp_arr = explode(
"/", $comp);
204 $import_class_file =
"./".$comp.
"/classes/class.il".$comp_arr[1].
"Importer.php";
205 $class =
"il".$comp_arr[1].
"Importer";
206 include_once($import_class_file);
207 $this->importer =
new $class();
208 $all_importers[] = $this->importer;
209 $this->importer->setImportDirectory($dir);
210 $this->importer->init();
211 $this->current_comp = $comp;
218 $GLOBALS[
'ilLog']->write(__METHOD__.
': Import failed with message: '.$e->getMessage());
219 #$GLOBALS['ilLog']->write(__METHOD__.': '.file_get_contents($dir.'/'.$expfile['path']));
225 foreach ($all_importers as $imp)
227 $imp->finalProcessing($this->mapping);
231 $top_mapping = $this->mapping->getMappingsOfEntity($this->comp, $a_type);
232 $new_id = (int) current($top_mapping);
242 function processItemXml($a_entity, $a_schema_version, $a_id, $a_xml,$a_install_id, $a_install_url)
244 global $objDefinition;
247 if ($this->skip_entity[$this->current_comp][$a_entity])
252 if($objDefinition->isRBACObject($a_entity) &&
253 $this->
getMapping()->getMapping(
'Services/Container',
'imported', $a_id))
255 $GLOBALS[
'ilLog']->write(__METHOD__.
': Ignoring referenced '.$a_entity.
' with id '.$a_id);
258 $this->importer->setInstallId($a_install_id);
259 $this->importer->setInstallUrl($a_install_url);
260 $this->importer->setSchemaVersion($a_schema_version);
261 $this->importer->setSkipEntities($this->skip_entity);
262 $new_id = $this->importer->importXmlRepresentation($a_entity, $a_id, $a_xml, $this->mapping);
265 if($objDefinition->isRBACObject($a_entity))
267 $this->
getMapping()->addMapping(
'Services/Container',
'imported', $a_id, 1);
273 $this->mapping->addMapping($this->comp ,$a_entity, $a_id, $new_id);