45 if (!empty(self::$file_type_str[$a_obj_type]))
47 return self::$file_type_str[$a_obj_type];
63 $valid_items = array();
64 $sub_items = $tree->getSubTree($tree->getNodeData($a_ref_id));
65 foreach ($sub_items as $sub_item)
67 if (in_array($sub_item[
"type"], self::$export_implementer))
69 $valid_items[] = array(
"type" => $sub_item[
"type"],
70 "title" => $sub_item[
"title"],
"ref_id" => $sub_item[
"child"],
71 "obj_id" => $sub_item[
"obj_id"],
88 return $files[0][
"timestamp"];
116 global $objDefinition;
118 if ($a_obj_type ==
"")
123 if(in_array($a_obj_type, self::$new_file_structure))
125 include_once
'./Services/FileSystemStorage/classes/class.ilFileSystemStorage.php';
127 $dir .=
'il'.$objDefinition->getClassName($a_obj_type).DIRECTORY_SEPARATOR;
129 $dir .= ($a_type ==
'xml' ?
'export' :
'export_'.$a_type);
134 if ($a_type !=
"xml")
136 $export_dir =
ilUtil::getDataDir().
"/".$a_obj_type.
"_data".
"/".$a_obj_type.
"_".$a_obj_id.
"/export_".$a_type;
140 $export_dir =
ilUtil::getDataDir().
"/".$a_obj_type.
"_data".
"/".$a_obj_type.
"_".$a_obj_id.
"/export";
143 $GLOBALS[
'ilLog']->write(__METHOD__.
': Export dir is '.$export_dir);
153 if ($a_obj_type ==
"")
158 if ($a_export_types ==
"")
160 $a_export_types = array(
"xml");
162 if (!is_array($a_export_types))
164 $a_export_types = array($a_export_types);
170 $types = $a_export_types;
172 foreach($types as
$type)
177 if (!@is_dir(
$dir) or
187 while ($entry = $h_dir->read())
189 if ($entry !=
"." and
191 substr($entry, -4) ==
".zip" and
194 $ts = substr($entry, 0, strpos($entry,
"__"));
195 $file[$entry.$type] = array(
"type" => $type,
"file" => $entry,
196 "size" => filesize(
$dir.
"/".$entry),
218 if ($a_obj_type ==
"")
223 if(in_array($a_obj_type, self::$new_file_structure))
233 if(!is_writable($data_dir))
235 $ilErr->raiseError(
"Data Directory (".$data_dir
236 .
") not writeable.",$ilErr->FATAL);
240 $res_dir = $data_dir.
"/".$a_obj_type.
"_".$a_obj_id;
242 if(!@is_dir($res_dir))
244 $ilErr->raiseError(
"Creation of Glossary Directory failed.",$ilErr->FATAL);
248 if ($a_export_type !=
"xml")
250 $export_dir = $res_dir.
"/export_".$a_export_type;
254 $export_dir = $res_dir.
"/export";
259 if(!@is_dir($export_dir))
261 $ilErr->raiseError(
"Creation of Export Directory failed.",$ilErr->FATAL);
273 $lng->loadLanguageModule(
"export");
279 $a_tpl =
new ilTemplate(
"tpl.main.html",
true,
true);
281 $a_tpl->setVariable(
"LOCATION_STYLESHEET",$location_stylesheet);
282 $a_tpl->getStandardTemplate();
284 $a_tpl->setDescription($lng->txt(
"export_export_date").
": ".
285 date(
'Y-m-d H:i:s', time()).
" (".date_default_timezone_get().
")");
286 $f_tpl =
new ilTemplate(
"tpl.export_list.html",
true,
true,
"Services/Export");
287 foreach ($a_files as
$file)
289 $f_tpl->setCurrentBlock(
"file_row");
290 $f_tpl->setVariable(
"TITLE", $file[
"title"]);
291 $f_tpl->setVariable(
"TYPE", $lng->txt(
"obj_".$file[
"type"]));
292 $f_tpl->setVariable(
"FILE", $file[
"file"]);
293 $f_tpl->parseCurrentBlock();
295 $a_tpl->setContent($f_tpl->get());
296 $index_content = $a_tpl->get(
"DEFAULT",
false,
false,
false,
true,
false,
false);
298 $f = fopen ($a_filename,
"w");
299 fwrite(
$f, $index_content);
327 function exportObject($a_type, $a_id, $a_target_release, $a_config =
"")
329 global $objDefinition,
$tpl;
331 $comp = $objDefinition->getComponentForType($a_type);
332 $c = explode(
"/", $comp);
333 $class =
"il".$c[1].
"Exporter";
336 include_once
"./Services/Xml/classes/class.ilXmlWriter.php";
338 $this->manifest_writer->xmlHeader();
339 $this->manifest_writer->xmlStartTag(
342 "MainEntity" => $a_type,
344 "TargetRelease" => $a_target_release,
345 "InstallationId" => IL_INST_ID,
346 "InstallationUrl" => ILIAS_HTTP_PATH));
355 $new_file = $sub_dir.
'.zip';
357 $this->export_run_dir = $export_dir.
"/".$sub_dir;
360 $this->cnt = array();
362 $success = $this->
processExporter($comp, $class, $a_type, $a_target_release, $a_id);
364 $this->manifest_writer->xmlEndTag(
'Manifest');
368 $this->manifest_writer->xmlDumpFile($this->export_run_dir.
"/manifest.xml",
false);
372 ilUtil::zip($this->export_run_dir, $export_dir.
"/".$new_file);
378 include_once
'./Services/Export/classes/class.ilExportFileInfo.php';
380 $exp->setVersion($a_target_release);
382 $exp->setExportType(
'xml');
383 $exp->setFilename($new_file);
388 "success" => $success,
390 "directory" => $directory
404 if (!is_array($a_id))
410 $a_id = array($a_id);
414 $export_class_file =
"./".$a_comp.
"/classes/class.".$a_class.
".php";
416 if (!is_file($export_class_file))
418 echo
"1-not found:".$export_class_file.
"-";
exit;
421 include_once($export_class_file);
422 $exp =
new $a_class();
423 if (!isset($this->cnt[$a_comp]))
425 $this->cnt[$a_comp] = 1;
429 $this->cnt[$a_comp]++;
431 $set_dir_relative = $a_comp.
"/set_".$this->cnt[$a_comp];
432 $set_dir_absolute = $this->export_run_dir.
"/".$set_dir_relative;
436 $sv = $exp->determineSchemaVersion($a_entity, $a_target_release);
439 $sequence = $exp->getXmlExportHeadDependencies($a_entity, $a_target_release, $a_id);
440 foreach ($sequence as $s)
442 $comp = explode(
"/", $s[
"component"]);
443 $exp_class =
"il".$comp[1].
"Exporter";
445 $s[
"entity"], $a_target_release, $s[
"ids"]);
454 $export_writer->xmlHeader();
456 $attribs = array(
"InstallationId" => IL_INST_ID,
457 "InstallationUrl" => ILIAS_HTTP_PATH,
458 "Entity" => $a_entity,
"SchemaVersion" => $sv[
"schema_version"],
"TargetRelease" => $a_target_release,
459 "xmlns:xsi" =>
"http://www.w3.org/2001/XMLSchema-instance",
460 "xmlns:exp" =>
"http://www.ilias.de/Services/Export/exp/4_1",
461 "xsi:schemaLocation" =>
"http://www.ilias.de/Services/Export/exp/4_1 ".ILIAS_HTTP_PATH.
"/xml/ilias_export_4_1.xsd"
463 if ($sv[
"namespace"] !=
"" && $sv[
"xsd_file"] !=
"")
465 $attribs[
"xsi:schemaLocation"].=
" ".$sv[
"namespace"].
" ".
466 ILIAS_HTTP_PATH.
"/xml/".$sv[
"xsd_file"];
467 $attribs[
"xmlns"] = $sv[
"namespace"];
469 if ($sv[
"uses_dataset"])
471 $attribs[
"xsi:schemaLocation"].=
" ".
472 "http://www.ilias.de/Services/DataSet/ds/4_1 ".ILIAS_HTTP_PATH.
"/xml/ilias_ds_4_1.xsd";
473 $attribs[
"xmlns:ds"] =
"http://www.ilias.de/Services/DataSet/ds/4_1";
477 $export_writer->xmlStartTag(
'exp:Export', $attribs);
480 foreach ($a_id as $id)
482 $exp->setExportDirectories($set_dir_relative.
"/expDir_".$dir_cnt,
483 $set_dir_absolute.
"/expDir_".$dir_cnt);
484 $export_writer->xmlStartTag(
'exp:ExportItem', array(
"Id" => $id));
485 $xml = $exp->getXmlRepresentation($a_entity, $a_target_release, $id);
486 $export_writer->appendXml($xml);
487 $export_writer->xmlEndTag(
'exp:ExportItem');
491 $export_writer->xmlEndTag(
'exp:Export');
492 $export_writer->xmlDumpFile($set_dir_absolute.
"/export.xml",
false);
494 $this->manifest_writer->xmlElement(
"ExportFile",
495 array(
"Component" => $a_comp,
"Path" => $set_dir_relative.
"/export.xml"));
498 $sequence = $exp->getXmlExportTailDependencies($a_entity, $a_target_release, $a_id);
499 foreach ($sequence as $s)
501 $comp = explode(
"/", $s[
"component"]);
502 $exp_class =
"il".$comp[1].
"Exporter";
504 $s[
"entity"], $a_target_release, $s[
"ids"]);