ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
Renderer.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 
26 
32 {
36  public function render(Component\Component $component, RendererInterface $default_renderer): string
37  {
38  if (!$component instanceof Component\MessageBox\MessageBox) {
39  $this->cannotHandleComponent($component);
40  }
41 
42  $ui_fac = $this->getUIFactory();
43  $tpl = $this->getTemplate("tpl.messagebox.html", true, true);
44 
45  $buttons = $component->getButtons();
46  if (count($buttons) > 0) {
47  $tpl->setCurrentBlock("buttons");
48  $tpl->setVariable("BUTTONS", $default_renderer->render($buttons));
49  $tpl->parseCurrentBlock();
50  }
51 
52  $tpl->setCurrentBlock("message_box");
53 
54  $tpl->setVariable("MESSAGE_TEXT", $component->getMessageText());
55  $tpl->setVariable("ACC_TEXT", $this->txt($component->getType() . "_message"));
56  if ($component->getType() == Component\MessageBox\MessageBox::FAILURE) {
57  $tpl->setVariable("ROLE", "alert");
58  } else {
59  $tpl->setVariable("ROLE", "status");
60  }
61 
62 
63  $links = $component->getLinks();
64  if (count($links) > 0) {
65  $unordered = $ui_fac->listing()->unordered(
66  $links
67  );
68 
69  $tpl->setVariable("LINK_LIST", $default_renderer->render($unordered));
70  }
71 
72  $tpl->touchBlock($component->getType() . "_class");
73 
74  $tpl->parseCurrentBlock();
75 
76  return $tpl->get();
77  }
78 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
txt(string $id)
Get a text from the language file.
render(Component\Component $component, RendererInterface $default_renderer)
Definition: Renderer.php:36
getTemplate(string $name, bool $purge_unfilled_vars, bool $purge_unused_blocks)
Get template of component this renderer is made for.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21
cannotHandleComponent(Component $component)
This method MUST be called by derived component renderers, if.