ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
Renderer.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 
26 
28 {
32  public function render(Component\Component $component, RendererInterface $default_renderer): string
33  {
34  $this->checkComponent($component);
35 
36  $tpl = $this->getTemplate("tpl.scale_bar.html", true, true);
37 
38  $items = $component->getItems();
39  if (count($items) == 0) {
40  return "";
41  }
42 
43  $width = str_replace(",", ".", (string) round(100 / count($items), 5));
44 
45  foreach ($component->getItems() as $txt => $active) {
46  if ($active) {
47  $tpl->setCurrentBlock("active");
48  $tpl->setVariable("TXT_ACTIVE", $this->txt("active"));
49  $tpl->parseCurrentBlock();
50  $tpl->touchBlock("active_class");
51  }
52 
53  $tpl->setCurrentBlock("item");
54  $tpl->setVariable("ITEM_TEXT", $txt);
55  $tpl->setVariable("ITEM_WIDTH", $width);
56  $tpl->parseCurrentBlock();
57  }
58 
59  return $tpl->get();
60  }
61 
65  protected function getComponentInterfaceName(): array
66  {
67  return array(Component\Chart\ScaleBar::class);
68  }
69 }
render(Component\Component $component, RendererInterface $default_renderer)
Definition: Renderer.php:32
checkComponent(Component $component)
Check if a given component fits this renderer and throw if that is not the case. ...
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.
getTemplate(string $name, bool $purge_unfilled_vars, bool $purge_unused_blocks)
Get template of component this renderer is made for.
$txt
Definition: error.php:13
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41