ILIAS  release_8 Revision v8.24
Renderer.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22
24use ILIAS\UI\Renderer as RendererInterface;
26
32{
36 public function render(Component\Component $component, RendererInterface $default_renderer): string
37 {
41 $this->checkComponent($component);
42 $tpl = $this->getTemplate("tpl.image.html", true, true);
43
44 $id = $this->bindJavaScript($component);
45 if (!empty($component->getAction())) {
46 $tpl->touchBlock("action_begin");
47
48 if (is_string($component->getAction())) {
49 $tpl->setCurrentBlock("with_href");
50 $tpl->setVariable("HREF", $component->getAction());
51 $tpl->parseCurrentBlock();
52 }
53
54 if (is_array($component->getAction())) {
55 $tpl->setCurrentBlock("with_href");
56 $tpl->setVariable("HREF", "#");
57 $tpl->parseCurrentBlock();
58 $tpl->setCurrentBlock("with_id");
59 $tpl->setVariable("ID", $id);
60 $tpl->parseCurrentBlock();
61 }
62 }
63
64 if (!is_array($component->getAction()) && $id !== null) {
65 $tpl->setVariable("IMG_ID", " id='" . $id . "' ");
66 }
67
68 $tpl->setCurrentBlock($component->getType());
69 $tpl->setVariable("SOURCE", $component->getSource());
70 $tpl->setVariable("ALT", htmlspecialchars($component->getAlt()));
71 $tpl->parseCurrentBlock();
72
73 if (!empty($component->getAction())) {
74 $tpl->touchBlock("action_end");
75 }
76
77 return $tpl->get();
78 }
79
83 protected function getComponentInterfaceName(): array
84 {
85 return [Component\Image\Image::class];
86 }
87}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
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.
getTemplate(string $name, bool $purge_unfilled_vars, bool $purge_unused_blocks)
Get template of component this renderer is made for.
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:31
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21