ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilExportContainer 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 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 ()
 
 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
 

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
ilLogger $log
 

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 Container

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

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

Constructor & Destructor Documentation

◆ __construct()

ilExportContainer::__construct ( ilExportOptions  $eo)

Constructor.

Parameters
ilExportOptions$eo

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

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

36  {
37  $this->eo = $eo;
39  }
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ addContainer()

ilExportContainer::addContainer ( )
protected

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

Referenced by exportObject().

91  : void
92  {
93  }
+ 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 95 of file class.ilExportContainer.php.

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

Referenced by exportObject().

95  : void
96  {
97  $set_number = 1;
98  foreach ($this->eo->getSubitemsForExport() as $ref_id) {
99  // get last export file
100  $obj_id = ilObject::_lookupObjId($ref_id);
101 
102  $expi = ilExportFileInfo::lookupLastExport($obj_id, 'xml', $a_target_release);
103 
104  if (!$expi instanceof ilExportFileInfo) {
105  $this->log->warning('Cannot find export file for refId ' . $ref_id . ', type ' . ilObject::_lookupType($a_id));
106  continue;
107  }
108 
109  $exp_dir = ilExport::_getExportDirectory($obj_id, 'xml', ilObject::_lookupType($obj_id));
110  $exp_full = $exp_dir . DIRECTORY_SEPARATOR . $expi->getFilename();
111 
112  $this->log->debug('Zip path ' . $exp_full);
113 
114  // Unzip
115  ilFileUtils::unzip($exp_full, true, false);
116 
117  // create set directory
118  ilFileUtils::makeDirParents($this->cont_export_dir . DIRECTORY_SEPARATOR . 'set_' . $set_number);
119 
120  // cut .zip
121  $new_path_rel = 'set_' . $set_number . DIRECTORY_SEPARATOR . $expi->getBasename();
122  $new_path_abs = $this->cont_export_dir . DIRECTORY_SEPARATOR . $new_path_rel;
123 
124  $this->log->debug($new_path_rel . ' ' . $new_path_abs);
125 
126  // Move export
127  rename(
128  $exp_dir . DIRECTORY_SEPARATOR . $expi->getBasename(),
129  $new_path_abs
130  );
131 
132  $this->log->debug($exp_dir . DIRECTORY_SEPARATOR . $expi->getBasename() . ' -> ' . $new_path_abs);
133 
134  // Delete latest container xml of source
135  if ($a_id == $obj_id) {
136  $expi->delete();
137  if (file_exists($exp_full)) {
138  $this->log->info('Deleting' . $exp_full);
139  unlink($exp_full);
140  }
141  }
142 
143  $this->cont_manifest_writer->xmlElement(
144  'ExportSet',
145  array(
146  'Path' => $new_path_rel,
147  'Type' => ilObject::_lookupType($obj_id)
148  )
149  );
150  ++$set_number;
151  }
152  }
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 unzip(string $path_to_zip_file, bool $overwrite_existing=false, bool $unpack_flat=false)
static _lookupObjId(int $ref_id)
$ref_id
Definition: ltiauth.php:67
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 44 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().

44  : array
45  {
46  $log = $GLOBALS['DIC']->logger()->exp();
47 
48  // if no target release specified, use latest major release number
49  if ($a_target_release == "") {
50  $v = explode(".", ILIAS_VERSION_NUMERIC);
51  $a_target_release = $v[0] . "." . $v[1] . ".0";
52  }
53 
54  // Create base export directory
55  ilExport::_createExportDirectory($a_id, "xml", $a_type);
56  $export_dir = ilExport::_getExportDirectory($a_id, "xml", $a_type);
57  $ts = time();
58  $sub_dir = $ts . "__" . IL_INST_ID . "__" . $a_type . "_" . $a_id;
59 
60  $this->cont_export_dir = $export_dir . DIRECTORY_SEPARATOR . $sub_dir;
61  ilFileUtils::makeDirParents($this->cont_export_dir);
62 
63  $log->debug('Using base directory: ' . $this->export_run_dir);
64 
65  $this->manifestWriterBegin($a_type, $a_id, $a_target_release);
66  $this->addContainer();
67  $this->addSubitems($a_id, $a_type, $a_target_release);
68  $this->manifestWriterEnd($a_type, $a_id, $a_target_release);
69 
70  ilFileUtils::zip($this->cont_export_dir, $this->cont_export_dir . '.zip');
71  ilFileUtils::delDir($this->cont_export_dir);
72  return [];
73  }
const IL_INST_ID
Definition: constants.php:40
const ILIAS_VERSION_NUMERIC
debug(string $a_message, array $a_context=array())
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.
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
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
addSubitems(int $a_id, string $a_type, string $a_target_release)
static zip(string $a_dir, string $a_file, bool $compress_content=false)
zips given directory/file into given zip.file
ilLogger $log
+ 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 75 of file class.ilExportContainer.php.

References ilObject\_lookupTitle(), and IL_INST_ID.

Referenced by exportObject().

75  : void
76  {
77  $this->cont_manifest_writer = new ilXmlWriter();
78  $this->cont_manifest_writer->xmlHeader();
79  $this->cont_manifest_writer->xmlStartTag(
80  'Manifest',
81  array(
82  "MainEntity" => $a_type,
83  "Title" => ilObject::_lookupTitle($a_id),
84  /* "TargetRelease" => $a_target_release, */
85  "InstallationId" => IL_INST_ID,
86  "InstallationUrl" => ILIAS_HTTP_PATH
87  )
88  );
89  }
const IL_INST_ID
Definition: constants.php:40
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 154 of file class.ilExportContainer.php.

Referenced by exportObject().

154  : void
155  {
156  $this->cont_manifest_writer->xmlEndTag('Manifest');
157  $this->log->debug($this->cont_export_dir . DIRECTORY_SEPARATOR . 'manifest.xml');
158  $this->cont_manifest_writer->xmlDumpFile($this->cont_export_dir . DIRECTORY_SEPARATOR . 'manifest.xml', true);
159  }
+ Here is the caller graph for this function:

Field Documentation

◆ $cont_export_dir

string ilExportContainer::$cont_export_dir = ''
private

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

◆ $cont_manifest_writer

ilXmlWriter ilExportContainer::$cont_manifest_writer = null
private

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

◆ $eo

ilExportOptions ilExportContainer::$eo
private

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

Referenced by __construct().


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