ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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="")
 
- Public Member Functions inherited from ilExport
 __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...
 

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="")
 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 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
 
string $export_dir_in_container
 
ExportPathInfoInterface $export_path_info
 

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.

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

41  {
42  $this->eo = $eo;
44  global $DIC;
45  $this->archives = $DIC->legacyArchives();
46  }
global $DIC
Definition: shib_login.php:22
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ addContainer()

ilExportContainer::addContainer ( )
protected

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

Referenced by exportObject().

98  : void
99  {
100  }
+ 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.

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

Referenced by exportObject().

102  : void
103  {
104  $set_number = 1;
105  foreach ($this->eo->getSubitemsForExport() as $ref_id) {
106  // get last export file
107  $obj_id = ilObject::_lookupObjId($ref_id);
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  }
static lookupLastExport(int $a_obj_id, string $a_type, string $a_version='')
Lookup last export.
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
static _lookupObjId(int $ref_id)
$ref_id
Definition: ltiauth.php:65
Stores information of creation date and versions of export files
static _lookupType(int $id, bool $reference=false)
+ 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 = "" 
)

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

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

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  }
const IL_INST_ID
Definition: constants.php:40
manifestWriterEnd(string $a_type, int $a_id, string $a_target_release)
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
$GLOBALS["DIC"]
Definition: wac.php:53
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="")
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
addSubitems(int $a_id, string $a_type, string $a_target_release)
static zip(string $a_dir, string $a_file, bool $compress_content=false)
ilLogger $log
debug(string $message, array $context=[])
+ 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.

References ilObject\_lookupTitle(), and IL_INST_ID.

Referenced by exportObject().

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  }
const IL_INST_ID
Definition: constants.php:40
static _lookupTitle(int $obj_id)
+ 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.

Referenced by exportObject().

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  }
+ 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: