ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilImport Class Reference

Import class. More...

+ Inheritance diagram for ilImport:
+ Collaboration diagram for ilImport:

Public Member Functions

 __construct ($a_target_id=0)
 Constructor.
 getMapping ()
 Get mapping object.
 setEntityTypes ($a_val)
 Set entity types.
 getEntityTypes ()
 Get entity types.
 addSkipEntity ($a_component, $a_entity, $skip=true)
 Add skip entity.
 setCurrentDataset ($a_val)
 Set currrent dataset.
 getCurrentDataset ()
 Get currrent dataset.
 afterEntityTypes ()
 After entity types are parsed.
 importRecord ($a_entity, $a_types, $a_record)
 After entity types are parsed.
 importEntity ($a_tmp_file, $a_filename, $a_entity, $a_component, $a_copy_file=false)
 Import entity.
 importObject ($a_new_obj, $a_tmp_file, $a_filename, $a_type, $a_comp="", $a_copy_file=false)
 Import repository object export file.
 processItemXml ($a_entity, $a_schema_version, $a_id, $a_xml, $a_install_id, $a_install_url)
 Process item xml.

Protected Member Functions

 doImportObject ($dir, $a_type, $a_component="", $a_tmpdir="")
 Import repository object export file.

Protected Attributes

 $install_id = ""
 $install_url = ""
 $entities = ""
 $mapping = null
 $skip_entity = array()

Detailed Description

Import class.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 11 of file class.ilImport.php.

Constructor & Destructor Documentation

ilImport::__construct (   $a_target_id = 0)

Constructor.

Parameters
intid of parent container
Returns

Reimplemented in ilImportContainer.

Definition at line 26 of file class.ilImport.php.

{
include_once("./Services/Export/classes/class.ilImportMapping.php");
$this->mapping = new ilImportMapping();
$this->mapping->setTagetId($a_target_id);
}

Member Function Documentation

ilImport::addSkipEntity (   $a_component,
  $a_entity,
  $skip = true 
)

Add skip entity.

Parameters
string$a_valcomponent
string$a_valentity

Definition at line 68 of file class.ilImport.php.

{
$this->skip_entity[$a_component][$a_entity] = $skip;
}
ilImport::afterEntityTypes ( )

After entity types are parsed.

Definition at line 97 of file class.ilImport.php.

References getCurrentDataset().

{
$this->getCurrentDataset()->setImport($this);
}

+ Here is the call graph for this function:

ilImport::doImportObject (   $dir,
  $a_type,
  $a_component = "",
  $a_tmpdir = "" 
)
protected

Import repository object export file.

Parameters
stringabsolute filename of temporary upload file

Definition at line 160 of file class.ilImport.php.

References $GLOBALS, $success, and $tpl.

Referenced by importObject().

{
global $objDefinition, $tpl;
if ($a_component == "")
{
$comp = $objDefinition->getComponentForType($a_type);
$class = $objDefinition->getClassName($a_type);
}
else
{
$comp = $a_component;
$c = explode("/", $comp);
$class = $c[count($c) - 1];
}
$this->comp = $comp;
// get import class
$success = true;
// process manifest file
include_once("./Services/Export/classes/class.ilManifestParser.php");
if (!is_file($dir."/manifest.xml"))
{
include_once("./Services/Export/exceptions/class.ilManifestFileNotFoundImportException.php");
$e = new ilManifestFileNotFoundImportException('Manifest file not found: "'.$dir."/manifest.xml".'".');
$e->setManifestDir($dir);
$e->setTmpDir($a_tmpdir);
throw $e;
}
$parser = new ilManifestParser($dir."/manifest.xml");
$this->mapping->setInstallUrl($parser->getInstallUrl());
$this->mapping->setInstallId($parser->getInstallId());
// process export files
$expfiles = $parser->getExportFiles();
include_once("./Services/Export/classes/class.ilExportFileParser.php");
$all_importers = array();
foreach ($expfiles as $expfile)
{
$comp = $expfile["component"];
$comp_arr = explode("/", $comp);
$import_class_file = "./".$comp."/classes/class.il".$comp_arr[1]."Importer.php";
$class = "il".$comp_arr[1]."Importer";
include_once($import_class_file);
$this->importer = new $class();
$all_importers[] = $this->importer;
$this->importer->setImportDirectory($dir);
$this->importer->init();
$this->current_comp = $comp;
try {
$parser = new ilExportFileParser($dir."/".$expfile["path"],$this, "processItemXml");
}
catch(Exception $e)
{
$GLOBALS['ilLog']->write(__METHOD__.': Import failed with message: '.$e->getMessage());
#$GLOBALS['ilLog']->write(__METHOD__.': '.file_get_contents($dir.'/'.$expfile['path']));
throw $e;
}
}
// final processing
foreach ($all_importers as $imp)
{
$imp->finalProcessing($this->mapping);
}
// we should only get on mapping here
$top_mapping = $this->mapping->getMappingsOfEntity($this->comp, $a_type);
$new_id = (int) current($top_mapping);
return $new_id;
}

+ Here is the caller graph for this function:

ilImport::getCurrentDataset ( )

Get currrent dataset.

Returns
object currrent dataset

Definition at line 89 of file class.ilImport.php.

Referenced by afterEntityTypes(), and importRecord().

{
return $this->current_dataset;
}

+ Here is the caller graph for this function:

ilImport::getEntityTypes ( )
final

Get entity types.

Returns
array entity types

Definition at line 57 of file class.ilImport.php.

{
return $this->entity_types;
}
ilImport::getMapping ( )

Get mapping object.

Returns
ilImportMapping ilImportMapping

Definition at line 37 of file class.ilImport.php.

References $mapping.

Referenced by ilImportContainer\createDummy(), and processItemXml().

{
}

+ Here is the caller graph for this function:

ilImport::importEntity (   $a_tmp_file,
  $a_filename,
  $a_entity,
  $a_component,
  $a_copy_file = false 
)
final

Import entity.

Definition at line 116 of file class.ilImport.php.

References importObject().

{
$this->importObject(null, $a_tmp_file, $a_filename, $a_entity, $a_component, $a_copy_file);
}

+ Here is the call graph for this function:

ilImport::importObject (   $a_new_obj,
  $a_tmp_file,
  $a_filename,
  $a_type,
  $a_comp = "",
  $a_copy_file = false 
)
final

Import repository object export file.

Parameters
stringabsolute filename of temporary upload file

Definition at line 128 of file class.ilImport.php.

References $GLOBALS, ilUtil\delDir(), doImportObject(), ilUtil\ilTempnam(), ilUtil\makeDir(), ilUtil\moveUploadedFile(), and ilUtil\unzip().

Referenced by importEntity().

{
// create temporary directory
$tmpdir = ilUtil::ilTempnam();
ilUtil::makeDir($tmpdir);
if ($a_copy_file)
{
copy($a_tmp_file, $tmpdir."/".$a_filename);
}
else
{
ilUtil::moveUploadedFile($a_tmp_file, $a_filename, $tmpdir."/".$a_filename);
}
ilUtil::unzip($tmpdir."/".$a_filename);
$dir = $tmpdir."/".substr($a_filename, 0, strlen($a_filename) - 4);
$GLOBALS['ilLog']->write(__METHOD__.': do import with dir '.$dir);
$new_id = $this->doImportObject($dir, $a_type, $a_comp, $tmpdir);
// delete temporary directory
ilUtil::delDir($tmpdir);
return $new_id;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilImport::importRecord (   $a_entity,
  $a_types,
  $a_record 
)

After entity types are parsed.

Parameters

Definition at line 107 of file class.ilImport.php.

References getCurrentDataset().

{
$this->getCurrentDataset()->importRecord($a_entity, $a_types, $a_record);
}

+ Here is the call graph for this function:

ilImport::processItemXml (   $a_entity,
  $a_schema_version,
  $a_id,
  $a_xml,
  $a_install_id,
  $a_install_url 
)

Process item xml.

ilObjectDefinition $objDefinition

Definition at line 242 of file class.ilImport.php.

References $GLOBALS, and getMapping().

{
global $objDefinition;
// skip
if ($this->skip_entity[$this->current_comp][$a_entity])
{
return;
}
if($objDefinition->isRBACObject($a_entity) &&
$this->getMapping()->getMapping('Services/Container', 'imported', $a_id))
{
$GLOBALS['ilLog']->write(__METHOD__.': Ignoring referenced '.$a_entity.' with id '.$a_id);
return;
}
$this->importer->setInstallId($a_install_id);
$this->importer->setInstallUrl($a_install_url);
$this->importer->setSchemaVersion($a_schema_version);
$this->importer->setSkipEntities($this->skip_entity);
$new_id = $this->importer->importXmlRepresentation($a_entity, $a_id, $a_xml, $this->mapping);
// Store information about imported obj_ids in mapping to avoid double imports of references
if($objDefinition->isRBACObject($a_entity))
{
$this->getMapping()->addMapping('Services/Container', 'imported', $a_id, 1);
}
// @TODO new id is not always set
if($new_id)
{
$this->mapping->addMapping($this->comp ,$a_entity, $a_id, $new_id);
}
}

+ Here is the call graph for this function:

ilImport::setCurrentDataset (   $a_val)

Set currrent dataset.

Parameters
objectcurrrent dataset

Definition at line 78 of file class.ilImport.php.

{
$this->current_dataset = $a_val;
}
ilImport::setEntityTypes (   $a_val)
final

Set entity types.

Parameters
arrayentity types

Definition at line 47 of file class.ilImport.php.

{
$this->entity_types = $a_val;
}

Field Documentation

ilImport::$entities = ""
protected

Definition at line 15 of file class.ilImport.php.

ilImport::$install_id = ""
protected

Definition at line 13 of file class.ilImport.php.

ilImport::$install_url = ""
protected

Definition at line 14 of file class.ilImport.php.

ilImport::$mapping = null
protected

Definition at line 17 of file class.ilImport.php.

Referenced by getMapping().

ilImport::$skip_entity = array()
protected

Definition at line 18 of file class.ilImport.php.


The documentation for this class was generated from the following file: