ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCOPageImporter.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 {
18  function init()
19  {
20  include_once("./Services/COPage/classes/class.ilCOPageDataSet.php");
21  $this->ds = new ilCOPageDataSet();
22  $this->ds->setDSPrefix("ds");
23  }
24 
25 
32  function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
33  {
34 
35  if ($a_entity == "pgtp")
36  {
37  include_once("./Services/DataSet/classes/class.ilDataSetImportParser.php");
38  $parser = new ilDataSetImportParser($a_entity, $this->getSchemaVersion(),
39  $a_xml, $this->ds, $a_mapping);
40  }
41 
42  if ($a_entity == "pg")
43  {
44  $pg_id = $a_mapping->getMapping("Services/COPage", "pg", $a_id);
45 
46  if ($pg_id != "")
47  {
48  $id = explode(":", $pg_id);
49  if (count($id) == 2)
50  {
51  include_once("./Services/COPage/classes/class.ilPageObject.php");
52  $new_page = new ilPageObject($id[0]);
53  $new_page->setId($id[1]);
54  $new_page->setXMLContent($a_xml);
55  //$new_page->saveMobUsage($a_xml); (will be done in final processing)
56  $new_page->createFromXML();
57  }
58  }
59  }
60  }
61 
67  function finalProcessing($a_mapping)
68  {
69  $pages = $a_mapping->getMappingsOfEntity("Services/COPage", "pg");
70  $media_objects = $a_mapping->getMappingsOfEntity("Services/MediaObjects", "mob");
71  $file_objects = $a_mapping->getMappingsOfEntity("Modules/File", "file");
72  if (count($media_objects) > 0 || count($file_objects) > 0)
73  {
74  foreach ($pages as $p)
75  {
76  $id = explode(":", $p);
77  if (count($id) == 2)
78  {
79  include_once("./Services/COPage/classes/class.ilPageObject.php");
80  if (ilPageObject::_exists($id[0], $id[1]))
81  {
82  $new_page = new ilPageObject($id[0], $id[1]);
83  $new_page->buildDom();
84  $med = $new_page->resolveMediaAliases($media_objects);
85  $fil = $new_page->resolveFileItems($file_objects);
86 
87  if ($med || $fil)
88  {
89  $new_page->update(false, true);
90  }
91  }
92  }
93  }
94  }
95  }
96 }
97 
98 ?>