ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilContainerReferenceImporter.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Export/classes/class.ilXmlImporter.php");
5
16{
17 protected $ref = null;
18
19
20 public function init()
21 {
22 }
23
28 protected function initReference($a_ref_id = 0)
29 {
30 $this->ref = ilObjectFactory::getInstanceByRefId($a_ref_id, true);
31 }
32
36 abstract protected function getType();
37
41 abstract protected function initParser($a_xml);
42
47 protected function getReference()
48 {
49 return $this->ref;
50 }
51
58 public function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
59 {
60 include_once './Modules/Category/classes/class.ilObjCategory.php';
61 if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
62 $refs = ilObject::_getAllReferences($new_id);
63 $this->initReference(end($refs));
64 }
65 // Mapping for containers without subitems
66 elseif ($new_id = $a_mapping->getMapping('Services/Container', 'refs', 0)) {
67 $this->initReference($new_id);
68 } elseif (!$this->getReference() instanceof ilContainerReference) {
69 $this->initReference();
70 $this->getReference()->create(true);
71 }
72
73 try {
74 $parser = $this->initParser($a_xml);
75 $parser->setReference($this->getReference());
77 $parser->startParsing();
78
79 $a_mapping->addMapping(
80 $GLOBALS['objDefinition']->getComponentForType($this->getType()),
81 $this->getType(),
82 $a_id,
83 $this->getReference()->getId()
84 );
85 } catch (ilSaxParserException $e) {
86 $GLOBALS['ilLog']->write(__METHOD__ . ': Parsing failed with message, "' . $e->getMessage() . '".');
87 } catch (Exception $e) {
88 $GLOBALS['ilLog']->write(__METHOD__ . ': Parsing failed with message, "' . $e->getMessage() . '".');
89 }
90 }
91}
$parser
Definition: BPMN2Parser.php:23
An exception for terminatinating execution or to throw for unit testing.
initParser($a_xml)
Init xml parser.
getType()
Get reference type.
importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
Import XML.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _getAllReferences($a_id)
get all reference ids of object
SaxParserException thrown by ilSaxParser if property throwException is set.
Xml importer class.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.