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 Timon Amstutz <timon.amstutz@ilub.unibe.ch> Extended GPL, see docs/LICENSE */
4 
6 
10 
12 {
16  public function render(Component\Component $component, RendererInterface $default_renderer)
17  {
21  $this->checkComponent($component);
22  $tpl = $this->getTemplate("tpl.card.html", true, true);
23 
24  if ($component->getImage()) {
25  $tpl->setVariable("IMAGE", $default_renderer->render($component->getImage(), $default_renderer));
26  }
27 
28  if ($component->isHighlighted()) {
29  $tpl->touchBlock("highlight");
30  } else {
31  $tpl->touchBlock("no_highlight");
32  }
33 
34  if ($component->getTitleAction()) {
35  $tpl->setCurrentBlock("title_action_begin");
36  $tpl->setVariable("HREF", $component->getTitleAction());
37  $tpl->parseCurrentBlock();
38  }
39 
40  $tpl->setVariable("TITLE", $component->getTitle());
41 
42  if ($component->getTitleAction()) {
43  $tpl->touchBlock("title_action_end");
44  }
45 
46  if (is_array($component->getSections())) {
47  foreach ($component->getSections() as $section) {
48  $tpl->setCurrentBlock("section");
49  $tpl->setVariable("SECTION", $default_renderer->render($section, $default_renderer));
50  $tpl->parseCurrentBlock();
51  }
52  }
53  return $tpl->get();
54  }
55 
59  protected function getComponentInterfaceName()
60  {
61  return array(Component\Card\Card::class);
62  }
63 }
checkComponent(Component $component)
Check if a given component fits this renderer and throw if that is not the case. ...
$tpl
Definition: ilias.php:10
$section
Definition: Utf8Test.php:83
Create styles array
The data for the language used.
render(Component $component, Renderer $default_renderer)
Render the component if possible and delegate additional rendering to the default_renderer.
getTemplate($name, $purge_unfilled_vars, $purge_unused_blocks)
Get template of component this renderer is made for.