Documentation TYPO3 par Ameos

tmenu_layers.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2004 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 
00087 // FULL DUPLICATE FROM gmenu_layers BEGIN:
00088 
00089         var $GMENU_fixKey='layers';
00090         var $divLayers=Array();
00091 
00092         var $WMx=0;
00093         var $WMy=0;
00094         var $WMxyArray=array();
00095         var $WMextraScript='';
00096         var $WMlastKey='';
00097         var $WMrestoreScript='';
00098         var $WMresetSubMenus='';
00099         var $WMactiveHasSubMenu='';
00100         var $WMactiveKey='';
00101         var $WMtheSubMenu;
00102         var $WMisSub;
00103         var $WMhideCode;
00104         var $WMonlyOnLoad=0;
00105         var $WMbordersWithin=array();
00106         var $WMsubIds=array();
00107         var $WMtempStore=array();
00108         var $WMlockPosition_addAccumulated=array();
00109         var $VMmouseoverActions=array();
00110         var $VMmouseoutActions=array();
00111 
00117         function extProc_init() {
00118                 $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!
00119 
00120                 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'][]=$this->WMid;
00121                 $this->WMtempStore = $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'];
00122                 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']=array();
00123 
00124                         // Save:
00125                 $this->WMonlyOnLoad = ($this->mconf['displayActiveOnLoad'] && !$this->mconf['displayActiveOnLoad.']['onlyOnLoad']);
00126                 $this->WMbordersWithin = t3lib_div::intExplode(',',$this->mconf['bordersWithin'].',0,0,0,0,0');
00127         }
00128 
00135         function extProc_RO($key)       {
00136                 if ($this->mconf['freezeMouseover'])    {
00137                         $this->VMmouseoverActions[$this->WMid.$key]='case "Menu'.$this->WMid.$key.'":'.$this->I['linkHREF']['onMouseover'].'; break;';
00138                         $this->VMmouseoutActions[$this->WMid.$key]='case "Menu'.$this->WMid.$key.'":'.$this->I['linkHREF']['onMouseout'].'; break;';
00139                         $this->I['linkHREF']['onMouseover']='GL'.$this->WMid.'_over(\'Menu'.$this->WMid.$key.'\');';
00140                         $this->I['linkHREF']['onMouseout']='';
00141                 }
00142         }
00143 
00151         function extProc_beforeLinking($key)    {
00152                 if ($this->I['uid'])    {
00153 
00154                         array_push($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId'],$this->WMid);
00155                         $this->WMtheSubMenu = $this->subMenu($this->I['uid']);
00156                         array_pop($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId']);
00157                         $this->WMisSub = trim($this->WMtheSubMenu) ? 1 : 0;
00158 
00159                         if ($this->mconf['lockPosition_addSelf'])               {
00160                                 $this->WMy+=(strcmp($this->mconf['setFixedHeight'],'')?$this->mconf['setFixedHeight']:$this->I['val']['output_h'])+intval($this->mconf['lockPosition_adjust']);
00161                                 $this->WMx+=(strcmp($this->mconf['setFixedWidth'],'')?$this->mconf['setFixedWidth']:$this->I['val']['output_w'])+intval($this->mconf['lockPosition_adjust']);
00162                         }
00163 
00164                         if ($this->isActive($this->I['uid'], $this->getMPvar($key)) && $this->mconf['displayActiveOnLoad'])     {       // orig: && $this->WMisSub, changed 210901
00165                                 $this->WMactiveHasSubMenu = $this->WMisSub;
00166                                 $this->WMactiveKey = 'Menu'.$this->WMid.$key;
00167 
00168 
00169                                 $this->WMrestoreVars=trim('
00170 GLV_restoreMenu["'.$this->WMid.'"] = "'.$this->WMactiveKey.'";
00171                                 ');
00172                                 $this->WMrestoreScript='        GL_doTop("'.$this->WMid.'",GLV_restoreMenu["'.$this->WMid.'"]);'.($this->mconf['freezeMouseover']?'
00173         GL'.$this->WMid.'_over(GLV_restoreMenu["'.$this->WMid.'"]);
00174 ':'');
00175                         }
00176 
00177                         if ($this->WMisSub)     {
00178                                 $event="GL_stopMove('".$this->WMid."');";
00179                                 $this->I['linkHREF']['onMouseover']='GL_doTop(\''.$this->WMid.'\', \'Menu'.$this->WMid.$key.'\');'.$this->I['linkHREF']['onMouseover'];
00180                                         // 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).
00181                                         // 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.
00182                                 if (t3lib_div::intInRange($this->mconf['hideMenuWhenNotOver'],0,600) && $this->mconf['hideMenuTimer'])  {
00183                                         $event.='GL_resetAll("'.$this->WMid.'");';
00184                                 }
00185                                 $this->I['linkHREF']['onMouseout'].=$event;
00186                         } else {
00187                                 $this->I['linkHREF']['onMouseover']='GL_hideAll("'.$this->WMid.'");'.$this->I['linkHREF']['onMouseover'];
00188                                 $event='GL_resetAll("'.$this->WMid.'");';
00189                                 $this->I['linkHREF']['onMouseout'].=$event;
00190                         }
00191 
00192                         $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).'");';
00193                 }
00194         }
00195 
00202         function extProc_afterLinking($key)     {
00203                 if ($this->I['uid'])    {
00204                         if (!$this->I['spacer'] && $this->WMisSub)      {
00205                                 $exStyle=$this->mconf['layerStyle'] ? $this->mconf['layerStyle'] : 'position:absolute;visibility:hidden';
00206                                 if (trim($exStyle))     {
00207                                         $exStyle=' '.$exStyle;
00208                                 }
00209                                 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['layerCounter']++;
00210                                 $zIndex = 10000-$GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['layerCounter'];
00211 #                               $zIndex = (($key+2)*$this->menuNumber*100);
00212                                 $divStart = '<div id="Menu'.$this->WMid.$key.'" style="z-index:'.$zIndex.';'.$exStyle.'">';
00213                                 $divStop = '</div>';
00214 
00215                                 $this->divLayers[]= $divStart.$this->WMtheSubMenu.$divStop;
00216 
00217                                 $this->WMhideCode.='
00218         GL_getObjCss("Menu'.$this->WMid.$key.'").visibility = "hidden";';
00219                                 $this->WMlastKey = 'Menu'.$this->WMid.$key;
00220                         }
00221 
00222                         if (!$this->mconf['lockPosition_addSelf'])              {
00223                                 $this->WMy+=(strcmp($this->mconf['setFixedHeight'],'')?$this->mconf['setFixedHeight']:$this->I['val']['output_h'])+intval($this->mconf['lockPosition_adjust']);
00224                                 $this->WMx+=(strcmp($this->mconf['setFixedWidth'],'')?$this->mconf['setFixedWidth']:$this->I['val']['output_w'])+intval($this->mconf['lockPosition_adjust']);
00225                         }
00226                 }
00227                 $this->WMresult.=$this->I['theItem'];
00228         }
00229 
00237         function extProc_beforeAllWrap($item,$key)      {
00238                 if ($this->mconf['relativeToTriggerItem'])      {
00239                         $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>';
00240                 }
00241                 return $item;
00242         }
00243 
00250         function isSetIntval($in)       {
00251                 return $this->mconf['blankStrEqFalse'] ? strcmp($in,'') : intval($in);
00252         }
00253 
00259         function extProc_finish ()      {
00260                 $dirL = $this->mconf['directionLeft'] ? '-GL_getObj(id).width' : '';
00261                 $dirU = $this->mconf['directionUp'] ? '-GL_getObj(id).height' : '';
00262 
00263                 $parentLayerId = end($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId']);
00264 
00265                 $DoTop=array();
00266                 $GLV_menuOn=array();
00267                 $relCode=array();
00268                 $relFlag=0;
00269                 if ($this->mconf['relativeToParentLayer'] && $parentLayerId)    {
00270                         $relCode['X'].='GLV_curLayerX["'.$parentLayerId.'"]+';
00271                         $relCode['Y'].='GLV_curLayerY["'.$parentLayerId.'"]+';
00272                         if ($this->mconf['relativeToParentLayer.']['addWidth'])         {       $relCode['X'].='GLV_curLayerWidth["'.$parentLayerId.'"]+';      }
00273                         if ($this->mconf['relativeToParentLayer.']['addHeight'])        {       $relCode['Y'].='GLV_curLayerHeight["'.$parentLayerId.'"]+';     }
00274                 }
00275                 if ($this->mconf['relativeToTriggerItem'])      {
00276                         $DoTop[]='
00277                 var parentObject = GL_getObj(GLV_menuXY[WMid][id][2]);
00278                 var TI_width = parentObject.width;
00279                 var TI_height = parentObject.height;
00280                 var anchorObj = GL_getObj(GLV_menuXY[WMid][id][3]);
00281                 var TI_x = anchorObj.x;
00282                 var TI_y = anchorObj.y;
00283                         ';
00284                         $relCode['X'].='TI_x+';
00285                         $relCode['Y'].='TI_y+';
00286 
00287                         if ($this->mconf['relativeToTriggerItem.']['addWidth']) {       $relCode['X'].='TI_width+';     }
00288                         if ($this->mconf['relativeToTriggerItem.']['addHeight'])        {       $relCode['Y'].='TI_height+';    }
00289                         $relFlag=1;
00290                 }
00291                 if ($relFlag)   {
00292                         $DoTop[]='GLV_menuOn["'.$this->WMid.'"].left = ('.$relCode['X'].intval($this->mconf['leftOffset']).$dirL.')+"px";';
00293                         $DoTop[]='GLV_menuOn["'.$this->WMid.'"].top =  ('.$relCode['Y'].intval($this->mconf['topOffset']).$dirU.')+"px";';
00294                 } else {
00295                                 // X position (y is fixed)
00296                         if (!strcmp($this->mconf['lockPosition'],'x'))  {
00297                                 $DoTop[]='GLV_menuOn["'.$this->WMid.'"].left = ('.$relCode['X'].'GLV_menuXY["'.$this->WMid.'"][id][0]-('.intval($this->mconf['xPosOffset']).')'.$dirL.')+"px";';
00298                                 if ($this->isSetIntval($this->mconf['topOffset']))      {
00299                                         $DoTop[]='GLV_menuOn["'.$this->WMid.'"].top = ('.$relCode['Y'].intval($this->mconf['topOffset']).$dirU.')+"px";';
00300                                 }
00301                         } elseif ($this->isSetIntval($this->mconf['xPosOffset'])) {
00302                                 $GLV_menuOn[]=$DoTop[]='GLV_menuOn["'.$this->WMid.'"].left = (GLV_x-('.intval($this->mconf['xPosOffset']).')'.$dirL.')+"px";';
00303                                 if ($this->isSetIntval($this->mconf['topOffset']))      {
00304                                         $DoTop[]='GLV_menuOn["'.$this->WMid.'"].top = ('.$relCode['Y'].intval($this->mconf['topOffset']).$dirU.')+"px";';
00305                                 }
00306                         }
00307                                 // Y position   (x is fixed)
00308                         if (!strcmp($this->mconf['lockPosition'],'y'))  {
00309                                 $DoTop[]='GLV_menuOn["'.$this->WMid.'"].top = ('.$relCode['Y'].'GLV_menuXY["'.$this->WMid.'"][id][1]-('.intval($this->mconf['yPosOffset']).')'.$dirU.')+"px";';
00310                                 if ($this->isSetIntval($this->mconf['leftOffset']))     {
00311                                         $DoTop[]='GLV_menuOn["'.$this->WMid.'"].left = ('.$relCode['X'].intval($this->mconf['leftOffset']).$dirL.')+"px";';
00312                                 }
00313                         } elseif ($this->isSetIntval($this->mconf['yPosOffset']))       {
00314                                 $GLV_menuOn[]=$DoTop[]='GLV_menuOn["'.$this->WMid.'"].top = (GLV_y-('.intval($this->mconf['yPosOffset']).')'.$dirU.')+"px";';
00315                                 if ($this->isSetIntval($this->mconf['leftOffset']))     {
00316                                         $DoTop[]='GLV_menuOn["'.$this->WMid.'"].left = ('.$relCode['X'].intval($this->mconf['leftOffset']).$dirL.')+"px";';
00317                                 }
00318                         }
00319                 }
00320 
00321                         // BordersWithIn:
00322                 $DoTop[]=$this->extCalcBorderWithin('left',$this->WMbordersWithin[0]);
00323                 $DoTop[]=$this->extCalcBorderWithin('top',$this->WMbordersWithin[1]);
00324                 $DoTop[]=$this->extCalcBorderWithin('right',$this->WMbordersWithin[2]);
00325                 $DoTop[]=$this->extCalcBorderWithin('bottom',$this->WMbordersWithin[3]);
00326                 $DoTop[]=$this->extCalcBorderWithin('left',$this->WMbordersWithin[4]);
00327                 $DoTop[]=$this->extCalcBorderWithin('top',$this->WMbordersWithin[5]);
00328 
00329 
00330                 if ($this->mconf['freezeMouseover'] && !$this->mconf['freezeMouseover.']['alwaysKeep']) {
00331                         $this->WMhideCode.='
00332 GL'.$this->WMid.'_out("");';
00333                 }
00334 
00335                 $TEST='';
00336                 if (count($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']))   {
00337                         reset($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']);
00338                         while(list(,$mIdStr)=each($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']))   {
00339                                 $this->WMhideCode.='
00340 GL_hideAll("'.$mIdStr.'");';
00341                                 $this->WMrestoreScript.='
00342 GL_restoreMenu("'.$mIdStr.'");';
00343                                 $this->WMresetSubMenus.='
00344 if (!GLV_doReset["'.$mIdStr.'"] && GLV_currentLayer["'.$mIdStr.'"]!=null)       resetSubMenu=0;';
00345                         }
00346                 }
00347                 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']=array_merge($this->WMtempStore,$GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']);
00348                 $GLOBALS['TSFE']->additionalHeaderData['gmenu_layer_shared']='<script type="text/javascript" src="'.$GLOBALS['TSFE']->absRefPrefix.'media/scripts/jsfunc.layermenu.js"></script>';
00349                 $GLOBALS['TSFE']->JSCode.= '
00350 
00351 GLV_curLayerWidth["'.$this->WMid.'"]=0;
00352 GLV_curLayerHeight["'.$this->WMid.'"]=0;
00353 GLV_curLayerX["'.$this->WMid.'"]=0;
00354 GLV_curLayerY["'.$this->WMid.'"]=0;
00355 GLV_menuOn["'.$this->WMid.'"] = null;
00356 GLV_gap["'.$this->WMid.'"]='.t3lib_div::intInRange($this->mconf['hideMenuWhenNotOver'],0,600).';
00357 GLV_currentLayer["'.$this->WMid.'"] = null;
00358 GLV_currentROitem["'.$this->WMid.'"] = null;
00359 GLV_hasBeenOver["'.$this->WMid.'"]=0;
00360 GLV_doReset["'.$this->WMid.'"]=false;
00361 GLV_lastKey["'.$this->WMid.'"] = "'.$this->WMlastKey.'";
00362 GLV_onlyOnLoad["'.$this->WMid.'"] = '.($this->WMonlyOnLoad?1:0).';
00363 GLV_dontHideOnMouseUp["'.$this->WMid.'"] = '.($this->mconf['dontHideOnMouseUp']?1:0).';
00364 GLV_dontFollowMouse["'.$this->WMid.'"] = '.($this->mconf['dontFollowMouse']?1:0).';
00365 GLV_date = new Date();
00366 GLV_timeout["'.$this->WMid.'"] = GLV_date.getTime();
00367 GLV_timeoutRef["'.$this->WMid.'"] = '.t3lib_div::intInRange($this->mconf['hideMenuTimer'],0,20000).';
00368 GLV_menuXY["'.$this->WMid.'"] = new Array();
00369 '.implode(chr(10),$this->WMxyArray).'
00370 '.$this->WMrestoreVars;
00371 
00372                 if ($this->mconf['freezeMouseover'])    {
00373                         $GLOBALS['TSFE']->JSCode.= '
00374 // Alternative rollover/out functions for use with GMENU_LAYER
00375 function GL'.$this->WMid.'_over(mitm_id)        {
00376         GL'.$this->WMid.'_out("");      // removes any old roll over state of an item. Needed for alwaysKeep and Opera browsers.
00377         switch(mitm_id) {
00378 '.implode(chr(10),$this->VMmouseoverActions).'
00379         }
00380         GLV_currentROitem["'.$this->WMid.'"]=mitm_id;
00381 }
00382 function GL'.$this->WMid.'_out(mitm_id) {
00383         if (!mitm_id)   mitm_id=GLV_currentROitem["'.$this->WMid.'"];
00384         switch(mitm_id) {
00385 '.implode(chr(10),$this->VMmouseoutActions).'
00386         }
00387 }
00388 ';
00389                 }
00390                 $GLOBALS["TSFE"]->JSCode.= '
00391 function GL'.$this->WMid.'_getMouse(e) {
00392         if (GLV_menuOn["'.$this->WMid.'"]!=null && !GLV_dontFollowMouse["'.$this->WMid.'"]){
00393 '.implode(chr(10),$GLV_menuOn).'
00394         }
00395         GL_mouseMoveEvaluate("'.$this->WMid.'");
00396 }
00397 function GL'.$this->WMid.'_hideCode() {
00398 '.$this->WMhideCode.'
00399 }
00400 function GL'.$this->WMid.'_doTop(WMid,id) {
00401 '.trim(implode(chr(10),$DoTop)).'
00402 }
00403 function GL'.$this->WMid.'_restoreMenu() {
00404 '.$this->WMrestoreScript.'
00405 }
00406 function GL'.$this->WMid.'_resetSubMenus() {
00407         var resetSubMenu=1;
00408 '.$this->WMresetSubMenus.'
00409         return resetSubMenu;
00410 }
00411 
00412 GLV_timeout_pointers[GLV_timeout_count] = "'.$this->WMid.'";
00413 GLV_timeout_count++;
00414 
00415 ';
00416                 $GLOBALS['TSFE']->JSeventFuncCalls['onload']['GL_initLayers()']= 'GL_initLayers();';
00417                 $GLOBALS['TSFE']->JSeventFuncCalls['onload'][$this->WMid]=      'GL_restoreMenu("'.$this->WMid.'");';
00418                 $GLOBALS['TSFE']->JSeventFuncCalls['onmousemove']['GL_getMouse(e)']= 'GL_getMouse(e);'; // Should be called BEFORE any of the 'local' getMouse functions!
00419                 $GLOBALS['TSFE']->JSeventFuncCalls['onmousemove'][$this->WMid]= 'GL'.$this->WMid.'_getMouse(e);';
00420                 $GLOBALS['TSFE']->JSeventFuncCalls['onmouseup'][$this->WMid]= 'GL_mouseUp(\''.$this->WMid.'\',e);';
00421 
00422                 $GLOBALS['TSFE']->divSection.=implode($this->divLayers,chr(10)).chr(10);
00423 
00424                 return parent::extProc_finish();
00425         }
00426 
00435         function extCalcBorderWithin($kind,$integer)    {
00436                 if ($integer)   {
00437                         switch($kind)   {
00438                                 case 'right':
00439                                 case 'bottom':
00440                                         $add='';
00441                                         if ($kind=='right')             {$add='GL_getObj(id).width'; $key = 'left';}
00442                                         if ($kind=='bottom')    {$add='GL_getObj(id).height'; $key = 'top';}
00443                                         $str = 'if (parseInt(GLV_menuOn["'.$this->WMid.'"].'.$key.')+'.$add.'>'.$integer.') GLV_menuOn["'.$this->WMid.'"].'.$key.'='.$integer.'-'.$add.';';
00444                                 break;
00445                                 default:
00446                                         $str = 'if (parseInt(GLV_menuOn["'.$this->WMid.'"].'.$kind.')<'.$integer.') GLV_menuOn["'.$this->WMid.'"].'.$kind.'='.$integer.';';
00447                                 break;
00448                         }
00449                 }
00450                 return $str;
00451         }
00452 }
00453 
00454 // FULL DUPLICATE FROM gmenu_layers END:
00455 
00456 
00457 $GLOBALS['TSFE']->tmpl->menuclasses.=',tmenu_layers';
00458 
00459 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['media/scripts/tmenu_layers.php'])  {
00460         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['media/scripts/tmenu_layers.php']);
00461 }
00462 
00463 ?>


Généré par TYPO3 Ameos avec  doxygen 1.4.6