ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilExportGUI Class Reference

Export User Interface Class. More...

+ Inheritance diagram for ilExportGUI:
+ Collaboration diagram for ilExportGUI:

Public Member Functions

 __construct (object $a_parent_gui, ?ilObject $a_main_obj=null, bool $public_access_enabled=true, bool $default_export_option_enabled=true)
 
 isPublicAccessEnabled ()
 
 executeCommand ()
 
 addFormat ()
 
 listExportFiles ()
 
 getFormats ()
 

Data Fields

const CMD_LIST_EXPORT_FILES = "listExportFiles"
 
const CMD_EXPORT_XML = "createXmlExportFile"
 

Protected Member Functions

 initExportOptionsFromPost ()
 
 builtExportOptionCommand (ilExportHandlerConsumerExportOptionInterface $export_option)
 
 enableStandardXMLExport ()
 
 initExportOptions ()
 
 displayExportFiles ()
 
 createXMLExportFile ()
 
 showItemSelection ()
 Show container item selection table. More...
 
 saveItemSelection ()
 
 createXMLExport (ExportConfigCollectionInterface $export_configs)
 
 createXMLContainerExport ()
 

Protected Attributes

const CMD_SAVE_ITEM_SELECTION = "saveItemSelection"
 
const CMD_EXPORT_OPTION_PREFIX = "exportOption"
 
ilExportHandlerConsumerExportOptionCollectionInterface $export_options
 
ilUIServices $ui_services
 
ilHTTPServices $http
 
ilRefineryFactory $refinery
 
ilObjUser $il_user
 
ilLanguage $lng
 
ilObject $obj
 
ilGlobalTemplateInterface $tpl
 
ilCtrlInterface $ctrl
 
ilAccessHandler $access
 
ilErrorHandling $error
 
ilToolbarGUI $toolbar
 
ilObjectDefinition $obj_definition
 
ilTree $tree
 
ilExportHandler $export_handler
 
ilExportHandlerConsumerContextInterface $context
 
ilDataFactory $data_factory
 
object $parent_gui
 
bool $public_access_enabled
 

Detailed Description

Export User Interface Class.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de ilExportGUI:

Definition at line 37 of file class.ilExportGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilExportGUI::__construct ( object  $a_parent_gui,
?ilObject  $a_main_obj = null,
bool  $public_access_enabled = true,
bool  $default_export_option_enabled = true 
)

Definition at line 65 of file class.ilExportGUI.php.

References $DIC, $public_access_enabled, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), enableStandardXMLExport(), ILIAS\FileDelivery\http(), initExportOptions(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\toolbar().

70  {
71  global $DIC;
72  $this->ui_services = $DIC->ui();
73  $this->http = $DIC->http();
74  $this->refinery = $DIC->refinery();
75  $this->il_user = $DIC->user();
76  $this->lng = $DIC->language();
77  $this->lng->loadLanguageModule("exp");
78  $this->tpl = $DIC->ui()->mainTemplate();
79  $this->ctrl = $DIC->ctrl();
80  $this->access = $DIC->access();
81  $this->error = $DIC['ilErr'];
82  $this->toolbar = $DIC->toolbar();
83  $this->parent_gui = $a_parent_gui;
84  $this->obj_definition = $DIC['objDefinition'];
85  $this->tree = $DIC->repositoryTree();
86  $this->obj = $a_main_obj ?? $a_parent_gui->getObject();
87  $this->export_handler = new ilExportHandler();
88  $this->context = $this->export_handler->consumer()->context()->handler($this, $this->obj);
89  $this->export_options = $this->export_handler->consumer()->exportOption()->collection();
90  $this->data_factory = new ilDataFactory();
91  $this->public_access_enabled = $public_access_enabled;
92  $this->initExportOptions();
93  if ($default_export_option_enabled) {
94  $this->enableStandardXMLExport();
95  }
96  }
static http()
Fetches the global http state from ILIAS.
bool $public_access_enabled
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:25
+ Here is the call graph for this function:

Member Function Documentation

◆ addFormat()

ilExportGUI::addFormat ( )

Definition at line 143 of file class.ilExportGUI.php.

Referenced by ilCmiXapiExportGUI\__construct().

143  : void
144  {
145 
146  }
+ Here is the caller graph for this function:

◆ builtExportOptionCommand()

ilExportGUI::builtExportOptionCommand ( ilExportHandlerConsumerExportOptionInterface  $export_option)
finalprotected

Definition at line 178 of file class.ilExportGUI.php.

Referenced by displayExportFiles(), and executeCommand().

178  : string
179  {
180  return self::CMD_EXPORT_OPTION_PREFIX . $export_option->getExportOptionId();
181  }
+ Here is the caller graph for this function:

◆ createXMLContainerExport()

ilExportGUI::createXMLContainerExport ( )
finalprotected

Definition at line 293 of file class.ilExportGUI.php.

References $access, $obj_definition, $ref_id, ilObject\_lookupObjId(), ilObject\_lookupType(), ilExportOptions\allocateExportId(), ilExportOptions\EXPORT_BUILD, ilExportOptions\EXPORT_EXISTING, ilExportOptions\EXPORT_OMIT, initExportOptionsFromPost(), ILIAS\Repository\int(), ilExportOptions\KEY_ROOT, and ilExportOptions\newInstance().

Referenced by saveItemSelection().

293  : void
294  {
295  $tree_nodes = $this->tree->getSubTree($this->tree->getNodeData($this->parent_gui->getObject()->getRefId()));
296  $post_export_options = $this->initExportOptionsFromPost();
298  $eo->addOption(ilExportOptions::KEY_ROOT, 0, 0, $this->obj->getId());
299  $items_selected = $eo->addOptions(
300  $this->parent_gui->getObject()->getRefId(),
303  $tree_nodes,
304  $post_export_options
305  );
306  $eo->read();
307  $ref_ids_export = [$this->parent_gui->getObject()->getRefId()];
308  $ref_ids_all = [$this->parent_gui->getObject()->getRefId()];
309  $tree_ref_ids = array_map(function ($node) { return (int) $node['ref_id']; }, $tree_nodes);
310  $post_ref_ids = array_map(function ($key) {return (int) $key; }, array_keys($post_export_options));
311  $valid_ref_ids = array_intersect($post_ref_ids, $tree_ref_ids);
312  foreach ($valid_ref_ids as $ref_id) {
313  $info = $post_export_options[$ref_id];
314  $export_option_id = (int) $info["type"];
315  if (
316  $export_option_id === ilExportOptions::EXPORT_OMIT ||
317  !$this->obj_definition->allowExport(ilObject::_lookupType($ref_id, true)) ||
318  !$this->access->checkAccess('write', '', $ref_id)
319  ) {
320  continue;
321  }
322  if ($export_option_id === ilExportOptions::EXPORT_BUILD) {
323  $ref_ids_export[] = $ref_id;
324  }
325  if (
326  $export_option_id === ilExportOptions::EXPORT_BUILD ||
327  $export_option_id === ilExportOptions::EXPORT_EXISTING
328  ) {
329  $ref_ids_all[] = $ref_id;
330  }
331  }
332  $export_configs = $this->export_handler->consumer()->exportConfig()->allExportConfigs();
333  $manager = $this->export_handler->manager()->handler();
334  if (count($ref_ids_all) === 1) {
335  $manager->createExportOfObject($this->obj, $this->il_user->getId(), $export_configs);
336  }
337  if (count($ref_ids_all) > 1) {
338  $obj_ids_export = array_map(function (int $ref_id) { return ilObject::_lookupObjId($ref_id); }, $ref_ids_export);
339  $obj_ids_all = array_map(function (int $ref_id) { return ilObject::_lookupObjId($ref_id); }, $ref_ids_all);
340  $object_id_collection_builder = $manager->getObjectIdCollectioBuilder();
341  foreach ($obj_ids_all as $obj_id) {
342  $object_id_collection_builder = $object_id_collection_builder->addObjectId(
343  $this->data_factory->objId($obj_id),
344  in_array($obj_id, $obj_ids_export)
345  );
346  }
347  $container_export_info = $manager->getContainerExportInfo(
348  $this->data_factory->objId($obj_ids_all[0]),
349  $object_id_collection_builder->getCollection(),
350  $export_configs
351  );
352  $element = $manager->createContainerExport($this->il_user->getId(), $container_export_info);
353  }
354  $eo->delete();
355  }
static newInstance(int $a_export_id)
static _lookupObjId(int $ref_id)
$ref_id
Definition: ltiauth.php:66
ilAccessHandler $access
ilObjectDefinition $obj_definition
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createXMLExport()

ilExportGUI::createXMLExport ( ExportConfigCollectionInterface  $export_configs)
finalprotected

Definition at line 286 of file class.ilExportGUI.php.

Referenced by createXMLExportFile().

288  : void {
289  $manager = $this->export_handler->manager()->handler();
290  $manager->createExportOfObject($this->obj, $this->il_user->getId(), $export_configs);
291  }
+ Here is the caller graph for this function:

◆ createXMLExportFile()

ilExportGUI::createXMLExportFile ( )
finalprotected

Definition at line 238 of file class.ilExportGUI.php.

References createXMLExport(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ilGlobalTemplateInterface\MESSAGE_TYPE_SUCCESS, and showItemSelection().

Referenced by executeCommand().

238  : void
239  {
240  if ($this->parent_gui instanceof ilContainerGUI) {
241  $this->showItemSelection();
242  return;
243  }
244  $this->createXMLExport($this->export_handler->consumer()->exportConfig()->allExportConfigs());
245  $this->tpl->setOnScreenMessage(
247  $this->lng->txt("exp_file_created"),
248  true
249  );
250  $this->ctrl->redirect($this, self::CMD_LIST_EXPORT_FILES);
251  }
showItemSelection()
Show container item selection table.
Class ilContainerGUI This is a base GUI class for all container objects in ILIAS: root folder...
createXMLExport(ExportConfigCollectionInterface $export_configs)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ displayExportFiles()

ilExportGUI::displayExportFiles ( )
finalprotected

Definition at line 201 of file class.ilExportGUI.php.

References builtExportOptionCommand(), ILIAS\Repository\ctrl(), isPublicAccessEnabled(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

Referenced by executeCommand(), and listExportFiles().

201  : void
202  {
203  if ($this->export_options->count() === 0) {
204  return;
205  }
206  $table = $this->export_handler->table()->handler()
207  ->withExportOptions($this->export_options)
208  ->withContext($this->context)
209  ->withPublicAccessEnabled($this->isPublicAccessEnabled());
210  $table->handleCommands();
211  $infos = [];
212  foreach ($this->export_options as $export_option) {
213  # Do not display export option if the label is missing.
214  if ($export_option->getLabel() === '') {
215  continue;
216  }
217  $infos[$export_option->getLabel()] = $this->ctrl->getLinkTarget($this, $this->builtExportOptionCommand($export_option));
218  }
219  if (count($infos) === 1) {
220  $this->toolbar->addComponent($this->ui_services->factory()->button()->standard(
221  sprintf($this->lng->txt("exp_export_single_option"), array_keys($infos)[0]),
222  array_values($infos)[0]
223  ));
224  }
225  if (count($infos) > 1) {
226  $links = [];
227  foreach ($infos as $label => $link) {
228  $links[] = $this->ui_services->factory()->link()->standard($label, $link);
229  }
230  $this->toolbar->addComponent(
231  $this->ui_services->factory()->dropdown()->standard($links)
232  ->withLabel($this->lng->txt("exp_export_dropdown"))
233  );
234  }
235  $this->tpl->setContent($table->getHTML());
236  }
builtExportOptionCommand(ilExportHandlerConsumerExportOptionInterface $export_option)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enableStandardXMLExport()

ilExportGUI::enableStandardXMLExport ( )
finalprotected

Definition at line 183 of file class.ilExportGUI.php.

Referenced by __construct().

183  : void
184  {
185  $this->export_options = $this->export_options->withElement(new ilExportExportOptionXML());
186  }
+ Here is the caller graph for this function:

◆ executeCommand()

ilExportGUI::executeCommand ( )

Definition at line 103 of file class.ilExportGUI.php.

References ilObject\_lookupType(), ILIAS\Repository\access(), builtExportOptionCommand(), createXMLExportFile(), ILIAS\Repository\ctrl(), displayExportFiles(), ILIAS\Repository\lng(), saveItemSelection(), and ilExportLimitation\SET_EXPORT_DISABLED.

103  : void
104  {
105  // this should work (at least) for repository objects
106  if (method_exists($this->obj, 'getRefId') and $this->obj->getRefId()) {
107  if (!$this->access->checkAccess('write', '', $this->obj->getRefId())) {
108  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->WARNING);
109  }
110  // check export activation of container
111  $exp_limit = new ilExportLimitation();
112  if ($this->obj_definition->isContainer(ilObject::_lookupType($this->obj->getRefId(), true)) &&
113  $exp_limit->getLimitationMode() == ilExportLimitation::SET_EXPORT_DISABLED) {
114  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("exp_error_disabled"));
115  return;
116  }
117  }
118  $cmd = $this->ctrl->getCmd(self::CMD_LIST_EXPORT_FILES);
119  if (str_starts_with($cmd, self::CMD_EXPORT_OPTION_PREFIX)) {
120  foreach ($this->export_options as $export_option) {
121  if ($cmd === $this->builtExportOptionCommand($export_option)) {
122  $export_option->onExportOptionSelected($this->context);
123  }
124  }
125  }
126  switch ($cmd) {
127  case self::CMD_EXPORT_XML:
128  $this->createXMLExportFile();
129  break;
130  case self::CMD_SAVE_ITEM_SELECTION:
131  $this->saveItemSelection();
132  break;
133  case self::CMD_LIST_EXPORT_FILES:
134  default:
135  $this->displayExportFiles();
136  break;
137  }
138  }
builtExportOptionCommand(ilExportHandlerConsumerExportOptionInterface $export_option)
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:

◆ getFormats()

ilExportGUI::getFormats ( )

Definition at line 156 of file class.ilExportGUI.php.

156  : array
157  {
158  return [];
159  }

◆ initExportOptions()

ilExportGUI::initExportOptions ( )
finalprotected

Definition at line 188 of file class.ilExportGUI.php.

Referenced by __construct().

188  : void
189  {
190  $export_options = $this->export_handler->consumer()->exportOption()->allExportOptions();
191  foreach ($export_options as $export_option) {
192  if (
193  in_array($this->obj->getType(), $export_option->getSupportedRepositoryObjectTypes()) and
194  $export_option->isObjectSupported($this->data_factory->objId($this->obj->getId()))
195  ) {
196  $this->export_options = $this->export_options->withElement($export_option);
197  }
198  }
199  }
ilExportHandlerConsumerExportOptionCollectionInterface $export_options
+ Here is the caller graph for this function:

◆ initExportOptionsFromPost()

ilExportGUI::initExportOptionsFromPost ( )
finalprotected

Definition at line 161 of file class.ilExportGUI.php.

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by createXMLContainerExport(), and saveItemSelection().

161  : array
162  {
163  $options = [];
164  if ($this->http->wrapper()->post()->has('cp_options')) {
165  $custom_transformer = $this->refinery->custom()->transformation(
166  function ($array) {
167  return $array;
168  }
169  );
170  $options = $this->http->wrapper()->post()->retrieve(
171  'cp_options',
172  $custom_transformer
173  );
174  }
175  return $options;
176  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isPublicAccessEnabled()

ilExportGUI::isPublicAccessEnabled ( )
final

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

References $public_access_enabled.

Referenced by displayExportFiles().

98  : bool
99  {
101  }
bool $public_access_enabled
+ Here is the caller graph for this function:

◆ listExportFiles()

ilExportGUI::listExportFiles ( )

Definition at line 148 of file class.ilExportGUI.php.

References displayExportFiles().

148  : void
149  {
150  $this->displayExportFiles();
151  }
+ Here is the call graph for this function:

◆ saveItemSelection()

ilExportGUI::saveItemSelection ( )
finalprotected

Definition at line 265 of file class.ilExportGUI.php.

References Vendor\Package\$e, createXMLContainerExport(), ILIAS\Repository\ctrl(), initExportOptionsFromPost(), ILIAS\Repository\lng(), and showItemSelection().

Referenced by executeCommand().

265  : void
266  {
267  // check export limitation
268  $cp_options = $this->initExportOptionsFromPost();
269  $exp_limit = new ilExportLimitation();
270  try {
271  $exp_limit->checkLimitation(
272  $this->parent_gui->getObject()->getRefId(),
273  $cp_options
274  );
275  } catch (Exception $e) {
276  $this->tpl->setOnScreenMessage('failure', $e->getMessage());
277  $this->showItemSelection();
278  return;
279  }
280  // create export
281  $this->createXMLContainerExport();
282  $this->tpl->setOnScreenMessage('success', $this->lng->txt('export_created'), true);
283  $this->ctrl->redirect($this, self::CMD_LIST_EXPORT_FILES);
284  }
showItemSelection()
Show container item selection table.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showItemSelection()

ilExportGUI::showItemSelection ( )
finalprotected

Show container item selection table.

Definition at line 256 of file class.ilExportGUI.php.

Referenced by createXMLExportFile(), and saveItemSelection().

256  : void
257  {
258  $this->tpl->addJavaScript('assets/js/ilContainer.js');
259  $this->tpl->setVariable('BODY_ATTRIBUTES', 'onload="ilDisableChilds(\'cmd\');"');
260  $table = new ilExportSelectionTableGUI($this, self::CMD_LIST_EXPORT_FILES, $this->export_handler);
261  $table->parseContainer($this->parent_gui->getObject()->getRefId());
262  $this->tpl->setContent($table->getHTML());
263  }
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilExportGUI::$access
protected

Definition at line 53 of file class.ilExportGUI.php.

Referenced by createXMLContainerExport().

◆ $context

ilExportHandlerConsumerContextInterface ilExportGUI::$context
protected

Definition at line 60 of file class.ilExportGUI.php.

◆ $ctrl

ilCtrlInterface ilExportGUI::$ctrl
protected

Definition at line 52 of file class.ilExportGUI.php.

◆ $data_factory

ilDataFactory ilExportGUI::$data_factory
protected

Definition at line 61 of file class.ilExportGUI.php.

◆ $error

ilErrorHandling ilExportGUI::$error
protected

Definition at line 54 of file class.ilExportGUI.php.

◆ $export_handler

ilExportHandler ilExportGUI::$export_handler
protected

Definition at line 59 of file class.ilExportGUI.php.

◆ $export_options

ilExportHandlerConsumerExportOptionCollectionInterface ilExportGUI::$export_options
protected

Definition at line 44 of file class.ilExportGUI.php.

◆ $http

ilHTTPServices ilExportGUI::$http
protected

Definition at line 46 of file class.ilExportGUI.php.

◆ $il_user

ilObjUser ilExportGUI::$il_user
protected

Definition at line 48 of file class.ilExportGUI.php.

◆ $lng

ilLanguage ilExportGUI::$lng
protected

Definition at line 49 of file class.ilExportGUI.php.

◆ $obj

ilObject ilExportGUI::$obj
protected

Definition at line 50 of file class.ilExportGUI.php.

◆ $obj_definition

ilObjectDefinition ilExportGUI::$obj_definition
protected

Definition at line 57 of file class.ilExportGUI.php.

Referenced by createXMLContainerExport().

◆ $parent_gui

object ilExportGUI::$parent_gui
protected

Definition at line 62 of file class.ilExportGUI.php.

◆ $public_access_enabled

bool ilExportGUI::$public_access_enabled
protected

Definition at line 63 of file class.ilExportGUI.php.

Referenced by __construct(), and isPublicAccessEnabled().

◆ $refinery

ilRefineryFactory ilExportGUI::$refinery
protected

Definition at line 47 of file class.ilExportGUI.php.

◆ $toolbar

ilToolbarGUI ilExportGUI::$toolbar
protected

Definition at line 56 of file class.ilExportGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilExportGUI::$tpl
protected

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

◆ $tree

ilTree ilExportGUI::$tree
protected

Definition at line 58 of file class.ilExportGUI.php.

◆ $ui_services

ilUIServices ilExportGUI::$ui_services
protected

Definition at line 45 of file class.ilExportGUI.php.

◆ CMD_EXPORT_OPTION_PREFIX

const ilExportGUI::CMD_EXPORT_OPTION_PREFIX = "exportOption"
protected

Definition at line 42 of file class.ilExportGUI.php.

◆ CMD_EXPORT_XML

const ilExportGUI::CMD_EXPORT_XML = "createXmlExportFile"

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

◆ CMD_LIST_EXPORT_FILES

◆ CMD_SAVE_ITEM_SELECTION

const ilExportGUI::CMD_SAVE_ITEM_SELECTION = "saveItemSelection"
protected

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


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