ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
Renderer.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2017 Alex Killing <killing@leifos.de> Extended GPL, see docs/LICENSE */
4
6
8use ILIAS\UI\Renderer as RendererInterface;
10
12{
16 public function render(Component\Component $component, RendererInterface $default_renderer)
17 {
18 $this->checkComponent($component);
19
20 $tpl = $this->getTemplate("tpl.scale_bar.html", true, true);
21
22 $items = $component->getItems();
23 if (count($items) == 0) {
24 return "";
25 }
26
27 $width = str_replace(",", ".", round(100 / count($items), 5));
28
29 foreach ($component->getItems() as $txt => $active) {
30 if ($active) {
31 $tpl->setCurrentBlock("active");
32 $tpl->setVariable("TXT_ACTIVE", $this->txt("active"));
33 $tpl->parseCurrentBlock();
34 $tpl->touchBlock("active_class");
35 }
36
37 $tpl->setCurrentBlock("item");
38 $tpl->setVariable("ITEM_TEXT", $txt);
39 $tpl->setVariable("ITEM_WIDTH", $width);
40 $tpl->parseCurrentBlock();
41 }
42
43 return $tpl->get();
44 }
45
49 protected function getComponentInterfaceName()
50 {
51 return array(Component\Chart\ScaleBar::class);
52 }
53}
An exception for terminatinating execution or to throw for unit testing.
render(Component\Component $component, RendererInterface $default_renderer)
@inheritdocs
Definition: Renderer.php:16
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.
$txt
Definition: error.php:13
A component is the most general form of an entity in the UI.
Definition: Component.php:14
An entity that renders components to a string output.
Definition: Renderer.php:15
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl