ILIAS  Release_4_2_x_branch Revision 61807
 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.
 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)
 Import entity.
 importObject ($a_new_obj, $a_tmp_file, $a_filename, $a_type, $a_comp="")
 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

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 25 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::afterEntityTypes ( )

After entity types are parsed.

Definition at line 84 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 140 of file class.ilImport.php.

References $dir, $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();
$parser = new ilExportFileParser($dir."/".$expfile["path"],
$this, "processItemXml");
}
// 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 76 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 56 of file class.ilImport.php.

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

Get mapping object.

Returns
object ilImportMapping

Definition at line 36 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 
)
final

Import entity.

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

References importObject().

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

+ Here is the call graph for this function:

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

Import repository object export file.

Parameters
stringabsolute filename of temporary upload file

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

References $dir, $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);
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 94 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 213 of file class.ilImport.php.

References $GLOBALS, and getMapping().

{
global $objDefinition;
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);
$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 66 of file class.ilImport.php.

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

Set entity types.

Parameters
arrayentity types

Definition at line 46 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().


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