ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)
 
 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 ()
 
 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
 

Detailed Description

Export User Interface Class.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilExportGUI::__construct ( object  $a_parent_gui,
?ilObject  $a_main_obj = null 
)

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

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

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

Member Function Documentation

◆ addFormat()

ilExportGUI::addFormat ( )

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

Referenced by ilCmiXapiExportGUI\__construct().

129  : void
130  {
131 
132  }
+ Here is the caller graph for this function:

◆ builtExportOptionCommand()

ilExportGUI::builtExportOptionCommand ( ilExportHandlerConsumerExportOptionInterface  $export_option)
finalprotected

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

Referenced by displayExportFiles(), and executeCommand().

164  : string
165  {
166  return self::CMD_EXPORT_OPTION_PREFIX . $export_option->getExportOptionId();
167  }
+ Here is the caller graph for this function:

◆ createXMLContainerExport()

ilExportGUI::createXMLContainerExport ( )
finalprotected

Definition at line 281 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().

282  {
283  $tree_nodes = $this->tree->getSubTree($this->tree->getNodeData($this->parent_gui->getObject()->getRefId()));
284  $post_export_options = $this->initExportOptionsFromPost();
286  $eo->addOption(ilExportOptions::KEY_ROOT, 0, 0, $this->obj->getId());
287  $items_selected = $eo->addOptions(
288  $this->parent_gui->getObject()->getRefId(),
291  $tree_nodes,
292  $post_export_options
293  );
294  $eo->read();
295  $ref_ids_export = [$this->parent_gui->getObject()->getRefId()];
296  $ref_ids_all = [$this->parent_gui->getObject()->getRefId()];
297  $tree_ref_ids = array_map(function ($node) { return (int) $node['ref_id']; }, $tree_nodes);
298  $post_ref_ids = array_map(function ($key) {return (int) $key; }, array_keys($post_export_options));
299  $valid_ref_ids = array_intersect($post_ref_ids, $tree_ref_ids);
300  foreach ($valid_ref_ids as $ref_id) {
301  $info = $post_export_options[$ref_id];
302  $export_option_id = (int) $info["type"];
303  if (
304  $export_option_id === ilExportOptions::EXPORT_OMIT ||
305  !$this->obj_definition->allowExport(ilObject::_lookupType($ref_id, true)) ||
306  !$this->access->checkAccess('write', '', $ref_id)
307  ) {
308  continue;
309  }
310  if ($export_option_id === ilExportOptions::EXPORT_BUILD) {
311  $ref_ids_export[] = $ref_id;
312  }
313  if (
314  $export_option_id === ilExportOptions::EXPORT_BUILD ||
315  $export_option_id === ilExportOptions::EXPORT_EXISTING
316  ) {
317  $ref_ids_all[] = $ref_id;
318  }
319  }
320  $manager = $this->export_handler->manager()->handler();
321  if (count($ref_ids_all) === 1) {
322  $export_info = $manager->getExportInfoWithObject(
323  $this->obj,
324  time()
325  );
326  $element = $manager->createExport(
327  $this->il_user->getId(),
328  $export_info,
329  ""
330  );
331  }
332  if (count($ref_ids_all) > 1) {
333  $obj_ids_export = array_map(function (int $ref_id) { return ilObject::_lookupObjId($ref_id); }, $ref_ids_export);
334  $obj_ids_all = array_map(function (int $ref_id) { return ilObject::_lookupObjId($ref_id); }, $ref_ids_all);
335  $object_id_collection_builder = $manager->getObjectIdCollectioBuilder();
336  foreach ($obj_ids_all as $obj_id) {
337  $object_id_collection_builder = $object_id_collection_builder->addObjectId(
338  $this->data_factory->objId($obj_id),
339  in_array($obj_id, $obj_ids_export)
340  );
341  }
342  $container_export_info = $manager->getContainerExportInfo(
343  $this->data_factory->objId($obj_ids_all[0]),
344  $object_id_collection_builder->getCollection()
345  );
346  $element = $manager->createContainerExport($this->il_user->getId(), $container_export_info);
347  }
348  $eo->delete();
349  }
static newInstance(int $a_export_id)
static _lookupObjId(int $ref_id)
$ref_id
Definition: ltiauth.php:65
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 ( )
finalprotected

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

Referenced by createXMLExportFile().

268  {
269  $manager = $this->export_handler->manager()->handler();
270  $export_info = $manager->getExportInfoWithObject(
271  $this->obj,
272  time()
273  );
274  $element = $manager->createExport(
275  $this->il_user->getId(),
276  $export_info,
277  ""
278  );
279  }
+ Here is the caller graph for this function:

◆ createXMLExportFile()

ilExportGUI::createXMLExportFile ( )
finalprotected

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

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

Referenced by executeCommand().

219  : void
220  {
221  if ($this->parent_gui instanceof ilContainerGUI) {
222  $this->showItemSelection();
223  return;
224  }
225  $this->createXMLExport();
226  $this->tpl->setOnScreenMessage(
228  $this->lng->txt("exp_file_created"),
229  true
230  );
231  $this->ctrl->redirect($this, self::CMD_LIST_EXPORT_FILES);
232  }
showItemSelection()
Show container item selection table.
Class ilContainerGUI This is a base GUI class for all container objects in ILIAS: root folder...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ displayExportFiles()

ilExportGUI::displayExportFiles ( )
finalprotected

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

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

Referenced by executeCommand(), and listExportFiles().

187  : void
188  {
189  if ($this->export_options->count() === 0) {
190  return;
191  }
192  $table = $this->export_handler->table()->handler()
193  ->withExportOptions($this->export_options)
194  ->withContext($this->context);
195  $table->handleCommands();
196  $infos = [];
197  foreach ($this->export_options as $export_option) {
198  $infos[$export_option->getLabel()] = $this->ctrl->getLinkTarget($this, $this->builtExportOptionCommand($export_option));
199  }
200  if (count($infos) === 1) {
201  $this->toolbar->addComponent($this->ui_services->factory()->button()->standard(
202  sprintf($this->lng->txt("exp_export_single_option"), array_keys($infos)[0]),
203  array_values($infos)[0]
204  ));
205  }
206  if (count($infos) > 1) {
207  $links = [];
208  foreach ($infos as $label => $link) {
209  $links[] = $this->ui_services->factory()->link()->standard($label, $link);
210  }
211  $this->toolbar->addComponent(
212  $this->ui_services->factory()->dropdown()->standard($links)
213  ->withLabel($this->lng->txt("exp_export_dropdown"))
214  );
215  }
216  $this->tpl->setContent($table->getHTML());
217  }
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 169 of file class.ilExportGUI.php.

Referenced by __construct().

169  : void
170  {
171  $this->export_options = $this->export_options->withElement(new ilExportExportOptionXML());
172  }
+ Here is the caller graph for this function:

◆ executeCommand()

ilExportGUI::executeCommand ( )

Definition at line 89 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.

89  : void
90  {
91  // this should work (at least) for repository objects
92  if (method_exists($this->obj, 'getRefId') and $this->obj->getRefId()) {
93  if (!$this->access->checkAccess('write', '', $this->obj->getRefId())) {
94  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->WARNING);
95  }
96  // check export activation of container
97  $exp_limit = new ilExportLimitation();
98  if ($this->obj_definition->isContainer(ilObject::_lookupType($this->obj->getRefId(), true)) &&
99  $exp_limit->getLimitationMode() == ilExportLimitation::SET_EXPORT_DISABLED) {
100  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("exp_error_disabled"));
101  return;
102  }
103  }
104  $cmd = $this->ctrl->getCmd(self::CMD_LIST_EXPORT_FILES);
105  if (str_starts_with($cmd, self::CMD_EXPORT_OPTION_PREFIX)) {
106  foreach ($this->export_options as $export_option) {
107  if ($cmd === $this->builtExportOptionCommand($export_option)) {
108  $export_option->onExportOptionSelected($this->context);
109  }
110  }
111  }
112  switch ($cmd) {
113  case self::CMD_EXPORT_XML:
114  $this->createXMLExportFile();
115  break;
116  case self::CMD_SAVE_ITEM_SELECTION:
117  $this->saveItemSelection();
118  break;
119  case self::CMD_LIST_EXPORT_FILES:
120  default:
121  $this->displayExportFiles();
122  break;
123  }
124  }
builtExportOptionCommand(ilExportHandlerConsumerExportOptionInterface $export_option)
Export limitation checker.
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ getFormats()

ilExportGUI::getFormats ( )

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

142  : array
143  {
144  return [];
145  }

◆ initExportOptions()

ilExportGUI::initExportOptions ( )
finalprotected

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

Referenced by __construct().

174  : void
175  {
176  $export_options = $this->export_handler->consumer()->exportOption()->allExportOptions();
177  foreach ($export_options as $export_option) {
178  if (
179  in_array($this->obj->getType(), $export_option->getSupportedRepositoryObjectTypes()) and
180  $export_option->isObjectSupported($this->data_factory->objId($this->obj->getId()))
181  ) {
182  $this->export_options = $this->export_options->withElement($export_option);
183  }
184  }
185  }
ilExportHandlerConsumerExportOptionCollectionInterface $export_options
+ Here is the caller graph for this function:

◆ initExportOptionsFromPost()

ilExportGUI::initExportOptionsFromPost ( )
finalprotected

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

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

Referenced by createXMLContainerExport(), and saveItemSelection().

147  : array
148  {
149  $options = [];
150  if ($this->http->wrapper()->post()->has('cp_options')) {
151  $custom_transformer = $this->refinery->custom()->transformation(
152  function ($array) {
153  return $array;
154  }
155  );
156  $options = $this->http->wrapper()->post()->retrieve(
157  'cp_options',
158  $custom_transformer
159  );
160  }
161  return $options;
162  }
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:

◆ listExportFiles()

ilExportGUI::listExportFiles ( )

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

References displayExportFiles().

134  : void
135  {
136  $this->displayExportFiles();
137  }
+ Here is the call graph for this function:

◆ saveItemSelection()

ilExportGUI::saveItemSelection ( )
finalprotected

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

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

Referenced by executeCommand().

246  : void
247  {
248  // check export limitation
249  $cp_options = $this->initExportOptionsFromPost();
250  $exp_limit = new ilExportLimitation();
251  try {
252  $exp_limit->checkLimitation(
253  $this->parent_gui->getObject()->getRefId(),
254  $cp_options
255  );
256  } catch (Exception $e) {
257  $this->tpl->setOnScreenMessage('failure', $e->getMessage());
258  $this->showItemSelection();
259  return;
260  }
261  // create export
262  $this->createXMLContainerExport();
263  $this->tpl->setOnScreenMessage('success', $this->lng->txt('export_created'), true);
264  $this->ctrl->redirect($this, self::CMD_LIST_EXPORT_FILES);
265  }
showItemSelection()
Show container item selection table.
Export limitation checker.
+ 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 237 of file class.ilExportGUI.php.

Referenced by createXMLExportFile(), and saveItemSelection().

237  : void
238  {
239  $this->tpl->addJavaScript('assets/js/ilContainer.js');
240  $this->tpl->setVariable('BODY_ATTRIBUTES', 'onload="ilDisableChilds(\'cmd\');"');
241  $table = new ilExportSelectionTableGUI($this, self::CMD_LIST_EXPORT_FILES, $this->export_handler);
242  $table->parseContainer($this->parent_gui->getObject()->getRefId());
243  $this->tpl->setContent($table->getHTML());
244  }
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilExportGUI::$access
protected

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

Referenced by createXMLContainerExport().

◆ $context

ilExportHandlerConsumerContextInterface ilExportGUI::$context
protected

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

◆ $ctrl

ilCtrlInterface ilExportGUI::$ctrl
protected

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

◆ $data_factory

ilDataFactory ilExportGUI::$data_factory
protected

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

◆ $error

ilErrorHandling ilExportGUI::$error
protected

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

◆ $export_handler

ilExportHandler ilExportGUI::$export_handler
protected

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

◆ $export_options

ilExportHandlerConsumerExportOptionCollectionInterface ilExportGUI::$export_options
protected

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

◆ $http

ilHTTPServices ilExportGUI::$http
protected

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

◆ $il_user

ilObjUser ilExportGUI::$il_user
protected

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

◆ $lng

ilLanguage ilExportGUI::$lng
protected

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

◆ $obj

ilObject ilExportGUI::$obj
protected

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

◆ $obj_definition

ilObjectDefinition ilExportGUI::$obj_definition
protected

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

Referenced by createXMLContainerExport().

◆ $parent_gui

object ilExportGUI::$parent_gui
protected

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

◆ $refinery

ilRefineryFactory ilExportGUI::$refinery
protected

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

◆ $toolbar

ilToolbarGUI ilExportGUI::$toolbar
protected

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

◆ $tpl

ilGlobalTemplateInterface ilExportGUI::$tpl
protected

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

◆ $tree

ilTree ilExportGUI::$tree
protected

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

◆ $ui_services

ilUIServices ilExportGUI::$ui_services
protected

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

◆ CMD_EXPORT_OPTION_PREFIX

const ilExportGUI::CMD_EXPORT_OPTION_PREFIX = "exportOption"
protected

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

◆ CMD_EXPORT_XML

const ilExportGUI::CMD_EXPORT_XML = "createXmlExportFile"

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

◆ CMD_LIST_EXPORT_FILES

◆ CMD_SAVE_ITEM_SELECTION

const ilExportGUI::CMD_SAVE_ITEM_SELECTION = "saveItemSelection"
protected

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


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