ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilLearningModuleExportOptionHTML.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 use ILIAS\Export\ExportHandler\I\Consumer\Context\HandlerInterface as ilExportHandlerConsumerContextInterface;
26 use ILIAS\Export\ExportHandler\I\Consumer\File\Identifier\CollectionInterface as ilExportHandlerConsumerFileIdentifierCollectionInterface;
27 use ILIAS\Export\ExportHandler\I\Consumer\File\Identifier\HandlerInterface as ilExportHandlerConsumerFileIdentifierInterface;
28 use ILIAS\Export\ExportHandler\I\Info\File\CollectionInterface as ilExportHandlerFileInfoCollectionInterface;
30 
31 class ilLearningModuleExportOptionHTML extends \ILIAS\Export\HTML\ExportOptionBase
32 {
33  protected ilLanguage $lng;
34  protected ilCtrl $ctrl;
36 
37  public function init(Container $DIC): void
38  {
39  parent::init($DIC);
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 }
$context
Definition: webdav.php:31
getFileSelection(ilExportHandlerConsumerContextInterface $context, ilExportHandlerConsumerFileIdentifierCollectionInterface $file_identifiers)
onExportOptionSelected(ilExportHandlerConsumerContextInterface $context)
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
getFiles(ilExportHandlerConsumerContextInterface $context)
global $DIC
Definition: shib_login.php:26
language()
Get interface to the i18n service.
Definition: Container.php:95
ctrl()
Get the interface to the control structure.
Definition: Container.php:63