[BUGFIX] Usage of deprecated returnFilemounts()
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / ContentObject / Menu / TextMenuLayersContentObject.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 TMENU_LAYERS menu object
32 * Class for the creation of text based DHTML menus
33 *
34 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
35 */
36 class TextMenuLayersContentObject extends \TYPO3\CMS\Frontend\ContentObject\Menu\TextMenuContentObject {
37
38 // FULL DUPLICATE FROM gmenu_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 variables (all prefixed "WM")
146 *
147 * @return void
148 * @todo Define visibility
149 */
150 public function extProc_init() {
151 $this->WMid = trim($this->mconf['layer_menu_id']) ? trim($this->mconf['layer_menu_id']) . 'x' : substr(md5('gl' . serialize($this->mconf)), 0, 6);
152 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'][] = $this->WMid;
153 $this->WMtempStore = $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'];
154 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'] = array();
155 // Save:
156 $this->WMonlyOnLoad = $this->mconf['displayActiveOnLoad'] && !$this->mconf['displayActiveOnLoad.']['onlyOnLoad'];
157 $this->WMbordersWithin = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $this->mconf['bordersWithin'] . ',0,0,0,0,0');
158 }
159
160 /**
161 * Processing of mouse-over features depending on whether "freezeMouseover" property is set.
162 *
163 * @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
164 * @return void
165 * @todo Define visibility
166 */
167 public function extProc_RO($key) {
168 if ($this->mconf['freezeMouseover']) {
169 $this->VMmouseoverActions[$this->WMid . $key] = 'case "Menu' . $this->WMid . $key . '":' . $this->I['linkHREF']['onMouseover'] . '; break;';
170 $this->VMmouseoutActions[$this->WMid . $key] = 'case "Menu' . $this->WMid . $key . '":' . $this->I['linkHREF']['onMouseout'] . '; break;';
171 $this->I['linkHREF']['onMouseover'] = 'GL' . $this->WMid . '_over(\'Menu' . $this->WMid . $key . '\');';
172 $this->I['linkHREF']['onMouseout'] = '';
173 }
174 }
175
176 /**
177 * Processing before the links are created.
178 * This means primarily creating some javaScript code for the management.
179 *
180 * @param integer $key Pointer to $this->menuArr[$key] where the current menu element record is found
181 * @return void
182 * @todo Define visibility
183 */
184 public function extProc_beforeLinking($key) {
185 if ($this->I['uid']) {
186 array_push($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId'], $this->WMid);
187 $this->WMtheSubMenu = $this->subMenu($this->I['uid'], $this->WMsubmenuObjSuffixes[$key]['sOSuffix']);
188 array_pop($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId']);
189 $this->WMisSub = trim($this->WMtheSubMenu) ? 1 : 0;
190 if ($this->mconf['lockPosition_addSelf']) {
191 $this->WMy += (strcmp($this->mconf['setFixedHeight'], '') ? $this->mconf['setFixedHeight'] : $this->I['val']['output_h']) + intval($this->mconf['lockPosition_adjust']);
192 $this->WMx += (strcmp($this->mconf['setFixedWidth'], '') ? $this->mconf['setFixedWidth'] : $this->I['val']['output_w']) + intval($this->mconf['lockPosition_adjust']);
193 }
194 // orig: && $this->WMisSub, changed 210901
195 if ($this->isActive($this->I['uid'], $this->getMPvar($key)) && $this->mconf['displayActiveOnLoad']) {
196 $this->WMactiveHasSubMenu = $this->WMisSub;
197 $this->WMactiveKey = 'Menu' . $this->WMid . $key;
198 $this->WMrestoreVars = trim('
199 GLV_restoreMenu["' . $this->WMid . '"] = "' . $this->WMactiveKey . '";
200 ');
201 $this->WMrestoreScript = ' GL_doTop("' . $this->WMid . '",GLV_restoreMenu["' . $this->WMid . '"]);' . ($this->mconf['freezeMouseover'] ? '
202 GL' . $this->WMid . '_over(GLV_restoreMenu["' . $this->WMid . '"]);
203 ' : '');
204 }
205 if ($this->WMisSub) {
206 $event = 'GL_stopMove(\'' . $this->WMid . '\');';
207 $this->I['linkHREF']['onMouseover'] = 'GL_doTop(\'' . $this->WMid . '\', \'Menu' . $this->WMid . $key . '\');' . $this->I['linkHREF']['onMouseover'];
208 // IESelectFix - Activates IFRAME layer below menu
209 if ($this->mconf['ieSelectFix']) {
210 $this->I['linkHREF']['onMouseover'] = $this->I['linkHREF']['onMouseover'] . 'GL_iframer(\'' . $this->WMid . '\',\'Menu' . $this->WMid . $key . '\',true);';
211 }
212 // Added 120802; This means that everytime leaving a menuitem the layer
213 // should be shut down (and if the layer is hit in the meantime it is
214 // not though). This should happen only for items that are auto-hidden
215 // when not over and possibly only when a hide-timer is set. Problem is
216 // if the hide-timer is not set and we leave the main element, then the
217 // layer will be hidden unless we reach the layer before the timeout will
218 // happen and the menu hidden.
219 if (\TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->mconf['hideMenuWhenNotOver'], 0, 600) && $this->mconf['hideMenuTimer']) {
220 $event .= 'GL_resetAll("' . $this->WMid . '");';
221 }
222 $this->I['linkHREF']['onMouseout'] .= $event;
223 } else {
224 $this->I['linkHREF']['onMouseover'] = 'GL_hideAll("' . $this->WMid . '");' . $this->I['linkHREF']['onMouseover'];
225 // IESelectFix - Hides IFRAME layer below menu
226 if ($this->mconf['ieSelectFix']) {
227 $this->I['linkHREF']['onMouseover'] = $this->I['linkHREF']['onMouseover'] . 'GL_iframer(\'' . $this->WMid . '\',\'\',false);';
228 }
229 $event = 'GL_resetAll("' . $this->WMid . '");';
230 $this->I['linkHREF']['onMouseout'] .= $event;
231 }
232 $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)) . '");';
233 }
234 }
235
236 /**
237 * Processing after linking, basically setting the <div>-layers for the menu
238 * items. Also some more JavaScript code is made.
239 *
240 * @param integer $key Pointer to $this->menuArr[$key] where the current menu element record is found
241 * @return void
242 * @todo Define visibility
243 */
244 public function extProc_afterLinking($key) {
245 if ($this->I['uid']) {
246 if (!$this->I['spacer'] && $this->WMisSub) {
247 $exStyle = $this->mconf['layerStyle'] ? $this->mconf['layerStyle'] : 'position:absolute;visibility:hidden';
248 if (trim($exStyle)) {
249 $exStyle = ' ' . $exStyle;
250 }
251 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['layerCounter']++;
252 $zIndex = 10000 - $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['layerCounter'];
253 $divStart = '<div id="Menu' . $this->WMid . $key . '" style="z-index:' . $zIndex . ';' . $exStyle . '">';
254 $divStop = '</div>';
255 $this->divLayers[] = $divStart . $this->WMtheSubMenu . $divStop;
256 $this->WMhideCode .= '
257 GL_getObjCss("Menu' . $this->WMid . $key . '").visibility = "hidden";';
258 $this->WMlastKey = 'Menu' . $this->WMid . $key;
259 }
260 if (!$this->mconf['lockPosition_addSelf']) {
261 $this->WMy += (strcmp($this->mconf['setFixedHeight'], '') ? $this->mconf['setFixedHeight'] : $this->I['val']['output_h']) + intval($this->mconf['lockPosition_adjust']);
262 $this->WMx += (strcmp($this->mconf['setFixedWidth'], '') ? $this->mconf['setFixedWidth'] : $this->I['val']['output_w']) + intval($this->mconf['lockPosition_adjust']);
263 }
264 }
265 $this->WMresult .= $this->I['theItem'];
266 }
267
268 /**
269 * Wrapping the item in a <div> section if 'relativeToTriggerItem' was set
270 *
271 * @param string $item The current content of the menu item, $this->I['theItem'], passed along.
272 * @param integer $key Pointer to $this->menuArr[$key] where the current menu element record is found
273 * @return string The modified version of $item, going back into $this->I['theItem']
274 * @todo Define visibility
275 */
276 public function extProc_beforeAllWrap($item, $key) {
277 if ($this->mconf['relativeToTriggerItem']) {
278 $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>';
279 }
280 return $item;
281 }
282
283 /**
284 * Returns TRUE if different from '' OR if intval()!=0
285 *
286 * @param string $in Value to evaluate
287 * @return boolean TRUE if $in is different from '' OR if intval()!=0
288 * @todo Define visibility
289 */
290 public function isSetIntval($in) {
291 return $this->mconf['blankStrEqFalse'] ? strcmp($in, '') : intval($in);
292 }
293
294 /**
295 * Putting things together, in particular the JavaScript code needed for the DHTML menu.
296 *
297 * @return mixed Returns the value of a call to the parent function, parent::extProc_finish();
298 * @todo Define visibility
299 */
300 public function extProc_finish() {
301 $dirL = $this->mconf['directionLeft'] ? '-GL_getObj(id).width' : '';
302 $dirU = $this->mconf['directionUp'] ? '-GL_getObj(id).height' : '';
303 $parentLayerId = end($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId']);
304 $DoTop = array();
305 $GLV_menuOn = array();
306 $relCode = array();
307 $relFlag = 0;
308 if ($this->mconf['relativeToParentLayer'] && $parentLayerId) {
309 $relCode['X'] .= 'GLV_curLayerX["' . $parentLayerId . '"]+';
310 $relCode['Y'] .= 'GLV_curLayerY["' . $parentLayerId . '"]+';
311 if ($this->mconf['relativeToParentLayer.']['addWidth']) {
312 $relCode['X'] .= 'GLV_curLayerWidth["' . $parentLayerId . '"]+';
313 }
314 if ($this->mconf['relativeToParentLayer.']['addHeight']) {
315 $relCode['Y'] .= 'GLV_curLayerHeight["' . $parentLayerId . '"]+';
316 }
317 }
318 if ($this->mconf['relativeToTriggerItem']) {
319 $DoTop[] = '
320 var parentObject = GL_getObj(GLV_menuXY[WMid][id][2]);
321 var TI_width = parentObject.width;
322 var TI_height = parentObject.height;
323 var anchorObj = GL_getObj(GLV_menuXY[WMid][id][3]);
324 var TI_x = anchorObj.x;
325 var TI_y = anchorObj.y;
326 ';
327 $relCode['X'] .= 'TI_x+';
328 $relCode['Y'] .= 'TI_y+';
329 if ($this->mconf['relativeToTriggerItem.']['addWidth']) {
330 $relCode['X'] .= 'TI_width+';
331 }
332 if ($this->mconf['relativeToTriggerItem.']['addHeight']) {
333 $relCode['Y'] .= 'TI_height+';
334 }
335 $relFlag = 1;
336 }
337 if ($relFlag) {
338 $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].left = (' . $relCode['X'] . intval($this->mconf['leftOffset']) . $dirL . ')+"px";';
339 $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].top = (' . $relCode['Y'] . intval($this->mconf['topOffset']) . $dirU . ')+"px";';
340 } else {
341 // X position (y is fixed)
342 if (!strcmp($this->mconf['lockPosition'], 'x')) {
343 $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].left = (' . $relCode['X'] . 'GLV_menuXY["' . $this->WMid . '"][id][0]-(' . intval($this->mconf['xPosOffset']) . ')' . $dirL . ')+"px";';
344 if ($this->isSetIntval($this->mconf['topOffset'])) {
345 $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].top = (' . $relCode['Y'] . intval($this->mconf['topOffset']) . $dirU . ')+"px";';
346 }
347 } elseif ($this->isSetIntval($this->mconf['xPosOffset'])) {
348 $GLV_menuOn[] = ($DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].left = (GLV_x-(' . intval($this->mconf['xPosOffset']) . ')' . $dirL . ')+"px";');
349 if ($this->isSetIntval($this->mconf['topOffset'])) {
350 $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].top = (' . $relCode['Y'] . intval($this->mconf['topOffset']) . $dirU . ')+"px";';
351 }
352 }
353 // Y position (x is fixed)
354 if (!strcmp($this->mconf['lockPosition'], 'y')) {
355 $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].top = (' . $relCode['Y'] . 'GLV_menuXY["' . $this->WMid . '"][id][1]-(' . intval($this->mconf['yPosOffset']) . ')' . $dirU . ')+"px";';
356 if ($this->isSetIntval($this->mconf['leftOffset'])) {
357 $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].left = (' . $relCode['X'] . intval($this->mconf['leftOffset']) . $dirL . ')+"px";';
358 }
359 } elseif ($this->isSetIntval($this->mconf['yPosOffset'])) {
360 $GLV_menuOn[] = ($DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].top = (GLV_y-(' . intval($this->mconf['yPosOffset']) . ')' . $dirU . ')+"px";');
361 if ($this->isSetIntval($this->mconf['leftOffset'])) {
362 $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].left = (' . $relCode['X'] . intval($this->mconf['leftOffset']) . $dirL . ')+"px";';
363 }
364 }
365 }
366 // BordersWithIn:
367 $DoTop[] = $this->extCalcBorderWithin('left', $this->WMbordersWithin[0]);
368 $DoTop[] = $this->extCalcBorderWithin('top', $this->WMbordersWithin[1]);
369 $DoTop[] = $this->extCalcBorderWithin('right', $this->WMbordersWithin[2]);
370 $DoTop[] = $this->extCalcBorderWithin('bottom', $this->WMbordersWithin[3]);
371 $DoTop[] = $this->extCalcBorderWithin('left', $this->WMbordersWithin[4]);
372 $DoTop[] = $this->extCalcBorderWithin('top', $this->WMbordersWithin[5]);
373 if ($this->mconf['freezeMouseover'] && !$this->mconf['freezeMouseover.']['alwaysKeep']) {
374 $this->WMhideCode .= '
375 GL' . $this->WMid . '_out("");';
376 }
377 $TEST = '';
378 if (count($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'])) {
379 foreach ($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'] as $mIdStr) {
380 $this->WMhideCode .= '
381 GL_hideAll("' . $mIdStr . '");';
382 $this->WMrestoreScript .= '
383 GL_restoreMenu("' . $mIdStr . '");';
384 $this->WMresetSubMenus .= '
385 if (!GLV_doReset["' . $mIdStr . '"] && GLV_currentLayer["' . $mIdStr . '"]!=null) resetSubMenu=0;';
386 }
387 }
388 // IESelectFix - Adds IFRAME tag to HTML, Hides IFRAME layer below menu
389 if ($this->mconf['ieSelectFix']) {
390 $this->WMhideCode .= '
391 GL_iframer(\'' . $this->WMid . '\',\'\',false);';
392 $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>';
393 }
394 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'] = array_merge($this->WMtempStore, $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']);
395 $GLOBALS['TSFE']->additionalHeaderData['gmenu_layer_shared'] = '<script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('statictemplates') . 'media/scripts/jsfunc.layermenu.js"></script>';
396 $GLOBALS['TSFE']->JSCode .= '
397
398 GLV_curLayerWidth["' . $this->WMid . '"]=0;
399 GLV_curLayerHeight["' . $this->WMid . '"]=0;
400 GLV_curLayerX["' . $this->WMid . '"]=0;
401 GLV_curLayerY["' . $this->WMid . '"]=0;
402 GLV_menuOn["' . $this->WMid . '"] = null;
403 GLV_gap["' . $this->WMid . '"]=' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->mconf['hideMenuWhenNotOver'], 0, 600) . ';
404 GLV_currentLayer["' . $this->WMid . '"] = null;
405 GLV_currentROitem["' . $this->WMid . '"] = null;
406 GLV_hasBeenOver["' . $this->WMid . '"]=0;
407 GLV_doReset["' . $this->WMid . '"]=false;
408 GLV_lastKey["' . $this->WMid . '"] = "' . $this->WMlastKey . '";
409 GLV_onlyOnLoad["' . $this->WMid . '"] = ' . ($this->WMonlyOnLoad ? 1 : 0) . ';
410 GLV_dontHideOnMouseUp["' . $this->WMid . '"] = ' . ($this->mconf['dontHideOnMouseUp'] ? 1 : 0) . ';
411 GLV_dontFollowMouse["' . $this->WMid . '"] = ' . ($this->mconf['dontFollowMouse'] ? 1 : 0) . ';
412 GLV_date = new Date();
413 GLV_timeout["' . $this->WMid . '"] = GLV_date.getTime();
414 GLV_timeoutRef["' . $this->WMid . '"] = ' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->mconf['hideMenuTimer'], 0, 20000) . ';
415 GLV_menuXY["' . $this->WMid . '"] = new Array();
416 ' . implode(LF, $this->WMxyArray) . '
417 ' . $this->WMrestoreVars;
418 if ($this->mconf['freezeMouseover']) {
419 $GLOBALS['TSFE']->JSCode .= '
420 // Alternative rollover/out functions for use with GMENU_LAYER
421 function GL' . $this->WMid . '_over(mitm_id) {
422 GL' . $this->WMid . '_out(""); // removes any old roll over state of an item. Needed for alwaysKeep and Opera browsers.
423 switch(mitm_id) {
424 ' . implode(LF, $this->VMmouseoverActions) . '
425 }
426 GLV_currentROitem["' . $this->WMid . '"]=mitm_id;
427 }
428 function GL' . $this->WMid . '_out(mitm_id) {
429 if (!mitm_id) mitm_id=GLV_currentROitem["' . $this->WMid . '"];
430 switch(mitm_id) {
431 ' . implode(LF, $this->VMmouseoutActions) . '
432 }
433 }
434 ';
435 }
436 $GLOBALS['TSFE']->JSCode .= '
437 function GL' . $this->WMid . '_getMouse(e) {
438 if (GLV_menuOn["' . $this->WMid . '"]!=null && !GLV_dontFollowMouse["' . $this->WMid . '"]){
439 ' . implode(LF, $GLV_menuOn) . '
440 }
441 GL_mouseMoveEvaluate("' . $this->WMid . '");
442 }
443 function GL' . $this->WMid . '_hideCode() {
444 ' . $this->WMhideCode . '
445 }
446 function GL' . $this->WMid . '_doTop(WMid,id) {
447 ' . trim(implode(LF, $DoTop)) . '
448 }
449 function GL' . $this->WMid . '_restoreMenu() {
450 ' . $this->WMrestoreScript . '
451 }
452 function GL' . $this->WMid . '_resetSubMenus() {
453 var resetSubMenu=1;
454 ' . $this->WMresetSubMenus . '
455 return resetSubMenu;
456 }
457
458 GLV_timeout_pointers[GLV_timeout_count] = "' . $this->WMid . '";
459 GLV_timeout_count++;
460
461 ';
462 $GLOBALS['TSFE']->JSeventFuncCalls['onload']['GL_initLayers()'] = 'GL_initLayers();';
463 $GLOBALS['TSFE']->JSeventFuncCalls['onload'][$this->WMid] = 'GL_restoreMenu("' . $this->WMid . '");';
464 // Should be called BEFORE any of the 'local' getMouse functions!
465 // is put inside in a try catch block to avoid JS errors in IE
466 $GLOBALS['TSFE']->JSeventFuncCalls['onmousemove']['GL_getMouse(e)'] = 'try{GL_getMouse(e);}catch(ex){};';
467 $GLOBALS['TSFE']->JSeventFuncCalls['onmousemove'][$this->WMid] = 'try{GL' . $this->WMid . '_getMouse(e);}catch(ex){};';
468 $GLOBALS['TSFE']->JSeventFuncCalls['onmouseup'][$this->WMid] = 'GL_mouseUp(\'' . $this->WMid . '\',e);';
469 $GLOBALS['TSFE']->divSection .= implode($this->divLayers, LF) . LF;
470 return parent::extProc_finish();
471 }
472
473 /**
474 * Creates a JavaScript line which corrects the position of the layer based on
475 * the constraints in TypoScript property 'bordersWithin'
476 *
477 * @param string $kind Direction to test.
478 * @param integer $integer The boundary limit in the direction set by $kind. If set then a value is returned, otherwise blank.
479 * @return string JavaScript string for correction of the layer position (if $integer is TRUE)
480 * @see extProc_finish(), extProc_init()
481 * @todo Define visibility
482 */
483 public function extCalcBorderWithin($kind, $integer) {
484 if ($integer) {
485 switch ($kind) {
486 case 'right':
487
488 case 'bottom':
489 $add = '';
490 if ($kind == 'right') {
491 $add = 'GL_getObj(id).width';
492 $key = 'left';
493 }
494 if ($kind == 'bottom') {
495 $add = 'GL_getObj(id).height';
496 $key = 'top';
497 }
498 $str = 'if (parseInt(GLV_menuOn["' . $this->WMid . '"].' . $key . ')+' . $add . '>' . $integer . ') GLV_menuOn["' . $this->WMid . '"].' . $key . '=' . $integer . '-' . $add . ';';
499 break;
500 default:
501 $str = 'if (parseInt(GLV_menuOn["' . $this->WMid . '"].' . $kind . ')<' . $integer . ') GLV_menuOn["' . $this->WMid . '"].' . $kind . '=' . $integer . ';';
502 break;
503 }
504 }
505 return $str;
506 }
507
508 }
509
510
511 ?>