ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
4include_once("./Services/Export/classes/class.ilXmlImporter.php");
5
14{
15
23 public function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
24 {
25 include_once './Modules/File/classes/class.ilObjFile.php';
26
27 // case i container
28 if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
29 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
30 $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
31 } else { // case ii, non container
32 $newObj = new ilObjFile();
33 $newObj->setNoMetaDataCreation(true); // #16545
34 $newObj->create(true);
35 }
36
37 include_once("./Modules/File/classes/class.ilFileXMLParser.php");
38 $parser = new ilFileXMLParser($newObj, $a_xml);
39 $parser->setImportDirectory($this->getImportDirectory());
40 $parser->startParsing();
41
42 $newObj->createProperties();
43
44 $parser->setFileContents();
45 $this->current_obj = $newObj;
46
47 $newObj->update(); // this is necessary for case ii (e.g. wiki import)
48
49 $a_mapping->addMapping("Modules/File", "file", $a_id, $newObj->getId());
50 $a_mapping->addMapping(
51 "Services/MetaData",
52 "md",
53 $a_id . ":0:file",
54 $newObj->getId() . ":0:file"
55 );
56 }
57}
$parser
Definition: BPMN2Parser.php:23
An exception for terminatinating execution or to throw for unit testing.
Importer class for files.
importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
Import XML.
Exercise XML Parser which completes/updates a given file by an xml string.
Class ilObjFile.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Xml importer class.
getImportDirectory()
Get import directory.