ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTestPlayerLayoutProvider.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
36
45{
46 public const TEST_PLAYER_KIOSK_MODE_ENABLED = 'test_player_kiosk_mode_enabled';
47 public const TEST_PLAYER_TITLE = 'test_player_title';
48 public const TEST_PLAYER_VIEW_TITLE = 'test_player_view_title';
49 public const TEST_PLAYER_SHORT_TITLE = 'test_player_instance_name';
50 public const TEST_PLAYER_QUESTIONLIST = 'test_player_questionlist';
51
52 private const MODIFICATION_PRIORITY = 5; //slightly above "low"
53
55 {
56 return $this->context_collection->main();
57 }
58
59 protected function isKioskModeEnabled(CalledContexts $called_contexts): bool
60 {
61 return $called_contexts->current()->getAdditionalData()
62 ->is(self::TEST_PLAYER_KIOSK_MODE_ENABLED, true);
63 }
64
65 public function getMainBarModification(CalledContexts $called_contexts): ?MainBarModification
66 {
67 $mainbar = $this->globalScreen()->layout()->factory()->mainbar();
68 $has_question_list = $called_contexts->current()->getAdditionalData()
69 ->exists(self::TEST_PLAYER_QUESTIONLIST);
70
71 if (!$this->isKioskModeEnabled($called_contexts)) {
72 return null;
73 }
74
75 $mainbar_modification = static fn(?MainBar $mainbar): ?MainBar => null;
76 if ($has_question_list) {
77 $f = $this->dic->ui()->factory();
78 $r = $this->dic->ui()->renderer();
79 $lng = $this->dic->language();
80 $question_listing = $called_contexts->current()->getAdditionalData()->get(self::TEST_PLAYER_QUESTIONLIST);
81
82 $mainbar_modification = static function (?MainBar $mainbar) use ($f, $r, $lng, $question_listing): ?MainBar {
83 $mainbar = $mainbar->withClearedEntries();
84
85 $icon = $f->symbol()->icon()->standard('tst', $lng->txt("more"));
86 $tools_button = $f->button()->bulky($icon, $lng->txt("tools"), "#")
87 ->withEngagedState(true);
88
89 $question_listing = $f->legacy()->content($r->render($question_listing));
90
91 $label = $lng->txt('mainbar_button_label_questionlist');
92 $entry = $f->maincontrols()->slate()->legacy(
93 $label,
94 $f->symbol()->icon()->standard('tst', $label),
95 $question_listing
96 );
97
98 return $mainbar
99 ->withToolsButton($tools_button)
100 ->withAdditionalToolEntry('questionlist', $entry);
101 };
102 }
103
104 return $mainbar
105 ->withModification($mainbar_modification)
106 ->withPriority(self::MODIFICATION_PRIORITY);
107 }
108
110 {
111 if (!$this->isKioskModeEnabled($called_contexts)) {
112 return null;
113 }
114
115 return $this->globalScreen()->layout()->factory()->metabar()
116 ->withModification(
117 function (?MetaBar $current): ?MetaBar {
118 return null;
119 }
120 )->withPriority(self::MODIFICATION_PRIORITY);
121 }
122
123 public function getFooterModification(CalledContexts $called_contexts): ?FooterModification
124 {
125 if (!$this->isKioskModeEnabled($called_contexts)) {
126 return null;
127 }
128
129 return $this->globalScreen()->layout()->factory()->footer()
130 ->withModification(
131 function (?Footer $current): ?Footer {
132 return null;
133 }
134 )->withPriority(self::MODIFICATION_PRIORITY);
135 }
136
138 {
139 if (!$this->isKioskModeEnabled($called_contexts)) {
140 return null;
141 }
142
143 $title = $called_contexts->current()->getAdditionalData()->get(self::TEST_PLAYER_SHORT_TITLE);
144 if ($title === null) {
145 $title = '';
146 }
147 return $this->globalScreen()->layout()->factory()->short_title()
148 ->withModification(
149 function (?string $content) use ($title): ?string {
150 return $title;
151 }
152 )->withPriority(self::MODIFICATION_PRIORITY);
153 }
154
156 {
157 if (!$called_contexts->current()->getAdditionalData()->exists(self::TEST_PLAYER_VIEW_TITLE)) {
158 return null;
159 }
160
161 $title = $called_contexts->current()->getAdditionalData()->get(self::TEST_PLAYER_VIEW_TITLE);
162 if ($title === null) {
163 $title = '';
164 }
165 return $this->globalScreen()->layout()->factory()->view_title()
166 ->withModification(
167 function (?string $content) use ($title): ?string {
168 return $title;
169 }
170 )->withPriority(self::MODIFICATION_PRIORITY);
171 }
172
173 public function getTitleModification(CalledContexts $called_contexts): ?TitleModification
174 {
175 if (!$called_contexts->current()->getAdditionalData()->exists(self::TEST_PLAYER_TITLE)) {
176 return null;
177 }
178
179 $title = $called_contexts->current()->getAdditionalData()->get(self::TEST_PLAYER_TITLE);
180
181 if ($title == null) {
182 $title = '';
183 }
184
185 if ($title === '' && !$this->isKioskModeEnabled($called_contexts)) {
186 return null;
187 }
188
189 return $this->globalScreen()->layout()->factory()->view_title()
190 ->withModification(
191 function (?string $content) use ($title): ?string {
192 return $title;
193 }
194 )->withPriority(self::MODIFICATION_PRIORITY);
195 }
196
197 public function getLogoModification(CalledContexts $called_contexts): ?LogoModification
198 {
199 if (!$this->isKioskModeEnabled($called_contexts)) {
200 return null;
201 }
202 return $this->globalScreen()->layout()->factory()->logo()->withModification(
203 static function (?Image $logo): ?Image {
204 return $logo->withAction('');
205 }
206 )->withPriority(self::MODIFICATION_PRIORITY);
207 }
208}
getFooterModification(CalledContexts $called_contexts)
@inheritDoc
getMetaBarModification(CalledContexts $called_contexts)
@inheritDoc
getMainBarModification(CalledContexts $called_contexts)
@inheritDoc
isKioskModeEnabled(CalledContexts $called_contexts)
getViewTitleModification(CalledContexts $called_contexts)
@inheritDoc
getTitleModification(CalledContexts $called_contexts)
@inheritDoc
getShortTitleModification(CalledContexts $called_contexts)
@inheritDoc
getLogoModification(CalledContexts $called_contexts)
@inheritDoc
withAction($action)
Get an image like this with an action.
Definition: Image.php:125
This describes the MainBar.
Definition: MainBar.php:34
withClearedEntries()
Get a copy of this MainBar without any entries.
withToolsButton(Button\Bulky $button)
Set button for the tools-trigger.
This describes the MetaBar.
Definition: MetaBar.php:33
global $lng
Definition: privfeed.php:31