ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
EmbeddedApplicationGSProvider.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\WOPI\Embed;
22
39
44{
48 private const USE_METABAR = 1;
52 private const USE_MODE_INFO = 2;
54 public const EMBEDDED_APPLICATION = 'embedded_application';
56
57 public function __construct(Container $dic)
58 {
60 global $DIC;
61 $this->signal_generator = new SignalGenerator();
62 }
63
65 {
66 return $this->context_collection->repository();
67 }
68
69
70 public function getPageBuilderDecorator(CalledContexts $screen_context_stack): ?PageBuilderModification
71 {
72 if ($this->display_mode !== self::USE_MODE_INFO) {
73 return null;
74 }
75 if (!$screen_context_stack->current()->getAdditionalData()->exists(self::EMBEDDED_APPLICATION)) {
76 return null;
77 }
78 $embedded_application = $screen_context_stack->current()->getAdditionalData()->get(
79 self::EMBEDDED_APPLICATION
80 );
81 if (!$embedded_application instanceof EmbeddedApplication) {
82 return null;
83 }
84
85 return $this->factory->page()->withHighPriority()->withModification(
86 function (PagePartProvider $p) use ($embedded_application): Page {
87 $uif = $this->dic->ui()->factory();
88 $builder = new StandardPageBuilder();
89 $page_part_provider = new EmbeddedApplicationPagePartProvider(
90 $p,
91 $embedded_application
92 );
93
94 $back_to = $this->dic->ctrl()->getLinkTargetByClass(
95 \ilWOPIEmbeddedApplicationGUI::class,
97 );
98 $back_to = new URI(rtrim(ILIAS_HTTP_PATH, '/') . '/' . ltrim($back_to, './'));
100 $page = $builder->build($page_part_provider);
101 if (!$embedded_application->isInline()) {
102 $page = $page->withModeInfo(
103 $uif->mainControls()->modeInfo(
104 $this->dic->language()->txt('close_wopi_editor'),
105 $back_to
106 )
107 );
108 $page = $page->withSystemInfos([]);
109 }
110
111 return $page;
112 }
113 );
114 }
115
116 public function getMetaBarModification(CalledContexts $screen_context_stack): ?MetaBarModification
117 {
118 if ($this->display_mode !== self::USE_METABAR) {
119 return null;
120 }
121 if (!$screen_context_stack->current()->getAdditionalData()->exists(self::EMBEDDED_APPLICATION)) {
122 return null;
123 }
124
125 $embedded_application = $screen_context_stack->current()->getAdditionalData()->get(
126 self::EMBEDDED_APPLICATION
127 );
128 if (!$embedded_application instanceof EmbeddedApplication) {
129 return null;
130 }
131
132 if ($embedded_application->isInline()) {
133 return null;
134 }
135
136 $button = $this->buildCloseButton($embedded_application);
137
138 return $this->factory->metabar()->withHighPriority()->withModification(
139 fn(?MetaBar $metabar): ?Metabar => $metabar !== null
140 ? $metabar->withClearedEntries()
141 ->withAdditionalEntry(
142 'close_editor',
143 $button
144 )
145 : null
146 );
147 }
148
149 protected function buildCloseButton(
150 EmbeddedApplication $embedded_application,
151 ): Bulky {
152 $uif = $this->dic->ui()->factory();
153 $back_target = $embedded_application->getBackTarget();
154 $signal = $this->signal_generator->create();
155 $signal->addOption('target_url', (string) $back_target);
156 return $uif->button()->bulky(
157 $uif->symbol()->glyph()->close(),
158 $this->dic->language()->txt('close'),
159 (string) $back_target
160 )->withOnClick(
161 $signal
162 )->withOnLoadCode(fn($id): string => "il.WOPI.bindCloseSignal('$id', '{$signal->getId()}');");
163 }
164}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
factory()
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
buildCloseButton(EmbeddedApplication $embedded_application,)
getMetaBarModification(CalledContexts $screen_context_stack)
@inheritDoc
This describes a bulky button.
Definition: Bulky.php:29
This describes the Page.
Definition: Page.php:31
This describes the Page.
Definition: Standard.php:38
This describes the MetaBar.
Definition: MetaBar.php:33
withClearedEntries()
Get a copy of this MetaBar without any entries.
$dic
Definition: ltiresult.php:33
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26