ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilExport Class Reference
+ Inheritance diagram for ilExport:
+ Collaboration diagram for ilExport:

Public Member Functions

 __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...
 

Static Public Member Functions

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

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

 $log
 
 $configs = array()
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilExport::__construct ( )

Default constructor.

Returns

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

References ilLoggerFactory\getLogger().

32  {
33  $this->log = ilLoggerFactory::getLogger('exp');
34  }
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

Member Function Documentation

◆ _createExportDirectory()

static ilExport::_createExportDirectory (   $a_obj_id,
  $a_export_type = "xml",
  $a_obj_type = "" 
)
static
Parameters
$a_obj_id
string$a_export_type
string$a_obj_type
Returns
bool

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

References $ilErr, _getExportDirectory(), ilObject\_lookupType(), and ilUtil\makeDirParents().

Referenced by ilPortfolioHTMLExport\buildExportFile(), ilWikiHTMLExport\buildExportFile(), ilObjBlogGUI\buildExportFile(), ilObjGlossary\createExportDirectory(), ilObjFileBasedLMGUI\exportHTML(), ilExportContainer\exportObject(), exportObject(), and ilOrgUnitExporter\sendAndCreateSimpleExportFile().

242  {
243  global $ilErr;
244 
245  if ($a_obj_type == "")
246  {
247  $a_obj_type = ilObject::_lookupType($a_obj_id);
248  }
249 
250  $edir = ilExport::_getExportDirectory($a_obj_id,$a_export_type,$a_obj_type);
251  ilUtil::makeDirParents($edir);
252  return true;
253  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
global $ilErr
Definition: raiseError.php:16
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _generateIndexFile()

static ilExport::_generateIndexFile (   $a_filename,
  $a_obj_id,
  $a_files,
  $a_type = "" 
)
static

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

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

References $a_type, $file, $lng, ilObject\_lookupTitle(), ilObject\_lookupType(), date, ilUtil\getStyleSheetLocation(), and time.

Referenced by ilCourseArchives\addXML().

260  {
261  global $lng;
262 
263  $lng->loadLanguageModule("export");
264 
265  if ($a_type == "")
266  {
267  $a_type = ilObject::_lookupType($a_obj_id);
268  }
269  $a_tpl = new ilTemplate("tpl.main.html", true, true);
270  $location_stylesheet = ilUtil::getStyleSheetLocation();
271  $a_tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
272  $a_tpl->getStandardTemplate();
273  $a_tpl->setTitle(ilObject::_lookupTitle($a_obj_id));
274  $a_tpl->setDescription($lng->txt("export_export_date").": ".
275  date('Y-m-d H:i:s', time())." (".date_default_timezone_get().")");
276  $f_tpl = new ilTemplate("tpl.export_list.html", true, true, "Services/Export");
277  foreach ($a_files as $file)
278  {
279  $f_tpl->setCurrentBlock("file_row");
280  $f_tpl->setVariable("TITLE", $file["title"]);
281  $f_tpl->setVariable("TYPE", $lng->txt("obj_".$file["type"]));
282  $f_tpl->setVariable("FILE", $file["file"]);
283  $f_tpl->parseCurrentBlock();
284  }
285  $a_tpl->setContent($f_tpl->get());
286  $index_content = $a_tpl->get("DEFAULT", false, false, false, true, false, false);
287 
288  $f = fopen ($a_filename, "w");
289  fwrite($f, $index_content);
290  fclose($f);
291  }
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static _lookupTitle($a_id)
lookup object title
$a_type
Definition: workflow.php:93
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
special template class to simplify handling of ITX/PEAR
static _lookupType($a_id, $a_reference=false)
lookup object type
global $lng
Definition: privfeed.php:17
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getExportDirectory()

static ilExport::_getExportDirectory (   $a_obj_id,
  $a_type = "xml",
  $a_obj_type = "",
  $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)
Returns
string export directory

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

References $a_type, $GLOBALS, ilFileSystemStorage\_createPathFromId(), ilObject\_lookupType(), array, and ilUtil\getDataDir().

Referenced by ilCourseArchives\__addZipFiles(), _createExportDirectory(), _getExportFiles(), ilExportContainer\addSubitems(), ilPortfolioHTMLExport\buildExportFile(), ilWikiHTMLExport\buildExportFile(), ilObjBlogGUI\buildExportFile(), ilExportGUI\delete(), ilExportGUI\download(), ilSAHSEditGUI\executeCommand(), ilObjFileBasedLMGUI\exportHTML(), ilExportContainer\exportObject(), exportObject(), ilObjUser\exportPersonalData(), ilDclContentExporter\getExportContentPath(), ilObjGlossary\getExportDirectory(), ilObjQuestionPool\getExportDirectory(), ilDclExportTableGUI\getExportFiles(), ilScormAiccDataSet\getExtendedXmlRepresentation(), ilObjUser\getPersonalDataExportFile(), ilWikiHTMLExport\getUserExportFile(), ilOrgUnitExporter\sendAndCreateSimpleExportFile(), and ilObjUser\sendPersonalDataFile().

138  {
139  global $objDefinition;
140 
141  $ent = ($a_entity == "")
142  ? ""
143  : "_".$a_entity;
144 
145 
146  if ($a_obj_type == "")
147  {
148  $a_obj_type = ilObject::_lookupType($a_obj_id);
149  }
150 
151  if(in_array($a_obj_type, self::$new_file_structure))
152  {
153  include_once './Services/FileSystem/classes/class.ilFileSystemStorage.php';
154  $dir = ilUtil::getDataDir().DIRECTORY_SEPARATOR;
155  $dir .= 'il'.$objDefinition->getClassName($a_obj_type).$ent.DIRECTORY_SEPARATOR;
156  $dir .= ilFileSystemStorage::_createPathFromId($a_obj_id, $a_obj_type).DIRECTORY_SEPARATOR;
157  $dir .= ($a_type == 'xml' ? 'export' : 'export_'.$a_type);
158  return $dir;
159  }
160 
161  include_once './Services/Export/classes/class.ilImportExportFactory.php';
162  $exporter_class = ilImportExportFactory::getExporterClass($a_obj_type);
163  $export_dir = call_user_func(array($exporter_class,'lookupExportDirectory'),$a_obj_type,$a_obj_id,$a_type,$a_entity);
164 
165  $GLOBALS['ilLog']->write(__METHOD__.': Export dir is '.$export_dir);
166  return $export_dir;
167  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static _createPathFromId($a_container_id, $a_name)
Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5.
$a_type
Definition: workflow.php:93
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static getDataDir()
get data directory (outside webspace)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getExportFiles()

static ilExport::_getExportFiles (   $a_obj_id,
  $a_export_types = "",
  $a_obj_type = "" 
)
static

Get Export Files for a repository object.

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

References $file, $GLOBALS, _getExportDirectory(), ilObject\_lookupType(), and array.

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

173  {
174  $GLOBALS['ilLog']->write(__METHOD__);
175 
176  if ($a_obj_type == "")
177  {
178  $a_obj_type = ilObject::_lookupType($a_obj_id);
179  }
180 
181  if ($a_export_types == "")
182  {
183  $a_export_types = array("xml");
184  }
185  if (!is_array($a_export_types))
186  {
187  $a_export_types = array($a_export_types);
188  }
189 
190  // initialize array
191  $file = array();
192 
193  $types = $a_export_types;
194 
195  foreach($types as $type)
196  {
197  $dir = ilExport::_getExportDirectory($a_obj_id, $type, $a_obj_type);
198 
199  // quit if import dir not available
200  if (!@is_dir($dir) or
201  !is_writeable($dir))
202  {
203  continue;
204  }
205 
206  // open directory
207  $h_dir = dir($dir);
208 
209  // get files and save the in the array
210  while ($entry = $h_dir->read())
211  {
212  if ($entry != "." and
213  $entry != ".." and
214  substr($entry, -4) == ".zip" and
215  preg_match("/^[0-9]{10}_{2}[0-9]+_{2}(".$a_obj_type."_)*[0-9]+\.zip\$/", $entry))
216  {
217  $ts = substr($entry, 0, strpos($entry, "__"));
218  $file[$entry.$type] = array("type" => $type, "file" => $entry,
219  "size" => filesize($dir."/".$entry),
220  "timestamp" => $ts);
221  }
222  }
223 
224  // close import directory
225  $h_dir->close();
226  }
227 
228  // sort files
229  ksort ($file);
230  reset ($file);
231  return $file;
232  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getLastExportFileDate()

static ilExport::_getLastExportFileDate (   $a_obj_id,
  $a_type = "",
  $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 99 of file class.ilExport.php.

References $a_type, $files, _getExportFiles(), and ilUtil\sortArray().

Referenced by _getValidExportSubItems().

100  {
101  $files = ilExport::_getExportFiles($a_obj_id, $a_type, $a_obj_type);
102  if (is_array($files))
103  {
104  $files = ilUtil::sortArray($files, "timestamp", "desc");
105  return $files[0]["timestamp"];
106  }
107  return false;
108  }
$files
Definition: add-vimline.php:18
static _getExportFiles($a_obj_id, $a_export_types="", $a_obj_type="")
Get Export Files for a repository object.
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
$a_type
Definition: workflow.php:93
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getLastExportFileInformation()

static ilExport::_getLastExportFileInformation (   $a_obj_id,
  $a_type = "",
  $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)

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

References $a_type, $files, _getExportFiles(), and ilUtil\sortArray().

Referenced by ilCourseArchives\__addZipFiles().

118  {
119  $files = ilExport::_getExportFiles($a_obj_id, $a_type, $a_obj_type);
120  if (is_array($files))
121  {
122  $files = ilUtil::sortArray($files, "timestamp", "desc");
123  return $files[0];
124  }
125  return false;
126  }
$files
Definition: add-vimline.php:18
static _getExportFiles($a_obj_id, $a_export_types="", $a_obj_type="")
Get Export Files for a repository object.
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
$a_type
Definition: workflow.php:93
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getValidExportSubItems()

static ilExport::_getValidExportSubItems (   $a_ref_id)
static

Get a list of subitems of a repository resource, that implement the export.

Includes also information on last export file.

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

References _getLastExportFileDate(), and array.

Referenced by ilSubItemSelectionTableGUI\__construct().

73  {
74  global $tree;
75 
76  $valid_items = array();
77  $sub_items = $tree->getSubTree($tree->getNodeData($a_ref_id));
78  foreach ($sub_items as $sub_item)
79  {
80  if (in_array($sub_item["type"], self::$export_implementer))
81  {
82  $valid_items[] = array("type" => $sub_item["type"],
83  "title" => $sub_item["title"], "ref_id" => $sub_item["child"],
84  "obj_id" => $sub_item["obj_id"],
85  "timestamp" =>
86  ilExport::_getLastExportFileDate($sub_item["obj_id"], "xml", $sub_item["type"]));
87  }
88  }
89  return $valid_items;
90  }
static _getLastExportFileDate($a_obj_id, $a_type="", $a_obj_type="")
Get date of last export file.
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportEntity()

ilExport::exportEntity (   $a_entity,
  $a_id,
  $a_target_release,
  $a_component,
  $a_title,
  $a_export_dir,
  $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 405 of file class.ilExport.php.

References $success, $tpl, array, ilUtil\delDir(), ILIAS_VERSION_NUMERIC, ilUtil\makeDirParents(), processExporter(), time, and ilUtil\zip().

407  {
408  global $objDefinition, $tpl;
409 
410  // if no target release specified, use latest major release number
411  if ($a_target_release == "")
412  {
413  $v = explode(".", ILIAS_VERSION_NUMERIC);
414  $a_target_release = $v[0].".".$v[1].".0";
415  }
416 
417  if ($a_type_for_file == "")
418  {
419  $a_type_for_file = $a_entity;
420  }
421 
422  $comp = $a_component;
423  $c = explode("/", $comp);
424  $class = "il".$c[1]."Exporter";
425 
426  // manifest writer
427  include_once "./Services/Xml/classes/class.ilXmlWriter.php";
428  $this->manifest_writer = new ilXmlWriter();
429  $this->manifest_writer->xmlHeader();
430  $this->manifest_writer->xmlStartTag(
431  'Manifest',
432  array(
433  "MainEntity" => $a_entity,
434  "Title" => $a_title,
435  "TargetRelease" => $a_target_release,
436  "InstallationId" => IL_INST_ID,
437  "InstallationUrl" => ILIAS_HTTP_PATH));
438 
439  $export_dir = $a_export_dir;
440  $ts = time();
441 
442  // determine file name and subdirectory
443  $sub_dir = $ts.'__'.IL_INST_ID.'__'.$a_type_for_file.'_'.$a_id;
444  $new_file = $sub_dir.'.zip';
445 
446  $this->export_run_dir = $export_dir."/".$sub_dir;
447  ilUtil::makeDirParents($this->export_run_dir);
448 
449  $this->cnt = array();
450 
451  $success = $this->processExporter($comp, $class, $a_entity, $a_target_release, $a_id);
452 
453  $this->manifest_writer->xmlEndTag('Manifest');
454 
455  $this->manifest_writer->xmlDumpFile($this->export_run_dir."/manifest.xml", false);
456 
457  // zip the file
458  ilUtil::zip($this->export_run_dir, $export_dir."/".$new_file);
459  ilUtil::delDir($this->export_run_dir);
460 
461  return array(
462  "success" => $success,
463  "file" => $new_file,
464  "directory" => $export_dir
465  );
466  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
const ILIAS_VERSION_NUMERIC
XML writer class.
global $tpl
Definition: ilias.php:8
$success
Definition: Utf8Test.php:86
processExporter($a_comp, $a_class, $a_entity, $a_target_release, $a_id)
Process exporter.
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
Create styles array
The data for the language used.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:

◆ exportObject()

ilExport::exportObject (   $a_type,
  $a_id,
  $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

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

References $a_type, $success, _createExportDirectory(), _getExportDirectory(), ilObject\_lookupTitle(), array, ilUtil\delDir(), IL_CAL_UNIX, ILIAS_VERSION_NUMERIC, ilUtil\makeDirParents(), processExporter(), time, and ilUtil\zip().

322  {
323  $this->log->debug("export type: $a_type, id: $a_id, target_release: ".$a_target_release);
324 
325  // if no target release specified, use latest major release number
326  if ($a_target_release == "")
327  {
328  $v = explode(".", ILIAS_VERSION_NUMERIC);
329  $a_target_release = $v[0].".".$v[1].".0";
330  $this->log->debug("target_release set to: ".$a_target_release);
331  }
332 
333  // manifest writer
334  include_once "./Services/Xml/classes/class.ilXmlWriter.php";
335  $this->manifest_writer = new ilXmlWriter();
336  $this->manifest_writer->xmlHeader();
337  $this->manifest_writer->xmlStartTag(
338  'Manifest',
339  array(
340  "MainEntity" => $a_type,
341  "Title" => ilObject::_lookupTitle($a_id),
342  "TargetRelease" => $a_target_release,
343  "InstallationId" => IL_INST_ID,
344  "InstallationUrl" => ILIAS_HTTP_PATH));
345 
346  // get export class
348  $export_dir = ilExport::_getExportDirectory($a_id, "xml", $a_type);
349  $ts = time();
350 
351  // Workaround for test assessment
352  $sub_dir = $ts.'__'.IL_INST_ID.'__'.$a_type.'_'.$a_id;
353  $new_file = $sub_dir.'.zip';
354 
355  $this->export_run_dir = $export_dir."/".$sub_dir;
356  ilUtil::makeDirParents($this->export_run_dir);
357  $this->log->debug("export dir: ".$this->export_run_dir);
358 
359  $this->cnt = array();
360 
361  include_once './Services/Export/classes/class.ilImportExportFactory.php';
362  $class = ilImportExportFactory::getExporterClass($a_type);
363  $comp = ilImportExportFactory::getComponentForExport($a_type);
364 
365  $success = $this->processExporter($comp, $class, $a_type, $a_target_release, $a_id);
366 
367  $this->manifest_writer->xmlEndTag('Manifest');
368 
369  $this->manifest_writer->xmlDumpFile($this->export_run_dir."/manifest.xml", false);
370 
371  // zip the file
372  $this->log->debug("zip: ".$export_dir."/".$new_file);
373  ilUtil::zip($this->export_run_dir, $export_dir."/".$new_file);
374  ilUtil::delDir($this->export_run_dir);
375 
376  // Store info about export
377  if($success)
378  {
379  include_once './Services/Export/classes/class.ilExportFileInfo.php';
380  $exp = new ilExportFileInfo($a_id);
381  $exp->setVersion($a_target_release);
382  $exp->setCreationDate(new ilDateTime($ts,IL_CAL_UNIX));
383  $exp->setExportType('xml');
384  $exp->setFilename($new_file);
385  $exp->create();
386  }
387 
388  return array(
389  "success" => $success,
390  "file" => $new_file,
391  "directory" => $export_dir
392  );
393  }
static _createExportDirectory($a_obj_id, $a_export_type="xml", $a_obj_type="")
static makeDirParents($a_dir)
Create a new directory and all parent directories.
const ILIAS_VERSION_NUMERIC
XML writer class.
static _lookupTitle($a_id)
lookup object title
const IL_CAL_UNIX
$a_type
Definition: workflow.php:93
$success
Definition: Utf8Test.php:86
processExporter($a_comp, $a_class, $a_entity, $a_target_release, $a_id)
Process exporter.
Stores information of creation date and versions of export files
Date and time handling
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
Create styles array
The data for the language used.
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:

◆ getConfig()

ilExport::getConfig (   $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 or null
Exceptions
ilExportException

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

44  {
45  // if created, return existing config object
46  if (isset($this->configs[$a_comp]))
47  {
48  return $this->configs[$a_comp];
49  }
50 
51  // create instance of export config object
52  $comp_arr = explode("/", $a_comp);
53  $a_class = "il".$comp_arr[1]."ExportConfig";
54  $export_config_file = "./".$a_comp."/classes/class.".$a_class.".php";
55  if (!is_file($export_config_file))
56  {
57  include_once("./Services/Export/exceptions/class.ilExportException.php");
58  throw new ilExportException('Component "'.$a_comp.'" does not provide ExportConfig class.');
59  }
60  include_once($export_config_file);
61  $exp_config = new $a_class();
62  $this->configs[$a_comp] = $exp_config;
63 
64  return $exp_config;
65  }
General export exception.

◆ processExporter()

ilExport::processExporter (   $a_comp,
  $a_class,
  $a_entity,
  $a_target_release,
  $a_id 
)

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

References $success, array, and ilUtil\makeDirParents().

Referenced by exportEntity(), and exportObject().

480  {
481  $success = true;
482 
483  $this->log->debug("process exporter, comp: ".$a_comp.", class: ".$a_class.", entity: ".$a_entity.
484  ", target release ".$a_target_release.", id: ".$a_id);
485 
486  if (!is_array($a_id))
487  {
488  if ($a_id == "")
489  {
490  return;
491  }
492  $a_id = array($a_id);
493  }
494 
495  // get exporter object
496  if(!class_exists($a_class))
497  {
498  $export_class_file = "./".$a_comp."/classes/class.".$a_class.".php";
499  if (!is_file($export_class_file))
500  {
501  include_once("./Services/Export/exceptions/class.ilExportException.php");
502  throw new ilExportException('Export class file "'.$export_class_file.'" not found.');
503  }
504  include_once($export_class_file);
505  }
506 
507  $exp = new $a_class();
508  $exp->setExport($this);
509  if (!isset($this->cnt[$a_comp]))
510  {
511  $this->cnt[$a_comp] = 1;
512  }
513  else
514  {
515  $this->cnt[$a_comp]++;
516  }
517  $set_dir_relative = $a_comp."/set_".$this->cnt[$a_comp];
518  $set_dir_absolute = $this->export_run_dir."/".$set_dir_relative;
519  ilUtil::makeDirParents($set_dir_absolute);
520  $this->log->debug("dir: ".$set_dir_absolute);
521 
522  $this->log->debug("init exporter");
523  $exp->init();
524 
525  // process head dependencies
526  $this->log->debug("process head dependencies for ".$a_entity);
527  $sequence = $exp->getXmlExportHeadDependencies($a_entity, $a_target_release, $a_id);
528  foreach ($sequence as $s)
529  {
530  $comp = explode("/", $s["component"]);
531  $exp_class = "il".$comp[1]."Exporter";
532  $s = $this->processExporter($s["component"], $exp_class,
533  $s["entity"], $a_target_release, $s["ids"]);
534  if (!$s)
535  {
536  $success = false;
537  }
538  }
539 
540  // write export.xml file
541  $export_writer = new ilXmlWriter();
542  $export_writer->xmlHeader();
543 
544  $sv = $exp->determineSchemaVersion($a_entity, $a_target_release);
545  $this->log->debug("schema version for entity: $a_entity, target release: $a_target_release");
546  $this->log->debug("...is: ".$sv["schema_version"].", namespace: ".$sv["namespace"].
547  ", xsd file: ".$sv["xsd_file"].", uses_dataset: ".((int)$sv["uses_dataset"]));
548 
549  $attribs = array("InstallationId" => IL_INST_ID,
550  "InstallationUrl" => ILIAS_HTTP_PATH,
551  "Entity" => $a_entity, "SchemaVersion" => $sv["schema_version"], "TargetRelease" => $a_target_release,
552  "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
553  "xmlns:exp" => "http://www.ilias.de/Services/Export/exp/4_1",
554  "xsi:schemaLocation" => "http://www.ilias.de/Services/Export/exp/4_1 ".ILIAS_HTTP_PATH."/xml/ilias_export_4_1.xsd"
555  );
556  if ($sv["namespace"] != "" && $sv["xsd_file"] != "")
557  {
558  $attribs["xsi:schemaLocation"].= " ".$sv["namespace"]." ".
559  ILIAS_HTTP_PATH."/xml/".$sv["xsd_file"];
560  $attribs["xmlns"] = $sv["namespace"];
561  }
562  if ($sv["uses_dataset"])
563  {
564  $attribs["xsi:schemaLocation"].= " ".
565  "http://www.ilias.de/Services/DataSet/ds/4_3 ".ILIAS_HTTP_PATH."/xml/ilias_ds_4_3.xsd";
566  $attribs["xmlns:ds"] = "http://www.ilias.de/Services/DataSet/ds/4_3";
567  }
568 
569 
570  $export_writer->xmlStartTag('exp:Export', $attribs);
571 
572  $dir_cnt = 1;
573  foreach ($a_id as $id)
574  {
575  $exp->setExportDirectories($set_dir_relative."/expDir_".$dir_cnt,
576  $set_dir_absolute."/expDir_".$dir_cnt);
577  $export_writer->xmlStartTag('exp:ExportItem', array("Id" => $id));
578  //$xml = $exp->getXmlRepresentation($a_entity, $a_target_release, $id);
579  $xml = $exp->getXmlRepresentation($a_entity, $sv["schema_version"], $id);
580  $export_writer->appendXml($xml);
581  $export_writer->xmlEndTag('exp:ExportItem');
582  $dir_cnt++;
583  }
584 
585  $export_writer->xmlEndTag('exp:Export');
586  $export_writer->xmlDumpFile($set_dir_absolute."/export.xml", false);
587 
588  $this->manifest_writer->xmlElement("ExportFile",
589  array("Component" => $a_comp, "Path" => $set_dir_relative."/export.xml"));
590 
591  // process tail dependencies
592  $this->log->debug("process tail dependencies of ".$a_entity);
593  $sequence = $exp->getXmlExportTailDependencies($a_entity, $a_target_release, $a_id);
594  foreach ($sequence as $s)
595  {
596  $comp = explode("/", $s["component"]);
597  $exp_class = "il".$comp[1]."Exporter";
598  $s = $this->processExporter($s["component"], $exp_class,
599  $s["entity"], $a_target_release, $s["ids"]);
600  if (!$s)
601  {
602  $success = false;
603  }
604  }
605 
606  $this->log->debug("returning ".((int) $success)." for ".$a_entity);
607  return $success;
608  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
XML writer class.
General export exception.
$success
Definition: Utf8Test.php:86
processExporter($a_comp, $a_class, $a_entity, $a_target_release, $a_id)
Process exporter.
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $configs

ilExport::$configs = array()
protected

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

◆ $export_implementer

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

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

◆ $log

ilExport::$log
protected

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

◆ $new_file_structure

ilExport::$new_file_structure = array('cat','exc','crs','sess','file','grp','frm', 'usr', 'catr', 'crsr', 'grpr')
static

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


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