3 declare(strict_types=1);
48 $this->objDefinition = $DIC[
'objDefinition'];
50 $this->mapping->setTargetId($a_target_id);
51 $this->log = $DIC->logger()->exp();
60 if (isset($this->configs[$a_comp])) {
61 return $this->configs[$a_comp];
65 $comp_arr = explode(
"/", $a_comp);
66 $a_class =
"il" . $comp_arr[1] .
"ImportConfig";
67 $imp_config =
new $a_class();
68 $this->configs[$a_comp] = $imp_config;
80 $this->entity_types = $a_val;
91 public function addSkipEntity(
string $a_component,
string $a_entity,
bool $skip =
true): void
93 $this->skip_entity[$a_component][$a_entity] = $skip;
98 $this->skip_importer[$a_component] = $skip;
109 bool $a_copy_file =
false 111 return $this->
importObject(null, $a_tmp_file, $a_filename, $a_entity, $a_component, $a_copy_file);
120 bool $a_copy_file =
false 127 copy($a_tmp_file, $tmpdir .
"/" . $a_filename);
132 $this->log->debug(
"unzip: " . $tmpdir .
"/" . $a_filename);
134 $dir = $tmpdir .
"/" . substr($a_filename, 0, strlen($a_filename) - 4);
136 $this->log->debug(
"dir: " . $dir);
139 if (is_array($ret) && array_key_exists(
'new_id', $ret)) {
140 $new_id = $ret[
'new_id'];
150 if (is_array($ret)) {
151 return $ret[
'new_id'];
162 $this->tmp_import_dir = $a_val;
180 string $a_component =
"",
181 string $a_tmpdir =
"" 183 if ($a_component ==
"") {
184 $a_component = ilImportExportFactory::getComponentForExport($a_type);
186 $this->comp = $a_component;
192 if (!is_file($dir .
"/manifest.xml")) {
194 ?
'Manifest file not found: "' . $dir .
"/manifest.xml" .
'".' 195 :
'Manifest file not found: "manifest.xml."';
197 $e->setManifestDir($dir);
198 $e->setTmpDir($a_tmpdir);
202 $this->mapping->setInstallUrl($parser->getInstallUrl());
203 $this->mapping->setInstallId($parser->getInstallId());
206 if ($parser->getMainEntity() != $a_type) {
208 "Object type does not match. Import file has type '" .
209 $parser->getMainEntity() .
"' but import being processed for '" . $a_type .
"'." 214 $expfiles = $parser->getExportFiles();
216 $all_importers = array();
217 foreach ($expfiles as $expfile) {
218 $comp = $expfile[
"component"];
220 if (isset($this->skip_importer[$comp]) && $this->skip_importer[$comp] ===
true) {
224 $class = ilImportExportFactory::getImporterClass($comp);
230 $this->log->warning(
"no class found for component: $comp");
234 $this->log->debug(
"create new class = $class");
236 $this->importer =
new $class();
237 $this->importer->setImport($this);
240 $this->importer->init();
241 $this->current_comp =
$comp;
243 $this->log->debug(
"Process file: " . $dir .
"/" . $expfile[
"path"]);
244 $parser =
new ilExportFileParser($dir .
"/" . $expfile[
"path"], $this,
"processItemXml");
246 $this->log->error(
"Import failed: " . $e->getMessage());
247 $this->log->error(
'XML failed: ' . file_get_contents($dir .
'/' . $expfile[
'path']));
253 $obj_map = $this->
getMapping()->getMappingsOfEntity(
'Services/Container',
'objs');
254 if (is_array($obj_map)) {
255 foreach ($obj_map as $obj_id_old => $obj_id_new) {
258 "il_" . $this->mapping->getInstallId() .
"_" .
ilObject::_lookupType((
int) $obj_id_new) .
"_" . $obj_id_old
264 foreach ($all_importers as $imp) {
265 $this->log->debug(
"Call finalProcessing for: " . get_class($imp));
266 $imp->finalProcessing($this->mapping);
270 $top_mapping = $this->mapping->getMappingsOfEntity($this->comp, $a_type);
272 $new_id = (
int) current($top_mapping);
275 'importers' => $all_importers
284 string $a_schema_version,
287 string $a_install_id,
288 string $a_install_url
291 if (isset($this->skip_entity[$this->current_comp][$a_entity]) &&
292 $this->skip_entity[$this->current_comp][$a_entity]) {
296 if ($this->objDefinition->isRBACObject($a_entity) &&
297 $this->
getMapping()->getMapping(
'Services/Container',
'imported', $a_id)) {
298 $this->log->info(
'Ignoring referenced ' . $a_entity .
' with id ' . $a_id);
301 $this->importer->setInstallId($a_install_id);
302 $this->importer->setInstallUrl($a_install_url);
303 $this->importer->setSchemaVersion($a_schema_version);
304 $this->importer->setSkipEntities($this->skip_entity);
305 $this->importer->importXmlRepresentation($a_entity, $a_id, $a_xml, $this->mapping);
308 if ($this->objDefinition->isRBACObject($a_entity)) {
309 $this->
getMapping()->addMapping(
'Services/Container',
'imported', $a_id,
'1');
doImportObject(string $dir, string $a_type, string $a_component="", string $a_tmpdir="")
Import repository object export file.
static _writeImportId(int $obj_id, string $import_id)
write import id to db (static)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setEntityTypes(array $a_val)
importEntity(string $a_tmp_file, string $a_filename, string $a_entity, string $a_component, bool $a_copy_file=false)
Import entity.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(int $a_target_id=0)
addSkipEntity(string $a_component, string $a_entity, bool $skip=true)
Add skip entity.
importObject(?object $a_new_obj, string $a_tmp_file, string $a_filename, string $a_type, string $a_comp="", bool $a_copy_file=false)
static unzip(string $path_to_zip_file, bool $overwrite_existing=false, bool $unpack_flat=false)
parses the objects.xml it handles the xml-description of all ilias objects
getTemporaryImportDir()
Get temporary import directory.
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
getConfig(string $a_comp)
Get configuration (note that configurations are optional, null may be returned!)
addSkipImporter(string $a_component, bool $skip=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Manifest parser for ILIAS standard export files.
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
setImportDirectory(string $a_val)
processItemXml(string $a_entity, string $a_schema_version, string $a_id, string $a_xml, string $a_install_id, string $a_install_url)
Process item xml.
importFromDirectory(string $dir, string $a_type, string $a_comp)
setTemporaryImportDir(string $a_val)
Set temporary import directory.
static _lookupType(int $id, bool $reference=false)
ilObjectDefinition $objDefinition
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...