ILIAS  release_8 Revision v8.24
class.ilModalGUI.php
Go to the documentation of this file.
1<?php
2
25{
26 protected string $heading = "";
27 protected string $body = "";
28 protected string $id = "";
29
30 public const TYPE_LARGE = "large";
31 public const TYPE_MEDIUM = "medium";
32 public const TYPE_SMALL = "small";
33
34 protected string $type = self::TYPE_MEDIUM;
35 protected array $buttons = array();
36
37 protected function __construct()
38 {
39 }
40
41 public static function getInstance(): self
42 {
43 return new ilModalGUI();
44 }
45
46 public function setId(string $a_val): void
47 {
48 $this->id = $a_val;
49 }
50
51 public function getId(): string
52 {
53 return $this->id;
54 }
55
56 public function setHeading(string $a_val): void
57 {
58 $this->heading = $a_val;
59 }
60
61
62 public function getHeading(): string
63 {
64 return $this->heading;
65 }
66
67 public function setBody(string $a_val): void
68 {
69 $this->body = $a_val;
70 }
71
72 public function getBody(): string
73 {
74 return $this->body;
75 }
76
82 public function setType(string $a_val): void
83 {
84 $this->type = $a_val;
85 }
86
87 public function getType(): string
88 {
89 return $this->type;
90 }
91
92 public function addButton(ilButtonBase $but): void
93 {
94 $this->buttons[] = $but;
95 }
96
101 public function getButtons(): array
102 {
103 return $this->buttons;
104 }
105
106 public function getHTML(): string
107 {
108 $tpl = new ilTemplate("tpl.modal.html", true, true, "Services/UIComponent/Modal");
109
110 if (count($this->getButtons()) > 0) {
111 foreach ($this->getButtons() as $b) {
112 $tpl->setCurrentBlock("button");
113 $tpl->setVariable("BUTTON", $b->render());
114 $tpl->parseCurrentBlock();
115 }
116 $tpl->setCurrentBlock("footer");
117 $tpl->parseCurrentBlock();
118 }
119
120 $tpl->setVariable("HEADING", $this->getHeading());
121
122 $tpl->setVariable("MOD_ID", $this->getId());
123 $tpl->setVariable("BODY", $this->getBody());
124
125 switch ($this->getType()) {
126 case self::TYPE_LARGE:
127 $tpl->setVariable("CLASS", "modal-lg");
128 break;
129
130 case self::TYPE_SMALL:
131 $tpl->setVariable("CLASS", "modal-sm");
132 break;
133 }
134
135 return $tpl->get();
136 }
137
138 public static function initJS(ilGlobalTemplateInterface $a_main_tpl = null): void
139 {
140 global $DIC;
141
142 $tpl = $a_main_tpl ?? $DIC["tpl"];
143
144 $tpl->addJavaScript("./Services/UIComponent/Modal/js/Modal.js");
145 }
146}
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...
setType(string $a_val)
Set type.
setBody(string $a_val)
getButtons()
Get buttons.
setId(string $a_val)
setHeading(string $a_val)
static getInstance()
addButton(ilButtonBase $but)
static initJS(ilGlobalTemplateInterface $a_main_tpl=null)
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...
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41