ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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)
33 {
34 $manifest_file = $dir."/manifest.xml";
35 if(!file_exists($manifest_file))
36 {
37 return false;
38 }
39
40 include_once("./Services/Export/classes/class.ilManifestParser.php");
41 $parser = new ilManifestParser($manifest_file);
42
43 // Handling single containers without subitems
44 if(!$parser->getExportSets())
45 {
46 $this->createDummy($type);
47 $new_id = parent::doImportObject($dir,$type);
48 return $new_id;
49 }
50
51 // Handling containers with subitems
52 $first = true;
53 foreach($parser->getExportSets() as $set)
54 {
55 $GLOBALS['ilLog']->write(__METHOD__.': do import with dir '.$dir.DIRECTORY_SEPARATOR.$set['path'].' and type '.$set['type']);
56 $new_id = parent::doImportObject($dir.DIRECTORY_SEPARATOR.$set['path'],$set['type']);
57
58 if($first)
59 {
60 $ret = $new_id;
61 $first = false;
62 }
63 }
64 return $ret;
65 }
66
72 protected function createDummy($a_type)
73 {
74 global $objDefinition;
75
76 $class_name = "ilObj".$objDefinition->getClassName($a_type);
77 $location = $objDefinition->getLocation($a_type);
78
79 include_once($location."/class.".$class_name.".php");
80 $new = new $class_name();
81 $new->setTitle('Import');
82 $new->create(true);
83 $new->createReference();
84 $new->putInTree($this->getMapping()->getTargetId());
85 $new->setPermissions($this->getMapping()->getTargetId());
86
87 $this->getMapping()->addMapping('Services/Container','objs', 0, $new->getId());
88 $this->getMapping()->addMapping('Services/Container','refs', 0,$new->getRefId());
89
90 return $new;
91
92 }
93}
94?>
$location
Definition: buildRTE.php:44
createDummy($a_type)
Create dummy object.
doImportObject($dir, $type)
Import a container.
__construct($a_target_id)
Constructor.
Import class.
getMapping()
Get mapping object.
Manifest parser for ILIAS standard export files.
$GLOBALS['ct_recipient']