ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilCOPageExporter.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.ilXmlExporter.php");
5 
14 {
15  private $ds;
16  protected $config;
17 
21  function init()
22  {
23  include_once("./Services/COPage/classes/class.ilCOPageDataSet.php");
24  $this->ds = new ilCOPageDataSet();
25  $this->ds->setExportDirectories($this->dir_relative, $this->dir_absolute);
26  $this->ds->setDSPrefix("ds");
27  $this->config = $this->getExport()->getConfig("Services/COPage");
28  if ($this->config->getMasterLanguageOnly())
29  {
30  $this->ds->setMasterLanguageOnly(true);
31  }
32  }
33 
34 
43  function getXmlExportHeadDependencies($a_entity, $a_target_release, $a_ids)
44  {
45  if ($a_entity == "pg")
46  {
47  // get all media objects and files of the page
48  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
49  include_once("./Modules/File/classes/class.ilObjFile.php");
50  $mob_ids = array();
51  $file_ids = array();
52  foreach ($a_ids as $pg_id)
53  {
54  $pg_id = explode(":", $pg_id);
55 
56  $lang = ($this->config->getMasterLanguageOnly())
57  ? "-"
58  : "";
59 
60  // get media objects
61  $mids = ilObjMediaObject::_getMobsOfObject($pg_id[0].":pg", $pg_id[1], 0, $lang);
62  foreach ($mids as $mid)
63  {
64  if (ilObject::_lookupType($mid) == "mob")
65  {
66  $mob_ids[] = $mid;
67  }
68  }
69 
70  // get files
71  $files = ilObjFile::_getFilesOfObject($pg_id[0].":pg", $pg_id[1], 0, $lang);
72  foreach ($files as $file)
73  {
74  if (ilObject::_lookupType($file) == "file")
75  {
76  $file_ids[] = $file;
77  }
78  }
79  }
80 
81  return array (
82  array(
83  "component" => "Services/MediaObjects",
84  "entity" => "mob",
85  "ids" => $mob_ids),
86  array(
87  "component" => "Modules/File",
88  "entity" => "file",
89  "ids" => $file_ids)
90  );
91  }
92 
93  return array();
94  }
95 
104  function getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
105  {
106  if ($a_entity == "pgtp")
107  {
108  $pg_ids = array();
109  foreach ($a_ids as $id)
110  {
111  $pg_ids[] = "stys:".$id;
112  }
113 
114  return array(
115  array(
116  "component" => "Services/COPage",
117  "entity" => "pg",
118  "ids" => $pg_ids)
119  );
120  }
121 
122  return array();
123  }
124 
125 
134  public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
135  {
136  if ($a_entity == "pg")
137  {
138  include_once("./Services/COPage/classes/class.ilPageObject.php");
139 
140  $id = explode(":", $a_id);
141 
142  $langs = array("-");
143  if (!$this->config->getMasterLanguageOnly())
144  {
145  $trans = ilPageObject::lookupTranslations($id[0], $id[1]);
146  foreach ($trans as $t)
147  {
148  if ($t != "-")
149  {
150  $langs[] = $t;
151  }
152  }
153  }
154 
155  include_once("./Services/COPage/classes/class.ilPageObjectFactory.php");
156  $xml = "";
157  foreach ($langs as $l)
158  {
159  $page_object = ilPageObjectFactory::getInstance($id[0], $id[1], 0, $l);
160  $page_object->buildDom();
161  $page_object->insertInstIntoIDs(IL_INST_ID);
162  $pxml = $page_object->getXMLFromDom(false, false, false, "", true);
163  $pxml = str_replace("&","&amp;", $pxml);
164  $xml.= '<PageObject Language="'.$l.'" Active="'.$page_object->getActive().'" ActivationStart="'.$page_object->getActivationStart().'" ActivationEnd="'.
165  $page_object->getActivationEnd().'" ShowActivationInfo="'.$page_object->getShowActivationInfo().'">';
166  $xml.= $pxml;
167  $xml.= "</PageObject>";
168  $page_object->freeDom();
169  }
170 
171  return $xml;
172  }
173  if ($a_entity == "pgtp")
174  {
175  return $this->ds->getXmlRepresentation($a_entity, $a_schema_version, $a_id, "", true, true);
176  }
177  }
178 
186  function getValidSchemaVersions($a_entity)
187  {
188  if ($a_entity == "pg")
189  {
190  return array (
191  "4.2.0" => array(
192  "namespace" => "http://www.ilias.de/Services/COPage/pg/4_2",
193  "xsd_file" => "ilias_pg_4_2.xsd",
194  "min" => "4.2.0",
195  "max" => ""),
196  "4.1.0" => array(
197  "namespace" => "http://www.ilias.de/Services/COPage/pg/4_1",
198  "xsd_file" => "ilias_pg_4_1.xsd",
199  "min" => "4.1.0",
200  "max" => "4.1.99")
201  );
202  }
203  if ($a_entity == "pgtp")
204  {
205  return array (
206  "4.2.0" => array(
207  "namespace" => "http://www.ilias.de/Services/COPage/pgtp/4_1",
208  "xsd_file" => "ilias_pgtp_4_1.xsd",
209  "uses_dataset" => true,
210  "min" => "4.2.0",
211  "max" => "")
212  );
213  }
214  }
215 
216 }
217 
218 ?>
$files
Definition: add-vimline.php:18
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
getXmlExportHeadDependencies($a_entity, $a_target_release, $a_ids)
Get head dependencies.
getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
Get tail dependencies.
COPage Data set class.
getValidSchemaVersions($a_entity)
Returns schema versions that the component can export to.
Xml Exporter class.
getXmlRepresentation($a_entity, $a_schema_version, $a_id)
Get xml representation.
init()
Initialisation.
static _getFilesOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_usage_lang="-")
get all files of an object
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static getInstance($a_parent_type, $a_id=0, $a_old_nr=0, $a_lang="-")
Get page object instance.
global $l
Definition: afr.php:30
static lookupTranslations($a_parent_type, $a_id)
Lookup translations.
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
Exporter class for meta data.
getExport()
Get export.