ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilFileImporter.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Export/classes/class.ilXmlImporter.php");
5 
14 {
21  function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
22  {
23  include_once './Modules/File/classes/class.ilObjFile.php';
24 
25  // case i container
26  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_id))
27  {
28  $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
29  }
30  else // case ii, non container
31  {
32  $newObj = new ilObjFile();
33  $newObj->create(true);
34  }
35 
36  include_once("./Modules/File/classes/class.ilFileXMLParser.php");
37  $parser = new ilFileXMLParser($newObj, $a_xml);
38  $parser->setImportDirectory($this->getImportDirectory());
39  $parser->startParsing();
40 
41  $newObj->createProperties(false,false);
42 
43  $parser->setFileContents();
44  $this->current_obj = $newObj;
45 
46  $newObj->update(); // this is necessary for case ii (e.g. wiki import)
47 
48  $a_mapping->addMapping("Modules/File", "file", $a_id, $newObj->getId());
49  $a_mapping->addMapping("Services/MetaData", "md", $a_id.":0:file",
50  $newObj->getId().":0:file");
51 
52  }
53 
54 }
55 
56 ?>