ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
4include_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 $objDefinition;
89
90 $class_name = "ilObj" . $objDefinition->getClassName($a_type);
91 $location = $objDefinition->getLocation($a_type);
92
93 include_once($location . "/class." . $class_name . ".php");
94 $new = new $class_name();
95 $new->setTitle('Import');
96 $new->create(true);
97 $new->createReference();
98 $new->putInTree($this->getMapping()->getTargetId());
99 $new->setPermissions($this->getMapping()->getTargetId());
100
101 $this->getMapping()->addMapping('Services/Container', 'objs', 0, $new->getId());
102 $this->getMapping()->addMapping('Services/Container', 'refs', 0, $new->getRefId());
103
104 return $new;
105 }
106}
$parser
Definition: BPMN2Parser.php:23
$location
Definition: buildRTE.php:44
An exception for terminatinating execution or to throw for unit testing.
doImportObject($dir, $type, $a_component="", $a_tmpdir="")
Import a container.
createDummy($a_type)
Create dummy object.
__construct($a_target_id)
Constructor.
Import class.
getMapping()
Get mapping object.
Manifest parser for ILIAS standard export files.
$ret
Definition: parser.php:6
$type
$a_type
Definition: workflow.php:92