15 public static $new_file_structure = array(
'cat',
'exc',
'crs',
'sess',
'file',
'grp',
'frm',
'usr',
'catr',
'crsr');
40 if (isset($this->configs[$a_comp]))
42 return $this->configs[$a_comp];
46 $comp_arr = explode(
"/", $a_comp);
47 $a_class =
"il".$comp_arr[1].
"ExportConfig";
48 $export_config_file =
"./".$a_comp.
"/classes/class.".$a_class.
".php";
49 if (!is_file($export_config_file))
51 include_once(
"./Services/Export/exceptions/class.ilExportException.php");
52 throw new ilExportException(
'Component "'.$a_comp.
'" does not provide ExportConfig class.');
54 include_once($export_config_file);
55 $exp_config =
new $a_class();
56 $this->configs[$a_comp] = $exp_config;
70 $valid_items = array();
71 $sub_items = $tree->getSubTree($tree->getNodeData($a_ref_id));
72 foreach ($sub_items as $sub_item)
74 if (in_array($sub_item[
"type"], self::$export_implementer))
76 $valid_items[] = array(
"type" => $sub_item[
"type"],
77 "title" => $sub_item[
"title"],
"ref_id" => $sub_item[
"child"],
78 "obj_id" => $sub_item[
"obj_id"],
99 return $files[0][
"timestamp"];
114 if (is_array($files))
133 global $objDefinition;
135 $ent = ($a_entity ==
"")
140 if ($a_obj_type ==
"")
145 if(in_array($a_obj_type, self::$new_file_structure))
147 include_once
'./Services/FileSystem/classes/class.ilFileSystemStorage.php';
149 $dir .=
'il'.$objDefinition->getClassName($a_obj_type).$ent.DIRECTORY_SEPARATOR;
151 $dir .= ($a_type ==
'xml' ?
'export' :
'export_'.$a_type);
155 include_once
'./Services/Export/classes/class.ilImportExportFactory.php';
156 $exporter_class = ilImportExportFactory::getExporterClass($a_obj_type);
157 $export_dir = call_user_func(array($exporter_class,
'lookupExportDirectory'),$a_obj_type,$a_obj_id,$a_type,$a_entity);
159 $GLOBALS[
'ilLog']->write(__METHOD__.
': Export dir is '.$export_dir);
168 $GLOBALS[
'ilLog']->write(__METHOD__);
170 if ($a_obj_type ==
"")
175 if ($a_export_types ==
"")
177 $a_export_types = array(
"xml");
179 if (!is_array($a_export_types))
181 $a_export_types = array($a_export_types);
187 $types = $a_export_types;
189 foreach($types as $type)
194 if (!@is_dir($dir) or
204 while ($entry = $h_dir->read())
206 if ($entry !=
"." and
208 substr($entry, -4) ==
".zip" and
209 ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(".$a_obj_type.
"_)*[0-9]+\.zip\$", $entry))
211 $ts = substr($entry, 0, strpos($entry,
"__"));
212 $file[$entry.$type] = array(
"type" => $type,
"file" => $entry,
213 "size" => filesize($dir.
"/".$entry),
235 if ($a_obj_type ==
"")
253 $lng->loadLanguageModule(
"export");
259 $a_tpl =
new ilTemplate(
"tpl.main.html",
true,
true);
261 $a_tpl->setVariable(
"LOCATION_STYLESHEET",$location_stylesheet);
262 $a_tpl->getStandardTemplate();
264 $a_tpl->setDescription($lng->txt(
"export_export_date").
": ".
265 date(
'Y-m-d H:i:s', time()).
" (".date_default_timezone_get().
")");
266 $f_tpl =
new ilTemplate(
"tpl.export_list.html",
true,
true,
"Services/Export");
267 foreach ($a_files as
$file)
269 $f_tpl->setCurrentBlock(
"file_row");
270 $f_tpl->setVariable(
"TITLE", $file[
"title"]);
271 $f_tpl->setVariable(
"TYPE", $lng->txt(
"obj_".$file[
"type"]));
272 $f_tpl->setVariable(
"FILE", $file[
"file"]);
273 $f_tpl->parseCurrentBlock();
275 $a_tpl->setContent($f_tpl->get());
276 $index_content = $a_tpl->get(
"DEFAULT",
false,
false,
false,
true,
false,
false);
278 $f = fopen ($a_filename,
"w");
279 fwrite($f, $index_content);
313 global $objDefinition,
$tpl;
316 if ($a_target_release ==
"")
319 $a_target_release = $v[0].
".".$v[1].
".0";
322 $comp = $objDefinition->getComponentForType($a_type);
323 $c = explode(
"/", $comp);
324 $class =
"il".$c[1].
"Exporter";
327 include_once
"./Services/Xml/classes/class.ilXmlWriter.php";
329 $this->manifest_writer->xmlHeader();
330 $this->manifest_writer->xmlStartTag(
333 "MainEntity" => $a_type,
335 "TargetRelease" => $a_target_release,
336 "InstallationId" => IL_INST_ID,
337 "InstallationUrl" => ILIAS_HTTP_PATH));
345 $sub_dir = $ts.
'__'.IL_INST_ID.
'__'.$a_type.
'_'.$a_id;
346 $new_file = $sub_dir.
'.zip';
348 $this->export_run_dir = $export_dir.
"/".$sub_dir;
351 $this->cnt = array();
355 $this->manifest_writer->xmlEndTag(
'Manifest');
357 $this->manifest_writer->xmlDumpFile($this->export_run_dir.
"/manifest.xml",
false);
360 ilUtil::zip($this->export_run_dir, $export_dir.
"/".$new_file);
366 include_once
'./Services/Export/classes/class.ilExportFileInfo.php';
368 $exp->setVersion($a_target_release);
370 $exp->setExportType(
'xml');
371 $exp->setFilename($new_file);
378 "directory" => $export_dir
393 $a_component, $a_title, $a_export_dir, $a_type_for_file =
"")
395 global $objDefinition,
$tpl;
397 if ($a_type_for_file ==
"")
399 $a_type_for_file = $a_entity;
402 $comp = $a_component;
403 $c = explode(
"/", $comp);
404 $class =
"il".$c[1].
"Exporter";
407 include_once
"./Services/Xml/classes/class.ilXmlWriter.php";
409 $this->manifest_writer->xmlHeader();
410 $this->manifest_writer->xmlStartTag(
413 "MainEntity" => $a_entity,
415 "TargetRelease" => $a_target_release,
416 "InstallationId" => IL_INST_ID,
417 "InstallationUrl" => ILIAS_HTTP_PATH));
419 $export_dir = $a_export_dir;
423 $sub_dir = $ts.
'__'.IL_INST_ID.
'__'.$a_type_for_file.
'_'.$a_id;
424 $new_file = $sub_dir.
'.zip';
426 $this->export_run_dir = $export_dir.
"/".$sub_dir;
429 $this->cnt = array();
433 $this->manifest_writer->xmlEndTag(
'Manifest');
435 $this->manifest_writer->xmlDumpFile($this->export_run_dir.
"/manifest.xml",
false);
438 ilUtil::zip($this->export_run_dir, $export_dir.
"/".$new_file);
444 "directory" => $export_dir
458 if (!is_array($a_id))
464 $a_id = array($a_id);
468 $export_class_file =
"./".$a_comp.
"/classes/class.".$a_class.
".php";
470 if (!is_file($export_class_file))
472 include_once(
"./Services/Export/exceptions/class.ilExportException.php");
473 throw new ilExportException(
'Export class file "'.$export_class_file.
'" not found.');
475 include_once($export_class_file);
476 $exp =
new $a_class();
477 $exp->setExport($this);
478 if (!isset($this->cnt[$a_comp]))
480 $this->cnt[$a_comp] = 1;
484 $this->cnt[$a_comp]++;
486 $set_dir_relative = $a_comp.
"/set_".$this->cnt[$a_comp];
487 $set_dir_absolute = $this->export_run_dir.
"/".$set_dir_relative;
491 $sv = $exp->determineSchemaVersion($a_entity, $a_target_release);
494 $sequence = $exp->getXmlExportHeadDependencies($a_entity, $a_target_release, $a_id);
495 foreach ($sequence as $s)
497 $comp = explode(
"/", $s[
"component"]);
498 $exp_class =
"il".$comp[1].
"Exporter";
500 $s[
"entity"], $a_target_release, $s[
"ids"]);
509 $export_writer->xmlHeader();
511 $attribs = array(
"InstallationId" => IL_INST_ID,
512 "InstallationUrl" => ILIAS_HTTP_PATH,
513 "Entity" => $a_entity,
"SchemaVersion" => $sv[
"schema_version"],
"TargetRelease" => $a_target_release,
514 "xmlns:xsi" =>
"http://www.w3.org/2001/XMLSchema-instance",
515 "xmlns:exp" =>
"http://www.ilias.de/Services/Export/exp/4_1",
516 "xsi:schemaLocation" =>
"http://www.ilias.de/Services/Export/exp/4_1 ".ILIAS_HTTP_PATH.
"/xml/ilias_export_4_1.xsd" 518 if ($sv[
"namespace"] !=
"" && $sv[
"xsd_file"] !=
"")
520 $attribs[
"xsi:schemaLocation"].=
" ".$sv[
"namespace"].
" ".
521 ILIAS_HTTP_PATH.
"/xml/".$sv[
"xsd_file"];
522 $attribs[
"xmlns"] = $sv[
"namespace"];
524 if ($sv[
"uses_dataset"])
526 $attribs[
"xsi:schemaLocation"].=
" ".
527 "http://www.ilias.de/Services/DataSet/ds/4_3 ".ILIAS_HTTP_PATH.
"/xml/ilias_ds_4_3.xsd";
528 $attribs[
"xmlns:ds"] =
"http://www.ilias.de/Services/DataSet/ds/4_3";
532 $export_writer->xmlStartTag(
'exp:Export', $attribs);
535 foreach ($a_id as $id)
537 $exp->setExportDirectories($set_dir_relative.
"/expDir_".$dir_cnt,
538 $set_dir_absolute.
"/expDir_".$dir_cnt);
539 $export_writer->xmlStartTag(
'exp:ExportItem', array(
"Id" => $id));
541 $xml = $exp->getXmlRepresentation($a_entity, $sv[
"schema_version"], $id);
542 $export_writer->appendXml($xml);
543 $export_writer->xmlEndTag(
'exp:ExportItem');
547 $export_writer->xmlEndTag(
'exp:Export');
548 $export_writer->xmlDumpFile($set_dir_absolute.
"/export.xml",
false);
550 $this->manifest_writer->xmlElement(
"ExportFile",
551 array(
"Component" => $a_comp,
"Path" => $set_dir_relative.
"/export.xml"));
554 $sequence = $exp->getXmlExportTailDependencies($a_entity, $a_target_release, $a_id);
555 foreach ($sequence as $s)
557 $comp = explode(
"/", $s[
"component"]);
558 $exp_class =
"il".$comp[1].
"Exporter";
560 $s[
"entity"], $a_target_release, $s[
"ids"]);
static makeDirParents($a_dir)
Create a new directory and all parent directories.
exportObject($a_type, $a_id, $a_target_release="")
Export an ILIAS object (the object type must be known by objDefinition)
static $new_file_structure
const ILIAS_VERSION_NUMERIC
exportEntity($a_entity, $a_id, $a_target_release, $a_component, $a_title, $a_export_dir, $a_type_for_file="")
Export an ILIAS entity.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
getConfig($a_comp)
Get configuration (note that configurations are optional, null may be returned!)
_createExportDirectory($a_obj_id, $a_export_type="xml", $a_obj_type="")
Create export directory.
static _lookupTitle($a_id)
lookup object title
General export exception.
_generateIndexFile($a_filename, $a_obj_id, $a_files, $a_type="")
Generates an index.html file including links to all xml files included (for container exports) ...
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static _createPathFromId($a_container_id, $a_name)
Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5.
static _getLastExportFileDate($a_obj_id, $a_type="", $a_obj_type="")
Get date of last export file.
processExporter($a_comp, $a_class, $a_entity, $a_target_release, $a_id)
Process exporter.
static _getValidExportSubItems($a_ref_id)
Get a list of subitems of a repository resource, that implement the export.
_getExportFiles($a_obj_id, $a_export_types="", $a_obj_type="")
Get Export Files for a repository object.
special template class to simplify handling of ITX/PEAR
Stores information of creation date and versions of export files
__construct()
Default constructor.
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
static _lookupType($a_id, $a_reference=false)
lookup object type
static getDataDir()
get data directory (outside webspace)
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static $export_implementer
static _getLastExportFileInformation($a_obj_id, $a_type="", $a_obj_type="")
Get last export file information.