ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Renderer.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2016 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4 
6 
10 
12 {
16  public function render(Component\Component $component, RendererInterface $default_renderer)
17  {
18  $this->checkComponent($component);
19 
20  $tpl = $this->getTemplate("tpl.glyph.html", true, true);
21 
22  $action = $component->getAction();
23  if ($action !== null) {
24  $tpl->setCurrentBlock("with_action");
25  $tpl->setVariable("ACTION", $component->getAction());
26  $tpl->parseCurrentBlock();
27  }
28 
29  if ($component->isHighlighted()) {
30  $tpl->touchBlock("highlighted");
31  }
32 
33  $tpl->setVariable("LABEL", $this->txt($component->getAriaLabel()));
34 
35  $id = $this->bindJavaScript($component);
36 
37  $tpl->touchBlock($component->getType());
38 
39  if ($id !== null) {
40  $tpl->setCurrentBlock("with_id");
41  $tpl->setVariable("ID", $id);
42  $tpl->parseCurrentBlock();
43  }
44 
45  $largest_counter = 0;
46  foreach ($component->getCounters() as $counter) {
47  if ($largest_counter < $counter->getNumber()) {
48  $largest_counter = $counter->getNumber();
49  }
50  $n = "counter_" . $counter->getType();
51  $tpl->setCurrentBlock($n);
52  $tpl->setVariable(strtoupper($n), $default_renderer->render($counter));
53  $tpl->parseCurrentBlock();
54  }
55 
56  if ($largest_counter) {
57  $tpl->setCurrentBlock("counter_spacer");
58  $tpl->setVariable("COUNTER_SPACER", $largest_counter);
59  $tpl->parseCurrentBlock();
60  }
61  return $tpl->get();
62  }
63 
67  protected function getComponentInterfaceName()
68  {
69  return array(Component\Glyph\Glyph::class);
70  }
71 }
$action
checkComponent(Component $component)
Check if a given component fits this renderer and throw if that is not the case. ...
$tpl
Definition: ilias.php:10
if(!array_key_exists('StateId', $_REQUEST)) $id
$counter
$n
Definition: RandomTest.php:85
Create styles array
The data for the language used.
render(Component\Component $component, RendererInterface $default_renderer)
Definition: Renderer.php:16
getTemplate($name, $purge_unfilled_vars, $purge_unused_blocks)
Get template of component this renderer is made for.
bindJavaScript(JavaScriptBindable $component)
Bind the component to JavaScript.