ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLearningModuleExportOptionHTML.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25use ILIAS\Export\ExportHandler\I\Consumer\Context\HandlerInterface as ilExportHandlerConsumerContextInterface;
26use ILIAS\Export\ExportHandler\I\Consumer\File\Identifier\CollectionInterface as ilExportHandlerConsumerFileIdentifierCollectionInterface;
27use ILIAS\Export\ExportHandler\I\Consumer\File\Identifier\HandlerInterface as ilExportHandlerConsumerFileIdentifierInterface;
28use ILIAS\Export\ExportHandler\I\Info\File\CollectionInterface as ilExportHandlerFileInfoCollectionInterface;
30
32{
33 protected ilLanguage $lng;
34 protected ilCtrl $ctrl;
35 protected LOMServices $lom_services;
36
37 public function init(Container $DIC): void
38 {
40 $this->lng = $DIC->language();
41 $this->ctrl = $DIC->ctrl();
42 $this->lom_services = $DIC->learningObjectMetadata();
43 }
44
45 public function isPublicAccessPossible(): bool
46 {
47 return true;
48 }
49
50 public function getExportType(): string
51 {
52 return "html";
53 }
54
55 public function getExportOptionId(): string
56 {
57 return "lm_exp_option_html";
58 }
59
60 public function getSupportedRepositoryObjectTypes(): array
61 {
62 return ["lm"];
63 }
64
65 public function getLabel(): string
66 {
67 $this->lng->loadLanguageModule('exp');
68 return $this->lng->txt("exp_format_dropdown-html");
69 }
70
71 public function getFileSelection(
72 ilExportHandlerConsumerContextInterface $context,
73 ilExportHandlerConsumerFileIdentifierCollectionInterface $file_identifiers
74 ): ilExportHandlerFileInfoCollectionInterface {
75 $collection_builder = $context->fileCollectionBuilder();
76 $file_identifiers_array = $file_identifiers->toStringArray();
77 foreach ($this->getFiles($context) as $file) {
78 if (in_array($file->getFileIdentifier(), $file_identifiers_array)) {
79 $collection_builder = $collection_builder->withFileInfo($file);
80 }
81 }
82 return $collection_builder->collection();
83 }
84
85 public function onExportOptionSelected(
86 ilExportHandlerConsumerContextInterface $context
87 ): void {
88 $this->ctrl->redirectByClass(ilObjContentObjectGUI::class, "showExportOptionsHTML");
89 }
90
91 protected function getSubDirs(int $object_id): array
92 {
93 $langs = [];
94 foreach ($this->lom_services->dataHelper()->getAllLanguages() as $language) {
95 $langs[] = $language->value();
96 }
97 $default_dirs = ["_html"];
98 $default_dirs = array_merge($default_dirs, ["_html_all"]);
99 return array_merge($default_dirs, array_map(function ($la) { return "_html_" . $la; }, $langs));
100 }
101}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
language()
Get interface to the i18n service.
Definition: Container.php:95
ctrl()
Get the interface to the control structure.
Definition: Container.php:63
getFiles(ilExportHandlerConsumerContextInterface $context)
Class ilCtrl provides processing control methods.
language handling
getFileSelection(ilExportHandlerConsumerContextInterface $context, ilExportHandlerConsumerFileIdentifierCollectionInterface $file_identifiers)
onExportOptionSelected(ilExportHandlerConsumerContextInterface $context)
Class ilObjContentObjectGUI.
global $DIC
Definition: shib_login.php:26
$context
Definition: webdav.php:31