15 public static $new_file_structure = array(
'cat',
'exc',
'crs',
'sess',
'file',
'grp',
'frm',
'usr',
'catr',
'crsr');
38 $valid_items = array();
39 $sub_items = $tree->getSubTree($tree->getNodeData($a_ref_id));
40 foreach ($sub_items as $sub_item)
42 if (in_array($sub_item[
"type"], self::$export_implementer))
44 $valid_items[] = array(
"type" => $sub_item[
"type"],
45 "title" => $sub_item[
"title"],
"ref_id" => $sub_item[
"child"],
46 "obj_id" => $sub_item[
"obj_id"],
67 return $files[0][
"timestamp"];
99 public static function _getExportDirectory($a_obj_id, $a_type =
"xml", $a_obj_type =
"", $a_entity =
"")
101 global $objDefinition;
103 $ent = ($a_entity ==
"")
108 if ($a_obj_type ==
"")
113 if(in_array($a_obj_type, self::$new_file_structure))
115 include_once
'./Services/FileSystem/classes/class.ilFileSystemStorage.php';
117 $dir .=
'il'.$objDefinition->getClassName($a_obj_type).$ent.DIRECTORY_SEPARATOR;
119 $dir .= ($a_type ==
'xml' ?
'export' :
'export_'.$a_type);
123 include_once
'./Services/Export/classes/class.ilImportExportFactory.php';
124 $exporter_class = ilImportExportFactory::getExporterClass($a_obj_type);
125 $export_dir = call_user_func(array($exporter_class,
'lookupExportDirectory'),$a_obj_type,$a_obj_id,$a_type,$a_entity);
127 $GLOBALS[
'ilLog']->write(__METHOD__.
': Export dir is '.$export_dir);
136 $GLOBALS[
'ilLog']->write(__METHOD__);
138 if ($a_obj_type ==
"")
143 if ($a_export_types ==
"")
145 $a_export_types = array(
"xml");
147 if (!is_array($a_export_types))
149 $a_export_types = array($a_export_types);
155 $types = $a_export_types;
157 foreach($types as $type)
162 if (!@is_dir($dir) or
172 while ($entry = $h_dir->read())
174 if ($entry !=
"." and
176 substr($entry, -4) ==
".zip" and
177 ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(".$a_obj_type.
"_)*[0-9]+\.zip\$", $entry))
179 $ts = substr($entry, 0, strpos($entry,
"__"));
180 $file[$entry.$type] = array(
"type" => $type,
"file" => $entry,
181 "size" => filesize($dir.
"/".$entry),
203 if ($a_obj_type ==
"")
221 $lng->loadLanguageModule(
"export");
227 $a_tpl =
new ilTemplate(
"tpl.main.html",
true,
true);
229 $a_tpl->setVariable(
"LOCATION_STYLESHEET",$location_stylesheet);
230 $a_tpl->getStandardTemplate();
232 $a_tpl->setDescription($lng->txt(
"export_export_date").
": ".
233 date(
'Y-m-d H:i:s', time()).
" (".date_default_timezone_get().
")");
234 $f_tpl =
new ilTemplate(
"tpl.export_list.html",
true,
true,
"Services/Export");
235 foreach ($a_files as
$file)
237 $f_tpl->setCurrentBlock(
"file_row");
238 $f_tpl->setVariable(
"TITLE", $file[
"title"]);
239 $f_tpl->setVariable(
"TYPE", $lng->txt(
"obj_".$file[
"type"]));
240 $f_tpl->setVariable(
"FILE", $file[
"file"]);
241 $f_tpl->parseCurrentBlock();
243 $a_tpl->setContent($f_tpl->get());
244 $index_content = $a_tpl->get(
"DEFAULT",
false,
false,
false,
true,
false,
false);
246 $f = fopen ($a_filename,
"w");
247 fwrite($f, $index_content);
281 global $objDefinition,
$tpl;
283 $comp = $objDefinition->getComponentForType($a_type);
284 $c = explode(
"/", $comp);
285 $class =
"il".$c[1].
"Exporter";
288 include_once
"./Services/Xml/classes/class.ilXmlWriter.php";
290 $this->manifest_writer->xmlHeader();
291 $this->manifest_writer->xmlStartTag(
294 "MainEntity" => $a_type,
296 "TargetRelease" => $a_target_release,
297 "InstallationId" => IL_INST_ID,
298 "InstallationUrl" => ILIAS_HTTP_PATH));
306 $sub_dir = $ts.
'__'.IL_INST_ID.
'__'.$a_type.
'_'.$a_id;
307 $new_file = $sub_dir.
'.zip';
309 $this->export_run_dir = $export_dir.
"/".$sub_dir;
312 $this->cnt = array();
316 $this->manifest_writer->xmlEndTag(
'Manifest');
318 $this->manifest_writer->xmlDumpFile($this->export_run_dir.
"/manifest.xml",
false);
321 ilUtil::zip($this->export_run_dir, $export_dir.
"/".$new_file);
327 include_once
'./Services/Export/classes/class.ilExportFileInfo.php';
329 $exp->setVersion($a_target_release);
331 $exp->setExportType(
'xml');
332 $exp->setFilename($new_file);
339 "directory" => $export_dir
354 $a_component, $a_title, $a_export_dir, $a_type_for_file =
"")
356 global $objDefinition,
$tpl;
358 if ($a_type_for_file ==
"")
360 $a_type_for_file = $a_entity;
363 $comp = $a_component;
364 $c = explode(
"/", $comp);
365 $class =
"il".$c[1].
"Exporter";
368 include_once
"./Services/Xml/classes/class.ilXmlWriter.php";
370 $this->manifest_writer->xmlHeader();
371 $this->manifest_writer->xmlStartTag(
374 "MainEntity" => $a_entity,
376 "TargetRelease" => $a_target_release,
377 "InstallationId" => IL_INST_ID,
378 "InstallationUrl" => ILIAS_HTTP_PATH));
380 $export_dir = $a_export_dir;
384 $sub_dir = $ts.
'__'.IL_INST_ID.
'__'.$a_type_for_file.
'_'.$a_id;
385 $new_file = $sub_dir.
'.zip';
387 $this->export_run_dir = $export_dir.
"/".$sub_dir;
390 $this->cnt = array();
394 $this->manifest_writer->xmlEndTag(
'Manifest');
396 $this->manifest_writer->xmlDumpFile($this->export_run_dir.
"/manifest.xml",
false);
399 ilUtil::zip($this->export_run_dir, $export_dir.
"/".$new_file);
405 "directory" => $export_dir
419 if (!is_array($a_id))
425 $a_id = array($a_id);
429 $export_class_file =
"./".$a_comp.
"/classes/class.".$a_class.
".php";
431 if (!is_file($export_class_file))
433 echo
"1-not found:".$export_class_file.
"-";
exit;
436 include_once($export_class_file);
437 $exp =
new $a_class();
438 if (!isset($this->cnt[$a_comp]))
440 $this->cnt[$a_comp] = 1;
444 $this->cnt[$a_comp]++;
446 $set_dir_relative = $a_comp.
"/set_".$this->cnt[$a_comp];
447 $set_dir_absolute = $this->export_run_dir.
"/".$set_dir_relative;
451 $sv = $exp->determineSchemaVersion($a_entity, $a_target_release);
454 $sequence = $exp->getXmlExportHeadDependencies($a_entity, $a_target_release, $a_id);
455 foreach ($sequence as $s)
457 $comp = explode(
"/", $s[
"component"]);
458 $exp_class =
"il".$comp[1].
"Exporter";
460 $s[
"entity"], $a_target_release, $s[
"ids"]);
469 $export_writer->xmlHeader();
471 $attribs = array(
"InstallationId" => IL_INST_ID,
472 "InstallationUrl" => ILIAS_HTTP_PATH,
473 "Entity" => $a_entity,
"SchemaVersion" => $sv[
"schema_version"],
"TargetRelease" => $a_target_release,
474 "xmlns:xsi" =>
"http://www.w3.org/2001/XMLSchema-instance",
475 "xmlns:exp" =>
"http://www.ilias.de/Services/Export/exp/4_1",
476 "xsi:schemaLocation" =>
"http://www.ilias.de/Services/Export/exp/4_1 ".ILIAS_HTTP_PATH.
"/xml/ilias_export_4_1.xsd"
478 if ($sv[
"namespace"] !=
"" && $sv[
"xsd_file"] !=
"")
480 $attribs[
"xsi:schemaLocation"].=
" ".$sv[
"namespace"].
" ".
481 ILIAS_HTTP_PATH.
"/xml/".$sv[
"xsd_file"];
482 $attribs[
"xmlns"] = $sv[
"namespace"];
484 if ($sv[
"uses_dataset"])
486 $attribs[
"xsi:schemaLocation"].=
" ".
487 "http://www.ilias.de/Services/DataSet/ds/4_3 ".ILIAS_HTTP_PATH.
"/xml/ilias_ds_4_3.xsd";
488 $attribs[
"xmlns:ds"] =
"http://www.ilias.de/Services/DataSet/ds/4_3";
492 $export_writer->xmlStartTag(
'exp:Export', $attribs);
495 foreach ($a_id as $id)
497 $exp->setExportDirectories($set_dir_relative.
"/expDir_".$dir_cnt,
498 $set_dir_absolute.
"/expDir_".$dir_cnt);
499 $export_writer->xmlStartTag(
'exp:ExportItem', array(
"Id" => $id));
501 $xml = $exp->getXmlRepresentation($a_entity, $sv[
"schema_version"], $id);
502 $export_writer->appendXml($xml);
503 $export_writer->xmlEndTag(
'exp:ExportItem');
507 $export_writer->xmlEndTag(
'exp:Export');
508 $export_writer->xmlDumpFile($set_dir_absolute.
"/export.xml",
false);
510 $this->manifest_writer->xmlElement(
"ExportFile",
511 array(
"Component" => $a_comp,
"Path" => $set_dir_relative.
"/export.xml"));
514 $sequence = $exp->getXmlExportTailDependencies($a_entity, $a_target_release, $a_id);
515 foreach ($sequence as $s)
517 $comp = explode(
"/", $s[
"component"]);
518 $exp_class =
"il".$comp[1].
"Exporter";
520 $s[
"entity"], $a_target_release, $s[
"ids"]);