ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilExportContainer Class Reference

Export Container. More...

+ Inheritance diagram for ilExportContainer:
+ Collaboration diagram for ilExportContainer:

Public Member Functions

 __construct (ilExportOptions $eo)
 Constructor. More...
 
 exportObject (string $a_type, int $a_id, string $a_target_release="")
 @inheritDoc More...
 
- Public Member Functions inherited from ilExport
 __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...
 

Protected Member Functions

 manifestWriterBegin (string $a_type, int $a_id, string $a_target_release)
 
 addContainer ()
 
 addSubitems (int $a_id, string $a_type, string $a_target_release)
 
 manifestWriterEnd (string $a_type, int $a_id, string $a_target_release)
 

Private Attributes

string $cont_export_dir = ''
 
ilXmlWriter $cont_manifest_writer = null
 
ilExportOptions $eo
 
LegacyArchives $archives
 

Additional Inherited Members

- Static Public Member Functions inherited from ilExport
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="")
 @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 inherited from ilExport
string $export_run_dir = ''
 
- Static Protected Member Functions inherited from ilExport
static createPathFromId (int $a_container_id, string $a_name)
 
- Protected Attributes inherited from ilExport
string $dir_relative = ""
 
string $dir_absolute = ""
 
ilLogger $log
 
ilExportHandlerConsumerExportWriterInterface $export_writer
 
ExportPathInfoInterface $export_path_info
 
ExportConfigCollectionInterface $export_configs
 

Detailed Description

Export Container.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

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

Constructor & Destructor Documentation

◆ __construct()

ilExportContainer::__construct ( ilExportOptions  $eo)

Constructor.

Parameters
ilExportOptions$eo

Definition at line 40 of file class.ilExportContainer.php.

41 {
42 $this->eo = $eo;
44 global $DIC;
45 $this->archives = $DIC->legacyArchives();
46 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $DIC, $eo, and ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ addContainer()

ilExportContainer::addContainer ( )
protected

Definition at line 98 of file class.ilExportContainer.php.

98 : void
99 {
100 }

Referenced by exportObject().

+ Here is the caller graph for this function:

◆ addSubitems()

ilExportContainer::addSubitems ( int  $a_id,
string  $a_type,
string  $a_target_release 
)
protected

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

102 : void
103 {
104 $set_number = 1;
105 foreach ($this->eo->getSubitemsForExport() as $ref_id) {
106 // get last export file
108
109 $expi = ilExportFileInfo::lookupLastExport($obj_id, 'xml', $a_target_release);
110
111 if (!$expi instanceof ilExportFileInfo) {
112 $this->log->warning('Cannot find export file for refId ' . $ref_id . ', type ' . ilObject::_lookupType($a_id));
113 continue;
114 }
115
116 $exp_dir = ilExport::_getExportDirectory($obj_id, 'xml', ilObject::_lookupType($obj_id));
117 $exp_full = $exp_dir . DIRECTORY_SEPARATOR . $expi->getFilename();
118
119 $this->log->debug('Zip path ' . $exp_full);
120
121 // Unzip
122 $this->archives->unzip(
123 $exp_full
124 );
125
126 // create set directory
127 ilFileUtils::makeDirParents($this->cont_export_dir . DIRECTORY_SEPARATOR . 'set_' . $set_number);
128
129 // cut .zip
130 $new_path_rel = 'set_' . $set_number . DIRECTORY_SEPARATOR . $expi->getBasename();
131 $new_path_abs = $this->cont_export_dir . DIRECTORY_SEPARATOR . $new_path_rel;
132
133 $this->log->debug($new_path_rel . ' ' . $new_path_abs);
134
135 // Move export
136 rename(
137 $exp_dir . DIRECTORY_SEPARATOR . $expi->getBasename(),
138 $new_path_abs
139 );
140
141 $this->log->debug($exp_dir . DIRECTORY_SEPARATOR . $expi->getBasename() . ' -> ' . $new_path_abs);
142
143 // Delete latest container xml of source
144 if ($a_id == $obj_id) {
145 $expi->delete();
146 if (file_exists($exp_full)) {
147 $this->log->info('Deleting' . $exp_full);
148 unlink($exp_full);
149 }
150 }
151
152 $this->cont_manifest_writer->xmlElement(
153 'ExportSet',
154 array(
155 'Path' => $new_path_rel,
156 'Type' => ilObject::_lookupType($obj_id)
157 )
158 );
159 ++$set_number;
160 }
161 }
@classDescription Stores information of creation date and versions of export files
static lookupLastExport(int $a_obj_id, string $a_type, string $a_version='')
Lookup last export.
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)
static _lookupObjId(int $ref_id)
$ref_id
Definition: ltiauth.php:66

References $ref_id, ilExport\_getExportDirectory(), ilObject\_lookupObjId(), ilObject\_lookupType(), ilExportFileInfo\lookupLastExport(), and ilFileUtils\makeDirParents().

Referenced by exportObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportObject()

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

@inheritDoc

Reimplemented from ilExport.

Definition at line 51 of file class.ilExportContainer.php.

51 : array
52 {
53 $log = $GLOBALS['DIC']->logger()->exp();
54
55 // if no target release specified, use latest major release number
56 if ($a_target_release == "") {
57 $v = explode(".", ILIAS_VERSION_NUMERIC);
58 $a_target_release = $v[0] . "." . $v[1] . ".0";
59 }
60
61 // Create base export directory
62 ilExport::_createExportDirectory($a_id, "xml", $a_type);
63 $export_dir = ilExport::_getExportDirectory($a_id, "xml", $a_type);
64 $ts = time();
65 $sub_dir = $ts . "__" . IL_INST_ID . "__" . $a_type . "_" . $a_id;
66
67 $this->cont_export_dir = $export_dir . DIRECTORY_SEPARATOR . $sub_dir;
68 ilFileUtils::makeDirParents($this->cont_export_dir);
69
70 $log->debug('Using base directory: ' . $this->export_run_dir);
71
72 $this->manifestWriterBegin($a_type, $a_id, $a_target_release);
73 $this->addContainer();
74 $this->addSubitems($a_id, $a_type, $a_target_release);
75 $this->manifestWriterEnd($a_type, $a_id, $a_target_release);
76
77 ilFileUtils::zip($this->cont_export_dir, $this->cont_export_dir . '.zip');
78 ilFileUtils::delDir($this->cont_export_dir);
79 return [];
80 }
addSubitems(int $a_id, string $a_type, string $a_target_release)
manifestWriterEnd(string $a_type, int $a_id, string $a_target_release)
manifestWriterBegin(string $a_type, int $a_id, string $a_target_release)
static _createExportDirectory(int $a_obj_id, string $a_export_type="xml", string $a_obj_type="")
ilLogger $log
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
debug(string $message, array $context=[])
const IL_INST_ID
Definition: constants.php:40
const ILIAS_VERSION_NUMERIC
$GLOBALS["DIC"]
Definition: wac.php:54

References $GLOBALS, ilExport\$log, ilExport\_createExportDirectory(), ilExport\_getExportDirectory(), addContainer(), addSubitems(), ilLogger\debug(), ilFileUtils\delDir(), IL_INST_ID, ILIAS_VERSION_NUMERIC, ilFileUtils\makeDirParents(), manifestWriterBegin(), manifestWriterEnd(), and ilFileUtils\zip().

+ Here is the call graph for this function:

◆ manifestWriterBegin()

ilExportContainer::manifestWriterBegin ( string  $a_type,
int  $a_id,
string  $a_target_release 
)
protected

Definition at line 82 of file class.ilExportContainer.php.

82 : void
83 {
84 $this->cont_manifest_writer = new ilXmlWriter();
85 $this->cont_manifest_writer->xmlHeader();
86 $this->cont_manifest_writer->xmlStartTag(
87 'Manifest',
88 array(
89 "MainEntity" => $a_type,
90 "Title" => ilObject::_lookupTitle($a_id),
91 /* "TargetRelease" => $a_target_release, */
92 "InstallationId" => IL_INST_ID,
93 "InstallationUrl" => ILIAS_HTTP_PATH
94 )
95 );
96 }
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ilObject\_lookupTitle(), and IL_INST_ID.

Referenced by exportObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ manifestWriterEnd()

ilExportContainer::manifestWriterEnd ( string  $a_type,
int  $a_id,
string  $a_target_release 
)
protected

Definition at line 163 of file class.ilExportContainer.php.

163 : void
164 {
165 $this->cont_manifest_writer->xmlEndTag('Manifest');
166 $this->log->debug($this->cont_export_dir . DIRECTORY_SEPARATOR . 'manifest.xml');
167 $this->cont_manifest_writer->xmlDumpFile($this->cont_export_dir . DIRECTORY_SEPARATOR . 'manifest.xml', true);
168 }

Referenced by exportObject().

+ Here is the caller graph for this function:

Field Documentation

◆ $archives

LegacyArchives ilExportContainer::$archives
private

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

◆ $cont_export_dir

string ilExportContainer::$cont_export_dir = ''
private

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

◆ $cont_manifest_writer

ilXmlWriter ilExportContainer::$cont_manifest_writer = null
private

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

◆ $eo

ilExportOptions ilExportContainer::$eo
private

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

Referenced by __construct().


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