ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
15  public function render(Component\Component $component, RendererInterface $default_renderer) {
16  $this->checkComponent($component);
17 
18  $tpl = $this->getTemplate("tpl.glyph.html", true, true);
19 
20  $action = $component->getAction();
21  if ($action !== null) {
22  $tpl->setCurrentBlock("with_action");
23  $tpl->setVariable("ACTION", $component->getAction());
24  $tpl->parseCurrentBlock();
25  }
26 
27  if ($component->isHighlighted()) {
28  $tpl->touchBlock("highlighted");
29  }
30 
31  $tpl->setVariable("LABEL", $this->txt($component->getAriaLabel()));
32 
33  $tpl->touchBlock($component->getType());
34 
35  $id = $this->bindJavaScript($component);
36  if ($id !== null) {
37  $tpl->setCurrentBlock("with_id");
38  $tpl->setVariable("ID", $id);
39  $tpl->parseCurrentBlock();
40  }
41 
42  $largest_counter = 0;
43  foreach ($component->getCounters() as $counter) {
44  if($largest_counter < $counter->getNumber()){
45  $largest_counter = $counter->getNumber();
46  }
47  $n = "counter_".$counter->getType();
48  $tpl->setCurrentBlock($n);
49  $tpl->setVariable(strtoupper($n), $default_renderer->render($counter));
50  $tpl->parseCurrentBlock();
51  }
52 
53  if($largest_counter){
54  $tpl->setCurrentBlock("counter_spacer");
55  $tpl->setVariable("COUNTER_SPACER",$largest_counter);
56  $tpl->parseCurrentBlock();
57  }
58  return $tpl->get();
59  }
60 
64  protected function getComponentInterfaceName() {
65  return array(Component\Glyph\Glyph::class);
66  }
67 }
checkComponent(Component $component)
Check if a given component fits this renderer and throw if that is not the case. ...
global $tpl
Definition: ilias.php:8
$counter
$n
Definition: RandomTest.php:80
Create styles array
The data for the language used.
getTemplate($name, $purge_unfilled_vars, $purge_unused_blocks)
Get template of component this renderer is made for.
render(Component\Component $component, RendererInterface $default_renderer)
Definition: Renderer.php:15
bindJavaScript(JavaScriptBindable $component)
Bind the component to JavaScript.