19declare(strict_types=1);
60 protected ilExportHandlerConsumerContextInterface
$context;
69 bool $default_export_option_enabled =
true
72 $this->ui_services =
$DIC->ui();
73 $this->
http = $DIC->http();
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();
93 if ($default_export_option_enabled) {
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);
114 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"exp_error_disabled"));
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) {
122 $export_option->onExportOptionSelected($this->context);
164 if ($this->
http->wrapper()->post()->has(
'cp_options')) {
165 $custom_transformer = $this->
refinery->custom()->transformation(
170 $options = $this->
http->wrapper()->post()->retrieve(
180 return self::CMD_EXPORT_OPTION_PREFIX . $export_option->getExportOptionId();
190 $export_options = $this->export_handler->consumer()->exportOption()->allExportOptions();
193 in_array($this->obj->getType(), $export_option->getSupportedRepositoryObjectTypes()) and
194 $export_option->isObjectSupported($this->data_factory->objId($this->obj->getId()))
196 $this->export_options = $this->export_options->withElement($export_option);
203 if ($this->export_options->count() === 0) {
206 $table = $this->export_handler->table()->handler()
207 ->withExportOptions($this->export_options)
208 ->withContext($this->context)
210 $table->handleCommands();
212 foreach ($this->export_options as $export_option) {
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]
221 if (count($infos) > 1) {
223 foreach ($infos as $label => $link) {
224 $links[] = $this->ui_services->factory()->link()->standard($label, $link);
227 $this->ui_services->factory()->dropdown()->standard($links)
228 ->withLabel($this->lng->txt(
"exp_export_dropdown"))
231 $this->tpl->setContent($table->getHTML());
240 $this->
createXMLExport($this->export_handler->consumer()->exportConfig()->allExportConfigs());
241 $this->tpl->setOnScreenMessage(
243 $this->
lng->txt(
"exp_file_created"),
246 $this->
ctrl->redirect($this, self::CMD_LIST_EXPORT_FILES);
254 $this->tpl->addJavaScript(
'assets/js/ilContainer.js');
255 $this->tpl->setVariable(
'BODY_ATTRIBUTES',
'onload="ilDisableChilds(\'cmd\');"');
257 $table->parseContainer($this->parent_gui->getObject()->getRefId());
258 $this->tpl->setContent($table->getHTML());
267 $exp_limit->checkLimitation(
268 $this->parent_gui->getObject()->getRefId(),
271 }
catch (Exception
$e) {
272 $this->tpl->setOnScreenMessage(
'failure',
$e->getMessage());
278 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'export_created'),
true);
279 $this->
ctrl->redirect($this, self::CMD_LIST_EXPORT_FILES);
283 ExportConfigCollectionInterface $export_configs
285 $manager = $this->export_handler->manager()->handler();
286 $manager->createExportOfObject($this->obj, $this->il_user->getId(), $export_configs);
291 $tree_nodes = $this->tree->getSubTree($this->tree->getNodeData($this->parent_gui->getObject()->getRefId()));
292 $post_export_options = $this->initExportOptionsFromPost();
295 $items_selected = $eo->addOptions(
296 $this->parent_gui->getObject()->getRefId(),
297 $this->obj_definition,
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) {
310 $export_option_id = (
int)
$info[
"type"];
314 !$this->
access->checkAccess(
'write',
'', $ref_id)
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);
333 if (count($ref_ids_all) > 1) {
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)
343 $container_export_info = $manager->getContainerExportInfo(
344 $this->data_factory->objId($obj_ids_all[0]),
345 $object_id_collection_builder->getCollection(),
348 $element = $manager->createContainerExport($this->il_user->getId(), $container_export_info);
Provides fluid interface to RBAC services.
Class ilContainerGUI This is a base GUI class for all container objects in ILIAS: root folder,...
Error Handling & global info handling.
Export User Interface Class.
ilRefineryFactory $refinery
bool $public_access_enabled
createXMLContainerExport()
ilDataFactory $data_factory
initExportOptionsFromPost()
const CMD_SAVE_ITEM_SELECTION
enableStandardXMLExport()
ilExportHandlerConsumerExportOptionCollectionInterface $export_options
ilExportHandler $export_handler
showItemSelection()
Show container item selection table.
builtExportOptionCommand(ilExportHandlerConsumerExportOptionInterface $export_option)
ilUIServices $ui_services
__construct(object $a_parent_gui, ?ilObject $a_main_obj=null, bool $public_access_enabled=true, bool $default_export_option_enabled=true)
const CMD_EXPORT_OPTION_PREFIX
const CMD_LIST_EXPORT_FILES
ilExportHandlerConsumerContextInterface $context
ilGlobalTemplateInterface $tpl
ilObjectDefinition $obj_definition
createXMLExport(ExportConfigCollectionInterface $export_configs)
Export limitation checker.
const SET_EXPORT_DISABLED
static newInstance(int $a_export_id)
static allocateExportId()
Object selection for export.
parses the objects.xml it handles the xml-description of all ilias objects
Class ilObject Basic functions for all objects.
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
const MESSAGE_TYPE_SUCCESS
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.