ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 ()
 @depricated More...
 
 listExportFiles ()
 
 getFormats ()
 @depricated More...
 

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 @ilCtrl_Calls 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.

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) {
95 }
96 }
error(string $a_errmsg)
bool $public_access_enabled
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addFormat()

ilExportGUI::addFormat ( )

@depricated

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

143 : void
144 {
145
146 }

Referenced by ilCmiXapiExportGUI\__construct().

+ Here is the caller graph for this function:

◆ builtExportOptionCommand()

ilExportGUI::builtExportOptionCommand ( ilExportHandlerConsumerExportOptionInterface  $export_option)
finalprotected

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

178 : string
179 {
180 return self::CMD_EXPORT_OPTION_PREFIX . $export_option->getExportOptionId();
181 }

Referenced by displayExportFiles(), and executeCommand().

+ Here is the caller graph for this function:

◆ createXMLContainerExport()

ilExportGUI::createXMLContainerExport ( )
finalprotected

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

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

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

Referenced by saveItemSelection().

+ 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 282 of file class.ilExportGUI.php.

284 : void {
285 $manager = $this->export_handler->manager()->handler();
286 $manager->createExportOfObject($this->obj, $this->il_user->getId(), $export_configs);
287 }

Referenced by createXMLExportFile().

+ Here is the caller graph for this function:

◆ createXMLExportFile()

ilExportGUI::createXMLExportFile ( )
finalprotected

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

234 : void
235 {
236 if ($this->parent_gui instanceof ilContainerGUI) {
237 $this->showItemSelection();
238 return;
239 }
240 $this->createXMLExport($this->export_handler->consumer()->exportConfig()->allExportConfigs());
241 $this->tpl->setOnScreenMessage(
243 $this->lng->txt("exp_file_created"),
244 true
245 );
246 $this->ctrl->redirect($this, self::CMD_LIST_EXPORT_FILES);
247 }
Class ilContainerGUI This is a base GUI class for all container objects in ILIAS: root folder,...
showItemSelection()
Show container item selection table.
createXMLExport(ExportConfigCollectionInterface $export_configs)

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

Referenced by executeCommand().

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

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 $infos[$export_option->getLabel()] = $this->ctrl->getLinkTarget($this, $this->builtExportOptionCommand($export_option));
214 }
215 if (count($infos) === 1) {
216 $this->toolbar->addComponent($this->ui_services->factory()->button()->standard(
217 sprintf($this->lng->txt("exp_export_single_option"), array_keys($infos)[0]),
218 array_values($infos)[0]
219 ));
220 }
221 if (count($infos) > 1) {
222 $links = [];
223 foreach ($infos as $label => $link) {
224 $links[] = $this->ui_services->factory()->link()->standard($label, $link);
225 }
226 $this->toolbar->addComponent(
227 $this->ui_services->factory()->dropdown()->standard($links)
228 ->withLabel($this->lng->txt("exp_export_dropdown"))
229 );
230 }
231 $this->tpl->setContent($table->getHTML());
232 }
builtExportOptionCommand(ilExportHandlerConsumerExportOptionInterface $export_option)

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

Referenced by executeCommand(), and listExportFiles().

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

183 : void
184 {
185 $this->export_options = $this->export_options->withElement(new ilExportExportOptionXML());
186 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ executeCommand()

ilExportGUI::executeCommand ( )

Reimplemented in ilOrgUnitExportGUI.

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

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) {
128 $this->createXMLExportFile();
129 break;
131 $this->saveItemSelection();
132 break;
134 default:
135 $this->displayExportFiles();
136 break;
137 }
138 }
const CMD_SAVE_ITEM_SELECTION
const CMD_LIST_EXPORT_FILES
Export limitation checker.

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

+ Here is the call graph for this function:

◆ getFormats()

ilExportGUI::getFormats ( )

@depricated

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.

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

References $export_options.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ initExportOptionsFromPost()

ilExportGUI::initExportOptionsFromPost ( )
finalprotected

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

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 }

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

Referenced by saveItemSelection().

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

98 : bool
99 {
101 }

References $public_access_enabled.

Referenced by displayExportFiles().

+ Here is the caller graph for this function:

◆ listExportFiles()

ilExportGUI::listExportFiles ( )

Reimplemented in ilOrgUnitExportGUI.

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

148 : void
149 {
150 $this->displayExportFiles();
151 }

References displayExportFiles().

+ Here is the call graph for this function:

◆ saveItemSelection()

ilExportGUI::saveItemSelection ( )
finalprotected

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

261 : void
262 {
263 // check export limitation
264 $cp_options = $this->initExportOptionsFromPost();
265 $exp_limit = new ilExportLimitation();
266 try {
267 $exp_limit->checkLimitation(
268 $this->parent_gui->getObject()->getRefId(),
269 $cp_options
270 );
271 } catch (Exception $e) {
272 $this->tpl->setOnScreenMessage('failure', $e->getMessage());
273 $this->showItemSelection();
274 return;
275 }
276 // create export
278 $this->tpl->setOnScreenMessage('success', $this->lng->txt('export_created'), true);
279 $this->ctrl->redirect($this, self::CMD_LIST_EXPORT_FILES);
280 }

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

Referenced by executeCommand().

+ 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 252 of file class.ilExportGUI.php.

252 : void
253 {
254 $this->tpl->addJavaScript('assets/js/ilContainer.js');
255 $this->tpl->setVariable('BODY_ATTRIBUTES', 'onload="ilDisableChilds(\'cmd\');"');
256 $table = new ilExportSelectionTableGUI($this, self::CMD_LIST_EXPORT_FILES, $this->export_handler);
257 $table->parseContainer($this->parent_gui->getObject()->getRefId());
258 $this->tpl->setContent($table->getHTML());
259 }

Referenced by createXMLExportFile(), and saveItemSelection().

+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilExportGUI::$access
protected

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

◆ $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.

Referenced by initExportOptions().

◆ $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.

◆ $parent_gui

object ilExportGUI::$parent_gui
protected

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

Referenced by ilTestExportGUI\__construct().

◆ $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.

Referenced by executeCommand().

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

Referenced by executeCommand().


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