ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules 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 {
15 
23  public function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
24  {
25  // case i container
26  if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
27  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
28  $newObj->setVersion(0); // If $version is 0 from database, it will be set to 1 in ilObFile::doRead(). In ilFileXMLParser::handlerBeginTag $version will being increased. So its incorrectly 2. Set $version to 0 like case ii, non container
29  } else { // case ii, non container
30  $newObj = new ilObjFile();
31  $newObj->setNoMetaDataCreation(true); // #16545
32  $newObj->create(true);
33  }
34 
35  $parser = new ilFileXMLParser($newObj, $a_xml);
36  $parser->setImportDirectory($this->getImportDirectory());
37  $parser->startParsing();
38 
39  if ($newObj instanceof ilObjFile) {
40  $newObj->setMaxVersion($newObj->getVersion());
41  }
42 
43  $newObj->createProperties();
44 
45  $parser->setFileContents();
46  $this->current_obj = $newObj;
47 
48  $newObj->update(); // this is necessary for case ii (e.g. wiki import)
49 
50  $a_mapping->addMapping("Modules/File", "file", $a_id, $newObj->getId());
51  $a_mapping->addMapping(
52  "Services/MetaData",
53  "md",
54  $a_id . ":0:file",
55  $newObj->getId() . ":0:file"
56  );
57  }
58 }
getImportDirectory()
Get import directory.
importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
Import XML.
Importer class for files.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Xml importer class.