ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Renderer.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2018 Thomas Famula <famula@leifos.de> Extended GPL, see docs/LICENSE */
4
6
8use ILIAS\UI\Renderer as RendererInterface;
10
16{
20 public function render(Component\Component $component, RendererInterface $default_renderer)
21 {
22 $ui_fac = $this->getUIFactory();
23
24 // @todo: workaround for tests... there should be a better way...
25 if ($ui_fac instanceof \NoUIFactory) {
26 $ui_fac = new \ILIAS\UI\Implementation\Factory();
27 }
28
32 $this->checkComponent($component);
33 $tpl = $this->getTemplate("tpl.messagebox.html", true, true);
34
35
36 $buttons = $component->getButtons();
37 if (count($buttons) > 0) {
38 $tpl->setCurrentBlock("buttons");
39 $tpl->setVariable("BUTTONS", $default_renderer->render($buttons));
40 $tpl->parseCurrentBlock();
41 }
42
43 $tpl->setCurrentBlock("message_box");
44
45 $tpl->setVariable("MESSAGE_TEXT", $component->getMessageText());
46 $tpl->setVariable("ACC_TEXT", $this->txt($component->getType() . "_message"));
47
48
49 $links = $component->getLinks();
50 if (count($links) > 0) {
51 $unordered = $ui_fac->listing()->unordered(
52 $links
53 );
54
55 $tpl->setVariable("LINK_LIST", $default_renderer->render($unordered));
56 }
57
58 $tpl->touchBlock($component->getType() . "_class");
59
60 $tpl->parseCurrentBlock();
61
62 return $tpl->get();
63 }
64
65 protected function getComponentInterfaceName()
66 {
67 return array(Component\MessageBox\MessageBox::class);
68 }
69}
$tpl
Definition: ilias.php:10
An exception for terminatinating execution or to throw for unit testing.
getComponentInterfaceName()
Get the name of the component-interface this renderer is supposed to render.
Definition: Renderer.php:65
getTemplate($name, $purge_unfilled_vars, $purge_unused_blocks)
Get template of component this renderer is made for.
checkComponent(Component $component)
Check if a given component fits this renderer and throw \LogicError if that is not the case.
$links
A component is the most general form of an entity in the UI.
Definition: Component.php:14
render(Component $component, Renderer $default_renderer)
Render the component if possible and delegate additional rendering to the default_renderer.
An entity that renders components to a string output.
Definition: Renderer.php:15