ILIAS  release_7 Revision v7.30-3-g800a261c036
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
8use ILIAS\UI\Renderer as RendererInterface;
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()));
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 (!$id) {
38 $id = $this->createId();
39 }
40 if (!empty($component->getTitleAction())) {
41 if (is_string($component->getTitleAction())) {
42 $tpl->setCurrentBlock("title_action_begin");
43 $tpl->setVariable("HREF", $component->getTitleAction());
44 $tpl->setVariable("ID", $id);
45 $tpl->parseCurrentBlock();
46 } elseif ($title instanceof \ILIAS\UI\Component\Button\Shy) {
47 $title = $default_renderer->render($title);
48 }
49 if (is_array($component->getTitleAction())) {
50 $tpl->setCurrentBlock("title_action_begin");
51 $tpl->setVariable("ID", $id);
52 $tpl->parseCurrentBlock();
53 }
54 }
55
56 $tpl->setVariable("TITLE", $title);
57
58 if (!empty($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));
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));
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}
$section
Definition: Utf8Test.php:83
An exception for terminatinating execution or to throw for unit testing.
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.
checkComponent(Component $component)
Check if a given component fits this renderer and throw \LogicError if that is not the case.
A component is the most general form of an entity in the UI.
Definition: Component.php:14
render(Component $component, Renderer $default_renderer)
Render the component if possible and delegate additional rendering to the default_renderer.
An entity that renders components to a string output.
Definition: Renderer.php:15
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.