ILIAS  release_8 Revision v8.24
class.ilLightboxGUI.php
Go to the documentation of this file.
1<?php
2
24{
26 protected string $id = "";
27 protected string $width;
28
29 public function __construct(string $a_id)
30 {
31 global $DIC;
32
33 $this->tpl = $DIC->ui()->mainTemplate();
34 $this->setId($a_id);
35 }
36
37 public function setId(string $a_val): void
38 {
39 $this->id = $a_val;
40 }
41
42 public function getId(): string
43 {
44 return $this->id;
45 }
46
47 public function setWidth(string $a_val): void
48 {
49 $this->width = $a_val;
50 }
51
52 public function getWidth(): string
53 {
54 return $this->width;
55 }
56
57 public static function getLocalLightboxJsPath(): string
58 {
59 return "./Services/UIComponent/Lightbox/js/Lightbox.js";
60 }
61
62 public function addLightbox(\ilGlobalTemplateInterface $a_tpl = null): void
63 {
65
66 if ($a_tpl === null) {
67 $a_tpl = $tpl;
68 }
69
70 $a_tpl->addJavaScript(self::getLocalLightboxJsPath());
71 $a_tpl->addLightbox($this->getHTML(), $this->getId());
72 }
73
74 public function getHTML(): string
75 {
76 $tpl = new ilTemplate("tpl.lightbox.html", true, true, "Services/UIComponent/Lightbox");
77 $tpl->setVariable("LIGHTBOX_CONTENT", "");
78 $tpl->setVariable("ID", $this->getId());
79 if ($this->getWidth() !== "") {
80 $tpl->setVariable("WIDTH", "width: " . $this->getWidth() . ";");
81 }
82 return $tpl->get();
83 }
84}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(string $a_id)
addLightbox(\ilGlobalTemplateInterface $a_tpl=null)
static getLocalLightboxJsPath()
setWidth(string $a_val)
ilGlobalTemplateInterface $tpl
setId(string $a_val)
special template class to simplify handling of ITX/PEAR
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addJavaScript(string $a_js_file, bool $a_add_version_parameter=true, int $a_batch=2)
Add a javascript file that should be included in the header.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.