ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
Renderer.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\UI\Renderer as RendererInterface;
26
28{
29 public function render(Component\Component $component, RendererInterface $default_renderer): string
30 {
31 if ($component instanceof Inline) {
32 return $this->renderInline($component, $default_renderer);
33 }
34 $this->cannotHandleComponent($component);
35 }
36
37 public function renderInline(Inline $component, RendererInterface $default_renderer): string
38 {
39 if ($result = $component->getResult()) {
40 $f = $component->getEvaluation();
41 $f($result, $component);
42 }
43
44 $tpl = $this->getTemplate("tpl.launcher_inline.html", true, true);
45 $ui_factory = $this->getUIFactory();
46
47 $target = $component->getTarget()->getURL();
48 $label = $component->getButtonLabel();
49 $launchable = $component->isLaunchable();
50
51 $launch_glyph = $ui_factory->symbol()->glyph()->launch();
52 $start_button = $ui_factory->button()->bulky($launch_glyph, $label, (string) $target);
53
54 if ($modal = $component->getModal()) {
55 if ($result?->isError()) {
56 $modal = $modal->withOnLoad($modal->getShowSignal());
57 }
58
59 if ($modal_submit_lable = $component->getModalSubmitLabel()) {
60 $modal = $modal->withSubmitLabel($modal_submit_lable);
61 }
62
63 if ($modal_cancel_label = $component->getModalCancelLabel()) {
64 $modal = $modal->withCancelButtonLabel($modal_cancel_label);
65 }
66
67 $tpl->setVariable("FORM", $default_renderer->render($modal));
68 $start_button = $start_button->withOnClick($modal->getShowSignal());
69 }
70
71 if (!$launchable) {
72 $start_button = $start_button->withUnavailableAction();
73 }
74 if ($status_icon = $component->getStatusIcon()) {
75 $tpl->setVariable("STATUS_ICON", $default_renderer->render($status_icon));
76 }
77 if ($status_message = $component->getStatusMessageBox()) {
78 $tpl->setVariable("STATUS_MESSAGE", $default_renderer->render($status_message));
79 }
80 $tpl->setVariable("DESCRIPTION", $component->getDescription());
81 $tpl->setVariable("BUTTON", $default_renderer->render($start_button));
82
83 return $tpl->get();
84 }
85}
renderInline(Inline $component, RendererInterface $default_renderer)
Definition: Renderer.php:37
render(Component\Component $component, RendererInterface $default_renderer)
Definition: Renderer.php:29
cannotHandleComponent(Component $component)
This method MUST be called by derived component renderers, if.
getTemplate(string $name, bool $purge_unfilled_vars, bool $purge_unused_blocks)
Get template of component this renderer is made for.
An entity that renders components to a string output.
Definition: Renderer.php:31