ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilHTLMExportOptionHTML.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 use ILIAS\Export\ExportHandler\I\Consumer\Context\HandlerInterface as ilExportHandlerConsumerContextInterface;
28 
29 class ilHTLMExportOptionHTML extends ilLegacyExportOption
30 {
31  protected ilCtrl $ctrl;
32  protected ilLanguage $lng;
33  protected IRSS $irss;
34  protected Filesystem $storage;
35 
36  public function init(Container $DIC): void
37  {
38  $this->ctrl = $DIC->ctrl();
39  $this->lng = $DIC->language();
40  $this->irss = $DIC->resourceStorage();
41  $this->storage = $DIC->filesystem()->storage();
42  parent::init($DIC);
43  }
44 
45  public function getExportType(): string
46  {
47  return "html";
48  }
49 
50  public function getExportOptionId(): string
51  {
52  return "htlm_exp_option_html";
53  }
54 
55  public function getSupportedRepositoryObjectTypes(): array
56  {
57  return ["htlm"];
58  }
59 
60  public function getLabel(): string
61  {
62  $this->lng->loadLanguageModule('exp');
63  return $this->lng->txt("exp_format_dropdown-html");
64  }
65 
66  public function onExportOptionSelected(
67  ilExportHandlerConsumerContextInterface $context
68  ): void {
69  $object = $context->exportObject();
70 
72  $object->getId(),
73  "html",
74  $object->getType()
75  );
76  $export_dir = ilExport::_getExportDirectory(
77  $object->getId(),
78  "html",
79  $object->getType()
80  );
81 
82  // write files as zip to legacy storage
83  $date = time();
84  $zip_file = LegacyPathHelper::createRelativePath(
85  $export_dir . "/" . $date . "__" . IL_INST_ID . "__" .
86  $object->getType() . "_" . $object->getId() . ".zip"
87  );
88 
89  $stream = $this->irss->consume()->stream($object->getResource()->getIdentification())->getStream();
90  $this->storage->writeStream($zip_file, $stream);
91 
92  $this->ctrl->redirect($context->exportGUIObject(), $context->exportGUIObject()::CMD_LIST_EXPORT_FILES);
93  }
94 }
$context
Definition: webdav.php:31
const IL_INST_ID
Definition: constants.php:40
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getExportDirectory(int $a_obj_id, string $a_type="xml", string $a_obj_type="", string $a_entity="")
Get export directory for an repository object
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
onExportOptionSelected(ilExportHandlerConsumerContextInterface $context)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _createExportDirectory(int $a_obj_id, string $a_export_type="xml", string $a_obj_type="")
global $DIC
Definition: shib_login.php:26
language()
Get interface to the i18n service.
Definition: Container.php:95
filesystem()
Get the Filesystem service interface.
Definition: Container.php:144
ctrl()
Get the interface to the control structure.
Definition: Container.php:63