ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilModalGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
4
13{
14 protected $heading = "";
15 protected $body = "";
16 protected $id = "";
17 const TYPE_LARGE = "large";
18 const TYPE_MEDIUM = "medium";
19 const TYPE_SMALL = "small";
20
22 protected $buttons = array();
23
27 protected function __construct()
28 {
29
30 }
31
37 static function getInstance()
38 {
39 return new ilModalGUI();
40 }
41
47 function setId($a_val)
48 {
49 $this->id = $a_val;
50 }
51
57 function getId()
58 {
59 return $this->id;
60 }
61
67 function setHeading($a_val)
68 {
69 $this->heading = $a_val;
70 }
71
77 function getHeading()
78 {
79 return $this->heading;
80 }
81
87 function setBody($a_val)
88 {
89 $this->body = $a_val;
90 }
91
97 function getBody()
98 {
99 return $this->body;
100 }
101
107 function setType($a_val)
108 {
109 $this->type = $a_val;
110 }
111
117 function getType()
118 {
119 return $this->type;
120 }
121
127 function addButton(ilButtonBase $but)
128 {
129 $this->buttons[] = $but;
130 }
131
137 function getButtons()
138 {
139 return $this->buttons;
140 }
141
142
148 function getHTML()
149 {
150 $tpl = new ilTemplate("tpl.modal.html", true, true, "Services/UIComponent/Modal");
151
152 if (count($this->getButtons()) > 0)
153 {
154 foreach ($this->getButtons() as $b)
155 {
156 $tpl->setCurrentBlock("button");
157 $tpl->setVariable("BUTTON", $b->render());
158 $tpl->parseCurrentBlock();
159 }
160 $tpl->setCurrentBlock("footer");
161 $tpl->parseCurrentBlock();
162 }
163
164 $tpl->setVariable("HEADING", $this->getHeading());
165
166 $tpl->setVariable("MOD_ID", $this->getId());
167 $tpl->setVariable("BODY", $this->getBody());
168
169 switch ($this->getType())
170 {
171 case self::TYPE_LARGE:
172 $tpl->setVariable("CLASS", "modal-lg");
173 break;
174
175 case self::TYPE_SMALL:
176 $tpl->setVariable("CLASS", "modal-sm");
177 break;
178 }
179
180 return $tpl->get();
181 }
182
186 static function initJS()
187 {
188 global $tpl;
189
190 $tpl->addJavascript("./Services/UIComponent/Modal/js/Modal.js");
191 }
192
193
194}
195
196?>
global $tpl
Definition: ilias.php:8
An exception for terminatinating execution or to throw for unit testing.
Modal class.
setBody($a_val)
Set body.
__construct()
Constructor.
setType($a_val)
Set type.
getHTML()
Get HTML.
getBody()
Get body.
setId($a_val)
Set id.
static initJS()
Init javascript.
getHeading()
Get heading.
getButtons()
Get buttons.
getId()
Get id.
getType()
Get type.
setHeading($a_val)
Set heading.
static getInstance()
Get instance.
addButton(ilButtonBase $but)
Add button.
special template class to simplify handling of ITX/PEAR