ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
PromptContextRenderer.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
26 
32 {
36  public function render(Component\Component $component, RendererInterface $default_renderer): string
37  {
38  $ui_fac = $this->getUIFactory();
39 
40  if (!$component instanceof Component\MessageBox\MessageBox) {
41  $this->cannotHandleComponent($component);
42  }
43 
44  $tpl = $this->getTemplate("tpl.messagebox.html", true, true);
45  $tpl->setCurrentBlock("message_box");
46 
47  $tpl->setVariable("MESSAGE_TEXT", $component->getMessageText());
48  $tpl->setVariable("ACC_TEXT", $this->txt($component->getType() . "_message"));
49  if ($component->getType() == Component\MessageBox\MessageBox::FAILURE) {
50  $tpl->setVariable("ROLE", "alert");
51  } else {
52  $tpl->setVariable("ROLE", "status");
53  }
54 
55 
56  $links = $component->getLinks();
57  if (count($links) > 0) {
58  $unordered = $ui_fac->listing()->unordered(
59  $links
60  );
61 
62  $tpl->setVariable("LINK_LIST", $default_renderer->render($unordered));
63  }
64 
65  $tpl->touchBlock($component->getType() . "_class");
66 
67  $tpl->parseCurrentBlock();
68 
69  return $tpl->get();
70  }
71 }
txt(string $id)
Get a text from the language file.
render(Component\Component $component, RendererInterface $default_renderer)
getTemplate(string $name, bool $purge_unfilled_vars, bool $purge_unused_blocks)
Get template of component this renderer is made for.
cannotHandleComponent(Component $component)
This method MUST be called by derived component renderers, if.