ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilExport Class Reference

Export. More...

+ Inheritance diagram for ilExport:
+ Collaboration diagram for ilExport:

Public Member Functions

 __construct ()
 
 setExportDirInContainer (string $export_dir_in_container)
 
 setPathInfo (ExportPathInfoInterface $export_path_info)
 
 getExportDirInContainer ()
 
 getPathToComponentExpDirInContainer ()
 
 setExportDirectories (string $a_dir_relative, string $a_dir_absolute)
 
 getRelativeExportDirectory ()
 
 getAbsoluteExportDirectory ()
 
 setExportWriter (ilExportHandlerConsumerExportWriterInterface $export_writer,)
 
 getExportWriter ()
 
 getConfig (string $a_comp)
 Get configuration (note that configurations are optional, null may be returned!) More...
 
 exportObject (string $a_type, int $a_id, string $a_target_release="")
 Export an ILIAS object (the object type must be known by objDefinition) More...
 
 exportEntity (string $a_entity, string $a_id, string $a_target_release, string $a_component, string $a_title, string $a_export_dir, string $a_type_for_file="")
 Export an ILIAS entity More...
 
 processExporter (string $a_comp, string $a_class, string $a_entity, string $a_target_release, ?array $a_id=null)
 Process exporter More...
 

Static Public Member Functions

static _getValidExportSubItems (int $a_ref_id)
 Get a list of subitems of a repository resource, that implement the export. More...
 
static _getLastExportFileDate (int $a_obj_id, string $a_type="", string $a_obj_type="")
 Get date of last export file More...
 
static _getLastExportFileInformation (int $a_obj_id, string $a_type="", string $a_obj_type="")
 Get last export file information More...
 
static _getExportDirectory (int $a_obj_id, string $a_type="xml", string $a_obj_type="", string $a_entity="")
 Get export directory for an repository object More...
 
static _getExportFiles (int $a_obj_id, $a_export_types="", string $a_obj_type="")
 
static _createExportDirectory (int $a_obj_id, string $a_export_type="xml", string $a_obj_type="")
 
static _generateIndexFile (string $a_filename, int $a_obj_id, array $a_files, string $a_type="")
 Generates an index.html file including links to all xml files included (for container exports) More...
 

Data Fields

string $export_run_dir = ''
 

Static Protected Member Functions

static createPathFromId (int $a_container_id, string $a_name)
 

Protected Attributes

string $dir_relative = ""
 
string $dir_absolute = ""
 
ilLogger $log
 
ilExportHandlerConsumerExportWriterInterface $export_writer
 
string $export_dir_in_container
 
ExportPathInfoInterface $export_path_info
 

Private Attributes

array $configs = []
 
array $cnt = []
 
ilXmlWriter $manifest_writer = null
 

Static Private Attributes

static array $new_file_structure
 
static array $export_implementer = array("tst", "lm", "glo", "sahs")
 

Detailed Description

Export.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e

Definition at line 28 of file class.ilExport.php.

Constructor & Destructor Documentation

◆ __construct()

ilExport::__construct ( )

Definition at line 58 of file class.ilExport.php.

References $DIC.

59  {
60  global $DIC;
61  $this->log = $DIC->logger()->exp();
62  }
global $DIC
Definition: shib_login.php:22

Member Function Documentation

◆ _createExportDirectory()

static ilExport::_createExportDirectory ( int  $a_obj_id,
string  $a_export_type = "xml",
string  $a_obj_type = "" 
)
static

Definition at line 322 of file class.ilExport.php.

References $DIC, $ilErr, _getExportDirectory(), ilObject\_lookupType(), and ilFileUtils\makeDirParents().

Referenced by ILIAS\Notes\Export\NotesHtmlExport\__construct(), ilObjBlogGUI\buildExportFile(), ilObjGlossary\createExportDirectory(), ilObjFileBasedLMGUI\exportHTML(), ilExportContainer\exportObject(), exportObject(), ILIAS\Export\ExportHandler\Info\Export\Handler\getLegacyExportRunDir(), ilHTLMExportOptionHTML\onExportOptionSelected(), and ilOrgUnitExporter\sendAndCreateSimpleExportFile().

326  : bool {
327  global $DIC;
328 
329  $ilErr = $DIC['ilErr'];
330 
331  if ($a_obj_type == "") {
332  $a_obj_type = ilObject::_lookupType($a_obj_id);
333  }
334 
335  $edir = ilExport::_getExportDirectory($a_obj_id, $a_export_type, $a_obj_type);
337  return true;
338  }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static _getExportDirectory(int $a_obj_id, string $a_type="xml", string $a_obj_type="", string $a_entity="")
Get export directory for an repository object
$ilErr
Definition: raiseError.php:33
global $DIC
Definition: shib_login.php:22
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _generateIndexFile()

static ilExport::_generateIndexFile ( string  $a_filename,
int  $a_obj_id,
array  $a_files,
string  $a_type = "" 
)
static

Generates an index.html file including links to all xml files included (for container exports)

Definition at line 345 of file class.ilExport.php.

References $DIC, Vendor\Package\$f, $lng, ilObject\_lookupTitle(), ilObject\_lookupType(), and ilUtil\getStyleSheetLocation().

350  : void {
351  global $DIC;
352 
353  $lng = $DIC->language();
354  $lng->loadLanguageModule("export");
355 
356  if ($a_type == "") {
357  $a_type = ilObject::_lookupType($a_obj_id);
358  }
359  $a_tpl = new ilGlobalTemplate("tpl.main.html", true, true);
360  $location_stylesheet = ilUtil::getStyleSheetLocation();
361  $a_tpl->setVariable("LOCATION_STYLESHEET", $location_stylesheet);
362  $a_tpl->loadStandardTemplate();
363  $a_tpl->setTitle(ilObject::_lookupTitle($a_obj_id));
364  $a_tpl->setDescription($lng->txt("export_export_date") . ": " .
365  date('Y-m-d H:i:s', time()) . " (" . date_default_timezone_get() . ")");
366  $f_tpl = new ilTemplate("tpl.export_list.html", true, true, "components/ILIAS/Export");
367  foreach ($a_files as $file) {
368  $f_tpl->setCurrentBlock("file_row");
369  $f_tpl->setVariable("TITLE", $file["title"]);
370  $f_tpl->setVariable("TYPE", $lng->txt("obj_" . $file["type"]));
371  $f_tpl->setVariable("FILE", $file["file"]);
372  $f_tpl->parseCurrentBlock();
373  }
374  $a_tpl->setContent($f_tpl->get());
375  $index_content = $a_tpl->getSpecial("DEFAULT", false, false, false, true, false, false);
376 
377  $f = fopen($a_filename, "w");
378  fwrite($f, $index_content);
379  fclose($f);
380  }
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
special template class to simplify handling of ITX/PEAR
static _lookupTitle(int $obj_id)
global $DIC
Definition: shib_login.php:22
global $lng
Definition: privfeed.php:31
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ _getExportDirectory()

static ilExport::_getExportDirectory ( int  $a_obj_id,
string  $a_type = "xml",
string  $a_obj_type = "",
string  $a_entity = "" 
)
static

Get export directory for an repository object

Parameters
int$a_obj_idobject id
string$a_typeexport type ("xml", "html", ...), default "xml"
string$a_obj_typeobject type (optional, if not given, type is looked up)
string$a_entity
Returns
string export directory

Definition at line 220 of file class.ilExport.php.

References $DIC, ilObject\_lookupType(), and ilFileUtils\getDataDir().

Referenced by ILIAS\Notes\Export\NotesHtmlExport\__construct(), _createExportDirectory(), _getExportFiles(), ilExportContainer\addSubitems(), ilObjBlogGUI\buildExportFile(), ilSAHSEditGUI\executeCommand(), ilObjFileBasedLMGUI\exportHTML(), ilExportContainer\exportObject(), exportObject(), ilObjUser\exportPersonalData(), ilCmiXapiDataSet\getDependencies(), ilDclContentExporter\getExportContentPath(), ilObjGlossary\getExportDirectory(), ilObjQuestionPool\getExportDirectory(), ilDclExportTableGUI\getExportFiles(), ilScormAiccDataSet\getExtendedXmlRepresentation(), ilDataCollectionExportOptionsXLSX\getFiles(), ILIAS\Export\ExportHandler\Consumer\ExportOption\BasicLegacyHandler\getFiles(), ilMediaPoolExportOptionXMLMaster\getFiles(), ILIAS\Export\ExportHandler\Info\Export\Handler\getLegacyExportRunDir(), ilObjUser\getPersonalDataExportFile(), ILIAS\Wiki\Export\WikiHtmlExport\getUserExportFile(), ILIAS\Export\ExportHandler\Consumer\ExportOption\BasicLegacyHandler\onDeleteFiles(), ilDataCollectionExportOptionsXLSX\onDeleteFiles(), ilMediaPoolExportOptionXMLMasterNoMedia\onDeleteFiles(), ilMediaPoolExportOptionXMLMaster\onDeleteFiles(), ilMediaPoolExportOptionXMLMaster\onDownloadFiles(), ilMediaPoolExportOptionXMLMasterNoMedia\onDownloadFiles(), ILIAS\Export\ExportHandler\Consumer\ExportOption\BasicLegacyHandler\onDownloadFiles(), ilMediaPoolExportOptionXMLMasterNoMedia\onDownloadWithLink(), ilMediaPoolExportOptionXMLMaster\onDownloadWithLink(), ILIAS\Export\ExportHandler\Consumer\ExportOption\BasicLegacyHandler\onDownloadWithLink(), ilHTLMExportOptionHTML\onExportOptionSelected(), ilOrgUnitExporter\sendAndCreateSimpleExportFile(), ilObjUser\sendPersonalDataFile(), ILIAS\Notes\Export\NotesHtmlExport\zipPackage(), and ILIAS\Wiki\Export\BlogHtmlExport\zipPackage().

225  : string {
226  global $DIC;
227 
228  $logger = $DIC->logger()->exp();
229  $objDefinition = $DIC['objDefinition'];
230 
231  $ent = ($a_entity == "")
232  ? ""
233  : "_" . $a_entity;
234 
235  if ($a_obj_type == "") {
236  $a_obj_type = ilObject::_lookupType($a_obj_id);
237  }
238 
239  if (in_array($a_obj_type, self::$new_file_structure)) {
240  $dir = ilFileUtils::getDataDir() . DIRECTORY_SEPARATOR;
241  $dir .= 'il' . $objDefinition->getClassName($a_obj_type) . $ent . DIRECTORY_SEPARATOR;
242  $dir .= self::createPathFromId($a_obj_id, $a_obj_type) . DIRECTORY_SEPARATOR;
243  $dir .= ($a_type == 'xml' ? 'export' : 'export_' . $a_type);
244  return $dir;
245  }
246 
247  $exporter_class = ilImportExportFactory::getExporterClass($a_obj_type);
248  $export_dir = call_user_func(
249  array($exporter_class, 'lookupExportDirectory'),
250  $a_obj_type,
251  $a_obj_id,
252  $a_type,
253  $a_entity
254  );
255 
256  $logger->debug('Export dir is ' . $export_dir);
257  return $export_dir;
258  }
global $DIC
Definition: shib_login.php:22
static getDataDir()
get data directory (outside webspace)
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getExportFiles()

static ilExport::_getExportFiles ( int  $a_obj_id,
  $a_export_types = "",
string  $a_obj_type = "" 
)
static

Parameters
int$a_obj_id
string | array$a_export_types
string$a_obj_type
Returns
array

Definition at line 267 of file class.ilExport.php.

References _getExportDirectory(), ilObject\_lookupType(), and ILIAS\Repository\int().

Referenced by _getLastExportFileDate(), _getLastExportFileInformation(), ilExportTableGUI\getExportFiles(), and ILIAS\Export\ExportHandler\Consumer\ExportOption\BasicLegacyHandler\getFiles().

267  : array
268  {
269  if ($a_obj_type == "") {
270  $a_obj_type = ilObject::_lookupType($a_obj_id);
271  }
272 
273  if ($a_export_types == "") {
274  $a_export_types = array("xml");
275  }
276  if (!is_array($a_export_types)) {
277  $a_export_types = array($a_export_types);
278  }
279 
280  // initialize array
281  $file = array();
282 
283  $types = $a_export_types;
284 
285  foreach ($types as $type) {
286  $dir = ilExport::_getExportDirectory($a_obj_id, $type, $a_obj_type);
287 
288  // quit if import dir not available
289  if (!is_dir($dir) || !is_writable($dir)) {
290  continue;
291  }
292 
293  // open directory
294  $h_dir = dir($dir);
295 
296  // get files and save the in the array
297  while ($entry = $h_dir->read()) {
298  if ($entry !== "." &&
299  $entry !== ".." &&
300  substr($entry, -4) === ".zip" &&
301  preg_match("/^[0-9]{10}_{2}[0-9]+_{2}(" . $a_obj_type . "_)*[0-9]+\.zip\$/", $entry)) {
302  $ts = substr($entry, 0, strpos($entry, "__"));
303  $file[$entry . $type] = [
304  "type" => (string) $type,
305  "file" => (string) $entry,
306  "size" => (int) filesize($dir . "/" . $entry),
307  "timestamp" => (int) $ts
308  ];
309  }
310  }
311 
312  // close import directory
313  $h_dir->close();
314  }
315 
316  // sort files
317  ksort($file);
318  reset($file);
319  return $file;
320  }
static _getExportDirectory(int $a_obj_id, string $a_type="xml", string $a_obj_type="", string $a_entity="")
Get export directory for an repository object
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getLastExportFileDate()

static ilExport::_getLastExportFileDate ( int  $a_obj_id,
string  $a_type = "",
string  $a_obj_type = "" 
)
static

Get date of last export file

Parameters
int$a_obj_idobject id
string$a_typeexport type ("xml", "html", ...), default "xml"
string$a_obj_typeobject type (optional, if not given, type is looked up)

Definition at line 180 of file class.ilExport.php.

References _getExportFiles(), and ilArrayUtil\sortArray().

Referenced by _getValidExportSubItems().

180  : int
181  {
182  $files = ilExport::_getExportFiles($a_obj_id, $a_type, $a_obj_type);
183  if (is_array($files)) {
184  $files = ilArrayUtil::sortArray($files, "timestamp", "desc");
185  return (int) $files[0]["timestamp"];
186  }
187  return 0;
188  }
static _getExportFiles(int $a_obj_id, $a_export_types="", string $a_obj_type="")
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getLastExportFileInformation()

static ilExport::_getLastExportFileInformation ( int  $a_obj_id,
string  $a_type = "",
string  $a_obj_type = "" 
)
static

Get last export file information

Parameters
int$a_obj_idobject id
string$a_typeexport type ("xml", "html", ...), default "xml"
string$a_obj_typeobject type (optional, if not given, type is looked up)
Returns
?array

Definition at line 198 of file class.ilExport.php.

References _getExportFiles(), null, and ilArrayUtil\sortArray().

202  : ?array {
203  $files = ilExport::_getExportFiles($a_obj_id, $a_type, $a_obj_type);
204  if (is_array($files)) {
205  $files = ilArrayUtil::sortArray($files, "timestamp", "desc");
206  return $files[0];
207  }
208  return null;
209  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _getExportFiles(int $a_obj_id, $a_export_types="", string $a_obj_type="")
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
+ Here is the call graph for this function:

◆ _getValidExportSubItems()

static ilExport::_getValidExportSubItems ( int  $a_ref_id)
static

Get a list of subitems of a repository resource, that implement the export.

Includes also information on last export file.

Returns
array<int, array<string, int|string>>

Definition at line 151 of file class.ilExport.php.

References $DIC, _getLastExportFileDate(), and ILIAS\Repository\int().

Referenced by ilSubItemSelectionTableGUI\__construct().

151  : array
152  {
153  global $DIC;
154 
155  $tree = $DIC->repositoryTree();
156 
157  $valid_items = array();
158  $sub_items = $tree->getSubTree($tree->getNodeData($a_ref_id));
159  foreach ($sub_items as $sub_item) {
160  if (in_array($sub_item["type"], self::$export_implementer)) {
161  $valid_items[] = [
162  "type" => (string) $sub_item["type"],
163  "title" => (string) $sub_item["title"],
164  "ref_id" => (int) $sub_item["child"],
165  "obj_id" => (int) $sub_item["obj_id"],
166  "timestamp" => ilExport::_getLastExportFileDate($sub_item["obj_id"], "xml", $sub_item["type"])
167  ];
168  }
169  }
170  return $valid_items;
171  }
static _getLastExportFileDate(int $a_obj_id, string $a_type="", string $a_obj_type="")
Get date of last export file
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createPathFromId()

static ilExport::createPathFromId ( int  $a_container_id,
string  $a_name 
)
staticprotected

Definition at line 707 of file class.ilExport.php.

References $path.

707  : string
708  {
709  $max_exponent = 3;
710  $factor = 100;
711 
712  $path = [];
713  $found = false;
714  $num = $a_container_id;
715  $path_string = '';
716  for ($i = $max_exponent; $i > 0; $i--) {
717  $factor = pow($factor, $i);
718  if (($tmp = (int) ($num / $factor)) or $found) {
719  $path[] = $tmp;
720  $num = $num % $factor;
721  $found = true;
722  }
723  }
724  if (count($path)) {
725  $path_string = (implode('/', $path) . '/');
726  }
727  return $path_string . $a_name . '_' . $a_container_id;
728  }
$path
Definition: ltiservices.php:29

◆ exportEntity()

ilExport::exportEntity ( string  $a_entity,
string  $a_id,
string  $a_target_release,
string  $a_component,
string  $a_title,
string  $a_export_dir,
string  $a_type_for_file = "" 
)

Export an ILIAS entity

Parameters
string$a_entityentity type, e.g. "sty"
mixed$a_identity id
string$a_target_releasetarget release
string$a_componentcomponent that exports (e.g. "components/ILIAS/Style")
Returns
array success and info array

Definition at line 484 of file class.ilExport.php.

References $c, $DIC, ilFileUtils\delDir(), IL_INST_ID, ILIAS_VERSION_NUMERIC, ilFileUtils\makeDirParents(), processExporter(), and ilFileUtils\zip().

492  : array {
493  global $DIC;
494 
495  $objDefinition = $DIC['objDefinition'];
496  $tpl = $DIC['tpl'];
497 
498  // if no target release specified, use latest major release number
499  if ($a_target_release == "") {
500  $v = explode(".", ILIAS_VERSION_NUMERIC);
501  $a_target_release = $v[0] . "." . $v[1] . ".0";
502  }
503 
504  if ($a_type_for_file == "") {
505  $a_type_for_file = $a_entity;
506  }
507 
508  $comp = $a_component;
509  $c = explode("/", $comp);
510  $component = str_replace("_", "", $c[2]);
511  $class = "il" . $component . "Exporter";
512 
513  // manifest writer
514  $this->manifest_writer = new ilXmlWriter();
515  $this->manifest_writer->xmlHeader();
516  $this->manifest_writer->xmlStartTag(
517  'Manifest',
518  array(
519  "MainEntity" => $a_entity,
520  "Title" => $a_title,
521  /* "TargetRelease" => $a_target_release, */
522  "InstallationId" => IL_INST_ID,
523  "InstallationUrl" => ILIAS_HTTP_PATH
524  )
525  );
526 
527  $export_dir = $a_export_dir;
528  $ts = time();
529 
530  // determine file name and subdirectory
531  $sub_dir = $ts . '__' . IL_INST_ID . '__' . $a_type_for_file . '_' . $a_id;
532  $new_file = $sub_dir . '.zip';
533 
534  $this->export_run_dir = $export_dir . "/" . $sub_dir;
535  ilFileUtils::makeDirParents($this->export_run_dir);
536 
537  $this->cnt = array();
538  $success = $this->processExporter($comp, $class, $a_entity, $a_target_release, [$a_id]);
539  $this->manifest_writer->xmlEndTag('Manifest');
540  $this->manifest_writer->xmlDumpFile($this->export_run_dir . "/manifest.xml", false);
541 
542  // zip the file
543  ilFileUtils::zip($this->export_run_dir, $export_dir . "/" . $new_file);
544  ilFileUtils::delDir($this->export_run_dir);
545 
546  return array(
547  "success" => $success,
548  "file" => $new_file,
549  "directory" => $export_dir
550  );
551  }
const IL_INST_ID
Definition: constants.php:40
processExporter(string $a_comp, string $a_class, string $a_entity, string $a_target_release, ?array $a_id=null)
Process exporter
$c
Definition: deliver.php:25
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
const ILIAS_VERSION_NUMERIC
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
global $DIC
Definition: shib_login.php:22
static zip(string $a_dir, string $a_file, bool $compress_content=false)
+ Here is the call graph for this function:

◆ exportObject()

ilExport::exportObject ( string  $a_type,
int  $a_id,
string  $a_target_release = "" 
)

Export an ILIAS object (the object type must be known by objDefinition)

Parameters
string$a_typerepository object type
int$a_idid of object or entity that shoudl be exported
string$a_target_releasetarget release
Returns
array success and info array

Definition at line 401 of file class.ilExport.php.

References _createExportDirectory(), _getExportDirectory(), ilObject\_lookupTitle(), ilFileUtils\delDir(), IL_CAL_UNIX, IL_INST_ID, ILIAS_VERSION_NUMERIC, ilFileUtils\makeDirParents(), processExporter(), and ilFileUtils\zip().

405  : array {
406  $this->log->debug("export type: $a_type, id: $a_id, target_release: " . $a_target_release);
407 
408  // if no target release specified, use latest major release number
409  if ($a_target_release == "") {
410  $v = explode(".", ILIAS_VERSION_NUMERIC);
411  $a_target_release = $v[0] . "." . $v[1] . ".0";
412  $this->log->debug("target_release set to: " . $a_target_release);
413  }
414 
415  // manifest writer
416  $this->manifest_writer = new ilXmlWriter();
417  $this->manifest_writer->xmlHeader();
418  $this->manifest_writer->xmlStartTag(
419  'Manifest',
420  array(
421  "MainEntity" => $a_type,
422  "Title" => ilObject::_lookupTitle($a_id),
423  /* "TargetRelease" => $a_target_release, */
424  "InstallationId" => IL_INST_ID,
425  "InstallationUrl" => ILIAS_HTTP_PATH
426  )
427  );
428 
429  // get export class
430  ilExport::_createExportDirectory($a_id, "xml", $a_type);
431  $export_dir = ilExport::_getExportDirectory($a_id, "xml", $a_type);
432  $ts = time();
433 
434  // Workaround for test assessment
435  $sub_dir = $ts . '__' . IL_INST_ID . '__' . $a_type . '_' . $a_id;
436  $new_file = $sub_dir . '.zip';
437 
438  $this->export_run_dir = $export_dir . "/" . $sub_dir;
439  ilFileUtils::makeDirParents($this->export_run_dir);
440  $this->log->debug("export dir: " . $this->export_run_dir);
441 
442  $this->cnt = array();
443 
444  $class = ilImportExportFactory::getExporterClass($a_type);
445  $comp = ilImportExportFactory::getComponentForExport($a_type);
446 
447  $success = $this->processExporter($comp, $class, $a_type, $a_target_release, [$a_id]);
448 
449  $this->manifest_writer->xmlEndTag('Manifest');
450  $this->manifest_writer->xmlDumpFile($this->export_run_dir . "/manifest.xml", false);
451 
452  // zip the file
453  $this->log->debug("zip: " . $export_dir . "/" . $new_file);
454  $this->log->debug("run dir: " . $this->export_run_dir);
455  ilFileUtils::zip($this->export_run_dir, $export_dir . "/" . $new_file);
456  ilFileUtils::delDir($this->export_run_dir);
457 
458  // Store info about export
459  if ($success) {
460  $exp = new ilExportFileInfo($a_id);
461  $exp->setVersion($a_target_release);
462  $exp->setCreationDate(new ilDateTime($ts, IL_CAL_UNIX));
463  $exp->setExportType('xml');
464  $exp->setFilename($new_file);
465  $exp->create();
466  }
467 
468  return array(
469  "success" => $success,
470  "file" => $new_file,
471  "directory" => $export_dir
472  );
473  }
const IL_INST_ID
Definition: constants.php:40
processExporter(string $a_comp, string $a_class, string $a_entity, string $a_target_release, ?array $a_id=null)
Process exporter
const IL_CAL_UNIX
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static _getExportDirectory(int $a_obj_id, string $a_type="xml", string $a_obj_type="", string $a_entity="")
Get export directory for an repository object
const ILIAS_VERSION_NUMERIC
static _lookupTitle(int $obj_id)
static _createExportDirectory(int $a_obj_id, string $a_export_type="xml", string $a_obj_type="")
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
Stores information of creation date and versions of export files
static zip(string $a_dir, string $a_file, bool $compress_content=false)
+ Here is the call graph for this function:

◆ getAbsoluteExportDirectory()

ilExport::getAbsoluteExportDirectory ( )

Definition at line 108 of file class.ilExport.php.

References $dir_absolute.

108  : string
109  {
110  return $this->dir_absolute;
111  }
string $dir_absolute

◆ getConfig()

ilExport::getConfig ( string  $a_comp)

Get configuration (note that configurations are optional, null may be returned!)

Parameters
string$a_compcomponent (e.g. "components/ILIAS/Glossary")
Returns
ilExportConfig $a_comp configuration object
Exceptions
ilExportExceptionthronw if no config exists

Definition at line 130 of file class.ilExport.php.

131  {
132  // if created, return existing config object
133  if (isset($this->configs[$a_comp])) {
134  return $this->configs[$a_comp];
135  }
136 
137  // create instance of export config object
138  $comp_arr = explode("/", $a_comp);
139  $component = str_replace("_", "", $comp_arr[2]);
140  $a_class = "il" . $component . "ExportConfig";
141  $exp_config = new $a_class();
142  $this->configs[$a_comp] = $exp_config;
143  return $exp_config;
144  }
Export configuration class parent class.

◆ getExportDirInContainer()

ilExport::getExportDirInContainer ( )
Returns
string the path to the export directory of the current component in the container, for example: "1737382047__0__cat_100/components/ILIAS/Style/set_0

Definition at line 80 of file class.ilExport.php.

80  : string
81  {
82  return $this->export_path_info->getPathToComponentDirInContainer();
83  }

◆ getExportWriter()

ilExport::getExportWriter ( )

Definition at line 119 of file class.ilExport.php.

References $export_writer.

119  : ilExportHandlerConsumerExportWriterInterface
120  {
121  return $this->export_writer;
122  }
ilExportHandlerConsumerExportWriterInterface $export_writer

◆ getPathToComponentExpDirInContainer()

ilExport::getPathToComponentExpDirInContainer ( )
Returns
string the path to the expDir folder in the export directory of the current component in the container, for example: "1737382047__0__cat_100/components/ILIAS/Style/set_0/expDir_1

Definition at line 90 of file class.ilExport.php.

90  : string
91  {
92  return $this->export_path_info->getPathToComponentExpDirInContainer();
93  }

◆ getRelativeExportDirectory()

ilExport::getRelativeExportDirectory ( )

Definition at line 103 of file class.ilExport.php.

References $dir_relative.

103  : string
104  {
105  return $this->dir_relative;
106  }
string $dir_relative

◆ processExporter()

ilExport::processExporter ( string  $a_comp,
string  $a_class,
string  $a_entity,
string  $a_target_release,
?array  $a_id = null 
)

Process exporter

Parameters
string$a_compe.g. "components/ILIAS/Forum"
string$a_class
string$a_entitye.g. "frm"
string$a_target_releasee.g. "5.1.0"
string$a_idid of entity (e.g. object id)
Returns
bool success true/false
Exceptions
ilExportException

Definition at line 564 of file class.ilExport.php.

References $id, IL_INST_ID, and ilFileUtils\makeDirParents().

Referenced by exportEntity(), and exportObject().

570  : bool {
571  $success = true;
572  $this->log->debug("process exporter, comp: " . $a_comp . ", class: " . $a_class . ", entity: " . $a_entity .
573  ", target release " . $a_target_release . ", id: " . print_r($a_id, true));
574 
575  if (!is_array($a_id)) {
576  if ($a_id == "") {
577  return true;
578  }
579  $a_id = array($a_id);
580  }
581 
582  // get exporter object
583  if (!class_exists($a_class)) {
584  $a_class = substr($a_class, 0, 2) . "ILIAS" . substr($a_class, 2);
585  if (!class_exists($a_class)) {
586  $export_class_file = "./" . $a_comp . "/classes/class." . $a_class . ".php";
587  if (!is_file($export_class_file)) {
588  throw new ilExportException('Export class file "' . $export_class_file . '" not found.');
589  }
590  }
591  }
592 
593  $exp = new $a_class();
594  $exp->setExport($this);
595  if (!isset($this->cnt[$a_comp])) {
596  $this->cnt[$a_comp] = 1;
597  } else {
598  $this->cnt[$a_comp]++;
599  }
600  $set_dir_relative = $a_comp . "/set_" . $this->cnt[$a_comp];
601  $set_dir_absolute = $this->export_run_dir . "/" . $set_dir_relative;
602  ilFileUtils::makeDirParents($set_dir_absolute);
603  $this->log->debug("dir: " . $set_dir_absolute);
604 
605  $this->log->debug("init exporter");
606  $exp->init();
607 
608  // process head dependencies
609  $this->log->debug("process head dependencies for " . $a_entity);
610  $sequence = $exp->getXmlExportHeadDependencies($a_entity, $a_target_release, $a_id);
611  foreach ($sequence as $s) {
612  $comp = explode("/", $s["component"]);
613  $component = str_replace("_", "", $comp[2]);
614  $exp_class = "il" . $component . "Exporter";
615  $s = $this->processExporter(
616  $s["component"],
617  $exp_class,
618  $s["entity"],
619  $a_target_release,
620  $s["ids"]
621  );
622  if (!$s) {
623  $success = false;
624  }
625  }
626 
627  // write export.xml file
628  $export_writer = new ilXmlWriter();
629  $export_writer->xmlHeader();
630 
631  $sv = $exp->determineSchemaVersion($a_entity, $a_target_release);
632  $sv["uses_dataset"] ??= false;
633  $sv['xsd_file'] ??= '';
634  $this->log->debug("schema version for entity: $a_entity, target release: $a_target_release");
635  $this->log->debug("...is: " . $sv["schema_version"] . ", namespace: " . $sv["namespace"] .
636  ", xsd file: " . $sv["xsd_file"] . ", uses_dataset: " . ((int) $sv["uses_dataset"]));
637 
638  $attribs = array("InstallationId" => IL_INST_ID,
639  "InstallationUrl" => ILIAS_HTTP_PATH,
640  "Entity" => $a_entity,
641  "SchemaVersion" => $sv["schema_version"],
642  /* "TargetRelease" => $a_target_release, */
643  "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
644  "xmlns:exp" => "http://www.ilias.de/Services/Export/exp/4_1",
645  "xsi:schemaLocation" => "http://www.ilias.de/Services/Export/exp/4_1 " . ILIAS_HTTP_PATH . "/components/ILIAS/Export/xml/ilias_export_4_1.xsd"
646  );
647  if ($sv["namespace"] != "" && $sv["xsd_file"] != "") {
648  $attribs["xsi:schemaLocation"] .= " " . $sv["namespace"] . " " .
649  ILIAS_HTTP_PATH . "/components/ILIAS/Export/xml/" . $sv["xsd_file"];
650  $attribs["xmlns"] = $sv["namespace"];
651  }
652  if ($sv["uses_dataset"]) {
653  $attribs["xsi:schemaLocation"] .= " " .
654  "http://www.ilias.de/Services/DataSet/ds/4_3 " . ILIAS_HTTP_PATH . "/components/ILIAS/Export/xml/ilias_ds_4_3.xsd";
655  $attribs["xmlns:ds"] = "http://www.ilias.de/Services/DataSet/ds/4_3";
656  }
657  $export_writer->xmlStartTag('exp:Export', $attribs);
658 
659  $dir_cnt = 1;
660  foreach ($a_id as $id) {
661  $exp->setExportDirectories(
662  $set_dir_relative . "/expDir_" . $dir_cnt,
663  $set_dir_absolute . "/expDir_" . $dir_cnt
664  );
665  $export_writer->xmlStartTag('exp:ExportItem', array("Id" => $id));
666  $xml = $exp->getXmlRepresentation($a_entity, $sv["schema_version"], (string) $id);
667  $export_writer->appendXML($xml);
668  $export_writer->xmlEndTag('exp:ExportItem');
669  $dir_cnt++;
670  }
671 
672  $export_writer->xmlEndTag('exp:Export');
673  $export_writer->xmlDumpFile($set_dir_absolute . "/export.xml", false);
674 
675  $this->manifest_writer->xmlElement(
676  "ExportFile",
677  array("Component" => $a_comp, "Path" => $set_dir_relative . "/export.xml")
678  );
679 
680  // process tail dependencies
681  $this->log->debug("process tail dependencies of " . $a_entity);
682  $sequence = $exp->getXmlExportTailDependencies($a_entity, $a_target_release, $a_id);
683  foreach ($sequence as $s) {
684  if (empty((array) ($s["ids"] ?? []))) {
685  continue;
686  }
687 
688  $comp = explode("/", $s["component"]);
689  $component = str_replace("_", "", $comp[2]);
690  $exp_class = "il" . $component . "Exporter";
691  $s = $this->processExporter(
692  $s["component"],
693  $exp_class,
694  $s["entity"],
695  $a_target_release,
696  (array) $s["ids"]
697  );
698  if (!$s) {
699  $success = false;
700  }
701  }
702 
703  $this->log->debug("returning " . ((int) $success) . " for " . $a_entity);
704  return $success;
705  }
ilExportHandlerConsumerExportWriterInterface $export_writer
const IL_INST_ID
Definition: constants.php:40
processExporter(string $a_comp, string $a_class, string $a_entity, string $a_target_release, ?array $a_id=null)
Process exporter
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setExportDirectories()

ilExport::setExportDirectories ( string  $a_dir_relative,
string  $a_dir_absolute 
)

Definition at line 95 of file class.ilExport.php.

98  : void {
99  $this->dir_relative = $a_dir_relative;
100  $this->dir_absolute = $a_dir_absolute;
101  }

◆ setExportDirInContainer()

ilExport::setExportDirInContainer ( string  $export_dir_in_container)

Definition at line 64 of file class.ilExport.php.

References $export_dir_in_container.

66  : void {
67  $this->export_dir_in_container = $export_dir_in_container;
68  }
string $export_dir_in_container

◆ setExportWriter()

ilExport::setExportWriter ( ilExportHandlerConsumerExportWriterInterface  $export_writer)

Definition at line 113 of file class.ilExport.php.

References $export_writer.

115  : void {
116  $this->export_writer = $export_writer;
117  }
ilExportHandlerConsumerExportWriterInterface $export_writer

◆ setPathInfo()

ilExport::setPathInfo ( ExportPathInfoInterface  $export_path_info)

Definition at line 70 of file class.ilExport.php.

References $export_path_info.

72  : void {
73  $this->export_path_info = $export_path_info;
74  }
ExportPathInfoInterface $export_path_info

Field Documentation

◆ $cnt

array ilExport::$cnt = []
private

Definition at line 55 of file class.ilExport.php.

◆ $configs

array ilExport::$configs = []
private

Definition at line 53 of file class.ilExport.php.

◆ $dir_absolute

string ilExport::$dir_absolute = ""
protected

Definition at line 32 of file class.ilExport.php.

Referenced by getAbsoluteExportDirectory().

◆ $dir_relative

string ilExport::$dir_relative = ""
protected

Definition at line 31 of file class.ilExport.php.

Referenced by getRelativeExportDirectory().

◆ $export_dir_in_container

string ilExport::$export_dir_in_container
protected

Definition at line 36 of file class.ilExport.php.

Referenced by setExportDirInContainer().

◆ $export_implementer

array ilExport::$export_implementer = array("tst", "lm", "glo", "sahs")
staticprivate

Definition at line 52 of file class.ilExport.php.

◆ $export_path_info

ExportPathInfoInterface ilExport::$export_path_info
protected

Definition at line 37 of file class.ilExport.php.

Referenced by setPathInfo().

◆ $export_run_dir

string ilExport::$export_run_dir = ''

Definition at line 30 of file class.ilExport.php.

◆ $export_writer

ilExportHandlerConsumerExportWriterInterface ilExport::$export_writer
protected

Definition at line 35 of file class.ilExport.php.

Referenced by getExportWriter(), and setExportWriter().

◆ $log

ilLogger ilExport::$log
protected

Definition at line 34 of file class.ilExport.php.

Referenced by ilExportContainer\exportObject().

◆ $manifest_writer

ilXmlWriter ilExport::$manifest_writer = null
private

Definition at line 56 of file class.ilExport.php.

◆ $new_file_structure

array ilExport::$new_file_structure
staticprivate
Initial value:
= array('cat',
'exc',
'crs',
'sess',
'file',
'grp',
'frm',
'usr',
'catr',
'crsr',
'grpr'
)

Definition at line 39 of file class.ilExport.php.


The documentation for this class was generated from the following file: