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 
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 }
checkComponent(Component $component)
Check if a given component fits this renderer and throw if that is not the case. ...
$tpl
Definition: ilias.php:10
render(Component $component, Renderer $default_renderer)
Render the component if possible and delegate additional rendering to the default_renderer.
$links
getTemplate($name, $purge_unfilled_vars, $purge_unused_blocks)
Get template of component this renderer is made for.