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 
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_id");
40  $tpl->setVariable("ID", $id);
41  $tpl->parseCurrentBlock();
42  }
43  }
44 
45  $tpl->setCurrentBlock($component->getType());
46  $tpl->setVariable("SOURCE", $component->getSource());
47  $tpl->setVariable("ALT", htmlspecialchars($component->getAlt()));
48  if (empty($component->getAction()) && $id !== null) {
49  $tpl->setVariable("IMG_ID", " id='" . $id . "' ");
50  }
51  $tpl->parseCurrentBlock();
52 
53  if (!empty($component->getAction())) {
54  $tpl->touchBlock("action_end");
55  }
56 
57  return $tpl->get();
58  }
59 
63  protected function getComponentInterfaceName()
64  {
65  return [Component\Image\Image::class];
66  }
67 }
checkComponent(Component $component)
Check if a given component fits this renderer and throw if that is not the case. ...
$tpl
Definition: ilias.php:10
if(!array_key_exists('StateId', $_REQUEST)) $id
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.