35                include_once(
"./Services/Export/classes/class.ilImportMapping.php");
 
   37                $this->mapping->setTargetId($a_target_id);
 
   51                if (isset($this->configs[$a_comp]))
 
   53                        return $this->configs[$a_comp];
 
   57                $comp_arr = explode(
"/", $a_comp);
 
   58                $a_class = 
"il".$comp_arr[1].
"ImportConfig";
 
   59                $import_config_file = 
"./".$a_comp.
"/classes/class.".$a_class.
".php";
 
   60                if (!is_file($import_config_file))
 
   62                        include_once(
"./Services/Export/exceptions/class.ilImportException.php");
 
   63                        throw new ilImportException(
'Component "'.$a_comp.
'" does not provide ImportConfig class.');
 
   65                include_once($import_config_file);
 
   66                $imp_config = 
new $a_class();
 
   67                $this->configs[$a_comp] = $imp_config;
 
   88                $this->entity_types = $a_val;
 
   98                return $this->entity_types;
 
  109                $this->skip_entity[$a_component][$a_entity] = $skip;
 
  119                $this->current_dataset = $a_val;
 
  130                return $this->current_dataset;
 
  156                $a_entity, $a_component, $a_copy_file = 
false)
 
  158                $this->
importObject(
null, $a_tmp_file, $a_filename, $a_entity, $a_component, $a_copy_file);
 
  168                $a_comp = 
"", $a_copy_file = 
false)
 
  176                        copy($a_tmp_file, $tmpdir.
"/".$a_filename);
 
  183                $this->log->debug(
"unzip: ".$tmpdir.
"/".$a_filename);
 
  186                $dir = $tmpdir.
"/".substr($a_filename, 0, strlen($a_filename) - 4);
 
  190                $this->log->debug(
"dir: ".$dir);
 
  196                        $new_id = 
$ret[
'new_id'];
 
  216                        return $ret[
'new_id'];
 
  229                $this->tmp_import_dir = $a_val;
 
  249                if ($a_component == 
"")
 
  251                        include_once(
"./Services/Export/classes/class.ilImportExportFactory.php");
 
  252                        $a_component = ilImportExportFactory::getComponentForExport(
$a_type);           
 
  254                $this->comp = $a_component;
 
  260                include_once(
"./Services/Export/classes/class.ilManifestParser.php");
 
  261                if (!is_file($dir.
"/manifest.xml"))
 
  263                        include_once(
"./Services/Export/exceptions/class.ilManifestFileNotFoundImportException.php");
 
  265                                ? 
'Manifest file not found: "'.$dir.
"/manifest.xml".
'".' 
  266                                : 
'Manifest file not found: "manifest.xml."';
 
  269                        $e->setTmpDir($a_tmpdir);
 
  273                $this->mapping->setInstallUrl(
$parser->getInstallUrl());
 
  274                $this->mapping->setInstallId(
$parser->getInstallId());
 
  279                        include_once(
"./Services/Export/exceptions/class.ilImportObjectTypeMismatchException.php");
 
  285                $expfiles = 
$parser->getExportFiles();
 
  287                include_once(
"./Services/Export/classes/class.ilExportFileParser.php");
 
  288                include_once(
"./Services/Export/classes/class.ilImportExportFactory.php");      
 
  289                $all_importers = array();
 
  290                foreach ($expfiles as $expfile)
 
  292                        $comp = $expfile[
"component"];
 
  293                        $class = ilImportExportFactory::getImporterClass($comp);
 
  295                        $this->log->debug(
"create new class = $class");
 
  297                        $this->importer = 
new $class();
 
  298                        $this->importer->setImport($this);
 
  299                        $all_importers[] = $this->importer;
 
  300                        $this->importer->setImportDirectory($dir);
 
  301                        $this->importer->init();
 
  302                        $this->current_comp = $comp;
 
  304                                $this->log->debug(
"Process file: ".$dir.
"/".$expfile[
"path"]);
 
  309                                $this->log->error(
"Import failed: ".$e->getMessage());
 
  315                $obj_map = $this->
getMapping()->getMappingsOfEntity(
'Services/Container', 
'objs');
 
  316                if (is_array($obj_map))
 
  318                        foreach ($obj_map as $obj_id_old => $obj_id_new)
 
  325                foreach ($all_importers as $imp)
 
  327                        $this->log->debug(
"Call finalProcessing for: ".get_class($imp));
 
  328                        $imp->finalProcessing($this->mapping);
 
  332                $top_mapping = $this->mapping->getMappingsOfEntity($this->comp, 
$a_type);
 
  333                $new_id = (int) current($top_mapping);
 
  336                        'importers' => (array) $all_importers
 
  345        function processItemXml($a_entity, $a_schema_version, $a_id, $a_xml,$a_install_id, $a_install_url)
 
  347                global $objDefinition;
 
  350                if ($this->skip_entity[$this->current_comp][$a_entity])
 
  355                if($objDefinition->isRBACObject($a_entity) &&
 
  356                        $this->getMapping()->getMapping(
'Services/Container', 
'imported', $a_id))
 
  358                        $this->log->info(
'Ignoring referenced '.$a_entity.
' with id '.$a_id);
 
  361                $this->importer->setInstallId($a_install_id);
 
  362                $this->importer->setInstallUrl($a_install_url);
 
  363                $this->importer->setSchemaVersion($a_schema_version);
 
  364                $this->importer->setSkipEntities($this->skip_entity);
 
  365                $new_id = $this->importer->importXmlRepresentation($a_entity, $a_id, $a_xml, $this->mapping);
 
  368                if($objDefinition->isRBACObject($a_entity))
 
  370                        $this->
getMapping()->addMapping(
'Services/Container', 
'imported', $a_id, 1);
 
  376                        $this->mapping->addMapping($this->comp ,$a_entity, $a_id, $new_id);
 
An exception for terminatinating execution or to throw for unit testing.
General import exception.
Import object type does not match.
importFromDirectory($dir, $a_type, $a_comp)
Import from directory.
setEntityTypes($a_val)
Set entity types.
getEntityTypes()
Get entity types.
processItemXml($a_entity, $a_schema_version, $a_id, $a_xml, $a_install_id, $a_install_url)
Process item xml.
getTemporaryImportDir()
Get temporary import directory.
__construct($a_target_id=0)
Constructor.
importEntity($a_tmp_file, $a_filename, $a_entity, $a_component, $a_copy_file=false)
Import entity.
addSkipEntity($a_component, $a_entity, $skip=true)
Add skip entity.
getMapping()
Get mapping object.
setTemporaryImportDir($a_val)
Set temporary import directory.
getConfig($a_comp)
Get configuration (note that configurations are optional, null may be returned!)
getCurrentDataset()
Get currrent dataset.
afterEntityTypes()
After entity types are parsed.
importRecord($a_entity, $a_types, $a_record)
After entity types are parsed.
setCurrentDataset($a_val)
Set currrent dataset.
doImportObject($dir, $a_type, $a_component="", $a_tmpdir="")
Import repository object export file.
importObject($a_new_obj, $a_tmp_file, $a_filename, $a_type, $a_comp="", $a_copy_file=false)
Import repository object export file.
static getLogger($a_component_id)
Get component logger.
manifest.xml file not found-exception for import
setManifestDir($a_val)
Set manifest directory.
Manifest parser for ILIAS standard export files.
static _writeImportId($a_obj_id, $a_import_id)
write import id to db (static)
static _lookupType($a_id, $a_reference=false)
lookup object type
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...