ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
4 include_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  include_once("./Services/Export/classes/class.ilManifestParser.php");
35  $parser = new ilManifestParser($dir."/manifest.xml");
36 
37 
38  // Handling single containers without subitems
39  if(!$parser->getExportSets())
40  {
41  $this->createDummy($type);
43  return $new_id;
44  }
45 
46  // Handling containers with subitems
47  $first = true;
48  foreach($parser->getExportSets() as $set)
49  {
50  $GLOBALS['ilLog']->write(__METHOD__.': do import with dir '.$dir.DIRECTORY_SEPARATOR.$set['path'].' and type '.$set['type']);
51  $new_id = parent::doImportObject($dir.DIRECTORY_SEPARATOR.$set['path'],$set['type']);
52 
53  if($first)
54  {
55  $ret = $new_id;
56  $first = false;
57  }
58  }
59  return $ret;
60  }
61 
67  protected function createDummy($a_type)
68  {
69  global $objDefinition;
70 
71  $class_name = "ilObj".$objDefinition->getClassName($a_type);
72  $location = $objDefinition->getLocation($a_type);
73 
74  include_once($location."/class.".$class_name.".php");
75  $new = new $class_name();
76  $new->setTitle('Import');
77  $new->create(true);
78  $new->createReference();
79  $new->putInTree($this->getMapping()->getTargetId());
80  $new->setPermissions($this->getMapping()->getTargetId());
81 
82  $this->getMapping()->addMapping('Services/Container','objs', 0, $new->getId());
83  $this->getMapping()->addMapping('Services/Container','refs', 0,$new->getRefId());
84 
85  return $new;
86 
87  }
88 }
89 ?>