ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilWikiExportOptionHTMLWithComments.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
24 use ILIAS\Export\ExportHandler\I\Consumer\Context\HandlerInterface as ilExportHandlerConsumerContextInterface;
26 use ILIAS\Export\ExportHandler\I\Info\File\CollectionInterface as ilExportHandlerFileInfoCollectionInterface;
27 use ILIAS\Export\ExportHandler\I\Consumer\File\Identifier\CollectionInterface as ilExportHandlerConsumerFileIdentifierCollectionInterface;
28 use ILIAS\Export\ExportHandler\I\Consumer\File\Identifier\HandlerInterface as ilExportHandlerConsumerFileIdentifierInterface;
30 
31 class ilWikiExportOptionHTMLWithComments extends ilBasicLegacyExportOption
32 {
33  protected ilLanguage $lng;
34 
35  public function init(Container $DIC): void
36  {
37  $this->lng = $DIC->language();
38  parent::init($DIC);
39  }
40 
41  public function getExportType(): string
42  {
43  return 'html_comments';
44  }
45 
46  public function getExportOptionId(): string
47  {
48  return 'wiki_exp_option_html_with_comments';
49  }
50 
51  public function getSupportedRepositoryObjectTypes(): array
52  {
53  return ['wiki'];
54  }
55 
56  public function getLabel(): string
57  {
58  $this->lng->loadLanguageModule('exp');
59  return $this->lng->txt("exp_format_dropdown-html") . " (" . $this->lng->txt("wiki_incl_comments") . ")";
60  }
61 
62  public function isObjectSupported(ObjectId $object_id): bool
63  {
64  try {
65  return (
66  ilObjWiki::_exists($object_id->toInt()) and
67  (new ilObjWiki($object_id->toInt(), false))->isCommentsExportPossible()
68  );
69  } catch (ilObjectTypeMismatchException $exception) {
70  return false;
71  }
72  }
73 
74  public function onExportOptionSelected(ilExportHandlerConsumerContextInterface $context): void
75  {
77  $wiki = $context->exportObject();
78  $cont_exp = new WikiHtmlExport($wiki);
79  $cont_exp->setMode(WikiHtmlExport::MODE_COMMENTS);
80  $cont_exp->buildExportFile();
81  $this->ctrl->redirectByClass(ilExportGUI::class, ilExportGUI::CMD_LIST_EXPORT_FILES);
82  }
83 }
$context
Definition: webdav.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Wiki HTML exporter class.
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:22
language()
Get interface to the i18n service.
Definition: Container.php:95
const CMD_LIST_EXPORT_FILES