ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilCourseImporter.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Export/classes/class.ilXmlImporter.php");
5 
16 {
17  const ENTITY_MAIN = 'crs';
18  const ENTITY_OBJECTIVE = 'objectives';
19 
20  private $course = null;
21 
23 
24 
25  public function init()
26  {
27  }
28 
35  function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
36  {
37  include_once './Modules/Course/classes/class.ilCourseXMLParser.php';
38  include_once './Modules/Course/classes/class.ilObjCourse.php';
39 
40 
41  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_id))
42  {
43  $refs = ilObject::_getAllReferences($new_id);
44  $this->course = ilObjectFactory::getInstanceByRefId(end($refs),false);
45  #$this->course = ilObjectFactory::getInstanceByObjId($new_id,false);
46  }
47  // Mapping for containers without subitems
48  elseif($new_id = $a_mapping->getMapping('Services/Container','refs',0))
49  {
50  $this->course = ilObjectFactory::getInstanceByRefId($new_id,false);
51  }
52  elseif(!$this->course instanceof ilObjCourse)
53  {
54  $this->course = new ilObjCourse();
55  $this->course->create(true);
56  }
57 
58  if($a_entity == self::ENTITY_OBJECTIVE)
59  {
60  $this->addFinalProcessingInfo($this->course, $a_entity, $a_xml);
61 
62  // import learning objectives => without materials and fixed questions.
63  // These are handled in afterContainerImportProcessing
64  include_once './Modules/Course/classes/Objectives/class.ilLOXmlParser.php';
65  $parser = new ilLOXmlParser($this->course,$a_xml);
66  $parser->setMapping($a_mapping);
67  $parser->parse();
68  return;
69  }
70 
71  try
72  {
73  $parser = new ilCourseXMLParser($this->course);
74  $parser->setXMLContent($a_xml);
75  $parser->startParsing();
76  $a_mapping->addMapping('Modules/Course','crs',$a_id,$this->course->getId());
77  }
78  catch(ilSaxParserException $e)
79  {
80  $GLOBALS['ilLog']->write(__METHOD__.': Parsing failed with message, "'.$e->getMessage().'".');
81  }
82  catch(Exception $e)
83  {
84  $GLOBALS['ilLog']->write(__METHOD__.': Parsing failed with message, "'.$e->getMessage().'".');
85  }
86  }
87 
88 
89 
95  {
96  foreach($this->final_processing_info as $info)
97  {
98  // import learning objectives
99  include_once './Modules/Course/classes/Objectives/class.ilLOXmlParser.php';
100  $parser = new ilLOXmlParser($info['course'],$info['xml']);
101  $parser->setMapping($mapping);
102  $parser->parseObjectDependencies();
103  return;
104  }
105  }
106 
110  protected function addFinalProcessingInfo($a_course, $a_entity, $a_xml)
111  {
112  $this->final_processing_info[] = array(
113  'course' => $a_course,
114  'entity' => $a_entity,
115  'xml' => $a_xml
116  );
117  }
118 }
119 ?>
afterContainerImportProcessing(\ilImportMapping $mapping)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
addFinalProcessingInfo($a_course, $a_entity, $a_xml)
Add information for final processing.
folder xml importer
SaxParserException thrown by ilSaxParser if property throwException is set.
static _getAllReferences($a_id)
get all reference ids of object
$info
Definition: example_052.php:80
Class ilLOXmlWriter.
Class ilObjCourse.
Create styles array
The data for the language used.
$parser
Definition: BPMN2Parser.php:24
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
Import XML.
Xml importer class.