ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilExport Class Reference

Export. More...

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

Public Member Functions

 __construct ()
 
 setPathInfo (ExportPathInfoInterface $export_path_info)
 
 getExportDirInContainer ()
 
 getPathToComponentExpDirInContainer ()
 
 getPathToComponentExpDirInContainerWithLeadingSetNumber ()
 
 getSetNumber ()
 
 isContainerExport ()
 
 setExportDirectories (string $a_dir_relative, string $a_dir_absolute)
 
 getRelativeExportDirectory ()
 
 getAbsoluteExportDirectory ()
 
 setExportWriter (ilExportHandlerConsumerExportWriterInterface $export_writer,)
 
 getExportWriter ()
 
 setExportConfigs (ExportConfigCollectionInterface $export_configs)
 
 getExportConfigs ()
 
 exportObject (string $a_type, int $a_id, string $a_target_release="")
 @depricated 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="")
 @depricated Export an ILIAS entity More...
 
 processExporter (string $a_comp, string $a_class, string $a_entity, string $a_target_release, ?array $a_id=null)
 @depricated Process exporter More...
 

Static Public Member Functions

static _getLastExportFileDate (int $a_obj_id, string $a_type="", string $a_obj_type="")
 @depricated Get date of last export file More...
 
static _getLastExportFileInformation (int $a_obj_id, string $a_type="", string $a_obj_type="")
 @depricated Get last export file information More...
 
static _getExportDirectory (int $a_obj_id, string $a_type="xml", string $a_obj_type="", string $a_entity="")
 @depricated Get export directory for an repository object More...
 
static _getExportFiles (int $a_obj_id, $a_export_types="", string $a_obj_type="")
 @depricated More...
 
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="")
 @depricated 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
 
ExportPathInfoInterface $export_path_info
 
ExportConfigCollectionInterface $export_configs
 

Private Attributes

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 30 of file class.ilExport.php.

Constructor & Destructor Documentation

◆ __construct()

ilExport::__construct ( )

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

57 {
58 global $DIC;
59 $this->log = $DIC->logger()->exp();
60 }
global $DIC
Definition: shib_login.php:26

References $DIC.

Member Function Documentation

◆ _createExportDirectory()

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

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

295 : bool {
296 global $DIC;
297
298 $ilErr = $DIC['ilErr'];
299
300 if ($a_obj_type == "") {
301 $a_obj_type = ilObject::_lookupType($a_obj_id);
302 }
303
304 $edir = ilExport::_getExportDirectory($a_obj_id, $a_export_type, $a_obj_type);
306 return true;
307 }
static _getExportDirectory(int $a_obj_id, string $a_type="xml", string $a_obj_type="", string $a_entity="")
@depricated Get export directory for an repository object
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static _lookupType(int $id, bool $reference=false)

References ilObject\_lookupType().

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

+ 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

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

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

319 : void {
320 global $DIC;
321
322 $lng = $DIC->language();
323 $lng->loadLanguageModule("export");
324
325 if ($a_type == "") {
326 $a_type = ilObject::_lookupType($a_obj_id);
327 }
328 $a_tpl = new ilGlobalTemplate("tpl.main.html", true, true);
329 $location_stylesheet = ilUtil::getStyleSheetLocation();
330 $a_tpl->setVariable("LOCATION_STYLESHEET", $location_stylesheet);
331 $a_tpl->loadStandardTemplate();
332 $a_tpl->setTitle(ilObject::_lookupTitle($a_obj_id));
333 $a_tpl->setDescription($lng->txt("export_export_date") . ": " .
334 date('Y-m-d H:i:s', time()) . " (" . date_default_timezone_get() . ")");
335 $f_tpl = new ilTemplate("tpl.export_list.html", true, true, "components/ILIAS/Export");
336 foreach ($a_files as $file) {
337 $f_tpl->setCurrentBlock("file_row");
338 $f_tpl->setVariable("TITLE", $file["title"]);
339 $f_tpl->setVariable("TYPE", $lng->txt("obj_" . $file["type"]));
340 $f_tpl->setVariable("FILE", $file["file"]);
341 $f_tpl->parseCurrentBlock();
342 }
343 $a_tpl->setContent($f_tpl->get());
344 $index_content = $a_tpl->getSpecial("DEFAULT", false, false, false, true, false, false);
345
346 $f = fopen($a_filename, "w");
347 fwrite($f, $index_content);
348 fclose($f);
349 }
special template class to simplify handling of ITX/PEAR
static _lookupTitle(int $obj_id)
special template class to simplify handling of ITX/PEAR
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
global $lng
Definition: privfeed.php:26

References ilObject\_lookupType().

+ 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

@depricated 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 189 of file class.ilExport.php.

194 : string {
195 global $DIC;
196
197 $logger = $DIC->logger()->exp();
198 $objDefinition = $DIC['objDefinition'];
199
200 $ent = ($a_entity == "")
201 ? ""
202 : "_" . $a_entity;
203
204 if ($a_obj_type == "") {
205 $a_obj_type = ilObject::_lookupType($a_obj_id);
206 }
207
208 if (in_array($a_obj_type, self::$new_file_structure)) {
209 $dir = ilFileUtils::getDataDir() . DIRECTORY_SEPARATOR;
210 $dir .= 'il' . $objDefinition->getClassName($a_obj_type) . $ent . DIRECTORY_SEPARATOR;
211 $dir .= self::createPathFromId($a_obj_id, $a_obj_type) . DIRECTORY_SEPARATOR;
212 $dir .= ($a_type == 'xml' ? 'export' : 'export_' . $a_type);
213 return $dir;
214 }
215
216 $exporter_class = ilImportExportFactory::getExporterClass($a_obj_type);
217 $export_dir = call_user_func(
218 array($exporter_class, 'lookupExportDirectory'),
219 $a_obj_type,
220 $a_obj_id,
221 $a_type,
222 $a_entity
223 );
224
225 $logger->debug('Export dir is ' . $export_dir);
226 return $export_dir;
227 }
static createPathFromId(int $a_container_id, string $a_name)
static getDataDir()
get data directory (outside webspace)

References ilObject\_lookupType().

Referenced by ILIAS\Notes\Export\NotesHtmlExport\__construct(), _getExportFiles(), ilExportContainer\addSubitems(), ilObjFileBasedLMGUI\exportHTML(), ilExportContainer\exportObject(), ilDclContentExporter\getExportContentPath(), ilObjGlossary\getExportDirectory(), ILIAS\Export\ExportHandler\Info\Export\Handler\getLegacyExportRunDir(), ilObjUser\getPersonalDataExportFile(), ILIAS\Wiki\Export\WikiHtmlExport\getUserExportFile(), ilDataCollectionExportOptionsXLSX\onDeleteFiles(), ILIAS\Export\ExportHandler\Consumer\ExportOption\BasicLegacyHandler\onDeleteFiles(), ilMediaPoolExportOptionXMLMaster\onDeleteFiles(), ilMediaPoolExportOptionXMLMasterNoMedia\onDeleteFiles(), ILIAS\Export\ExportHandler\Consumer\ExportOption\BasicLegacyHandler\onDownloadFiles(), ilMediaPoolExportOptionXMLMaster\onDownloadFiles(), ilMediaPoolExportOptionXMLMasterNoMedia\onDownloadFiles(), ilOrgUnitExporter\sendAndCreateSimpleExportFile(), ilObjUser\sendPersonalDataFile(), and ILIAS\Notes\Export\NotesHtmlExport\zipPackage().

+ 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

@depricated

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

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

236 : array
237 {
238 if ($a_obj_type == "") {
239 $a_obj_type = ilObject::_lookupType($a_obj_id);
240 }
241
242 if ($a_export_types == "") {
243 $a_export_types = array("xml");
244 }
245 if (!is_array($a_export_types)) {
246 $a_export_types = array($a_export_types);
247 }
248
249 // initialize array
250 $file = array();
251
252 $types = $a_export_types;
253
254 foreach ($types as $type) {
255 $dir = ilExport::_getExportDirectory($a_obj_id, $type, $a_obj_type);
256
257 // quit if import dir not available
258 if (!is_dir($dir) || !is_writable($dir)) {
259 continue;
260 }
261
262 // open directory
263 $h_dir = dir($dir);
264
265 // get files and save the in the array
266 while ($entry = $h_dir->read()) {
267 if ($entry !== "." &&
268 $entry !== ".." &&
269 substr($entry, -4) === ".zip" &&
270 preg_match("/^[0-9]{10}_{2}[0-9]+_{2}(" . $a_obj_type . "_)*[0-9]+\.zip\$/", $entry)) {
271 $ts = substr($entry, 0, strpos($entry, "__"));
272 $file[$entry . $type] = [
273 "type" => (string) $type,
274 "file" => (string) $entry,
275 "size" => (int) filesize($dir . "/" . $entry),
276 "timestamp" => (int) $ts
277 ];
278 }
279 }
280
281 // close import directory
282 $h_dir->close();
283 }
284
285 // sort files
286 ksort($file);
287 reset($file);
288 return $file;
289 }

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

Referenced by _getLastExportFileDate().

+ 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

@depricated 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 149 of file class.ilExport.php.

149 : int
150 {
151 $files = ilExport::_getExportFiles($a_obj_id, $a_type, $a_obj_type);
152 if (is_array($files)) {
153 $files = ilArrayUtil::sortArray($files, "timestamp", "desc");
154 return (int) $files[0]["timestamp"];
155 }
156 return 0;
157 }
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
static _getExportFiles(int $a_obj_id, $a_export_types="", string $a_obj_type="")
@depricated

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

+ Here is the call graph for this function:

◆ _getLastExportFileInformation()

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

@depricated 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 167 of file class.ilExport.php.

171 : ?array {
172 $files = ilExport::_getExportFiles($a_obj_id, $a_type, $a_obj_type);
173 if (is_array($files)) {
174 $files = ilArrayUtil::sortArray($files, "timestamp", "desc");
175 return $files[0];
176 }
177 return null;
178 }

References $files, and ilArrayUtil\sortArray().

+ Here is the call graph for this function:

◆ createPathFromId()

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

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

676 : string
677 {
678 $max_exponent = 3;
679 $factor = 100;
680
681 $path = [];
682 $found = false;
683 $num = $a_container_id;
684 $path_string = '';
685 for ($i = $max_exponent; $i > 0; $i--) {
686 $factor = pow($factor, $i);
687 if (($tmp = (int) ($num / $factor)) or $found) {
688 $path[] = $tmp;
689 $num = $num % $factor;
690 $found = true;
691 }
692 }
693 if (count($path)) {
694 $path_string = (implode('/', $path) . '/');
695 }
696 return $path_string . $a_name . '_' . $a_container_id;
697 }

◆ 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 = "" 
)

@depricated 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 453 of file class.ilExport.php.

461 : array {
462 global $DIC;
463
464 $objDefinition = $DIC['objDefinition'];
465 $tpl = $DIC['tpl'];
466
467 // if no target release specified, use latest major release number
468 if ($a_target_release == "") {
469 $v = explode(".", ILIAS_VERSION_NUMERIC);
470 $a_target_release = $v[0] . "." . $v[1] . ".0";
471 }
472
473 if ($a_type_for_file == "") {
474 $a_type_for_file = $a_entity;
475 }
476
477 $comp = $a_component;
478 $c = explode("/", $comp);
479 $component = str_replace("_", "", $c[2]);
480 $class = "il" . $component . "Exporter";
481
482 // manifest writer
483 $this->manifest_writer = new ilXmlWriter();
484 $this->manifest_writer->xmlHeader();
485 $this->manifest_writer->xmlStartTag(
486 'Manifest',
487 array(
488 "MainEntity" => $a_entity,
489 "Title" => $a_title,
490 /* "TargetRelease" => $a_target_release, */
491 "InstallationId" => IL_INST_ID,
492 "InstallationUrl" => ILIAS_HTTP_PATH
493 )
494 );
495
496 $export_dir = $a_export_dir;
497 $ts = time();
498
499 // determine file name and subdirectory
500 $sub_dir = $ts . '__' . IL_INST_ID . '__' . $a_type_for_file . '_' . $a_id;
501 $new_file = $sub_dir . '.zip';
502
503 $this->export_run_dir = $export_dir . "/" . $sub_dir;
504 ilFileUtils::makeDirParents($this->export_run_dir);
505
506 $this->cnt = array();
507 $success = $this->processExporter($comp, $class, $a_entity, $a_target_release, [$a_id]);
508 $this->manifest_writer->xmlEndTag('Manifest');
509 $this->manifest_writer->xmlDumpFile($this->export_run_dir . "/manifest.xml", false);
510
511 // zip the file
512 ilFileUtils::zip($this->export_run_dir, $export_dir . "/" . $new_file);
513 ilFileUtils::delDir($this->export_run_dir);
514
515 return array(
516 "success" => $success,
517 "file" => $new_file,
518 "directory" => $export_dir
519 );
520 }
processExporter(string $a_comp, string $a_class, string $a_entity, string $a_target_release, ?array $a_id=null)
@depricated Process exporter
static zip(string $a_dir, string $a_file, bool $compress_content=false)
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_INST_ID
Definition: constants.php:40
const ILIAS_VERSION_NUMERIC
readonly ilGlobalTemplateInterface $tpl

References ILIAS_VERSION_NUMERIC.

◆ exportObject()

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

@depricated 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

Reimplemented in ilExportContainer.

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

374 : array {
375 $this->log->debug("export type: $a_type, id: $a_id, target_release: " . $a_target_release);
376
377 // if no target release specified, use latest major release number
378 if ($a_target_release == "") {
379 $v = explode(".", ILIAS_VERSION_NUMERIC);
380 $a_target_release = $v[0] . "." . $v[1] . ".0";
381 $this->log->debug("target_release set to: " . $a_target_release);
382 }
383
384 // manifest writer
385 $this->manifest_writer = new ilXmlWriter();
386 $this->manifest_writer->xmlHeader();
387 $this->manifest_writer->xmlStartTag(
388 'Manifest',
389 array(
390 "MainEntity" => $a_type,
391 "Title" => ilObject::_lookupTitle($a_id),
392 /* "TargetRelease" => $a_target_release, */
393 "InstallationId" => IL_INST_ID,
394 "InstallationUrl" => ILIAS_HTTP_PATH
395 )
396 );
397
398 // get export class
399 ilExport::_createExportDirectory($a_id, "xml", $a_type);
400 $export_dir = ilExport::_getExportDirectory($a_id, "xml", $a_type);
401 $ts = time();
402
403 // Workaround for test assessment
404 $sub_dir = $ts . '__' . IL_INST_ID . '__' . $a_type . '_' . $a_id;
405 $new_file = $sub_dir . '.zip';
406
407 $this->export_run_dir = $export_dir . "/" . $sub_dir;
408 ilFileUtils::makeDirParents($this->export_run_dir);
409 $this->log->debug("export dir: " . $this->export_run_dir);
410
411 $this->cnt = array();
412
413 $class = ilImportExportFactory::getExporterClass($a_type);
414 $comp = ilImportExportFactory::getComponentForExport($a_type);
415
416 $success = $this->processExporter($comp, $class, $a_type, $a_target_release, [$a_id]);
417
418 $this->manifest_writer->xmlEndTag('Manifest');
419 $this->manifest_writer->xmlDumpFile($this->export_run_dir . "/manifest.xml", false);
420
421 // zip the file
422 $this->log->debug("zip: " . $export_dir . "/" . $new_file);
423 $this->log->debug("run dir: " . $this->export_run_dir);
424 ilFileUtils::zip($this->export_run_dir, $export_dir . "/" . $new_file);
425 ilFileUtils::delDir($this->export_run_dir);
426
427 // Store info about export
428 if ($success) {
429 $exp = new ilExportFileInfo($a_id);
430 $exp->setVersion($a_target_release);
431 $exp->setCreationDate(new ilDateTime($ts, IL_CAL_UNIX));
432 $exp->setExportType('xml');
433 $exp->setFilename($new_file);
434 $exp->create();
435 }
436
437 return array(
438 "success" => $success,
439 "file" => $new_file,
440 "directory" => $export_dir
441 );
442 }
const IL_CAL_UNIX
@classDescription Date and time handling
@classDescription Stores information of creation date and versions of export files
static _createExportDirectory(int $a_obj_id, string $a_export_type="xml", string $a_obj_type="")

References ILIAS_VERSION_NUMERIC.

◆ getAbsoluteExportDirectory()

ilExport::getAbsoluteExportDirectory ( )

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

115 : string
116 {
117 return $this->dir_absolute;
118 }
string $dir_absolute

◆ getExportConfigs()

ilExport::getExportConfigs ( )

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

137 : ExportConfigCollectionInterface
138 {
140 }
ExportConfigCollectionInterface $export_configs

◆ 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 72 of file class.ilExport.php.

72 : string
73 {
74 return $this->export_path_info->getPathToComponentDirInContainer();
75 }

◆ getExportWriter()

ilExport::getExportWriter ( )

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

126 : ilExportHandlerConsumerExportWriterInterface
127 {
129 }
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 82 of file class.ilExport.php.

82 : string
83 {
84 return $this->export_path_info->getPathToComponentExpDirInContainer();
85 }

◆ getPathToComponentExpDirInContainerWithLeadingSetNumber()

ilExport::getPathToComponentExpDirInContainerWithLeadingSetNumber ( )

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

87 : string
88 {
89 return "set_" . $this->export_path_info->getSetNumber() . DIRECTORY_SEPARATOR . $this->export_path_info->getPathToComponentExpDirInContainer();
90 }

◆ getRelativeExportDirectory()

ilExport::getRelativeExportDirectory ( )

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

110 : string
111 {
112 return $this->dir_relative;
113 }
string $dir_relative

◆ getSetNumber()

ilExport::getSetNumber ( )

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

92 : int
93 {
94 return $this->export_path_info->getSetNumber();
95 }

◆ isContainerExport()

ilExport::isContainerExport ( )

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

97 : bool
98 {
99 return $this->export_path_info->isContainerExport();
100 }

◆ processExporter()

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

@depricated 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 533 of file class.ilExport.php.

539 : bool {
540 $success = true;
541 $this->log->debug("process exporter, comp: " . $a_comp . ", class: " . $a_class . ", entity: " . $a_entity .
542 ", target release " . $a_target_release . ", id: " . print_r($a_id, true));
543
544 if (!is_array($a_id)) {
545 if ($a_id == "") {
546 return true;
547 }
548 $a_id = array($a_id);
549 }
550
551 // get exporter object
552 if (!class_exists($a_class)) {
553 $a_class = substr($a_class, 0, 2) . "ILIAS" . substr($a_class, 2);
554 if (!class_exists($a_class)) {
555 $export_class_file = "./" . $a_comp . "/classes/class." . $a_class . ".php";
556 if (!is_file($export_class_file)) {
557 throw new ilExportException('Export class file "' . $export_class_file . '" not found.');
558 }
559 }
560 }
561
562 $exp = new $a_class();
563 $exp->setExport($this);
564 if (!isset($this->cnt[$a_comp])) {
565 $this->cnt[$a_comp] = 1;
566 } else {
567 $this->cnt[$a_comp]++;
568 }
569 $set_dir_relative = $a_comp . "/set_" . $this->cnt[$a_comp];
570 $set_dir_absolute = $this->export_run_dir . "/" . $set_dir_relative;
571 ilFileUtils::makeDirParents($set_dir_absolute);
572 $this->log->debug("dir: " . $set_dir_absolute);
573
574 $this->log->debug("init exporter");
575 $exp->init();
576
577 // process head dependencies
578 $this->log->debug("process head dependencies for " . $a_entity);
579 $sequence = $exp->getXmlExportHeadDependencies($a_entity, $a_target_release, $a_id);
580 foreach ($sequence as $s) {
581 $comp = explode("/", $s["component"]);
582 $component = str_replace("_", "", $comp[2]);
583 $exp_class = "il" . $component . "Exporter";
584 $s = $this->processExporter(
585 $s["component"],
586 $exp_class,
587 $s["entity"],
588 $a_target_release,
589 $s["ids"]
590 );
591 if (!$s) {
592 $success = false;
593 }
594 }
595
596 // write export.xml file
598 $export_writer->xmlHeader();
599
600 $sv = $exp->determineSchemaVersion($a_entity, $a_target_release);
601 $sv["uses_dataset"] ??= false;
602 $sv['xsd_file'] ??= '';
603 $this->log->debug("schema version for entity: $a_entity, target release: $a_target_release");
604 $this->log->debug("...is: " . $sv["schema_version"] . ", namespace: " . $sv["namespace"] .
605 ", xsd file: " . $sv["xsd_file"] . ", uses_dataset: " . ((int) $sv["uses_dataset"]));
606
607 $attribs = array("InstallationId" => IL_INST_ID,
608 "InstallationUrl" => ILIAS_HTTP_PATH,
609 "Entity" => $a_entity,
610 "SchemaVersion" => $sv["schema_version"],
611 /* "TargetRelease" => $a_target_release, */
612 "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
613 "xmlns:exp" => "http://www.ilias.de/Services/Export/exp/4_1",
614 "xsi:schemaLocation" => "http://www.ilias.de/Services/Export/exp/4_1 " . ILIAS_HTTP_PATH . "/components/ILIAS/Export/xml/ilias_export_4_1.xsd"
615 );
616 if ($sv["namespace"] != "" && $sv["xsd_file"] != "") {
617 $attribs["xsi:schemaLocation"] .= " " . $sv["namespace"] . " " .
618 ILIAS_HTTP_PATH . "/components/ILIAS/Export/xml/" . $sv["xsd_file"];
619 $attribs["xmlns"] = $sv["namespace"];
620 }
621 if ($sv["uses_dataset"]) {
622 $attribs["xsi:schemaLocation"] .= " " .
623 "http://www.ilias.de/Services/DataSet/ds/4_3 " . ILIAS_HTTP_PATH . "/components/ILIAS/Export/xml/ilias_ds_4_3.xsd";
624 $attribs["xmlns:ds"] = "http://www.ilias.de/Services/DataSet/ds/4_3";
625 }
626 $export_writer->xmlStartTag('exp:Export', $attribs);
627
628 $dir_cnt = 1;
629 foreach ($a_id as $id) {
630 $exp->setExportDirectories(
631 $set_dir_relative . "/expDir_" . $dir_cnt,
632 $set_dir_absolute . "/expDir_" . $dir_cnt
633 );
634 $export_writer->xmlStartTag('exp:ExportItem', array("Id" => $id));
635 $xml = $exp->getXmlRepresentation($a_entity, $sv["schema_version"], (string) $id);
636 $export_writer->appendXML($xml);
637 $export_writer->xmlEndTag('exp:ExportItem');
638 $dir_cnt++;
639 }
640
641 $export_writer->xmlEndTag('exp:Export');
642 $export_writer->xmlDumpFile($set_dir_absolute . "/export.xml", false);
643
644 $this->manifest_writer->xmlElement(
645 "ExportFile",
646 array("Component" => $a_comp, "Path" => $set_dir_relative . "/export.xml")
647 );
648
649 // process tail dependencies
650 $this->log->debug("process tail dependencies of " . $a_entity);
651 $sequence = $exp->getXmlExportTailDependencies($a_entity, $a_target_release, $a_id);
652 foreach ($sequence as $s) {
653 if (empty((array) ($s["ids"] ?? []))) {
654 continue;
655 }
656
657 $comp = explode("/", $s["component"]);
658 $component = str_replace("_", "", $comp[2]);
659 $exp_class = "il" . $component . "Exporter";
660 $s = $this->processExporter(
661 $s["component"],
662 $exp_class,
663 $s["entity"],
664 $a_target_release,
665 (array) $s["ids"]
666 );
667 if (!$s) {
668 $success = false;
669 }
670 }
671
672 $this->log->debug("returning " . ((int) $success) . " for " . $a_entity);
673 return $success;
674 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ setExportConfigs()

ilExport::setExportConfigs ( ExportConfigCollectionInterface  $export_configs)

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

133 : void {
134 $this->export_configs = $export_configs;
135 }

◆ setExportDirectories()

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

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

105 : void {
106 $this->dir_relative = $a_dir_relative;
107 $this->dir_absolute = $a_dir_absolute;
108 }

◆ setExportWriter()

ilExport::setExportWriter ( ilExportHandlerConsumerExportWriterInterface  $export_writer)

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

122 : void {
123 $this->export_writer = $export_writer;
124 }

◆ setPathInfo()

ilExport::setPathInfo ( ExportPathInfoInterface  $export_path_info)

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

64 : void {
65 $this->export_path_info = $export_path_info;
66 }
ExportPathInfoInterface $export_path_info

Field Documentation

◆ $cnt

array ilExport::$cnt = []
private

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

◆ $dir_absolute

string ilExport::$dir_absolute = ""
protected

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

◆ $dir_relative

string ilExport::$dir_relative = ""
protected

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

◆ $export_configs

ExportConfigCollectionInterface ilExport::$export_configs
protected

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

◆ $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.

◆ $export_run_dir

string ilExport::$export_run_dir = ''

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

◆ $export_writer

ilExportHandlerConsumerExportWriterInterface ilExport::$export_writer
protected

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

◆ $log

ilLogger ilExport::$log
protected

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

Referenced by ilExportContainer\exportObject().

◆ $manifest_writer

ilXmlWriter ilExport::$manifest_writer = null
private

Definition at line 54 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: