ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 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 {
63 $refs = ilObject::_getAllReferences($new_id);
64 $this->initReference(end($refs));
65 }
66 // Mapping for containers without subitems
67 elseif($new_id = $a_mapping->getMapping('Services/Container','refs',0))
68 {
69 $this->initReference($new_id);
70 }
71 elseif(!$this->getReference() instanceof ilContainerReference)
72 {
73 $this->initReference();
74 $this->getReference()->create(true);
75 }
76
77 try
78 {
79 $parser = $this->initParser($a_xml);
80 $parser->setReference($this->getReference());
82 $parser->startParsing();
83
84 $a_mapping->addMapping(
85 $GLOBALS['objDefinition']->getComponentForType($this->getType()),
86 $this->getType(),
87 $a_id,
88 $this->getReference()->getId()
89 );
90 }
91 catch(ilSaxParserException $e)
92 {
93 $GLOBALS['ilLog']->write(__METHOD__.': Parsing failed with message, "'.$e->getMessage().'".');
94 }
95 catch(Exception $e)
96 {
97 $GLOBALS['ilLog']->write(__METHOD__.': Parsing failed with message, "'.$e->getMessage().'".');
98 }
99 }
100}
101?>
initParser($a_xml)
Init xml parser.
getType()
Get reference type.
importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
Import XML.
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['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276