ILIAS  release_4-4 Revision
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  private $course = null;
18 
19 
20  public function init()
21  {
22  }
23 
30  function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
31  {
32  include_once './Modules/Course/classes/class.ilCourseXMLParser.php';
33  include_once './Modules/Course/classes/class.ilObjCourse.php';
34 
35 
36  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_id))
37  {
38  $refs = ilObject::_getAllReferences($new_id);
39  $this->course = ilObjectFactory::getInstanceByRefId(end($refs),false);
40  #$this->course = ilObjectFactory::getInstanceByObjId($new_id,false);
41  }
42  // Mapping for containers without subitems
43  elseif($new_id = $a_mapping->getMapping('Services/Container','refs',0))
44  {
45  $this->course = ilObjectFactory::getInstanceByRefId($new_id,false);
46  }
47  elseif(!$this->course instanceof ilObjCourse)
48  {
49  $this->course = new ilObjCourse();
50  $this->course->create(true);
51  }
52 
53  try
54  {
55  $parser = new ilCourseXMLParser($this->course);
56  $parser->setXMLContent($a_xml);
57  $parser->startParsing();
58  $a_mapping->addMapping('Modules/Course','crs',$a_id,$this->course->getId());
59  }
60  catch(ilSaxParserException $e)
61  {
62  $GLOBALS['ilLog']->write(__METHOD__.': Parsing failed with message, "'.$e->getMessage().'".');
63  }
64  catch(Exception $e)
65  {
66  $GLOBALS['ilLog']->write(__METHOD__.': Parsing failed with message, "'.$e->getMessage().'".');
67  }
68  }
69 }
70 ?>
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
folder xml importer
SaxParserException thrown by ilSaxParser if property throwException is set.
static _getAllReferences($a_id)
get all reference ids of object
Class ilObjCourse.
$GLOBALS['ct_recipient']
importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
Import XML.
Xml importer class.