ILIAS  release_8 Revision v8.24
class.ilWebDAVMountInstructionsModalGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
24
26{
27 private const MOUNT_INSTRUCTIONS_CONTENT_ID = 'webdav_mount_instructions_content';
28
32 protected ilLanguage $lng;
34
36 {
37 $this->repository = $repository;
38 $this->ui_factory = $ui_factory;
39 $this->ui_renderer = $ui_renderer;
40 $this->lng = $lng;
41
42 try {
43 $document = $this->repository->getMountInstructionsByLanguage($this->lng->getUserLanguage());
44 $title = $document->getTitle();
45 } catch (InvalidArgumentException $e) {
46 $title = $this->lng->txt('webfolder_instructions_titletext');
47 }
48
49 $content_div = '<div id="' . self::MOUNT_INSTRUCTIONS_CONTENT_ID . '"></div>';
50 $page = $this->ui_factory->modal()->lightboxTextPage($content_div, $title);
51 $this->modal = $this->ui_factory->modal()->lightbox($page);
52 }
53
54 private function getRenderedModal(): string
55 {
56 return $this->ui_renderer->render($this->modal);
57 }
58
59 private function getModalShowSignalId(): string
60 {
61 return $this->modal->getShowSignal()->getId();
62 }
63
64 private static bool $modal_already_rendered = false;
65
66 public static function maybeRenderWebDAVModalInGlobalTpl(): void
67 {
68 if (self::$modal_already_rendered) {
69 return;
70 }
71
72 global $DIC;
74 $instance = new ilWebDAVMountInstructionsModalGUI($repository, $DIC->ui()->factory(), $DIC->ui()->renderer(), $DIC->language());
75
76 self::$modal_already_rendered = true;
77 $js_function = '<script>function triggerWebDAVModal(api_url){ $.ajax(api_url).done(function(data){ $(document).trigger("' . $instance->getModalShowSignalId() . '", "{}"); $("#' . self::MOUNT_INSTRUCTIONS_CONTENT_ID . '").html(data);}) }</script>';
78
79 $webdav_modal_html = $instance->getRenderedModal() . $js_function;
80
81 $tpl = $DIC->ui()->mainTemplate();
82 $tpl->setVariable('WEBDAV_MODAL', $webdav_modal_html);
83 }
84}
language handling
ilWebDAVMountInstructionsRepositoryImpl $repository
__construct(ilWebDAVMountInstructionsRepositoryImpl $repository, Factory $ui_factory, Renderer $ui_renderer, ilLanguage $lng)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
This is how the factory for UI elements looks.
Definition: Factory.php:38
An entity that renders components to a string output.
Definition: Renderer.php:31
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
modal()
This second example shows a scenario in which the Close Button is used in an overlay as indicated in ...
Definition: modal.php:12