Documentation TYPO3 par Ameos |
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00084 class tslib_tmenu_layers extends tslib_tmenu { 00085 00086 // FULL DUPLICATE FROM gmenu_layers BEGIN: 00087 00088 var $GMENU_fixKey='layers'; 00089 var $divLayers=Array(); 00090 00091 var $WMx=0; 00092 var $WMy=0; 00093 var $WMxyArray=array(); 00094 var $WMextraScript=''; 00095 var $WMlastKey=''; 00096 var $WMrestoreScript=''; 00097 var $WMresetSubMenus=''; 00098 var $WMactiveHasSubMenu=''; 00099 var $WMactiveKey=''; 00100 var $WMtheSubMenu; 00101 var $WMisSub; 00102 var $WMhideCode; 00103 var $WMonlyOnLoad=0; 00104 var $WMbordersWithin=array(); 00105 var $WMsubIds=array(); 00106 var $WMtempStore=array(); 00107 var $WMlockPosition_addAccumulated=array(); 00108 var $VMmouseoverActions=array(); 00109 var $VMmouseoutActions=array(); 00110 00116 function extProc_init() { 00117 $this->WMid = trim($this->mconf['layer_menu_id'])?trim($this->mconf['layer_menu_id']).'x':substr(md5(microtime()),0,6); // NO '_' (underscore) in the ID!!! NN4 breaks! 00118 00119 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'][]=$this->WMid; 00120 $this->WMtempStore = $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']; 00121 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']=array(); 00122 00123 // Save: 00124 $this->WMonlyOnLoad = ($this->mconf['displayActiveOnLoad'] && !$this->mconf['displayActiveOnLoad.']['onlyOnLoad']); 00125 $this->WMbordersWithin = t3lib_div::intExplode(',',$this->mconf['bordersWithin'].',0,0,0,0,0'); 00126 } 00127 00134 function extProc_RO($key) { 00135 if ($this->mconf['freezeMouseover']) { 00136 $this->VMmouseoverActions[$this->WMid.$key]='case "Menu'.$this->WMid.$key.'":'.$this->I['linkHREF']['onMouseover'].'; break;'; 00137 $this->VMmouseoutActions[$this->WMid.$key]='case "Menu'.$this->WMid.$key.'":'.$this->I['linkHREF']['onMouseout'].'; break;'; 00138 $this->I['linkHREF']['onMouseover']='GL'.$this->WMid.'_over(\'Menu'.$this->WMid.$key.'\');'; 00139 $this->I['linkHREF']['onMouseout']=''; 00140 } 00141 } 00142 00150 function extProc_beforeLinking($key) { 00151 if ($this->I['uid']) { 00152 00153 array_push($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId'],$this->WMid); 00154 $this->WMtheSubMenu = $this->subMenu($this->I['uid'], $this->WMsubmenuObjSuffixes[$key]['sOSuffix']); 00155 array_pop($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId']); 00156 $this->WMisSub = trim($this->WMtheSubMenu) ? 1 : 0; 00157 00158 if ($this->mconf['lockPosition_addSelf']) { 00159 $this->WMy+=(strcmp($this->mconf['setFixedHeight'],'')?$this->mconf['setFixedHeight']:$this->I['val']['output_h'])+intval($this->mconf['lockPosition_adjust']); 00160 $this->WMx+=(strcmp($this->mconf['setFixedWidth'],'')?$this->mconf['setFixedWidth']:$this->I['val']['output_w'])+intval($this->mconf['lockPosition_adjust']); 00161 } 00162 00163 if ($this->isActive($this->I['uid'], $this->getMPvar($key)) && $this->mconf['displayActiveOnLoad']) { // orig: && $this->WMisSub, changed 210901 00164 $this->WMactiveHasSubMenu = $this->WMisSub; 00165 $this->WMactiveKey = 'Menu'.$this->WMid.$key; 00166 00167 00168 $this->WMrestoreVars=trim(' 00169 GLV_restoreMenu["'.$this->WMid.'"] = "'.$this->WMactiveKey.'"; 00170 '); 00171 $this->WMrestoreScript=' GL_doTop("'.$this->WMid.'",GLV_restoreMenu["'.$this->WMid.'"]);'.($this->mconf['freezeMouseover']?' 00172 GL'.$this->WMid.'_over(GLV_restoreMenu["'.$this->WMid.'"]); 00173 ':''); 00174 } 00175 00176 if ($this->WMisSub) { 00177 $event="GL_stopMove('".$this->WMid."');"; 00178 $this->I['linkHREF']['onMouseover']='GL_doTop(\''.$this->WMid.'\', \'Menu'.$this->WMid.$key.'\');'.$this->I['linkHREF']['onMouseover']; 00179 // IESelectFix - Activates IFRAME layer below menu 00180 if ($this->mconf['ieSelectFix']) $this->I['linkHREF']['onMouseover']=$this->I['linkHREF']['onMouseover'].'GL_iframer(\''.$this->WMid.'\',\'Menu'.$this->WMid.$key.'\',true);'; 00181 // 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). 00182 // 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. 00183 if (t3lib_div::intInRange($this->mconf['hideMenuWhenNotOver'],0,600) && $this->mconf['hideMenuTimer']) { 00184 $event.='GL_resetAll("'.$this->WMid.'");'; 00185 } 00186 $this->I['linkHREF']['onMouseout'].=$event; 00187 } else { 00188 $this->I['linkHREF']['onMouseover'] = 'GL_hideAll("'.$this->WMid.'");'.$this->I['linkHREF']['onMouseover']; 00189 // IESelectFix - Hides IFRAME layer below menu 00190 if ($this->mconf['ieSelectFix']) $this->I['linkHREF']['onMouseover'] = $this->I['linkHREF']['onMouseover'].'GL_iframer(\''.$this->WMid.'\',\'\',false);'; 00191 $event='GL_resetAll("'.$this->WMid.'");'; 00192 $this->I['linkHREF']['onMouseout'].=$event; 00193 } 00194 00195 $this->WMxyArray[] = 'GLV_menuXY["'.$this->WMid.'"]["Menu'.$this->WMid.$key.'"] = new Array('.$this->WMx.','.$this->WMy.',"itemID'.t3lib_div::shortmd5($this->I['uid'].'-'.$this->WMid).'","anchorID'.t3lib_div::shortmd5($this->I['uid'].'-'.$this->WMid).'");'; 00196 } 00197 } 00198 00205 function extProc_afterLinking($key) { 00206 if ($this->I['uid']) { 00207 if (!$this->I['spacer'] && $this->WMisSub) { 00208 $exStyle=$this->mconf['layerStyle'] ? $this->mconf['layerStyle'] : 'position:absolute;visibility:hidden'; 00209 if (trim($exStyle)) { 00210 $exStyle=' '.$exStyle; 00211 } 00212 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['layerCounter']++; 00213 $zIndex = 10000-$GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['layerCounter']; 00214 # $zIndex = (($key+2)*$this->menuNumber*100); 00215 $divStart = '<div id="Menu'.$this->WMid.$key.'" style="z-index:'.$zIndex.';'.$exStyle.'">'; 00216 $divStop = '</div>'; 00217 00218 $this->divLayers[]= $divStart.$this->WMtheSubMenu.$divStop; 00219 00220 $this->WMhideCode.=' 00221 GL_getObjCss("Menu'.$this->WMid.$key.'").visibility = "hidden";'; 00222 $this->WMlastKey = 'Menu'.$this->WMid.$key; 00223 } 00224 00225 if (!$this->mconf['lockPosition_addSelf']) { 00226 $this->WMy+=(strcmp($this->mconf['setFixedHeight'],'')?$this->mconf['setFixedHeight']:$this->I['val']['output_h'])+intval($this->mconf['lockPosition_adjust']); 00227 $this->WMx+=(strcmp($this->mconf['setFixedWidth'],'')?$this->mconf['setFixedWidth']:$this->I['val']['output_w'])+intval($this->mconf['lockPosition_adjust']); 00228 } 00229 } 00230 $this->WMresult.=$this->I['theItem']; 00231 } 00232 00240 function extProc_beforeAllWrap($item,$key) { 00241 if ($this->mconf['relativeToTriggerItem']) { 00242 $item = '<div id="anchorID'.t3lib_div::shortmd5($this->I['uid'].'-'.$this->WMid).'" style="position:absolute;visibility:hidden;"></div><div id="itemID'.t3lib_div::shortmd5($this->I['uid'].'-'.$this->WMid).'" style="width:100%; height:100%;">'.$item.'</div>'; 00243 } 00244 return $item; 00245 } 00246 00253 function isSetIntval($in) { 00254 return $this->mconf['blankStrEqFalse'] ? strcmp($in,'') : intval($in); 00255 } 00256 00262 function extProc_finish () { 00263 $dirL = $this->mconf['directionLeft'] ? '-GL_getObj(id).width' : ''; 00264 $dirU = $this->mconf['directionUp'] ? '-GL_getObj(id).height' : ''; 00265 00266 $parentLayerId = end($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId']); 00267 00268 $DoTop=array(); 00269 $GLV_menuOn=array(); 00270 $relCode=array(); 00271 $relFlag=0; 00272 if ($this->mconf['relativeToParentLayer'] && $parentLayerId) { 00273 $relCode['X'].='GLV_curLayerX["'.$parentLayerId.'"]+'; 00274 $relCode['Y'].='GLV_curLayerY["'.$parentLayerId.'"]+'; 00275 if ($this->mconf['relativeToParentLayer.']['addWidth']) { $relCode['X'].='GLV_curLayerWidth["'.$parentLayerId.'"]+'; } 00276 if ($this->mconf['relativeToParentLayer.']['addHeight']) { $relCode['Y'].='GLV_curLayerHeight["'.$parentLayerId.'"]+'; } 00277 } 00278 if ($this->mconf['relativeToTriggerItem']) { 00279 $DoTop[]=' 00280 var parentObject = GL_getObj(GLV_menuXY[WMid][id][2]); 00281 var TI_width = parentObject.width; 00282 var TI_height = parentObject.height; 00283 var anchorObj = GL_getObj(GLV_menuXY[WMid][id][3]); 00284 var TI_x = anchorObj.x; 00285 var TI_y = anchorObj.y; 00286 '; 00287 $relCode['X'].='TI_x+'; 00288 $relCode['Y'].='TI_y+'; 00289 00290 if ($this->mconf['relativeToTriggerItem.']['addWidth']) { $relCode['X'].='TI_width+'; } 00291 if ($this->mconf['relativeToTriggerItem.']['addHeight']) { $relCode['Y'].='TI_height+'; } 00292 $relFlag=1; 00293 } 00294 if ($relFlag) { 00295 $DoTop[]='GLV_menuOn["'.$this->WMid.'"].left = ('.$relCode['X'].intval($this->mconf['leftOffset']).$dirL.')+"px";'; 00296 $DoTop[]='GLV_menuOn["'.$this->WMid.'"].top = ('.$relCode['Y'].intval($this->mconf['topOffset']).$dirU.')+"px";'; 00297 } else { 00298 // X position (y is fixed) 00299 if (!strcmp($this->mconf['lockPosition'],'x')) { 00300 $DoTop[]='GLV_menuOn["'.$this->WMid.'"].left = ('.$relCode['X'].'GLV_menuXY["'.$this->WMid.'"][id][0]-('.intval($this->mconf['xPosOffset']).')'.$dirL.')+"px";'; 00301 if ($this->isSetIntval($this->mconf['topOffset'])) { 00302 $DoTop[]='GLV_menuOn["'.$this->WMid.'"].top = ('.$relCode['Y'].intval($this->mconf['topOffset']).$dirU.')+"px";'; 00303 } 00304 } elseif ($this->isSetIntval($this->mconf['xPosOffset'])) { 00305 $GLV_menuOn[]=$DoTop[]='GLV_menuOn["'.$this->WMid.'"].left = (GLV_x-('.intval($this->mconf['xPosOffset']).')'.$dirL.')+"px";'; 00306 if ($this->isSetIntval($this->mconf['topOffset'])) { 00307 $DoTop[]='GLV_menuOn["'.$this->WMid.'"].top = ('.$relCode['Y'].intval($this->mconf['topOffset']).$dirU.')+"px";'; 00308 } 00309 } 00310 // Y position (x is fixed) 00311 if (!strcmp($this->mconf['lockPosition'],'y')) { 00312 $DoTop[]='GLV_menuOn["'.$this->WMid.'"].top = ('.$relCode['Y'].'GLV_menuXY["'.$this->WMid.'"][id][1]-('.intval($this->mconf['yPosOffset']).')'.$dirU.')+"px";'; 00313 if ($this->isSetIntval($this->mconf['leftOffset'])) { 00314 $DoTop[]='GLV_menuOn["'.$this->WMid.'"].left = ('.$relCode['X'].intval($this->mconf['leftOffset']).$dirL.')+"px";'; 00315 } 00316 } elseif ($this->isSetIntval($this->mconf['yPosOffset'])) { 00317 $GLV_menuOn[]=$DoTop[]='GLV_menuOn["'.$this->WMid.'"].top = (GLV_y-('.intval($this->mconf['yPosOffset']).')'.$dirU.')+"px";'; 00318 if ($this->isSetIntval($this->mconf['leftOffset'])) { 00319 $DoTop[]='GLV_menuOn["'.$this->WMid.'"].left = ('.$relCode['X'].intval($this->mconf['leftOffset']).$dirL.')+"px";'; 00320 } 00321 } 00322 } 00323 00324 // BordersWithIn: 00325 $DoTop[]=$this->extCalcBorderWithin('left',$this->WMbordersWithin[0]); 00326 $DoTop[]=$this->extCalcBorderWithin('top',$this->WMbordersWithin[1]); 00327 $DoTop[]=$this->extCalcBorderWithin('right',$this->WMbordersWithin[2]); 00328 $DoTop[]=$this->extCalcBorderWithin('bottom',$this->WMbordersWithin[3]); 00329 $DoTop[]=$this->extCalcBorderWithin('left',$this->WMbordersWithin[4]); 00330 $DoTop[]=$this->extCalcBorderWithin('top',$this->WMbordersWithin[5]); 00331 00332 00333 if ($this->mconf['freezeMouseover'] && !$this->mconf['freezeMouseover.']['alwaysKeep']) { 00334 $this->WMhideCode.=' 00335 GL'.$this->WMid.'_out("");'; 00336 } 00337 00338 $TEST=''; 00339 if (count($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'])) { 00340 reset($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']); 00341 while(list(,$mIdStr)=each($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'])) { 00342 $this->WMhideCode.=' 00343 GL_hideAll("'.$mIdStr.'");'; 00344 $this->WMrestoreScript.=' 00345 GL_restoreMenu("'.$mIdStr.'");'; 00346 $this->WMresetSubMenus.=' 00347 if (!GLV_doReset["'.$mIdStr.'"] && GLV_currentLayer["'.$mIdStr.'"]!=null) resetSubMenu=0;'; 00348 } 00349 } 00350 // IESelectFix - Adds IFRAME tag to HTML, Hides IFRAME layer below menu 00351 if ($this->mconf['ieSelectFix']) { 00352 $this->WMhideCode.= ' 00353 GL_iframer(\''.$this->WMid.'\',\'\',false);'; 00354 $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>'; 00355 } 00356 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']=array_merge($this->WMtempStore,$GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']); 00357 $GLOBALS['TSFE']->additionalHeaderData['gmenu_layer_shared']='<script type="text/javascript" src="'.$GLOBALS['TSFE']->absRefPrefix.'media/scripts/jsfunc.layermenu.js"></script>'; 00358 $GLOBALS['TSFE']->JSCode.= ' 00359 00360 GLV_curLayerWidth["'.$this->WMid.'"]=0; 00361 GLV_curLayerHeight["'.$this->WMid.'"]=0; 00362 GLV_curLayerX["'.$this->WMid.'"]=0; 00363 GLV_curLayerY["'.$this->WMid.'"]=0; 00364 GLV_menuOn["'.$this->WMid.'"] = null; 00365 GLV_gap["'.$this->WMid.'"]='.t3lib_div::intInRange($this->mconf['hideMenuWhenNotOver'],0,600).'; 00366 GLV_currentLayer["'.$this->WMid.'"] = null; 00367 GLV_currentROitem["'.$this->WMid.'"] = null; 00368 GLV_hasBeenOver["'.$this->WMid.'"]=0; 00369 GLV_doReset["'.$this->WMid.'"]=false; 00370 GLV_lastKey["'.$this->WMid.'"] = "'.$this->WMlastKey.'"; 00371 GLV_onlyOnLoad["'.$this->WMid.'"] = '.($this->WMonlyOnLoad?1:0).'; 00372 GLV_dontHideOnMouseUp["'.$this->WMid.'"] = '.($this->mconf['dontHideOnMouseUp']?1:0).'; 00373 GLV_dontFollowMouse["'.$this->WMid.'"] = '.($this->mconf['dontFollowMouse']?1:0).'; 00374 GLV_date = new Date(); 00375 GLV_timeout["'.$this->WMid.'"] = GLV_date.getTime(); 00376 GLV_timeoutRef["'.$this->WMid.'"] = '.t3lib_div::intInRange($this->mconf['hideMenuTimer'],0,20000).'; 00377 GLV_menuXY["'.$this->WMid.'"] = new Array(); 00378 '.implode(chr(10),$this->WMxyArray).' 00379 '.$this->WMrestoreVars; 00380 00381 if ($this->mconf['freezeMouseover']) { 00382 $GLOBALS['TSFE']->JSCode.= ' 00383 // Alternative rollover/out functions for use with GMENU_LAYER 00384 function GL'.$this->WMid.'_over(mitm_id) { 00385 GL'.$this->WMid.'_out(""); // removes any old roll over state of an item. Needed for alwaysKeep and Opera browsers. 00386 switch(mitm_id) { 00387 '.implode(chr(10),$this->VMmouseoverActions).' 00388 } 00389 GLV_currentROitem["'.$this->WMid.'"]=mitm_id; 00390 } 00391 function GL'.$this->WMid.'_out(mitm_id) { 00392 if (!mitm_id) mitm_id=GLV_currentROitem["'.$this->WMid.'"]; 00393 switch(mitm_id) { 00394 '.implode(chr(10),$this->VMmouseoutActions).' 00395 } 00396 } 00397 '; 00398 } 00399 $GLOBALS["TSFE"]->JSCode.= ' 00400 function GL'.$this->WMid.'_getMouse(e) { 00401 if (GLV_menuOn["'.$this->WMid.'"]!=null && !GLV_dontFollowMouse["'.$this->WMid.'"]){ 00402 '.implode(chr(10),$GLV_menuOn).' 00403 } 00404 GL_mouseMoveEvaluate("'.$this->WMid.'"); 00405 } 00406 function GL'.$this->WMid.'_hideCode() { 00407 '.$this->WMhideCode.' 00408 } 00409 function GL'.$this->WMid.'_doTop(WMid,id) { 00410 '.trim(implode(chr(10),$DoTop)).' 00411 } 00412 function GL'.$this->WMid.'_restoreMenu() { 00413 '.$this->WMrestoreScript.' 00414 } 00415 function GL'.$this->WMid.'_resetSubMenus() { 00416 var resetSubMenu=1; 00417 '.$this->WMresetSubMenus.' 00418 return resetSubMenu; 00419 } 00420 00421 GLV_timeout_pointers[GLV_timeout_count] = "'.$this->WMid.'"; 00422 GLV_timeout_count++; 00423 00424 '; 00425 $GLOBALS['TSFE']->JSeventFuncCalls['onload']['GL_initLayers()']= 'GL_initLayers();'; 00426 $GLOBALS['TSFE']->JSeventFuncCalls['onload'][$this->WMid]= 'GL_restoreMenu("'.$this->WMid.'");'; 00427 $GLOBALS['TSFE']->JSeventFuncCalls['onmousemove']['GL_getMouse(e)']= 'GL_getMouse(e);'; // Should be called BEFORE any of the 'local' getMouse functions! 00428 $GLOBALS['TSFE']->JSeventFuncCalls['onmousemove'][$this->WMid]= 'GL'.$this->WMid.'_getMouse(e);'; 00429 $GLOBALS['TSFE']->JSeventFuncCalls['onmouseup'][$this->WMid]= 'GL_mouseUp(\''.$this->WMid.'\',e);'; 00430 00431 $GLOBALS['TSFE']->divSection.=implode($this->divLayers,chr(10)).chr(10); 00432 00433 return parent::extProc_finish(); 00434 } 00435 00444 function extCalcBorderWithin($kind,$integer) { 00445 if ($integer) { 00446 switch($kind) { 00447 case 'right': 00448 case 'bottom': 00449 $add=''; 00450 if ($kind=='right') {$add='GL_getObj(id).width'; $key = 'left';} 00451 if ($kind=='bottom') {$add='GL_getObj(id).height'; $key = 'top';} 00452 $str = 'if (parseInt(GLV_menuOn["'.$this->WMid.'"].'.$key.')+'.$add.'>'.$integer.') GLV_menuOn["'.$this->WMid.'"].'.$key.'='.$integer.'-'.$add.';'; 00453 break; 00454 default: 00455 $str = 'if (parseInt(GLV_menuOn["'.$this->WMid.'"].'.$kind.')<'.$integer.') GLV_menuOn["'.$this->WMid.'"].'.$kind.'='.$integer.';'; 00456 break; 00457 } 00458 } 00459 return $str; 00460 } 00461 } 00462 00463 // FULL DUPLICATE FROM gmenu_layers END: 00464 00465 00466 $GLOBALS['TSFE']->tmpl->menuclasses.=',tmenu_layers'; 00467 00468 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['media/scripts/tmenu_layers.php']) { 00469 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['media/scripts/tmenu_layers.php']); 00470 } 00471 00472 ?>