47 final public function init($a_entity, $a_target_release)
49 $this->entity = $a_entity;
50 $this->target_release = $a_target_release;
51 $this->data = array();
69 abstract protected function getTypes($a_entity, $a_version);
75 abstract protected function getXmlNamespace($a_entity, $a_target_release);
83 abstract function readData($a_entity, $a_version, $a_ids);
93 $this->relative_export_dir = $a_relative;
94 $this->absolute_export_dir = $a_absolute;
104 $this->import_directory = $a_val;
114 return $this->import_directory;
156 $set = $ilDB->query($a_query);
157 $this->data = array();
158 while ($rec = $ilDB->fetchAssoc($set))
160 if ($a_convert_to_leading_upper)
163 foreach ($rec as $k => $v)
171 $this->data[] = $rec;
183 $a_str = strtoupper(substr($a_str, 0, 1)).substr($a_str, 1);
184 while (is_int(
$pos = strpos($a_str,
"_")))
186 $a_str = substr($a_str, 0,
$pos).
187 strtoupper(substr($a_str,
$pos+1, 1)).
188 substr($a_str,
$pos+2);
199 if ($this->version ===
false)
205 $arr[
"version"] = $this->version;
206 $arr[
"install_id"] = IL_INST_ID;
207 $arr[
"install_url"] = ILIAS_HTTP_PATH;
209 $arr[
"set"] = array();
210 foreach ($this->data as
$d)
215 include_once(
"./Services/JSON/classes/class.ilJsonUtil.php");
242 $a_ids, $a_field =
"", $a_omit_header =
false, $a_omit_types =
false)
251 include_once
"./Services/Xml/classes/class.ilXmlWriter.php";
255 $writer->xmlHeader();
259 $namespaces = $prefixes = array();
260 $this->
getNamespaces($namespaces, $a_entity, $a_target_release);
261 $atts = array(
"InstallationId" => IL_INST_ID,
262 "InstallationUrl" => ILIAS_HTTP_PATH,
"TopEntity" => $a_entity);
264 foreach ($namespaces as $entity => $ns)
267 $prefixes[$entity] = $prefix;
277 $this->
addTypesXml($writer, $a_entity, $a_target_release);
281 $this->
addRecordsXml($writer, $prefixes, $a_entity, $a_target_release, $a_ids, $a_field =
"");
289 return $writer->xmlDumpMem(
false);
299 function addRecordsXml($a_writer, $a_prefixes, $a_entity, $a_target_release, $a_ids, $a_field =
"")
301 $types = $this->
getXmlTypes($a_entity, $a_target_release);
303 $this->
readData($a_entity, $a_target_release, $a_ids, $a_field);
304 if (is_array($this->data))
306 foreach ($this->data as
$d)
309 array(
"Entity" => $this->getXmlEntityName($a_entity, $a_target_release)));
312 $a_writer->xmlStartTag($this->getXmlEntityTag($a_entity, $a_target_release));
314 $rec = $this->
getXmlRecord($a_entity, $a_target_release, $d);
315 foreach ($rec as
$f => $c)
320 if ($this->absolute_export_dir !=
"" && $this->relative_export_dir !=
"")
323 ilUtil::rCopy($c, $this->absolute_export_dir.
"/dsDir_".$this->dircnt);
333 $a_writer->xmlElement($f, array(), $c);
336 $a_writer->xmlEndTag($this->getXmlEntityTag($a_entity, $a_target_release));
341 $deps = $this->getDependencies($a_entity, $a_target_release, $rec, $a_ids);
344 foreach ($deps as $dp => $par)
346 $this->
addRecordsXml($a_writer, $a_prefixes, $dp, $a_target_release, $par[
"ids"], $par[
"field"]);
351 else if ($this->data ===
false)
354 $deps = $this->getDependencies($a_entity, $a_target_release, null, $a_ids);
357 foreach ($deps as $dp => $par)
359 $this->
addRecordsXml($a_writer, $a_prefixes, $dp, $a_target_release, $par[
"ids"], $par[
"field"]);
370 private function addTypesXml($a_writer, $a_entity, $a_target_release)
372 $types = $this->
getXmlTypes($a_entity, $a_target_release);
375 if (is_array($types))
378 array(
"Entity" => $this->getXmlEntityName($a_entity, $a_target_release),
379 "TargetRelease" => $a_target_release));
383 array(
"Name" =>
$f,
"Type" =>
$t));
389 $deps = $this->getDependencies($a_entity, $a_target_release, null, null);
392 foreach ($deps as $dp => $w)
394 $this->
addTypesXml($a_writer, $dp, $a_target_release);
412 $namespaces[$a_entity] = $ns;
415 $deps = $this->getDependencies($a_entity, $a_target_release, null, null);
418 foreach ($deps as $dp => $w)
454 return $this->
getTypes($a_entity, $a_version);
464 return $this->
getTypes($a_entity, $a_version);
505 $this->
import = $a_val;
515 return $this->import;