ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
36 public static function getInstance()
37 {
38 return new ilModalGUI();
39 }
40
46 public function setId($a_val)
47 {
48 $this->id = $a_val;
49 }
50
56 public function getId()
57 {
58 return $this->id;
59 }
60
66 public function setHeading($a_val)
67 {
68 $this->heading = $a_val;
69 }
70
76 public function getHeading()
77 {
78 return $this->heading;
79 }
80
86 public function setBody($a_val)
87 {
88 $this->body = $a_val;
89 }
90
96 public function getBody()
97 {
98 return $this->body;
99 }
100
106 public function setType($a_val)
107 {
108 $this->type = $a_val;
109 }
110
116 public function getType()
117 {
118 return $this->type;
119 }
120
126 public function addButton(ilButtonBase $but)
127 {
128 $this->buttons[] = $but;
129 }
130
136 public function getButtons()
137 {
138 return $this->buttons;
139 }
140
141
147 public function getHTML()
148 {
149 $tpl = new ilTemplate("tpl.modal.html", true, true, "Services/UIComponent/Modal");
150
151 if (count($this->getButtons()) > 0) {
152 foreach ($this->getButtons() as $b) {
153 $tpl->setCurrentBlock("button");
154 $tpl->setVariable("BUTTON", $b->render());
155 $tpl->parseCurrentBlock();
156 }
157 $tpl->setCurrentBlock("footer");
158 $tpl->parseCurrentBlock();
159 }
160
161 $tpl->setVariable("HEADING", $this->getHeading());
162
163 $tpl->setVariable("MOD_ID", $this->getId());
164 $tpl->setVariable("BODY", $this->getBody());
165
166 switch ($this->getType()) {
167 case self::TYPE_LARGE:
168 $tpl->setVariable("CLASS", "modal-lg");
169 break;
170
171 case self::TYPE_SMALL:
172 $tpl->setVariable("CLASS", "modal-sm");
173 break;
174 }
175
176 return $tpl->get();
177 }
178
182 public static function initJS(ilTemplate $a_main_tpl = null)
183 {
184 global $DIC;
185
186 if ($a_main_tpl != null) {
187 $tpl = $a_main_tpl;
188 } else {
189 $tpl = $DIC["tpl"];
190 }
191
192 $tpl->addJavascript("./Services/UIComponent/Modal/js/Modal.js");
193 }
194}
$tpl
Definition: ilias.php:10
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.
getHeading()
Get heading.
getButtons()
Get buttons.
getId()
Get id.
getType()
Get type.
static initJS(ilTemplate $a_main_tpl=null)
Init javascript.
setHeading($a_val)
Set heading.
static getInstance()
Get instance.
addButton(ilButtonBase $but)
Add button.
special template class to simplify handling of ITX/PEAR
global $DIC
Definition: saml.php:7