Documentation TYPO3 par Ameos

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


Généré par Les experts TYPO3 avec  doxygen 1.4.6