diff --git a/components/ILIAS/OrgUnit/classes/class.ilOrgUnitExportGUI.php b/components/ILIAS/OrgUnit/classes/class.ilOrgUnitExportGUI.php index 2a836512f842..712ddaadf81e 100755 --- a/components/ILIAS/OrgUnit/classes/class.ilOrgUnitExportGUI.php +++ b/components/ILIAS/OrgUnit/classes/class.ilOrgUnitExportGUI.php @@ -46,11 +46,19 @@ public function __construct(ilObjOrgUnitGUI $a_parent_gui, /*null|ilObject|ilObj $this->ui_factory = $DIC['ui.factory']; $this->ilObjOrgUnit = $a_parent_gui->getObject(); + } - if ($this->ilObjOrgUnit->getRefId() === ilObjOrgUnit::getRootOrgRefId()) { - //Simple XML and Simple XLS Export should only be available in the root orgunit folder as it always exports the whole tree - $this->extendExportGUI(); + public function executeCommand(): void + { + $cmd = $this->ctrl->getCmd(); + if ( + $cmd === "simpleExport" || + $cmd === "simpleExportExcel" + ) { + $this->$cmd(); + return; } + parent::executeCommand(); } public function listExportFiles(): void @@ -60,22 +68,6 @@ public function listExportFiles(): void } } - private function extendExportGUI(): void - { - $this->toolbar->addComponent( - $this->ui_factory->link()->standard( - $this->lng->txt('simple_xml'), - $this->ctrl->getLinkTarget($this, "simpleExport") - ) - ); - $this->toolbar->addComponent( - $this->ui_factory->link()->standard( - $this->lng->txt('simple_xls'), - $this->ctrl->getLinkTarget($this, "simpleExportExcel") - ) - ); - } - public function simpleExport(): void { $ilOrgUnitExporter = new ilOrgUnitExporter(); diff --git a/components/ILIAS/OrgUnit/classes/class.ilOrgUnitExportOptionXLS.php b/components/ILIAS/OrgUnit/classes/class.ilOrgUnitExportOptionXLS.php new file mode 100644 index 000000000000..494a1295387e --- /dev/null +++ b/components/ILIAS/OrgUnit/classes/class.ilOrgUnitExportOptionXLS.php @@ -0,0 +1,107 @@ +lng = $DIC->language(); + $this->ctrl = $DIC->ctrl(); + } + + public function getExportType(): string + { + return "simple xls"; + } + + public function getExportOptionId(): string + { + return "orgu_exp_option_simple_xls"; + } + + public function getSupportedRepositoryObjectTypes(): array + { + return ["orgu"]; + } + + public function getLabel(): string + { + return $this->lng->txt('simple_xls'); + } + + public function isObjectSupported(ObjectId $object_id): bool + { + //Simple XML and Simple XLS Export should only be available in the root orgunit folder as it always exports the whole tree + return $object_id->toInt() === ilObjOrgUnit::getRootOrgId(); + } + + public function onExportOptionSelected(ilExportHandlerConsumerContextInterface $context): void + { + $this->ctrl->redirect($context->exportGUIObject(), "simpleExportExcel"); + } + + public function onDeleteFiles( + ilExportHandlerConsumerContextInterface $context, + ilExportHandlerConsumerFileIdentifierCollectionInterface $file_identifiers + ): void { + # Direct download on export creation, no local files + } + + public function onDownloadFiles( + ilExportHandlerConsumerContextInterface $context, + ilExportHandlerConsumerFileIdentifierCollectionInterface $file_identifiers + ): void { + # Direct download on export creation, no local files + } + + public function onDownloadWithLink( + ReferenceId $reference_id, + ilExportHandlerConsumerFileIdentifierInterface $file_identifier + ): void { + # Direct download on export creation, no local files + } + + public function getFiles( + ilExportHandlerConsumerContextInterface $context + ): ilExportHandlerFileInfoCollectionInterface { + # Direct download on export creation, no local files + return $context->fileCollectionBuilder()->collection(); + } + + public function getFileSelection( + ilExportHandlerConsumerContextInterface $context, + ilExportHandlerConsumerFileIdentifierCollectionInterface $file_identifiers + ): ilExportHandlerFileInfoCollectionInterface { + # Direct download on export creation, no local files + return $context->fileCollectionBuilder()->collection(); + } +} diff --git a/components/ILIAS/OrgUnit/classes/class.ilOrgUnitExportOptionXML.php b/components/ILIAS/OrgUnit/classes/class.ilOrgUnitExportOptionXML.php new file mode 100644 index 000000000000..bed7947c1e8d --- /dev/null +++ b/components/ILIAS/OrgUnit/classes/class.ilOrgUnitExportOptionXML.php @@ -0,0 +1,107 @@ +lng = $DIC->language(); + $this->ctrl = $DIC->ctrl(); + } + + public function getExportType(): string + { + return "simple xml"; + } + + public function getExportOptionId(): string + { + return "orgu_exp_option_simple_xml"; + } + + public function getSupportedRepositoryObjectTypes(): array + { + return ["orgu"]; + } + + public function isObjectSupported(ObjectId $object_id): bool + { + //Simple XML and Simple XLS Export should only be available in the root orgunit folder as it always exports the whole tree + return $object_id->toInt() === ilObjOrgUnit::getRootOrgId(); + } + + public function getLabel(): string + { + return $this->lng->txt('simple_xml'); + } + + public function onExportOptionSelected(ilExportHandlerConsumerContextInterface $context): void + { + $this->ctrl->redirect($context->exportGUIObject(), "simpleExport"); + } + + public function onDeleteFiles( + ilExportHandlerConsumerContextInterface $context, + ilExportHandlerConsumerFileIdentifierCollectionInterface $file_identifiers + ): void { + # Direct download on export creation, no local files + } + + public function onDownloadFiles( + ilExportHandlerConsumerContextInterface $context, + ilExportHandlerConsumerFileIdentifierCollectionInterface $file_identifiers + ): void { + # Direct download on export creation, no local files + } + + public function onDownloadWithLink( + ReferenceId $reference_id, + ilExportHandlerConsumerFileIdentifierInterface $file_identifier + ): void { + # Direct download on export creation, no local files + } + + public function getFiles( + ilExportHandlerConsumerContextInterface $context + ): ilExportHandlerFileInfoCollectionInterface { + # Direct download on export creation, no local files + return $context->fileCollectionBuilder()->collection(); + } + + public function getFileSelection( + ilExportHandlerConsumerContextInterface $context, + ilExportHandlerConsumerFileIdentifierCollectionInterface $file_identifiers + ): ilExportHandlerFileInfoCollectionInterface { + # Direct download on export creation, no local files + return $context->fileCollectionBuilder()->collection(); + } +}