ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilOverlayGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
9{
13 protected $tpl;
14
15 protected $width = "";
16 protected $height = "";
17 protected $fixed_center = false;
18 protected $visible = false;
19 protected $anchor_el_id = "";
20 protected $anchor_ov_corner = "";
21 protected $anchor_anch_corner = "";
22 protected $auto_hide = false;
23 protected $close_el = null;
24
31 public function __construct($a_overlay_el_id)
32 {
33 global $DIC;
34
35 // please check learning modules (e.g. rating) before removing this globals
36 // use (they do not use standard template)
37 $this->tpl = $GLOBALS["tpl"];
38 $this->overlay_el_id = $a_overlay_el_id;
39 }
40
48 public function setAnchor($a_anchor_el_id, $a_ov_corner = "tl", $a_anch_corner = "bl")
49 {
50 $this->anchor_el_id = $a_anchor_el_id;
51 $this->anchor_ov_corner = $a_ov_corner;
52 $this->anchor_anch_corner = $a_anch_corner;
53 }
54
61 public function setSize($a_width = "", $a_height = "")
62 {
63 $this->width = $a_width;
64 $this->height = $a_height;
65 }
66
72 public function setFixedCenter($a_fixed_center = true)
73 {
74 $this->fixed_center = $a_fixed_center;
75 }
76
82 public function setVisible($a_visible = true)
83 {
84 $this->visible = $a_visible;
85 }
86
93 public function setTrigger($a_el_id, $a_event = "click", $a_trigger_anchor_el_id = null)
94 {
95 $this->trigger_el_id = $a_el_id;
96 $this->trigger_event = $a_event;
97 $this->trigger_anchor_el_id = $a_trigger_anchor_el_id;
98 }
99
105 public function setAutoHide($a_val)
106 {
107 $this->auto_hide = $a_val;
108 }
109
115 public function getAutoHide()
116 {
117 return $this->auto_hide;
118 }
119
125 public function setCloseElementId($a_val)
126 {
127 $this->close_el = $a_val;
128 }
129
135 public function getCloseElementId()
136 {
137 return $this->close_el;
138 }
139
143 public function getOnLoadCode()
144 {
145 // yui cfg string
146 $yuicfg["visible"] = $this->visible ? true : false;
147
148 if ($this->width != "") {
149 $yuicfg["width"] = $this->width;
150 }
151
152 if ($this->height != "") {
153 $yuicfg["height"] = $this->height;
154 }
155 $yuicfg["fixedcenter"] = $this->fixed_center ? true : false;
156 if ($this->anchor_el_id != "") {
157 $yuicfg["context"] = array($this->anchor_el_id, $this->anchor_ov_corner,
158 $this->anchor_anch_corner, array("beforeShow", "windowResize"));
159 }
160 // general cfg string
161 $cfg["yuicfg"] = $yuicfg;
162 $cfg["trigger"] = $this->trigger_el_id;
163 $cfg["trigger_event"] = $this->trigger_event;
164 $cfg["anchor_id"] = $this->trigger_anchor_el_id;
165 $cfg["auto_hide"] = $this->auto_hide;
166 $cfg["close_el"] = $this->close_el;
167
168 include_once("./Services/JSON/classes/class.ilJsonUtil.php");
169 //var_dump(ilJsonUtil::encode($cfg));
170 return 'il.Overlay.add("' . $this->overlay_el_id . '", ' .
171 ilJsonUtil::encode($cfg) . '); ';
172 }
173
177 public function add()
178 {
180 include_once("./Services/YUI/classes/class.ilYuiUtil.php");
181
183 $tpl->addOnLoadCode($this->getOnLoadCode());
184 }
185
192 public static function initJavascript()
193 {
194 global $DIC;
195
196 $tpl = $GLOBALS["tpl"];
197
198 include_once("./Services/YUI/classes/class.ilYuiUtil.php");
200 $tpl->addJavascript("./Services/UIComponent/Overlay/js/ilOverlay.js");
201 }
202
203
210 public function getTriggerOnLoadCode(
211 $a_tr_id,
212 $a_tr_event,
213 $a_anchor_el_id,
214 $a_center = false,
215 $a_ov_corner = "tl",
216 $a_anch_corner = "bl"
217 ) {
218 $center = ($a_center) ? "true" : "false";
219 return 'il.Overlay.addTrigger("' . $a_tr_id . '","' . $a_tr_event . '","' . $this->overlay_el_id . '","' .
220 $a_anchor_el_id . '", ' . $center . ',"' . $a_ov_corner . '","' . $a_anch_corner . '"); ';
221 }
222
226 public function addTrigger(
227 $a_tr_id,
228 $a_tr_event,
229 $a_anchor_el_id,
230 $a_center = false,
231 $a_ov_corner = "tl",
232 $a_anch_corner = "bl"
233 ) {
235 include_once("./Services/YUI/classes/class.ilYuiUtil.php");
236 //echo "-".$a_tr_id."-".$a_tr_event."-".$a_anchor_el_id."-";
238 $tpl->addOnLoadCode($this->getTriggerOnLoadCode(
239 $a_tr_id,
240 $a_tr_event,
241 $a_anchor_el_id,
242 $a_center,
243 $a_ov_corner,
244 $a_anch_corner
245 ));
246 }
247}
An exception for terminatinating execution or to throw for unit testing.
static encode($mixed, $suppress_native=false)
This is a utility class for the yui overlays.
static initJavascript()
Init javascript.
addTrigger( $a_tr_id, $a_tr_event, $a_anchor_el_id, $a_center=false, $a_ov_corner="tl", $a_anch_corner="bl")
Add trigger.
setSize($a_width="", $a_height="")
Set size.
setAnchor($a_anchor_el_id, $a_ov_corner="tl", $a_anch_corner="bl")
Set anchor element.
getCloseElementId()
Get close element id.
setVisible($a_visible=true)
Set visible.
getTriggerOnLoadCode( $a_tr_id, $a_tr_event, $a_anchor_el_id, $a_center=false, $a_ov_corner="tl", $a_anch_corner="bl")
Get trigger onload code.
setAutoHide($a_val)
Set auto hiding.
__construct($a_overlay_el_id)
Constructor.
getAutoHide()
Get auto_hide.
setFixedCenter($a_fixed_center=true)
Set fixed center.
setTrigger($a_el_id, $a_event="click", $a_trigger_anchor_el_id=null)
Set trigger element.
setCloseElementId($a_val)
Set close element id.
getOnLoadCode()
Makes an existing HTML element an overlay.
add()
Makes an existing HTML element an overlay.
static initOverlay(ilTemplate $a_main_tpl=null)
Init YUI Overlay module.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $DIC
Definition: saml.php:7
catch(Exception $e) if(isset( $_POST[ 'cancel'])) if(isset($_POST['continue'])) $cfg