ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 ($modal_submit_lable = $component->getModalSubmitLabel()) {
56 $modal = $modal->withSubmitLabel($modal_submit_lable);
57 }
58
59 if ($modal_cancel_label = $component->getModalCancelLabel()) {
60 $modal = $modal->withCancelButtonLabel($modal_cancel_label);
61 }
62
63 $tpl->setVariable("FORM", $default_renderer->render($modal));
64 $start_button = $start_button->withOnClick($modal->getShowSignal());
65 }
66
67 if (!$launchable) {
68 $start_button = $start_button->withUnavailableAction();
69 }
70 if ($status_icon = $component->getStatusIcon()) {
71 $tpl->setVariable("STATUS_ICON", $default_renderer->render($status_icon));
72 }
73 if ($status_message = $component->getStatusMessageBox()) {
74 $tpl->setVariable("STATUS_MESSAGE", $default_renderer->render($status_message));
75 }
76 $tpl->setVariable("DESCRIPTION", $component->getDescription());
77 $tpl->setVariable("BUTTON", $default_renderer->render($start_button));
78
79 return $tpl->get();
80 }
81}
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