[BUGFIX] Usage of deprecated returnFilemounts()
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / ContentObject / Menu / GraphicalMenuLayersContentObject.php
1 <?php
2 namespace TYPO3\CMS\Frontend\ContentObject\Menu;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 1999-2013 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 /**
31 * Contains the GMENU_LAYERS menu object
32 * Class for the creation of DHTML menus
33 *
34 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
35 */
36 class GraphicalMenuLayersContentObject extends \TYPO3\CMS\Frontend\ContentObject\Menu\GraphicalMenuContentObject {
37
38 // FULL DUPLICATE TO tmenu_layers BEGIN:
39 /**
40 * @todo Define visibility
41 */
42 public $GMENU_fixKey = 'layers';
43
44 /**
45 * @todo Define visibility
46 */
47 public $divLayers = array();
48
49 /**
50 * @todo Define visibility
51 */
52 public $WMx = 0;
53
54 /**
55 * @todo Define visibility
56 */
57 public $WMy = 0;
58
59 /**
60 * @todo Define visibility
61 */
62 public $WMxyArray = array();
63
64 /**
65 * @todo Define visibility
66 */
67 public $WMextraScript = '';
68
69 /**
70 * @todo Define visibility
71 */
72 public $WMlastKey = '';
73
74 /**
75 * @todo Define visibility
76 */
77 public $WMrestoreScript = '';
78
79 /**
80 * @todo Define visibility
81 */
82 public $WMresetSubMenus = '';
83
84 /**
85 * @todo Define visibility
86 */
87 public $WMactiveHasSubMenu = '';
88
89 /**
90 * @todo Define visibility
91 */
92 public $WMactiveKey = '';
93
94 /**
95 * @todo Define visibility
96 */
97 public $WMtheSubMenu;
98
99 /**
100 * @todo Define visibility
101 */
102 public $WMisSub;
103
104 /**
105 * @todo Define visibility
106 */
107 public $WMhideCode;
108
109 /**
110 * @todo Define visibility
111 */
112 public $WMonlyOnLoad = 0;
113
114 /**
115 * @todo Define visibility
116 */
117 public $WMbordersWithin = array();
118
119 /**
120 * @todo Define visibility
121 */
122 public $WMsubIds = array();
123
124 /**
125 * @todo Define visibility
126 */
127 public $WMtempStore = array();
128
129 /**
130 * @todo Define visibility
131 */
132 public $WMlockPosition_addAccumulated = array();
133
134 /**
135 * @todo Define visibility
136 */
137 public $VMmouseoverActions = array();
138
139 /**
140 * @todo Define visibility
141 */
142 public $VMmouseoutActions = array();
143
144 /**
145 * Creating unique menu id string plus other initialization of internal
146 * variables (all prefixed "WM")
147 *
148 * @return void
149 * @todo Define visibility
150 */
151 public function extProc_init() {
152 $this->WMid = trim($this->mconf['layer_menu_id']) ? trim($this->mconf['layer_menu_id']) . 'x' : substr(md5('gl' . serialize($this->mconf)), 0, 6);
153 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'][] = $this->WMid;
154 $this->WMtempStore = $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'];
155 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'] = array();
156 // Save:
157 $this->WMonlyOnLoad = $this->mconf['displayActiveOnLoad'] && !$this->mconf['displayActiveOnLoad.']['onlyOnLoad'];
158 $this->WMbordersWithin = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $this->mconf['bordersWithin'] . ',0,0,0,0,0');
159 }
160
161 /**
162 * Processing of mouse-over features depending on whether "freezeMouseover"
163 * property is set.
164 *
165 * @param integer $key Pointer to $this->menuArr[$key] where the current menu element record is found OR $this->result['RO'][$key] where the configuration for that elements RO version is found! Here it is used with the ->WMid to make unique names
166 * @return void
167 * @todo Define visibility
168 */
169 public function extProc_RO($key) {
170 if ($this->mconf['freezeMouseover']) {
171 $this->VMmouseoverActions[$this->WMid . $key] = 'case "Menu' . $this->WMid . $key . '":' . $this->I['linkHREF']['onMouseover'] . '; break;';
172 $this->VMmouseoutActions[$this->WMid . $key] = 'case "Menu' . $this->WMid . $key . '":' . $this->I['linkHREF']['onMouseout'] . '; break;';
173 $this->I['linkHREF']['onMouseover'] = 'GL' . $this->WMid . '_over(\'Menu' . $this->WMid . $key . '\');';
174 $this->I['linkHREF']['onMouseout'] = '';
175 }
176 }
177
178 /**
179 * Processing before the links are created.
180 * This means primarily creating some javaScript code for the management.
181 *
182 * @param integer $key Pointer to $this->menuArr[$key] where the current menu element record is found
183 * @return void
184 * @todo Define visibility
185 */
186 public function extProc_beforeLinking($key) {
187 if ($this->I['uid']) {
188 array_push($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId'], $this->WMid);
189 $this->WMtheSubMenu = $this->subMenu($this->I['uid'], $this->WMsubmenuObjSuffixes[$key]['sOSuffix']);
190 array_pop($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId']);
191 $this->WMisSub = trim($this->WMtheSubMenu) ? 1 : 0;
192 if ($this->mconf['lockPosition_addSelf']) {
193 $this->WMy += (strcmp($this->mconf['setFixedHeight'], '') ? $this->mconf['setFixedHeight'] : $this->I['val']['output_h']) + intval($this->mconf['lockPosition_adjust']);
194 $this->WMx += (strcmp($this->mconf['setFixedWidth'], '') ? $this->mconf['setFixedWidth'] : $this->I['val']['output_w']) + intval($this->mconf['lockPosition_adjust']);
195 }
196 // orig: && $this->WMisSub, changed 210901
197 if ($this->isActive($this->I['uid'], $this->getMPvar($key)) && $this->mconf['displayActiveOnLoad']) {
198 $this->WMactiveHasSubMenu = $this->WMisSub;
199 $this->WMactiveKey = 'Menu' . $this->WMid . $key;
200 $this->WMrestoreVars = trim('
201 GLV_restoreMenu["' . $this->WMid . '"] = "' . $this->WMactiveKey . '";
202 ');
203 $this->WMrestoreScript = ' GL_doTop("' . $this->WMid . '",GLV_restoreMenu["' . $this->WMid . '"]);' . ($this->mconf['freezeMouseover'] ? '
204 GL' . $this->WMid . '_over(GLV_restoreMenu["' . $this->WMid . '"]);
205 ' : '');
206 }
207 if ($this->WMisSub) {
208 $event = 'GL_stopMove(\'' . $this->WMid . '\');';
209 $this->I['linkHREF']['onMouseover'] = 'GL_doTop(\'' . $this->WMid . '\', \'Menu' . $this->WMid . $key . '\');' . $this->I['linkHREF']['onMouseover'];
210 // IESelectFix - Activates IFRAME layer below menu
211 if ($this->mconf['ieSelectFix']) {
212 $this->I['linkHREF']['onMouseover'] = $this->I['linkHREF']['onMouseover'] . 'GL_iframer(\'' . $this->WMid . '\',\'Menu' . $this->WMid . $key . '\',true);';
213 }
214 // Added 120802; This means that everytime leaving a menuitem the layer should be shut down (and if the layer is hit in the meantime it is not though).
215 // This should happen only for items that are auto-hidden when not over and possibly only when a hide-timer is set. Problem is if the hide-timer is not set and we leave the main element, then the layer will be hidden unless we reach the layer before the timeout will happen and the menu hidden.
216 if (\TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->mconf['hideMenuWhenNotOver'], 0, 600) && $this->mconf['hideMenuTimer']) {
217 $event .= 'GL_resetAll("' . $this->WMid . '");';
218 }
219 $this->I['linkHREF']['onMouseout'] .= $event;
220 } else {
221 $this->I['linkHREF']['onMouseover'] = 'GL_hideAll("' . $this->WMid . '");' . $this->I['linkHREF']['onMouseover'];
222 // IESelectFix - Hides IFRAME layer below menu
223 if ($this->mconf['ieSelectFix']) {
224 $this->I['linkHREF']['onMouseover'] = $this->I['linkHREF']['onMouseover'] . 'GL_iframer(\'' . $this->WMid . '\',\'\',false);';
225 }
226 $event = 'GL_resetAll("' . $this->WMid . '");';
227 $this->I['linkHREF']['onMouseout'] .= $event;
228 }
229 $this->WMxyArray[] = 'GLV_menuXY["' . $this->WMid . '"]["Menu' . $this->WMid . $key . '"] = new Array(' . $this->WMx . ',' . $this->WMy . ',"itemID' . \TYPO3\CMS\Core\Utility\GeneralUtility::shortmd5(($this->I['uid'] . '-' . $this->WMid)) . '","anchorID' . \TYPO3\CMS\Core\Utility\GeneralUtility::shortmd5(($this->I['uid'] . '-' . $this->WMid)) . '");';
230 }
231 }
232
233 /**
234 * Processing after linking, basically setting the <div>-layers for the
235 * menu items. Also some more JavaScript code is made.
236 *
237 * @param integer $key Pointer to $this->menuArr[$key] where the current menu element record is found
238 * @return void
239 * @todo Define visibility
240 */
241 public function extProc_afterLinking($key) {
242 if ($this->I['uid']) {
243 if (!$this->I['spacer'] && $this->WMisSub) {
244 $exStyle = $this->mconf['layerStyle'] ? $this->mconf['layerStyle'] : 'position:absolute;visibility:hidden';
245 if (trim($exStyle)) {
246 $exStyle = ' ' . $exStyle;
247 }
248 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['layerCounter']++;
249 $zIndex = 10000 - $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['layerCounter'];
250 $divStart = '<div id="Menu' . $this->WMid . $key . '" style="z-index:' . $zIndex . ';' . $exStyle . '">';
251 $divStop = '</div>';
252 $this->divLayers[] = $divStart . $this->WMtheSubMenu . $divStop;
253 $this->WMhideCode .= '
254 GL_getObjCss("Menu' . $this->WMid . $key . '").visibility = "hidden";';
255 $this->WMlastKey = 'Menu' . $this->WMid . $key;
256 }
257 if (!$this->mconf['lockPosition_addSelf']) {
258 $this->WMy += (strcmp($this->mconf['setFixedHeight'], '') ? $this->mconf['setFixedHeight'] : $this->I['val']['output_h']) + intval($this->mconf['lockPosition_adjust']);
259 $this->WMx += (strcmp($this->mconf['setFixedWidth'], '') ? $this->mconf['setFixedWidth'] : $this->I['val']['output_w']) + intval($this->mconf['lockPosition_adjust']);
260 }
261 }
262 $this->WMresult .= $this->I['theItem'];
263 }
264
265 /**
266 * Wrapping the item in a <div> section if 'relativeToTriggerItem' was set
267 *
268 * @param string The current content of the menu item, $this->I['theItem'], passed along.
269 * @param integer Pointer to $this->menuArr[$key] where the current menu element record is found
270 * @return string The modified version of $item, going back into $this->I['theItem']
271 * @todo Define visibility
272 */
273 public function extProc_beforeAllWrap($item, $key) {
274 if ($this->mconf['relativeToTriggerItem']) {
275 $item = '<div id="anchorID' . \TYPO3\CMS\Core\Utility\GeneralUtility::shortmd5(($this->I['uid'] . '-' . $this->WMid)) . '" style="position:absolute;visibility:hidden;"></div><div id="itemID' . \TYPO3\CMS\Core\Utility\GeneralUtility::shortmd5(($this->I['uid'] . '-' . $this->WMid)) . '" style="width:100%; height:100%;">' . $item . '</div>';
276 }
277 return $item;
278 }
279
280 /**
281 * Returns TRUE if different from '' OR if intval()!=0
282 *
283 * @param string $in Value to evaluate
284 * @return boolean TRUE if $in is different from '' OR if intval()!=0
285 * @todo Define visibility
286 */
287 public function isSetIntval($in) {
288 return $this->mconf['blankStrEqFalse'] ? strcmp($in, '') : intval($in);
289 }
290
291 /**
292 * Putting things together, in particular the JavaScript code needed
293 * for the DHTML menu.
294 *
295 * @return mixed Returns the value of a call to the parent function, parent::extProc_finish();
296 * @todo Define visibility
297 */
298 public function extProc_finish() {
299 $dirL = $this->mconf['directionLeft'] ? '-GL_getObj(id).width' : '';
300 $dirU = $this->mconf['directionUp'] ? '-GL_getObj(id).height' : '';
301 $parentLayerId = end($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId']);
302 $DoTop = array();
303 $GLV_menuOn = array();
304 $relCode = array();
305 $relFlag = 0;
306 if ($this->mconf['relativeToParentLayer'] && $parentLayerId) {
307 $relCode['X'] .= 'GLV_curLayerX["' . $parentLayerId . '"]+';
308 $relCode['Y'] .= 'GLV_curLayerY["' . $parentLayerId . '"]+';
309 if ($this->mconf['relativeToParentLayer.']['addWidth']) {
310 $relCode['X'] .= 'GLV_curLayerWidth["' . $parentLayerId . '"]+';
311 }
312 if ($this->mconf['relativeToParentLayer.']['addHeight']) {
313 $relCode['Y'] .= 'GLV_curLayerHeight["' . $parentLayerId . '"]+';
314 }
315 }
316 if ($this->mconf['relativeToTriggerItem']) {
317 $DoTop[] = '
318 var parentObject = GL_getObj(GLV_menuXY[WMid][id][2]);
319 var TI_width = parentObject.width;
320 var TI_height = parentObject.height;
321 var anchorObj = GL_getObj(GLV_menuXY[WMid][id][3]);
322 var TI_x = anchorObj.x;
323 var TI_y = anchorObj.y;
324 ';
325 $relCode['X'] .= 'TI_x+';
326 $relCode['Y'] .= 'TI_y+';
327 if ($this->mconf['relativeToTriggerItem.']['addWidth']) {
328 $relCode['X'] .= 'TI_width+';
329 }
330 if ($this->mconf['relativeToTriggerItem.']['addHeight']) {
331 $relCode['Y'] .= 'TI_height+';
332 }
333 $relFlag = 1;
334 }
335 if ($relFlag) {
336 $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].left = (' . $relCode['X'] . intval($this->mconf['leftOffset']) . $dirL . ')+"px";';
337 $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].top = (' . $relCode['Y'] . intval($this->mconf['topOffset']) . $dirU . ')+"px";';
338 } else {
339 // X position (y is fixed)
340 if (!strcmp($this->mconf['lockPosition'], 'x')) {
341 $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].left = (' . $relCode['X'] . 'GLV_menuXY["' . $this->WMid . '"][id][0]-(' . intval($this->mconf['xPosOffset']) . ')' . $dirL . ')+"px";';
342 if ($this->isSetIntval($this->mconf['topOffset'])) {
343 $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].top = (' . $relCode['Y'] . intval($this->mconf['topOffset']) . $dirU . ')+"px";';
344 }
345 } elseif ($this->isSetIntval($this->mconf['xPosOffset'])) {
346 $GLV_menuOn[] = ($DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].left = (GLV_x-(' . intval($this->mconf['xPosOffset']) . ')' . $dirL . ')+"px";');
347 if ($this->isSetIntval($this->mconf['topOffset'])) {
348 $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].top = (' . $relCode['Y'] . intval($this->mconf['topOffset']) . $dirU . ')+"px";';
349 }
350 }
351 // Y position (x is fixed)
352 if (!strcmp($this->mconf['lockPosition'], 'y')) {
353 $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].top = (' . $relCode['Y'] . 'GLV_menuXY["' . $this->WMid . '"][id][1]-(' . intval($this->mconf['yPosOffset']) . ')' . $dirU . ')+"px";';
354 if ($this->isSetIntval($this->mconf['leftOffset'])) {
355 $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].left = (' . $relCode['X'] . intval($this->mconf['leftOffset']) . $dirL . ')+"px";';
356 }
357 } elseif ($this->isSetIntval($this->mconf['yPosOffset'])) {
358 $GLV_menuOn[] = ($DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].top = (GLV_y-(' . intval($this->mconf['yPosOffset']) . ')' . $dirU . ')+"px";');
359 if ($this->isSetIntval($this->mconf['leftOffset'])) {
360 $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].left = (' . $relCode['X'] . intval($this->mconf['leftOffset']) . $dirL . ')+"px";';
361 }
362 }
363 }
364 // BordersWithIn:
365 $DoTop[] = $this->extCalcBorderWithin('left', $this->WMbordersWithin[0]);
366 $DoTop[] = $this->extCalcBorderWithin('top', $this->WMbordersWithin[1]);
367 $DoTop[] = $this->extCalcBorderWithin('right', $this->WMbordersWithin[2]);
368 $DoTop[] = $this->extCalcBorderWithin('bottom', $this->WMbordersWithin[3]);
369 $DoTop[] = $this->extCalcBorderWithin('left', $this->WMbordersWithin[4]);
370 $DoTop[] = $this->extCalcBorderWithin('top', $this->WMbordersWithin[5]);
371 if ($this->mconf['freezeMouseover'] && !$this->mconf['freezeMouseover.']['alwaysKeep']) {
372 $this->WMhideCode .= '
373 GL' . $this->WMid . '_out("");';
374 }
375 $TEST = '';
376 if (count($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'])) {
377 foreach ($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'] as $mIdStr) {
378 $this->WMhideCode .= '
379 GL_hideAll("' . $mIdStr . '");';
380 $this->WMrestoreScript .= '
381 GL_restoreMenu("' . $mIdStr . '");';
382 $this->WMresetSubMenus .= '
383 if (!GLV_doReset["' . $mIdStr . '"] && GLV_currentLayer["' . $mIdStr . '"]!=null) resetSubMenu=0;';
384 }
385 }
386 // IESelectFix - Adds IFRAME tag to HTML, Hides IFRAME layer below menu
387 if ($this->mconf['ieSelectFix']) {
388 $this->WMhideCode .= '
389 GL_iframer(\'' . $this->WMid . '\',\'\',false);';
390 $this->divLayers['iframe'] = '<iframe id="Iframe' . $this->WMid . '" scrolling="no" frameborder="0" style="position:absolute; top:0px; left:0px; background-color:transparent; layer-background-color:transparent; display:none;"></iframe>';
391 }
392 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'] = array_merge($this->WMtempStore, $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']);
393 $GLOBALS['TSFE']->additionalHeaderData['gmenu_layer_shared'] = '<script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('statictemplates') . 'media/scripts/jsfunc.layermenu.js"></script>';
394 $GLOBALS['TSFE']->JSCode .= '
395
396 GLV_curLayerWidth["' . $this->WMid . '"]=0;
397 GLV_curLayerHeight["' . $this->WMid . '"]=0;
398 GLV_curLayerX["' . $this->WMid . '"]=0;
399 GLV_curLayerY["' . $this->WMid . '"]=0;
400 GLV_menuOn["' . $this->WMid . '"] = null;
401 GLV_gap["' . $this->WMid . '"]=' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->mconf['hideMenuWhenNotOver'], 0, 600) . ';
402 GLV_currentLayer["' . $this->WMid . '"] = null;
403 GLV_currentROitem["' . $this->WMid . '"] = null;
404 GLV_hasBeenOver["' . $this->WMid . '"]=0;
405 GLV_doReset["' . $this->WMid . '"]=false;
406 GLV_lastKey["' . $this->WMid . '"] = "' . $this->WMlastKey . '";
407 GLV_onlyOnLoad["' . $this->WMid . '"] = ' . ($this->WMonlyOnLoad ? 1 : 0) . ';
408 GLV_dontHideOnMouseUp["' . $this->WMid . '"] = ' . ($this->mconf['dontHideOnMouseUp'] ? 1 : 0) . ';
409 GLV_dontFollowMouse["' . $this->WMid . '"] = ' . ($this->mconf['dontFollowMouse'] ? 1 : 0) . ';
410 GLV_date = new Date();
411 GLV_timeout["' . $this->WMid . '"] = GLV_date.getTime();
412 GLV_timeoutRef["' . $this->WMid . '"] = ' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->mconf['hideMenuTimer'], 0, 20000) . ';
413 GLV_menuXY["' . $this->WMid . '"] = new Array();
414 ' . implode(LF, $this->WMxyArray) . '
415 ' . $this->WMrestoreVars;
416 if ($this->mconf['freezeMouseover']) {
417 $GLOBALS['TSFE']->JSCode .= '
418 // Alternative rollover/out functions for use with GMENU_LAYER
419 function GL' . $this->WMid . '_over(mitm_id) {
420 GL' . $this->WMid . '_out(""); // removes any old roll over state of an item. Needed for alwaysKeep and Opera browsers.
421 switch(mitm_id) {
422 ' . implode(LF, $this->VMmouseoverActions) . '
423 }
424 GLV_currentROitem["' . $this->WMid . '"]=mitm_id;
425 }
426 function GL' . $this->WMid . '_out(mitm_id) {
427 if (!mitm_id) mitm_id=GLV_currentROitem["' . $this->WMid . '"];
428 switch(mitm_id) {
429 ' . implode(LF, $this->VMmouseoutActions) . '
430 }
431 }
432 ';
433 }
434 $GLOBALS['TSFE']->JSCode .= '
435 function GL' . $this->WMid . '_getMouse(e) {
436 if (GLV_menuOn["' . $this->WMid . '"]!=null && !GLV_dontFollowMouse["' . $this->WMid . '"]){
437 ' . implode(LF, $GLV_menuOn) . '
438 }
439 GL_mouseMoveEvaluate("' . $this->WMid . '");
440 }
441 function GL' . $this->WMid . '_hideCode() {
442 ' . $this->WMhideCode . '
443 }
444 function GL' . $this->WMid . '_doTop(WMid,id) {
445 ' . trim(implode(LF, $DoTop)) . '
446 }
447 function GL' . $this->WMid . '_restoreMenu() {
448 ' . $this->WMrestoreScript . '
449 }
450 function GL' . $this->WMid . '_resetSubMenus() {
451 var resetSubMenu=1;
452 ' . $this->WMresetSubMenus . '
453 return resetSubMenu;
454 }
455
456 GLV_timeout_pointers[GLV_timeout_count] = "' . $this->WMid . '";
457 GLV_timeout_count++;
458
459 ';
460 $GLOBALS['TSFE']->JSeventFuncCalls['onload']['GL_initLayers()'] = 'GL_initLayers();';
461 $GLOBALS['TSFE']->JSeventFuncCalls['onload'][$this->WMid] = 'GL_restoreMenu("' . $this->WMid . '");';
462 // Should be called BEFORE any of the 'local' getMouse functions!
463 // is put inside in a try catch block to avoid JS errors in IE
464 $GLOBALS['TSFE']->JSeventFuncCalls['onmousemove']['GL_getMouse(e)'] = 'try{GL_getMouse(e);}catch(ex){};';
465 $GLOBALS['TSFE']->JSeventFuncCalls['onmousemove'][$this->WMid] = 'try{GL' . $this->WMid . '_getMouse(e);}catch(ex){};';
466 $GLOBALS['TSFE']->JSeventFuncCalls['onmouseup'][$this->WMid] = 'GL_mouseUp(\'' . $this->WMid . '\',e);';
467 $GLOBALS['TSFE']->divSection .= implode($this->divLayers, LF) . LF;
468 return parent::extProc_finish();
469 }
470
471 /**
472 * Creates a JavaScript line which corrects the position of the layer
473 * based on the constraints in TypoScript property 'bordersWithin'
474 *
475 * @param string $kind Direction to test.
476 * @param integer $integer The boundary limit in the direction set by $kind. If set then a value is returned, otherwise blank.
477 * @return string JavaScript string for correction of the layer position (if $integer is TRUE)
478 * @see extProc_finish(), extProc_init()
479 * @todo Define visibility
480 */
481 public function extCalcBorderWithin($kind, $integer) {
482 if ($integer) {
483 switch ($kind) {
484 case 'right':
485
486 case 'bottom':
487 $add = '';
488 if ($kind == 'right') {
489 $add = 'GL_getObj(id).width';
490 $key = 'left';
491 }
492 if ($kind == 'bottom') {
493 $add = 'GL_getObj(id).height';
494 $key = 'top';
495 }
496 $str = 'if (parseInt(GLV_menuOn["' . $this->WMid . '"].' . $key . ')+' . $add . '>' . $integer . ') GLV_menuOn["' . $this->WMid . '"].' . $key . '=' . $integer . '-' . $add . ';';
497 break;
498 default:
499 $str = 'if (parseInt(GLV_menuOn["' . $this->WMid . '"].' . $kind . ')<' . $integer . ') GLV_menuOn["' . $this->WMid . '"].' . $kind . '=' . $integer . ';';
500 break;
501 }
502 }
503 return $str;
504 }
505
506 }
507
508
509 ?>