ILIAS  release_8 Revision v8.24
ilExport Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 __construct ()
 
 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

ilLogger $log
 

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

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Export

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

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

Constructor & Destructor Documentation

◆ __construct()

ilExport::__construct ( )

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

53 {
54 global $DIC;
55 $this->log = $DIC->logger()->exp();
56 }
global $DIC
Definition: feed.php:28

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

255 : bool {
256 global $DIC;
257
258 $ilErr = $DIC['ilErr'];
259
260 if ($a_obj_type == "") {
261 $a_obj_type = ilObject::_lookupType($a_obj_id);
262 }
263
264 $edir = ilExport::_getExportDirectory($a_obj_id, $a_export_type, $a_obj_type);
266 return true;
267 }
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 makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static _lookupType(int $id, bool $reference=false)
$ilErr
Definition: raiseError.php:17

References ilObject\_lookupType().

Referenced by ILIAS\Notes\Export\NotesHtmlExport\__construct(), ILIAS\Wiki\Export\WikiHtmlExport\buildExportFile(), ilObjGlossary\createExportDirectory(), ilObjFileBasedLMGUI\exportHTML(), ilExportContainer\exportObject(), ILIAS\Portfolio\Export\PortfolioHtmlExport\initDirectories(), 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

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

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

278 : void {
279 global $DIC;
280
281 $lng = $DIC->language();
282 $lng->loadLanguageModule("export");
283
284 if ($a_type == "") {
285 $a_type = ilObject::_lookupType($a_obj_id);
286 }
287 $a_tpl = new ilGlobalTemplate("tpl.main.html", true, true);
288 $location_stylesheet = ilUtil::getStyleSheetLocation();
289 $a_tpl->setVariable("LOCATION_STYLESHEET", $location_stylesheet);
290 $a_tpl->loadStandardTemplate();
291 $a_tpl->setTitle(ilObject::_lookupTitle($a_obj_id));
292 $a_tpl->setDescription($lng->txt("export_export_date") . ": " .
293 date('Y-m-d H:i:s', time()) . " (" . date_default_timezone_get() . ")");
294 $f_tpl = new ilTemplate("tpl.export_list.html", true, true, "Services/Export");
295 foreach ($a_files as $file) {
296 $f_tpl->setCurrentBlock("file_row");
297 $f_tpl->setVariable("TITLE", $file["title"]);
298 $f_tpl->setVariable("TYPE", $lng->txt("obj_" . $file["type"]));
299 $f_tpl->setVariable("FILE", $file["file"]);
300 $f_tpl->parseCurrentBlock();
301 }
302 $a_tpl->setContent($f_tpl->get());
303 $index_content = $a_tpl->getSpecial("DEFAULT", false, false, false, true, false, false);
304
305 $f = fopen($a_filename, "w");
306 fwrite($f, $index_content);
307 fclose($f);
308 }
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="", string $a_css_location="")
get full style sheet file name (path inclusive) of current user
$lng

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

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

155 : string {
156 global $DIC;
157
158 $logger = $DIC->logger()->exp();
159 $objDefinition = $DIC['objDefinition'];
160
161 $ent = ($a_entity == "")
162 ? ""
163 : "_" . $a_entity;
164
165 if ($a_obj_type == "") {
166 $a_obj_type = ilObject::_lookupType($a_obj_id);
167 }
168
169 if (in_array($a_obj_type, self::$new_file_structure)) {
170 $dir = ilFileUtils::getDataDir() . DIRECTORY_SEPARATOR;
171 $dir .= 'il' . $objDefinition->getClassName($a_obj_type) . $ent . DIRECTORY_SEPARATOR;
172 $dir .= self::createPathFromId($a_obj_id, $a_obj_type) . DIRECTORY_SEPARATOR;
173 $dir .= ($a_type == 'xml' ? 'export' : 'export_' . $a_type);
174 return $dir;
175 }
176
177 $exporter_class = ilImportExportFactory::getExporterClass($a_obj_type);
178 $export_dir = call_user_func(
179 array($exporter_class, 'lookupExportDirectory'),
180 $a_obj_type,
181 $a_obj_id,
182 $a_type,
183 $a_entity
184 );
185
186 $logger->debug('Export dir is ' . $export_dir);
187 return $export_dir;
188 }
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(), ILIAS\Wiki\Export\WikiHtmlExport\buildExportFile(), ilExportGUI\delete(), ilExportGUI\download(), ilSAHSEditGUI\executeCommand(), ilObjFileBasedLMGUI\exportHTML(), ilExportContainer\exportObject(), ilObjUser\exportPersonalData(), ilDclContentExporter\getExportContentPath(), ilObjQuestionPool\getExportDirectory(), ilObjGlossary\getExportDirectory(), ilDclExportTableGUI\getExportFiles(), ilObjUser\getPersonalDataExportFile(), ILIAS\Wiki\Export\WikiHtmlExport\getUserExportFile(), ILIAS\Portfolio\Export\PortfolioHtmlExport\init(), ilOrgUnitExporter\sendAndCreateSimpleExportFile(), ilObjUser\sendPersonalDataFile(), ILIAS\Blog\Export\BlogHtmlExport\zipPackage(), ILIAS\Portfolio\Export\PortfolioHtmlExport\zipPackage(), 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
Parameters
int$a_obj_id
string | array$a_export_types
string$a_obj_type
Returns
array

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

196 : array
197 {
198 if ($a_obj_type == "") {
199 $a_obj_type = ilObject::_lookupType($a_obj_id);
200 }
201
202 if ($a_export_types == "") {
203 $a_export_types = array("xml");
204 }
205 if (!is_array($a_export_types)) {
206 $a_export_types = array($a_export_types);
207 }
208
209 // initialize array
210 $file = array();
211
212 $types = $a_export_types;
213
214 foreach ($types as $type) {
215 $dir = ilExport::_getExportDirectory($a_obj_id, $type, $a_obj_type);
216
217 // quit if import dir not available
218 if (!is_dir($dir) || !is_writable($dir)) {
219 continue;
220 }
221
222 // open directory
223 $h_dir = dir($dir);
224
225 // get files and save the in the array
226 while ($entry = $h_dir->read()) {
227 if ($entry !== "." &&
228 $entry !== ".." &&
229 substr($entry, -4) === ".zip" &&
230 preg_match("/^[0-9]{10}_{2}[0-9]+_{2}(" . $a_obj_type . "_)*[0-9]+\.zip\$/", $entry)) {
231 $ts = substr($entry, 0, strpos($entry, "__"));
232 $file[$entry . $type] = [
233 "type" => (string) $type,
234 "file" => (string) $entry,
235 "size" => (int) filesize($dir . "/" . $entry),
236 "timestamp" => (int) $ts
237 ];
238 }
239 }
240
241 // close import directory
242 $h_dir->close();
243 }
244
245 // sort files
246 ksort($file);
247 reset($file);
248 return $file;
249 }
$type

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

Referenced by _getLastExportFileDate(), ilObjGlossary\getExportFiles(), and ilExportTableGUI\getExportFiles().

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

112 : int
113 {
114 $files = ilExport::_getExportFiles($a_obj_id, $a_type, $a_obj_type);
115 if (is_array($files)) {
116 $files = ilArrayUtil::sortArray($files, "timestamp", "desc");
117 return (int) $files[0]["timestamp"];
118 }
119 return 0;
120 }
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="")

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

Referenced by _getValidExportSubItems().

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

133 : ?array {
134 $files = ilExport::_getExportFiles($a_obj_id, $a_type, $a_obj_type);
135 if (is_array($files)) {
136 $files = ilArrayUtil::sortArray($files, "timestamp", "desc");
137 return $files[0];
138 }
139 return null;
140 }

References ilArrayUtil\sortArray().

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

84 : array
85 {
86 global $DIC;
87
88 $tree = $DIC->repositoryTree();
89
90 $valid_items = array();
91 $sub_items = $tree->getSubTree($tree->getNodeData($a_ref_id));
92 foreach ($sub_items as $sub_item) {
93 if (in_array($sub_item["type"], self::$export_implementer)) {
94 $valid_items[] = [
95 "type" => (string) $sub_item["type"],
96 "title" => (string) $sub_item["title"],
97 "ref_id" => (int) $sub_item["child"],
98 "obj_id" => (int) $sub_item["obj_id"],
99 "timestamp" => ilExport::_getLastExportFileDate($sub_item["obj_id"], "xml", $sub_item["type"])
100 ];
101 }
102 }
103 return $valid_items;
104 }
static _getLastExportFileDate(int $a_obj_id, string $a_type="", string $a_obj_type="")
Get date of last export file.

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

Referenced by ilSubItemSelectionTableGUI\__construct().

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

623 : string
624 {
625 $max_exponent = 3;
626 $factor = 100;
627
628 $path = [];
629 $found = false;
630 $num = $a_container_id;
631 $path_string = '';
632 for ($i = $max_exponent; $i > 0; $i--) {
633 $factor = pow($factor, $i);
634 if (($tmp = (int) ($num / $factor)) or $found) {
635 $path[] = $tmp;
636 $num = $num % $factor;
637 $found = true;
638 }
639 }
640 if (count($path)) {
641 $path_string = (implode('/', $path) . '/');
642 }
643 return $path_string . $a_name . '_' . $a_container_id;
644 }
$path
Definition: ltiservices.php:32
$i
Definition: metadata.php:41

References $i, and $path.

◆ 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. "Services/Style")
Returns
array success and info array

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

418 : array {
419 global $DIC;
420
421 $objDefinition = $DIC['objDefinition'];
422 $tpl = $DIC['tpl'];
423
424 // if no target release specified, use latest major release number
425 if ($a_target_release == "") {
426 $v = explode(".", ILIAS_VERSION_NUMERIC);
427 $a_target_release = $v[0] . "." . $v[1] . ".0";
428 }
429
430 if ($a_type_for_file == "") {
431 $a_type_for_file = $a_entity;
432 }
433
434 $comp = $a_component;
435 $c = explode("/", $comp);
436 $class = "il" . $c[1] . "Exporter";
437
438 // manifest writer
439 $this->manifest_writer = new ilXmlWriter();
440 $this->manifest_writer->xmlHeader();
441 $this->manifest_writer->xmlStartTag(
442 'Manifest',
443 array(
444 "MainEntity" => $a_entity,
445 "Title" => $a_title,
446 /* "TargetRelease" => $a_target_release, */
447 "InstallationId" => IL_INST_ID,
448 "InstallationUrl" => ILIAS_HTTP_PATH
449 )
450 );
451
452 $export_dir = $a_export_dir;
453 $ts = time();
454
455 // determine file name and subdirectory
456 $sub_dir = $ts . '__' . IL_INST_ID . '__' . $a_type_for_file . '_' . $a_id;
457 $new_file = $sub_dir . '.zip';
458
459 $this->export_run_dir = $export_dir . "/" . $sub_dir;
460 ilFileUtils::makeDirParents($this->export_run_dir);
461
462 $this->cnt = array();
463 $success = $this->processExporter($comp, $class, $a_entity, $a_target_release, [$a_id]);
464 $this->manifest_writer->xmlEndTag('Manifest');
465 $this->manifest_writer->xmlDumpFile($this->export_run_dir . "/manifest.xml", false);
466
467 // zip the file
468 ilFileUtils::zip($this->export_run_dir, $export_dir . "/" . $new_file);
469 ilFileUtils::delDir($this->export_run_dir);
470
471 return array(
472 "success" => $success,
473 "file" => $new_file,
474 "directory" => $export_dir
475 );
476 }
processExporter(string $a_comp, string $a_class, string $a_entity, string $a_target_release, array $a_id=null)
Process exporter.
static zip(string $a_dir, string $a_file, bool $compress_content=false)
zips given directory/file into given zip.file
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...
$c
Definition: cli.php:38
const IL_INST_ID
Definition: constants.php:40
const ILIAS_VERSION_NUMERIC
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41

References ILIAS_VERSION_NUMERIC.

◆ 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

Reimplemented in ilExportContainer.

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

332 : array {
333 $this->log->debug("export type: $a_type, id: $a_id, target_release: " . $a_target_release);
334
335 // if no target release specified, use latest major release number
336 if ($a_target_release == "") {
337 $v = explode(".", ILIAS_VERSION_NUMERIC);
338 $a_target_release = $v[0] . "." . $v[1] . ".0";
339 $this->log->debug("target_release set to: " . $a_target_release);
340 }
341
342 // manifest writer
343 $this->manifest_writer = new ilXmlWriter();
344 $this->manifest_writer->xmlHeader();
345 $this->manifest_writer->xmlStartTag(
346 'Manifest',
347 array(
348 "MainEntity" => $a_type,
349 "Title" => ilObject::_lookupTitle($a_id),
350 /* "TargetRelease" => $a_target_release, */
351 "InstallationId" => IL_INST_ID,
352 "InstallationUrl" => ILIAS_HTTP_PATH
353 )
354 );
355
356 // get export class
357 ilExport::_createExportDirectory($a_id, "xml", $a_type);
358 $export_dir = ilExport::_getExportDirectory($a_id, "xml", $a_type);
359 $ts = time();
360
361 // Workaround for test assessment
362 $sub_dir = $ts . '__' . IL_INST_ID . '__' . $a_type . '_' . $a_id;
363 $new_file = $sub_dir . '.zip';
364
365 $this->export_run_dir = $export_dir . "/" . $sub_dir;
366 ilFileUtils::makeDirParents($this->export_run_dir);
367 $this->log->debug("export dir: " . $this->export_run_dir);
368
369 $this->cnt = array();
370
371 $class = ilImportExportFactory::getExporterClass($a_type);
372 $comp = ilImportExportFactory::getComponentForExport($a_type);
373
374 $success = $this->processExporter($comp, $class, $a_type, $a_target_release, [$a_id]);
375
376 $this->manifest_writer->xmlEndTag('Manifest');
377 $this->manifest_writer->xmlDumpFile($this->export_run_dir . "/manifest.xml", false);
378
379 // zip the file
380 $this->log->debug("zip: " . $export_dir . "/" . $new_file);
381 $this->log->debug("run dir: " . $this->export_run_dir);
382 ilFileUtils::zip($this->export_run_dir, $export_dir . "/" . $new_file);
383 ilFileUtils::delDir($this->export_run_dir);
384
385 // Store info about export
386 if ($success) {
387 $exp = new ilExportFileInfo($a_id);
388 $exp->setVersion($a_target_release);
389 $exp->setCreationDate(new ilDateTime($ts, IL_CAL_UNIX));
390 $exp->setExportType('xml');
391 $exp->setFilename($new_file);
392 $exp->create();
393 }
394
395 return array(
396 "success" => $success,
397 "file" => $new_file,
398 "directory" => $export_dir
399 );
400 }
const IL_CAL_UNIX
@classDescription Date and time handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _createExportDirectory(int $a_obj_id, string $a_export_type="xml", string $a_obj_type="")

References ILIAS_VERSION_NUMERIC.

◆ getConfig()

ilExport::getConfig ( string  $a_comp)

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

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

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

65 {
66 // if created, return existing config object
67 if (isset($this->configs[$a_comp])) {
68 return $this->configs[$a_comp];
69 }
70
71 // create instance of export config object
72 $comp_arr = explode("/", $a_comp);
73 $a_class = "il" . $comp_arr[1] . "ExportConfig";
74 $exp_config = new $a_class();
75 $this->configs[$a_comp] = $exp_config;
76 return $exp_config;
77 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ 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. "Modules/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 488 of file class.ilExport.php.

494 : bool {
495 $success = true;
496 $this->log->debug("process exporter, comp: " . $a_comp . ", class: " . $a_class . ", entity: " . $a_entity .
497 ", target release " . $a_target_release . ", id: " . print_r($a_id, true));
498
499 if (!is_array($a_id)) {
500 if ($a_id == "") {
501 return true;
502 }
503 $a_id = array($a_id);
504 }
505
506 // get exporter object
507 if (!class_exists($a_class)) {
508 $export_class_file = "./" . $a_comp . "/classes/class." . $a_class . ".php";
509 if (!is_file($export_class_file)) {
510 throw new ilExportException('Export class file "' . $export_class_file . '" not found.');
511 }
512 }
513
514 $exp = new $a_class();
515 $exp->setExport($this);
516 if (!isset($this->cnt[$a_comp])) {
517 $this->cnt[$a_comp] = 1;
518 } else {
519 $this->cnt[$a_comp]++;
520 }
521 $set_dir_relative = $a_comp . "/set_" . $this->cnt[$a_comp];
522 $set_dir_absolute = $this->export_run_dir . "/" . $set_dir_relative;
523 ilFileUtils::makeDirParents($set_dir_absolute);
524 $this->log->debug("dir: " . $set_dir_absolute);
525
526 $this->log->debug("init exporter");
527 $exp->init();
528
529 // process head dependencies
530 $this->log->debug("process head dependencies for " . $a_entity);
531 $sequence = $exp->getXmlExportHeadDependencies($a_entity, $a_target_release, $a_id);
532 foreach ($sequence as $s) {
533 $comp = explode("/", $s["component"]);
534 $exp_class = "il" . $comp[1] . "Exporter";
535 $s = $this->processExporter(
536 $s["component"],
537 $exp_class,
538 $s["entity"],
539 $a_target_release,
540 $s["ids"]
541 );
542 if (!$s) {
543 $success = false;
544 }
545 }
546
547 // write export.xml file
548 $export_writer = new ilXmlWriter();
549 $export_writer->xmlHeader();
550
551 $sv = $exp->determineSchemaVersion($a_entity, $a_target_release);
552 $sv["uses_dataset"] ??= false;
553 $sv['xsd_file'] ??= '';
554 $this->log->debug("schema version for entity: $a_entity, target release: $a_target_release");
555 $this->log->debug("...is: " . $sv["schema_version"] . ", namespace: " . $sv["namespace"] .
556 ", xsd file: " . $sv["xsd_file"] . ", uses_dataset: " . ((int) $sv["uses_dataset"]));
557
558 $attribs = array("InstallationId" => IL_INST_ID,
559 "InstallationUrl" => ILIAS_HTTP_PATH,
560 "Entity" => $a_entity,
561 "SchemaVersion" => $sv["schema_version"],
562 /* "TargetRelease" => $a_target_release, */
563 "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
564 "xmlns:exp" => "http://www.ilias.de/Services/Export/exp/4_1",
565 "xsi:schemaLocation" => "http://www.ilias.de/Services/Export/exp/4_1 " . ILIAS_HTTP_PATH . "/xml/ilias_export_4_1.xsd"
566 );
567 if ($sv["namespace"] != "" && $sv["xsd_file"] != "") {
568 $attribs["xsi:schemaLocation"] .= " " . $sv["namespace"] . " " .
569 ILIAS_HTTP_PATH . "/xml/" . $sv["xsd_file"];
570 $attribs["xmlns"] = $sv["namespace"];
571 }
572 if ($sv["uses_dataset"]) {
573 $attribs["xsi:schemaLocation"] .= " " .
574 "http://www.ilias.de/Services/DataSet/ds/4_3 " . ILIAS_HTTP_PATH . "/xml/ilias_ds_4_3.xsd";
575 $attribs["xmlns:ds"] = "http://www.ilias.de/Services/DataSet/ds/4_3";
576 }
577 $export_writer->xmlStartTag('exp:Export', $attribs);
578
579 $dir_cnt = 1;
580 foreach ($a_id as $id) {
581 $exp->setExportDirectories(
582 $set_dir_relative . "/expDir_" . $dir_cnt,
583 $set_dir_absolute . "/expDir_" . $dir_cnt
584 );
585 $export_writer->xmlStartTag('exp:ExportItem', array("Id" => $id));
586 //$xml = $exp->getXmlRepresentation($a_entity, $a_target_release, $id);
587 $xml = $exp->getXmlRepresentation($a_entity, $sv["schema_version"], (string) $id);
588 $export_writer->appendXML($xml);
589 $export_writer->xmlEndTag('exp:ExportItem');
590 $dir_cnt++;
591 }
592
593 $export_writer->xmlEndTag('exp:Export');
594 $export_writer->xmlDumpFile($set_dir_absolute . "/export.xml", false);
595
596 $this->manifest_writer->xmlElement(
597 "ExportFile",
598 array("Component" => $a_comp, "Path" => $set_dir_relative . "/export.xml")
599 );
600
601 // process tail dependencies
602 $this->log->debug("process tail dependencies of " . $a_entity);
603 $sequence = $exp->getXmlExportTailDependencies($a_entity, $a_target_release, $a_id);
604 foreach ($sequence as $s) {
605 $comp = explode("/", $s["component"]);
606 $exp_class = "il" . $comp[1] . "Exporter";
607 $s = $this->processExporter(
608 $s["component"],
609 $exp_class,
610 $s["entity"],
611 $a_target_release,
612 (array) $s["ids"]
613 );
614 if (!$s) {
615 $success = false;
616 }
617 }
618
619 $this->log->debug("returning " . ((int) $success) . " for " . $a_entity);
620 return $success;
621 }
$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...
$xml
Definition: metadata.php:351

Field Documentation

◆ $cnt

array ilExport::$cnt = []
private

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

◆ $configs

array ilExport::$configs = []
private

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

◆ $export_implementer

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

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

◆ $export_run_dir

string ilExport::$export_run_dir = ''
Todo:
currently used in ilLeanringModuleExporter

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

◆ $log

ilLogger ilExport::$log
protected

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

Referenced by ilExportContainer\exportObject().

◆ $manifest_writer

ilXmlWriter ilExport::$manifest_writer = null
private

Definition at line 50 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 33 of file class.ilExport.php.


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