ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilCategoryImporter.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 $category = 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/Category/classes/class.ilObjCategory.php';
33  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_id))
34  {
35  $refs = ilObject::_getAllReferences($new_id);
36  $this->category = ilObjectFactory::getInstanceByRefId(end($refs),false);
37  }
38  // Mapping for containers without subitems
39  elseif($new_id = $a_mapping->getMapping('Services/Container','refs',0))
40  {
41  $this->category = ilObjectFactory::getInstanceByRefId($new_id,false);
42  }
43  elseif(!$this->category instanceof ilObjCategory)
44  {
45  $this->category = new ilObjCategory();
46  $this->category->create(true);
47  }
48 
49  include_once './Modules/Category/classes/class.ilCategoryXmlParser.php';
50 
51  try
52  {
53  $parser = new ilCategoryXmlParser($a_xml,0);
54  $parser->setCategory($this->category);
55  $parser->setMode(ilCategoryXmlParser::MODE_UPDATE);
56  $parser->startParsing();
57  $a_mapping->addMapping('Modules/Category','cat',$a_id,$this->category->getId());
58  }
59  catch(ilSaxParserException $e)
60  {
61  $GLOBALS['ilLog']->write(__METHOD__.': Parsing failed with message, "'.$e->getMessage().'".');
62  }
63  catch(Excpetion $e)
64  {
65  $GLOBALS['ilLog']->write(__METHOD__.': Parsing failed with message, "'.$e->getMessage().'".');
66  }
67  }
68 }
69 ?>
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
SaxParserException thrown by ilSaxParser if property throwException is set.
static _getAllReferences($a_id)
get all reference ids of object
$GLOBALS['ct_recipient']
Class ilObjCategory.
importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
Import XML.
Xml importer class.