ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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  $tpl->setVariable("IMAGE", $default_renderer->render($component->getImage(), $default_renderer));
27  }
28 
29  if ($component->isHighlighted()) {
30  $tpl->touchBlock("highlight");
31  } else {
32  $tpl->touchBlock("no_highlight");
33  }
34 
35  $title = $component->getTitle();
36  $id = $this->bindJavaScript($component);
37  if (!empty($component->getTitleAction())) {
38  if (is_string($component->getTitleAction())) {
39  $tpl->setCurrentBlock("title_action_begin");
40  $tpl->setVariable("HREF", $component->getTitleAction());
41  $tpl->parseCurrentBlock();
42  } else {
43  if ($title instanceof \ILIAS\UI\Component\Button\Shy) {
44  $title = $default_renderer->render($title);
45  }
46  }
47  if (is_array($component->getTitleAction())) {
48  $tpl->setCurrentBlock("title_action_begin");
49  $tpl->setVariable("ID", $id);
50  $tpl->parseCurrentBlock();
51  }
52  }
53 
54  $tpl->setVariable("TITLE", $title);
55 
56  if (!empty($component->getTitleAction())) {
57  $tpl->touchBlock("title_action_end");
58  }
59 
60  if (is_array($component->getSections())) {
61  foreach ($component->getSections() as $section) {
62  $tpl->setCurrentBlock("section");
63  $tpl->setVariable("SECTION", $default_renderer->render($section, $default_renderer));
64  $tpl->parseCurrentBlock();
65  }
66  }
67 
68  if ($component instanceof Component\Card\RepositoryObject) {
69  $tpl->setCurrentBlock("action");
70 
71  $obj_icon = $component->getObjectIcon();
72  if ($obj_icon !== null) {
73  $tpl->setVariable("OBJECT_ICON", $default_renderer->render($obj_icon, $default_renderer));
74  }
75 
76  $progress = $component->getProgress();
77  if ($progress !== null) {
78  $tpl->setVariable("PROGRESS_STATUS", $default_renderer->render($progress));
79  }
80 
81  $certificate = $component->getCertificateIcon();
82  if ($certificate !== null) {
83  $certificate_icon = new StandardIcon("cert", "Certificate", "medium", false);
84  $certificate_icon = $certificate_icon->withIsOutlined(true);
85  $tpl->setVariable("PROGRESS_STATUS", $default_renderer->render($certificate_icon));
86  }
87 
88  $dropdown = $component->getActions();
89  if ($dropdown !== null) {
90  $tpl->setVariable("DROPDOWN", $default_renderer->render($dropdown));
91  }
92 
93  $tpl->parseCurrentBlock();
94  }
95 
96  return $tpl->get();
97  }
98 
102  protected function getComponentInterfaceName()
103  {
104  return array(Component\Card\Card::class);
105  }
106 }
Class Factory.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
checkComponent(Component $component)
Check if a given component fits this renderer and throw if that is not the case. ...
Class ChatMainBarProvider .
$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.
bindJavaScript(JavaScriptBindable $component)
Bind the component to JavaScript.