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;
10
16{
20 public function render(Component\Component $component, RendererInterface $default_renderer)
21 {
25 $this->checkComponent($component);
26 $tpl = $this->getTemplate("tpl.image.html", true, true);
27
28 $id = $this->bindJavaScript($component);
29 if (!empty($component->getAction())) {
30 $tpl->touchBlock("action_begin");
31
32 if (is_string($component->getAction())) {
33 $tpl->setCurrentBlock("with_href");
34 $tpl->setVariable("HREF", $component->getAction());
35 $tpl->parseCurrentBlock();
36 }
37
38 if (is_array($component->getAction())) {
39 $tpl->setCurrentBlock("with_href");
40 $tpl->setVariable("HREF", "#");
41 $tpl->parseCurrentBlock();
42 $tpl->setCurrentBlock("with_id");
43 $tpl->setVariable("ID", $id);
44 $tpl->parseCurrentBlock();
45 }
46 }
47
48 if (!is_array($component->getAction()) && $id !== null) {
49 $tpl->setVariable("IMG_ID", " id='" . $id . "' ");
50 }
51
52 $tpl->setCurrentBlock($component->getType());
53 $tpl->setVariable("SOURCE", $component->getSource());
54 $tpl->setVariable("ALT", htmlspecialchars($component->getAlt()));
55 $tpl->parseCurrentBlock();
56
57 if (!empty($component->getAction())) {
58 $tpl->touchBlock("action_end");
59 }
60
61 return $tpl->get();
62 }
63
67 protected function getComponentInterfaceName()
68 {
69 return [Component\Image\Image::class];
70 }
71}
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