ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
11 
13 {
17  public function render(Component\Component $component, RendererInterface $default_renderer)
18  {
22  $this->checkComponent($component);
23  $tpl = $this->getTemplate("tpl.card.html", true, true);
24 
25  if ($component->getImage()) {
26  if ($component->getImageAction()) {
27  $tpl->setCurrentBlock("image_action_begin");
28  $tpl->setVariable("IMG_HREF", $component->getImageAction());
29  $tpl->parseCurrentBlock();
30  }
31 
32  $tpl->setVariable("IMAGE", $default_renderer->render($component->getImage(), $default_renderer));
33 
34  if ($component->getImageAction()) {
35  $tpl->touchBlock("image_action_end");
36  }
37  }
38 
39  if ($component->isHighlighted()) {
40  $tpl->touchBlock("highlight");
41  } else {
42  $tpl->touchBlock("no_highlight");
43  }
44 
45  $title = $component->getTitle();
46  if ($component->getTitleAction()) {
47  $tpl->setCurrentBlock("title_action_begin");
48  $tpl->setVariable("HREF", $component->getTitleAction());
49  $tpl->parseCurrentBlock();
50  } else {
51  if ($title instanceof \ILIAS\UI\Component\Button\Shy) {
52  $title = $default_renderer->render($title);
53  }
54  }
55 
56  $tpl->setVariable("TITLE", $title);
57 
58  if ($component->getTitleAction()) {
59  $tpl->touchBlock("title_action_end");
60  }
61 
62  if (is_array($component->getSections())) {
63  foreach ($component->getSections() as $section) {
64  $tpl->setCurrentBlock("section");
65  $tpl->setVariable("SECTION", $default_renderer->render($section, $default_renderer));
66  $tpl->parseCurrentBlock();
67  }
68  }
69 
70  if ($component instanceof Component\Card\RepositoryObject) {
71  $tpl->setCurrentBlock("action");
72 
73  $obj_icon = $component->getObjectIcon();
74  if ($obj_icon !== null) {
75  $tpl->setVariable("OBJECT_ICON", $default_renderer->render($obj_icon, $default_renderer));
76  }
77 
78  $progress = $component->getProgress();
79  if ($progress !== null) {
80  $tpl->setVariable("PROGRESS_STATUS", $default_renderer->render($progress));
81  }
82 
83  $certificate = $component->getCertificateIcon();
84  if ($certificate !== null) {
85  $certificate_icon = new StandardIcon("cert", "Certificate", "medium", false);
86  $certificate_icon = $certificate_icon->withIsOutlined(true);
87  $tpl->setVariable("PROGRESS_STATUS", $default_renderer->render($certificate_icon));
88  }
89 
90  $dropdown = $component->getActions();
91  if ($dropdown !== null) {
92  $tpl->setVariable("DROPDOWN", $default_renderer->render($dropdown));
93  }
94 
95  $tpl->parseCurrentBlock();
96  }
97 
98  return $tpl->get();
99  }
100 
104  protected function getComponentInterfaceName()
105  {
106  return array(Component\Card\Card::class);
107  }
108 }
Class Factory.
checkComponent(Component $component)
Check if a given component fits this renderer and throw if that is not the case. ...
$tpl
Definition: ilias.php:10
Class BaseForm.
if(@file_exists(dirname(__FILE__).'/lang/eng.php')) $certificate
Definition: example_052.php:77
$section
Definition: Utf8Test.php:83
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.