ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilExportContainer Class Reference

Export Container. More...

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

Public Member Functions

 __construct (ilExportOptions $eo)
 Constructor. More...
 
 exportObject ($a_type, $a_id, $a_target_release="")
 Export a container. More...
 
- Public Member Functions inherited from ilExport
 __construct ()
 Default constructor. More...
 
 getConfig ($a_comp)
 Get configuration (note that configurations are optional, null may be returned!) More...
 
 exportObject ($a_type, $a_id, $a_target_release="")
 Export an ILIAS object (the object type must be known by objDefinition) More...
 
 exportEntity ( $a_entity, $a_id, $a_target_release, $a_component, $a_title, $a_export_dir, $a_type_for_file="")
 Export an ILIAS entity. More...
 
 processExporter ($a_comp, $a_class, $a_entity, $a_target_release, $a_id)
 Process exporter. More...
 

Protected Member Functions

 manifestWriterBegin ($a_type, $a_id, $a_target_release)
 Write container manifest. More...
 
 addContainer ()
 Add container description. More...
 
 addSubitems ($a_id, $a_type, $a_target_release)
 Add subitems. More...
 
 manifestWriterEnd ($a_type, $a_id, $a_target_release)
 Write manifest footer. More...
 

Private Attributes

 $cont_export_dir = ''
 
 $cont_manifest_writer = null
 
 $eo = null
 

Additional Inherited Members

- Static Public Member Functions inherited from ilExport
static _getValidExportSubItems ($a_ref_id)
 Get a list of subitems of a repository resource, that implement the export. More...
 
static _getLastExportFileDate ($a_obj_id, $a_type="", $a_obj_type="")
 Get date of last export file. More...
 
static _getLastExportFileInformation ($a_obj_id, $a_type="", $a_obj_type="")
 Get last export file information. More...
 
static _getExportDirectory ($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
 Get export directory for an repository object. More...
 
static _getExportFiles ($a_obj_id, $a_export_types="", $a_obj_type="")
 Get Export Files for a repository object. More...
 
static _createExportDirectory ($a_obj_id, $a_export_type="xml", $a_obj_type="")
 
static _generateIndexFile ($a_filename, $a_obj_id, $a_files, $a_type="")
 Generates an index.html file including links to all xml files included (for container exports) More...
 
- Static Public Attributes inherited from ilExport
static $new_file_structure = array('cat','exc','crs','sess','file','grp','frm', 'usr', 'catr', 'crsr', 'grpr')
 
static $export_implementer = array("tst", "lm", "glo", "sahs")
 
- Protected Attributes inherited from ilExport
 $log
 
 $configs = array()
 

Detailed Description

Export Container.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilExportContainer::__construct ( ilExportOptions  $eo)

Constructor.

Parameters
ilExportOptions$eo
Returns

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

28 {
29 $this->eo = $eo;
30 parent::__construct();
31 }

References $eo.

Member Function Documentation

◆ addContainer()

ilExportContainer::addContainer ( )
protected

Add container description.

Returns

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

95 {
96 }

Referenced by exportObject().

+ Here is the caller graph for this function:

◆ addSubitems()

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

Add subitems.

Parameters
object$a_id
object$a_type
Returns

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

106 {
107 $GLOBALS['ilLog']->write(__METHOD__);
108 $set_number = 1;
109 foreach ($this->eo->getSubitemsForExport() as $ref_id) {
110 // get last export file
111 $obj_id = ilObject::_lookupObjId($ref_id);
112
113 $expi = ilExportFileInfo::lookupLastExport($obj_id, 'xml', $a_target_release);
114
115 if (!$expi instanceof ilExportFileInfo) {
116 $GLOBALS['ilLog']->write(__METHOD__ . ': Cannot find export file for refId ' . $ref_id . ', type ' . ilObject::_lookupType($a_id));
117 continue;
118 }
119
120 $exp_dir = ilExport::_getExportDirectory($obj_id, 'xml', ilObject::_lookupType($obj_id));
121 $exp_full = $exp_dir . DIRECTORY_SEPARATOR . $expi->getFilename();
122
123 $GLOBALS['ilLog']->write(__METHOD__ . ': zip path ' . $exp_full);
124
125 // Unzip
126 ilUtil::unzip($exp_full, true, false);
127
128 // create set directory
129 ilUtil::makeDirParents($this->cont_export_dir . DIRECTORY_SEPARATOR . 'set_' . $set_number);
130
131 // cut .zip
132 $new_path_rel = 'set_' . $set_number . DIRECTORY_SEPARATOR . $expi->getBasename();
133 $new_path_abs = $this->cont_export_dir . DIRECTORY_SEPARATOR . $new_path_rel;
134
135 $GLOBALS['ilLog']->write(__METHOD__ . ': ' . $new_path_rel . ' ' . $new_path_abs);
136
137 // Move export
138 rename(
139 $exp_dir . DIRECTORY_SEPARATOR . $expi->getBasename(),
140 $new_path_abs
141 );
142
143 $GLOBALS['ilLog']->write($exp_dir . DIRECTORY_SEPARATOR . $expi->getBasename() . ' -> ' . $new_path_abs);
144
145 // Delete latest container xml of source
146 if ($a_id == $obj_id) {
147 $expi->delete();
148 if (file_exists($exp_full)) {
149 $GLOBALS['ilLog']->write(__METHOD__ . ': Deleting' . $exp_full);
150 unlink($exp_full);
151 }
152 }
153
154 $this->cont_manifest_writer->xmlElement(
155 'ExportSet',
156 array(
157 'Path' => $new_path_rel,
158 'Type' => ilObject::_lookupType($obj_id)
159 )
160 );
161
162
163 ++$set_number;
164 }
165 }
@classDescription Stores information of creation date and versions of export files
static lookupLastExport($a_obj_id, $a_type, $a_version='')
Lookup last export.
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static makeDirParents($a_dir)
Create a new directory and all parent directories.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.

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

Referenced by exportObject().

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

◆ exportObject()

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

Export a container.

Parameters
object$a_type
object$a_obj_id
object$a_target_release
Returns

Reimplemented from ilExport.

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

42 {
43 // if no target release specified, use latest major release number
44 if ($a_target_release == "") {
45 $v = explode(".", ILIAS_VERSION_NUMERIC);
46 $a_target_release = $v[0] . "." . $v[1] . ".0";
47 }
48
49 // Create base export directory
51 $export_dir = ilExport::_getExportDirectory($a_id, "xml", $a_type);
52 $ts = time();
53 $sub_dir = $ts . "__" . IL_INST_ID . "__" . $a_type . "_" . $a_id;
54
55 $this->cont_export_dir = $export_dir . DIRECTORY_SEPARATOR . $sub_dir;
56 ilUtil::makeDirParents($this->cont_export_dir);
57
58 $GLOBALS['ilLog']->write(__METHOD__ . ' using base directory: ' . $this->export_run_dir);
59
60 $this->manifestWriterBegin($a_type, $a_id, $a_target_release);
61 $this->addContainer();
62 $this->addSubitems($a_id, $a_type, $a_target_release);
63 $this->manifestWriterEnd($a_type, $a_id, $a_target_release);
64
65 ilUtil::zip($this->cont_export_dir, $this->cont_export_dir . '.zip');
66 ilUtil::delDir($this->cont_export_dir);
67 }
manifestWriterBegin($a_type, $a_id, $a_target_release)
Write container manifest.
addSubitems($a_id, $a_type, $a_target_release)
Add subitems.
manifestWriterEnd($a_type, $a_id, $a_target_release)
Write manifest footer.
addContainer()
Add container description.
static _createExportDirectory($a_obj_id, $a_export_type="xml", $a_obj_type="")
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
const ILIAS_VERSION_NUMERIC
$a_type
Definition: workflow.php:92

References $a_type, $GLOBALS, ilExport\_createExportDirectory(), ilExport\_getExportDirectory(), addContainer(), addSubitems(), ilUtil\delDir(), ILIAS_VERSION_NUMERIC, ilUtil\makeDirParents(), manifestWriterBegin(), manifestWriterEnd(), and ilUtil\zip().

+ Here is the call graph for this function:

◆ manifestWriterBegin()

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

Write container manifest.

Returns

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

74 {
75 $GLOBALS['ilLog']->write(__METHOD__ . ': wrinting manifest');
76 include_once "./Services/Xml/classes/class.ilXmlWriter.php";
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 }
static _lookupTitle($a_id)
lookup object title
XML writer class.

References $a_type, $GLOBALS, and ilObject\_lookupTitle().

Referenced by exportObject().

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

◆ manifestWriterEnd()

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

Write manifest footer.

Parameters
object$a_type
object$a_id
object$a_target_release
Returns

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

175 {
176 $this->cont_manifest_writer->xmlEndTag('Manifest');
177 $GLOBALS['ilLog']->write(__METHOD__ . ': ' . $this->cont_export_dir . DIRECTORY_SEPARATOR . 'manifest.xml');
178 $this->cont_manifest_writer->xmlDumpFile($this->cont_export_dir . DIRECTORY_SEPARATOR . 'manifest.xml', true);
179 }

References $GLOBALS.

Referenced by exportObject().

+ Here is the caller graph for this function:

Field Documentation

◆ $cont_export_dir

ilExportContainer::$cont_export_dir = ''
private

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

◆ $cont_manifest_writer

ilExportContainer::$cont_manifest_writer = null
private

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

◆ $eo

ilExportContainer::$eo = null
private

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

Referenced by __construct().


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