Documentation TYPO3 par Ameos

class.tslib_menu.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 ***************************************************************/
00143 class tslib_menu {
00144         var $menuNumber = 1;                            // tells you which menu-number this is. This is important when getting data from the setup
00145         var $entryLevel = 0;                            // 0 = rootFolder
00146         var $subLevelClass = '';                        // Points to the menu-class, that should be used for the next level
00147         var $spacerIDList = '199';                      // The doktype-number that defines a spacer
00148         var $doktypeExcludeList = '5,6';                        // doktypes that define which should not be included in a menu
00149         var $alwaysActivePIDlist=array();
00150         var $imgNamePrefix = 'img';
00151         var $imgNameNotRandom=0;
00152         var $debug = 0;
00153         var $parent_cObj ='';                           // Loaded with the parent cObj-object when a new HMENU is made
00154         var $GMENU_fixKey='gmenu';
00155         var $MP_array=array();                          // accumulation of mount point data
00156 
00157                 // internal
00158         var $conf = Array();                            // HMENU configuration
00159         var $mconf = Array();                           // xMENU configuration (TMENU, GMENU etc)
00160         var $tmpl;              // template-object
00161         var $sys_page;  // sys_page-object
00162         var $id;                                                        // The base page-id of the menu.
00163         var $nextActive;                                        // Holds the page uid of the NEXT page in the root line from the page pointed to by entryLevel; Used to expand the menu automatically if in a certain root line.
00164         var $menuArr;   // The array of menuItems which is built
00165         var $hash;
00166         var $result = Array();
00167         var $rL_uidRegister = '';                       // Array: Is filled with an array of page uid numbers + RL parameters which are in the current root line (used to evaluate whether a menu item is in active state)
00168         var $INPfixMD5;
00169         var $I;
00170         var $WMresult;
00171         var $WMfreezePrefix;
00172         var $WMmenuItems;
00173         var $WMextraScript;
00174         var $alternativeMenuTempArray='';               // Can be set to contain menu item arrays for sub-levels.
00175 
00187         function start(&$tmpl,&$sys_page,$id,$conf,$menuNumber) {
00188 
00189                         // Init:
00190                 $this->conf = $conf;
00191                 $this->menuNumber = $menuNumber;
00192                 $this->mconf = $conf[$this->menuNumber.'.'];
00193                 $this->debug=$GLOBALS['TSFE']->debug;
00194 
00195                         // Sets the internal vars. $tmpl MUST be the template-object. $sys_page MUST be the sys_page object
00196                 if ($this->conf[$this->menuNumber] && is_object($tmpl) && is_object($sys_page)) {
00197                         $this->tmpl = &$tmpl;
00198                         $this->sys_page = &$sys_page;
00199 
00200                                 // alwaysActivePIDlist initialized:
00201                         if (trim($this->conf['alwaysActivePIDlist']))   {
00202                                 $this->alwaysActivePIDlist = t3lib_div::intExplode(',', $this->conf['alwaysActivePIDlist']);
00203                         }
00204 
00205                                 // 'not in menu' doktypes
00206                         if($this->conf['excludeDoktypes']) {
00207                                 $this->doktypeExcludeList = $GLOBALS['TYPO3_DB']->cleanIntList($this->conf['excludeDoktypes']);
00208                         }
00209                         if($this->conf['includeNotInMenu']) {
00210                                 $exclDoktypeArr = t3lib_div::trimExplode(',',$this->doktypeExcludeList,1);
00211                                 $exclDoktypeArr = t3lib_div::removeArrayEntryByValue($exclDoktypeArr,'5');
00212                                 $this->doktypeExcludeList = implode(',',$exclDoktypeArr);
00213                         }
00214 
00215                                 // EntryLevel
00216                         $this->entryLevel = tslib_cObj::getKey ($conf['entryLevel'],$this->tmpl->rootLine);
00217 
00218                                 // Set parent page: If $id not stated with start() then the base-id will be found from rootLine[$this->entryLevel]
00219                         if ($id)        {       // Called as the next level in a menu. It is assumed that $this->MP_array is set from parent menu.
00220                                 $this->id = intval($id);
00221                         } else {        // This is a BRAND NEW menu, first level. So we take ID from rootline and also find MP_array (mount points)
00222                                 $this->id = intval($this->tmpl->rootLine[$this->entryLevel]['uid']);
00223 
00224                                         // Traverse rootline to build MP_array of pages BEFORE the entryLevel
00225                                         // (MP var for ->id is picked up in the next part of the code...)
00226                                 foreach($this->tmpl->rootLine as $entryLevel => $levelRec)      {
00227                                                 // For overlaid mount points, set the variable right now:
00228                                         if ($levelRec['_MP_PARAM'] && $levelRec['_MOUNT_OL'])   {
00229                                                 $this->MP_array[] = $levelRec['_MP_PARAM'];
00230                         }
00231                                                 // Break when entry level is reached:
00232                                         if ($entryLevel>=$this->entryLevel)     break;
00233 
00234                                                 // For normal mount points, set the variable for next level.
00235                                         if ($levelRec['_MP_PARAM'] && !$levelRec['_MOUNT_OL'])  {
00236                                                 $this->MP_array[] = $levelRec['_MP_PARAM'];
00237                                         }
00238                                 }
00239                         }
00240 
00241                                 // Return false if no page ID was set (thus no menu of subpages can be made).
00242                         if ($this->id<=0)       {
00243                                 return FALSE;
00244                         }
00245 
00246                                 // Check if page is a mount point, and if so set id and MP_array
00247                                 // (basically this is ONLY for non-overlay mode, but in overlay mode an ID with a mount point should never reach this point anyways, so no harm done...)
00248                         $mount_info = $this->sys_page->getMountPointInfo($this->id);
00249                         if (is_array($mount_info))      {
00250                                 $this->MP_array[] = $mount_info['MPvar'];
00251                                 $this->id = $mount_info['mount_pid'];
00252                         }
00253 
00254                                 // Gather list of page uids in root line (for "isActive" evaluation). Also adds the MP params in the path so Mount Points are respected.
00255                                 // (List is specific for this rootline, so it may be supplied from parent menus for speed...)
00256                         if (!is_array($this->rL_uidRegister))   {
00257                                 $rl_MParray = array();
00258                                 foreach($this->tmpl->rootLine as $v_rl) {
00259                                                 // For overlaid mount points, set the variable right now:
00260                                         if ($v_rl['_MP_PARAM'] && $v_rl['_MOUNT_OL'])   {
00261                                                 $rl_MParray[] = $v_rl['_MP_PARAM'];
00262                                         }
00263 
00264                                                 // Add to register:
00265                                         $this->rL_uidRegister[] = 'ITEM:'.$v_rl['uid'].(count($rl_MParray) ? ':'.implode(',',$rl_MParray) : '');
00266 
00267                                                 // For normal mount points, set the variable for next level.
00268                                         if ($v_rl['_MP_PARAM'] && !$v_rl['_MOUNT_OL'])  {
00269                                                 $rl_MParray[] = $v_rl['_MP_PARAM'];
00270                                         }
00271                                 }
00272                         }
00273 
00274                                 // Setting "nextActive": This is the page uid + MPvar of the NEXT page in rootline. Used to expand the menu if we are in the right branch of the tree
00275                                 // Notice: The automatic expansion of a menu is designed to work only when no "special" modes are used.
00276                         if (is_array($this->tmpl->rootLine[$this->entryLevel+$this->menuNumber]))       {
00277                                 $nextMParray = $this->MP_array;
00278                                 if ($this->tmpl->rootLine[$this->entryLevel+$this->menuNumber]['_MOUNT_OL'])    {       // In overlay mode, add next level MPvars as well:
00279                                         $nextMParray[] = $this->tmpl->rootLine[$this->entryLevel+$this->menuNumber]['_MP_PARAM'];
00280                                 }
00281                                 $this->nextActive = $this->tmpl->rootLine[$this->entryLevel+$this->menuNumber]['uid'].
00282                                                                                 (count($nextMParray)?':'.implode(',',$nextMParray):'');
00283                         } else {
00284                                 $this->nextActive = '';
00285                         }
00286 
00287                                 // imgNamePrefix
00288                         if ($this->mconf['imgNamePrefix']) {
00289                                 $this->imgNamePrefix=$this->mconf['imgNamePrefix'];
00290                         }
00291                         $this->imgNameNotRandom = $this->mconf['imgNameNotRandom'];
00292 
00293                                 // subLevelClass
00294                         $cls = strtolower($this->conf[$this->menuNumber+1]);
00295                         if ($cls && t3lib_div::inList($this->tmpl->menuclasses,$cls))   {
00296                                 $this->subLevelClass = $cls;
00297                         }
00298                         $retVal = TRUE;
00299                 } else {
00300                         $GLOBALS['TT']->setTSlogMessage('ERROR in menu',3);
00301                         $retVal = FALSE;
00302                 }
00303                 return $retVal;
00304         }
00305 
00313         function makeMenu()     {
00314                 if ($this->id)  {
00315                         $temp = array();
00316                         $altSortFieldValue = trim($this->mconf['alternativeSortingField']);
00317                         $altSortField = $altSortFieldValue ? $altSortFieldValue : 'sorting';
00318                         if ($this->menuNumber==1 && $this->conf['special'])     {               // ... only for the FIRST level of a HMENU
00319                                 $value = $this->conf['special.']['value'];
00320 
00321                                 switch($this->conf['special'])  {
00322                                         case 'userdefined':
00323                                                 $temp = $this->includeMakeMenu($this->conf['special.'],$altSortField);
00324                                         break;
00325                                         case 'userfunction':
00326                                                 $temp = $this->parent_cObj->callUserFunction(
00327                                                         $this->conf['special.']['userFunc'],
00328                                                         array_merge($this->conf['special.'],array('_altSortField'=>$altSortField)),
00329                                                         ''
00330                                                 );
00331                                                 if (!is_array($temp))   $temp=array();
00332                                         break;
00333                                         case 'language':
00334                                                 $temp = array();
00335 
00336                                                         // Getting current page record NOT overlaid by any translation:
00337                                                 $currentPageWithNoOverlay = $this->sys_page->getRawRecord('pages',$GLOBALS['TSFE']->page['uid']);
00338 
00339                                                         // Traverse languages set up:
00340                                                 $languageItems = t3lib_div::intExplode(',',$value);
00341                                                 foreach($languageItems as $sUid)        {
00342                                                                 // Find overlay record:
00343                                                         if ($sUid)      {
00344                                                                 $lRecs = $this->sys_page->getPageOverlay($GLOBALS['TSFE']->page['uid'],$sUid);
00345                                                         } else $lRecs=array();
00346                                                                 // Checking if the "disabled" state should be set.
00347                                                         if (
00348                                                                                 ($GLOBALS['TSFE']->page['l18n_cfg']&2 && $sUid && !count($lRecs)) // Blocking for all translations?
00349                                                                         || ($GLOBALS['TSFE']->page['l18n_cfg']&1 && (!$sUid || !count($lRecs))) // Blocking default translation?
00350                                                                         || (!$this->conf['special.']['normalWhenNoLanguage'] && $sUid && !count($lRecs))
00351                                                                 )       {
00352                                                                 $iState = $GLOBALS['TSFE']->sys_language_uid==$sUid ? 'USERDEF2' : 'USERDEF1';
00353                                                         } else {
00354                                                                 $iState = $GLOBALS['TSFE']->sys_language_uid==$sUid ? 'ACT' : 'NO';
00355                                                         }
00356                                                                 // Adding menu item:
00357                                                         $temp[] = array_merge(
00358                                                                 array_merge($currentPageWithNoOverlay, $lRecs),
00359                                                                 array(
00360                                                                         'ITEM_STATE' => $iState,
00361                                                                         '_ADD_GETVARS' => '&L='.$sUid,
00362                                                                         '_SAFE' => TRUE
00363                                                                 )
00364                                                         );
00365                                                 }
00366                                         break;
00367                                         case 'directory':
00368                                                 if ($value=='') {
00369                                                         $value=$GLOBALS['TSFE']->page['uid'];
00370                                                 }
00371                                                 $items=t3lib_div::intExplode(',',$value);
00372 
00373                                                 foreach($items as $id)  {
00374                                                         $MP = $this->tmpl->getFromMPmap($id);
00375 
00376                                                                 // Checking if a page is a mount page and if so, change the ID and set the MP var properly.
00377                                                         $mount_info = $this->sys_page->getMountPointInfo($id);
00378                                                         if (is_array($mount_info))      {
00379                                                                 if ($mount_info['overlay'])     {       // Overlays should already have their full MPvars calculated:
00380                                                                         $MP = $this->tmpl->getFromMPmap($mount_info['mount_pid']);
00381                                                                         $MP = $MP ? $MP : $mount_info['MPvar'];
00382                                                                 } else {
00383                                                                         $MP = ($MP ? $MP.',' : '').$mount_info['MPvar'];
00384                                                         }
00385                                                                 $id = $mount_info['mount_pid'];
00386                                                 }
00387 
00388                                                                 // Get sub-pages:
00389                                                         $res = $GLOBALS['TSFE']->cObj->exec_getQuery('pages',Array('pidInList'=>$id,'orderBy'=>$altSortField));
00390                                                         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))      {
00391 
00392                                                                         // Keep mount point?
00393                                                                 $mount_info = $this->sys_page->getMountPointInfo($row['uid'], $row);
00394                                                                 if (is_array($mount_info) && $mount_info['overlay'])    {       // There is a valid mount point.
00395                                                                         $mp_row = $this->sys_page->getPage($mount_info['mount_pid']);           // Using "getPage" is OK since we need the check for enableFields AND for type 2 of mount pids we DO require a doktype < 200!
00396                                                                         if (count($mp_row))     {
00397                                                                                 $row = $mp_row;
00398                                                                                 $row['_MP_PARAM'] = $mount_info['MPvar'];
00399                                                                         } else unset($row);     // If the mount point could not be fetched with respect to enableFields, unset the row so it does not become a part of the menu!
00400                                                                 }
00401 
00402                                                                         // Add external MP params, then the row:
00403                                                                 if (is_array($row))     {
00404                                                                         if ($MP)        $row['_MP_PARAM'] = $MP.($row['_MP_PARAM'] ? ','.$row['_MP_PARAM'] : '');
00405                                                                         $temp[$row['uid']] = $this->sys_page->getPageOverlay($row);
00406                                                                 }
00407                                                         }
00408                                                 }
00409                                         break;
00410                                         case 'list':
00411                                                 if ($value=='') {
00412                                                         $value=$this->id;
00413                                                 }
00414                                                 $loadDB = t3lib_div::makeInstance('FE_loadDBGroup');
00415                                                 $loadDB->start($value, 'pages');
00416                                                 $loadDB->additionalWhere['pages']=tslib_cObj::enableFields('pages');
00417                                                 $loadDB->getFromDB();
00418 
00419                                                 foreach($loadDB->itemArray as $val)     {
00420                                                         $MP = $this->tmpl->getFromMPmap($val['id']);
00421 
00422                                                                 // Keep mount point?
00423                                                         $mount_info = $this->sys_page->getMountPointInfo($val['id']);
00424                                                         if (is_array($mount_info) && $mount_info['overlay'])    {       // There is a valid mount point.
00425                                                                 $mp_row = $this->sys_page->getPage($mount_info['mount_pid']);           // Using "getPage" is OK since we need the check for enableFields AND for type 2 of mount pids we DO require a doktype < 200!
00426                                                                 if (count($mp_row))     {
00427                                                                         $row = $mp_row;
00428                                                                         $row['_MP_PARAM'] = $mount_info['MPvar'];
00429 
00430                                                                         if ($mount_info['overlay'])     {       // Overlays should already have their full MPvars calculated:
00431                                                                                 $MP = $this->tmpl->getFromMPmap($mount_info['mount_pid']);
00432                                                                                 if ($MP) unset($row['_MP_PARAM']);
00433                                                         }
00434 
00435                                                                 } else unset($row);     // If the mount point could not be fetched with respect to enableFields, unset the row so it does not become a part of the menu!
00436                                                         } else {
00437                                                                 $row = $loadDB->results['pages'][$val['id']];
00438                                                 }
00439 
00440                                                                 // Add external MP params, then the row:
00441                                                         if (is_array($row))     {
00442                                                                 if ($MP)        $row['_MP_PARAM'] = $MP.($row['_MP_PARAM'] ? ','.$row['_MP_PARAM'] : '');
00443                                                                 $temp[] = $this->sys_page->getPageOverlay($row);
00444                                                         }
00445                                                 }
00446                                         break;
00447                                         case 'updated':
00448                                                 if ($value=='') {
00449                                                         $value=$GLOBALS['TSFE']->page['uid'];
00450                                                 }
00451                                                 $items=t3lib_div::intExplode(',',$value);
00452                                                 if (t3lib_div::testInt($this->conf['special.']['depth']))       {
00453                                                         $depth = t3lib_div::intInRange($this->conf['special.']['depth'],1,20);          // Tree depth
00454                                                 } else {
00455                                                         $depth=20;
00456                                                 }
00457                                                 $limit = t3lib_div::intInRange($this->conf['special.']['limit'],0,100); // max number of items
00458                                                 $maxAge = intval(tslib_cObj::calc($this->conf['special.']['maxAge']));
00459                                                 if (!$limit)    $limit=10;
00460                                                 $mode = $this->conf['special.']['mode'];        // *'auto', 'manual', 'tstamp'
00461                                                         // Get id's
00462                                                 $id_list_arr = Array();
00463 
00464                                                 foreach($items as $id)  {
00465                                                         $bA = t3lib_div::intInRange($this->conf['special.']['beginAtLevel'],0,100);
00466                                                         $id_list_arr[] = tslib_cObj::getTreeList(-1*$id,$depth-1+$bA,$bA-1);
00467                                                 }
00468                                                 $id_list = implode(',',$id_list_arr);
00469                                                         // Get sortField (mode)
00470                                                 switch($mode)   {
00471                                                         case 'starttime':
00472                                                                 $sortField = 'starttime';
00473                                                         break;
00474                                                         case 'lastUpdated':
00475                                                         case 'manual':
00476                                                                 $sortField = 'lastUpdated';
00477                                                         break;
00478                                                         case 'tstamp':
00479                                                                 $sortField = 'tstamp';
00480                                                         break;
00481                                                         case 'crdate':
00482                                                                 $sortField = 'crdate';
00483                                                         break;
00484                                                         default:
00485                                                                 $sortField = 'SYS_LASTCHANGED';
00486                                                         break;
00487                                                 }
00488                                                         // Get
00489                                                 $extraWhere = ' AND pages.nav_hide=0'.$this->getDoktypeExcludeWhere();
00490 
00491                                                 if ($this->conf['special.']['excludeNoSearchPages']) {
00492                                                         $extraWhere.= ' AND pages.no_search=0';
00493                                                 }
00494                                                 if ($maxAge>0)  {
00495                                                         $extraWhere.=' AND '.$sortField.'>'.($GLOBALS['SIM_EXEC_TIME']-$maxAge);
00496                                                 }
00497 
00498                                                 $res = $GLOBALS['TSFE']->cObj->exec_getQuery('pages',Array('pidInList'=>'0', 'uidInList'=>$id_list, 'where'=>$sortField.'>=0'.$extraWhere, 'orderBy'=>($altSortFieldValue ? $altSortFieldValue : $sortField.' desc'),'max'=>$limit));
00499                                                 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))      {
00500                                                         $temp[$row['uid']]=$this->sys_page->getPageOverlay($row);
00501                                                 }
00502                                         break;
00503                                         case 'keywords':
00504                                                 list($value)=t3lib_div::intExplode(',',$value);
00505                                                 if (!$value) {
00506                                                         $value=$GLOBALS['TSFE']->page['uid'];
00507                                                 }
00508                                                 if ($this->conf['special.']['setKeywords'] || $this->conf['special.']['setKeywords.']) {
00509                                                         $kw = $this->parent_cObj->stdWrap($this->conf['special.']['setKeywords'], $this->conf['special.']['setKeywords.']);
00510                                                 } else {
00511                                                         $value_rec=$this->sys_page->getPage($value);    // The page record of the 'value'.
00512 
00513                                                         $kfieldSrc = $this->conf['special.']['keywordsField.']['sourceField'] ? $this->conf['special.']['keywordsField.']['sourceField'] : 'keywords';
00514                                                         $kw = trim(tslib_cObj::keywords($value_rec[$kfieldSrc]));               // keywords.
00515                                                 }
00516 
00517                                                 $mode = $this->conf['special.']['mode'];        // *'auto', 'manual', 'tstamp'
00518                                                 switch($mode)   {
00519                                                         case 'starttime':
00520                                                                 $sortField = 'starttime';
00521                                                         break;
00522                                                         case 'lastUpdated':
00523                                                         case 'manual':
00524                                                                 $sortField = 'lastUpdated';
00525                                                         break;
00526                                                         case 'tstamp':
00527                                                                 $sortField = 'tstamp';
00528                                                         break;
00529                                                         case 'crdate':
00530                                                                 $sortField = 'crdate';
00531                                                         break;
00532                                                         default:
00533                                                                 $sortField = 'SYS_LASTCHANGED';
00534                                                         break;
00535                                                 }
00536 
00537                                                         // depth, limit, extra where
00538                                                 if (t3lib_div::testInt($this->conf['special.']['depth']))       {
00539                                                         $depth = t3lib_div::intInRange($this->conf['special.']['depth'],0,20);          // Tree depth
00540                                                 } else {
00541                                                         $depth=20;
00542                                                 }
00543                                                 $limit = t3lib_div::intInRange($this->conf['special.']['limit'],0,100); // max number of items
00544                                                 $extraWhere = ' AND pages.uid!='.$value.' AND pages.nav_hide=0'.$this->getDoktypeExcludeWhere();
00545                                                 if ($this->conf['special.']['excludeNoSearchPages']) {
00546                                                         $extraWhere.= ' AND pages.no_search=0';
00547                                                 }
00548                                                         // start point
00549                                                 $eLevel = tslib_cObj::getKey (intval($this->conf['special.']['entryLevel']),$this->tmpl->rootLine);
00550                                                 $startUid = intval($this->tmpl->rootLine[$eLevel]['uid']);
00551 
00552                                                         // which field is for keywords
00553                                                 $kfield = 'keywords';
00554                                                 if ( $this->conf['special.']['keywordsField'] ) {
00555                                                         list($kfield) = explode(' ',trim ($this->conf['special.']['keywordsField']));
00556                                                 }
00557 
00558                                                         // If there are keywords and the startuid is present.
00559                                                 if ($kw && $startUid)   {
00560                                                         $bA = t3lib_div::intInRange($this->conf['special.']['beginAtLevel'],0,100);
00561                                                         $id_list=tslib_cObj::getTreeList(-1*$startUid,$depth-1+$bA,$bA-1);
00562 
00563                                                         $kwArr = explode(',',$kw);
00564                                                         foreach($kwArr as $word)        {
00565                                                                 $word = trim($word);
00566                                                                 if ($word)      {
00567                                                                         $keyWordsWhereArr[] = $kfield.' LIKE "%'.$GLOBALS['TYPO3_DB']->quoteStr($word, 'pages').'%"';
00568                                                                 }
00569                                                         }
00570                                                         $res = $GLOBALS['TSFE']->cObj->exec_getQuery('pages',Array('pidInList'=>'0', 'uidInList'=>$id_list, 'where'=>'('.implode(' OR ',$keyWordsWhereArr).')'.$extraWhere, 'orderBy'=>($altSortFieldValue ? $altSortFieldValue : $sortField.' desc'),'max'=>$limit));
00571                                                         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))      {
00572                                                                 $temp[$row['uid']]=$this->sys_page->getPageOverlay($row);
00573                                                         }
00574                                                 }
00575                                         break;
00576                                         case 'rootline':
00577                                                 $begin_end = explode('|',$this->conf['special.']['range']);
00578                                                 if (!t3lib_div::testInt($begin_end[0])) {intval($begin_end[0]);}
00579                                                 if (!t3lib_div::testInt($begin_end[1])) {$begin_end[1]=-1;}
00580 
00581                                                 $beginKey = tslib_cObj::getKey ($begin_end[0],$this->tmpl->rootLine);
00582                                                 $endKey = tslib_cObj::getKey ($begin_end[1],$this->tmpl->rootLine);
00583                                                 if ($endKey<$beginKey)  {$endKey=$beginKey;}
00584 
00585                                                 $rl_MParray = array();
00586                                                 foreach($this->tmpl->rootLine as $k_rl => $v_rl)        {
00587                                                                 // For overlaid mount points, set the variable right now:
00588                                                         if ($v_rl['_MP_PARAM'] && $v_rl['_MOUNT_OL'])   {
00589                                                                 $rl_MParray[] = $v_rl['_MP_PARAM'];
00590                                                         }
00591                                                                 // Traverse rootline:
00592                                                         if ($k_rl>=$beginKey && $k_rl<=$endKey) {
00593                                                                 $temp_key=$k_rl;
00594                                                                 $temp[$temp_key]=$this->sys_page->getPage($v_rl['uid']);
00595                                                                 if (count($temp[$temp_key]))    {
00596                                                                         if (!$temp[$temp_key]['target'])        {       // If there are no specific target for the page, put the level specific target on.
00597                                                                                 $temp[$temp_key]['target'] = $this->conf['special.']['targets.'][$k_rl];
00598                                                                                 $temp[$temp_key]['_MP_PARAM'] = implode(',',$rl_MParray);
00599                                                                         }
00600                                                                 } else unset($temp[$temp_key]);
00601                                                         }
00602                                                                 // For normal mount points, set the variable for next level.
00603                                                         if ($v_rl['_MP_PARAM'] && !$v_rl['_MOUNT_OL'])  {
00604                                                                 $rl_MParray[] = $v_rl['_MP_PARAM'];
00605                                                 }
00606                                                 }
00607                                         break;
00608                                         case 'browse':
00609                                                 list($value)=t3lib_div::intExplode(',',$value);
00610                                                 if (!$value) {
00611                                                         $value=$GLOBALS['TSFE']->page['uid'];
00612                                                 }
00613                                                 if ($value!=$this->tmpl->rootLine[0]['uid'])    {       // Will not work out of rootline
00614                                                         $recArr=array();
00615                                                         $value_rec=$this->sys_page->getPage($value);    // The page record of the 'value'.
00616                                                         if ($value_rec['pid'])  {       // 'up' page cannot be outside rootline
00617                                                                 $recArr['up']=$this->sys_page->getPage($value_rec['pid']);      // The page record of 'up'.
00618                                                         }
00619                                                         if ($recArr['up']['pid'] && $value_rec['pid']!=$this->tmpl->rootLine[0]['uid']) {       // If the 'up' item was NOT level 0 in rootline...
00620                                                                 $recArr['index']=$this->sys_page->getPage($recArr['up']['pid']);        // The page record of "index".
00621                                                         }
00622 
00623                                                                 // prev / next is found
00624                                                         $prevnext_menu = $this->sys_page->getMenu($value_rec['pid'],'*',$altSortField);
00625                                                         $lastKey=0;
00626                                                         $nextActive=0;
00627                                                         reset($prevnext_menu);
00628                                                         while(list($k_b,$v_b)=each($prevnext_menu))     {
00629                                                                 if ($nextActive)        {
00630                                                                         $recArr['next']=$v_b;
00631                                                                         $nextActive=0;
00632                                                                 }
00633                                                                 if ($v_b['uid']==$value)        {
00634                                                                         if ($lastKey)   {
00635                                                                                 $recArr['prev']=$prevnext_menu[$lastKey];
00636                                                                         }
00637                                                                         $nextActive=1;
00638                                                                 }
00639                                                                 $lastKey=$k_b;
00640                                                         }
00641                                                         reset($prevnext_menu);
00642                                                         $recArr['first']=pos($prevnext_menu);
00643                                                         end($prevnext_menu);
00644                                                         $recArr['last']=pos($prevnext_menu);
00645 
00646                                                                 // prevsection / nextsection is found
00647                                                         if (is_array($recArr['index'])) {       // You can only do this, if there is a valid page two levels up!
00648                                                                 $prevnextsection_menu = $this->sys_page->getMenu($recArr['index']['uid'],'*',$altSortField);
00649                                                                 $lastKey=0;
00650                                                                 $nextActive=0;
00651                                                                 reset($prevnextsection_menu);
00652                                                                 while(list($k_b,$v_b)=each($prevnextsection_menu))      {
00653                                                                         if ($nextActive)        {
00654                                                                                 $sectionRec_temp = $this->sys_page->getMenu($v_b['uid'],'*',$altSortField);
00655                                                                                 if (count($sectionRec_temp))    {
00656                                                                                         reset($sectionRec_temp);
00657                                                                                         $recArr['nextsection']=pos($sectionRec_temp);
00658                                                                                         end ($sectionRec_temp);
00659                                                                                         $recArr['nextsection_last']=pos($sectionRec_temp);
00660                                                                                         $nextActive=0;
00661                                                                                 }
00662                                                                         }
00663                                                                         if ($v_b['uid']==$value_rec['pid'])     {
00664                                                                                 if ($lastKey)   {
00665                                                                                         $sectionRec_temp = $this->sys_page->getMenu($prevnextsection_menu[$lastKey]['uid'],'*',$altSortField);
00666                                                                                         if (count($sectionRec_temp))    {
00667                                                                                                 reset($sectionRec_temp);
00668                                                                                                 $recArr['prevsection']=pos($sectionRec_temp);
00669                                                                                                 end ($sectionRec_temp);
00670                                                                                                 $recArr['prevsection_last']=pos($sectionRec_temp);
00671                                                                                         }
00672                                                                                 }
00673                                                                                 $nextActive=1;
00674                                                                         }
00675                                                                         $lastKey=$k_b;
00676                                                                 }
00677                                                         }
00678                                                         if ($this->conf['special.']['items.']['prevnextToSection'])     {
00679                                                                 if (!is_array($recArr['prev']) && is_array($recArr['prevsection_last']))        {
00680                                                                         $recArr['prev']=$recArr['prevsection_last'];
00681                                                                 }
00682                                                                 if (!is_array($recArr['next']) && is_array($recArr['nextsection']))     {
00683                                                                         $recArr['next']=$recArr['nextsection'];
00684                                                                 }
00685                                                         }
00686 
00687                                                         $items = explode('|',$this->conf['special.']['items']);
00688                                                         $c=0;
00689                                                         while(list($k_b,$v_b)=each($items))     {
00690                                                                 $v_b=strtolower(trim($v_b));
00691                                                                 if (intval($this->conf['special.'][$v_b.'.']['uid']))   {
00692                                                                         $recArr[$v_b] = $this->sys_page->getPage(intval($this->conf['special.'][$v_b.'.']['uid']));     // fetches the page in case of a hardcoded pid in template
00693                                                                 }
00694                                                                 if (is_array($recArr[$v_b]))    {
00695                                                                         $temp[$c]=$recArr[$v_b];
00696                                                                         if ($this->conf['special.'][$v_b.'.']['target'])        {
00697                                                                                 $temp[$c]['target']=$this->conf['special.'][$v_b.'.']['target'];
00698                                                                         }
00699                                                                         if (is_array($this->conf['special.'][$v_b.'.']['fields.']))     {
00700                                                                                 reset($this->conf['special.'][$v_b.'.']['fields.']);
00701                                                                                 while(list($fk,$val)=each($this->conf['special.'][$v_b.'.']['fields.']))        {
00702                                                                                         $temp[$c][$fk]=$val;
00703                                                                                 }
00704                                                                         }
00705                                                                         $c++;
00706                                                                 }
00707                                                         }
00708                                                 }
00709                                         break;
00710                                 }
00711                         } elseif (is_array($this->alternativeMenuTempArray))    {       // Setting $temp array if not level 1.
00712                                 $temp = $this->alternativeMenuTempArray;
00713                         } elseif ($this->mconf['sectionIndex']) {
00714                                 if ($GLOBALS['TSFE']->sys_language_uid && count($this->sys_page->getPageOverlay($this->id)))    {
00715                                         $sys_language_uid = intval($GLOBALS['TSFE']->sys_language_uid);
00716                                 } else $sys_language_uid=0;
00717 
00718                                 $selectSetup = Array(
00719                                         'pidInList'=>$this->id,
00720                                         'orderBy'=>$altSortField,
00721                                         'where' => 'colPos=0 AND sys_language_uid='.$sys_language_uid,
00722                                         'andWhere' => 'sectionIndex!=0'
00723                                         );
00724                                 switch($this->mconf['sectionIndex.']['type'])   {
00725                                         case 'all':
00726                                                 unset($selectSetup['andWhere']);
00727                                         break;
00728                                         case 'header':
00729                                                 $selectSetup['andWhere']='header_layout!=100 AND header!=""';
00730                                         break;
00731                                 }
00732                                 $basePageRow=$this->sys_page->getPage($this->id);
00733                                 if (is_array($basePageRow))     {
00734                                         $res = $GLOBALS['TSFE']->cObj->exec_getQuery('tt_content',      $selectSetup);
00735                                         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))      {
00736                                                 $temp[$row['uid']]=$basePageRow;
00737                                                 $temp[$row['uid']]['title']=$row['header'];
00738                                                 $temp[$row['uid']]['subtitle']=$row['subheader'];
00739                                                 $temp[$row['uid']]['starttime']=$row['starttime'];
00740                                                 $temp[$row['uid']]['endtime']=$row['endtime'];
00741                                                 $temp[$row['uid']]['fe_group']=$row['fe_group'];
00742                                                 $temp[$row['uid']]['media']=$row['media'];
00743 
00744                                                 $temp[$row['uid']]['header_layout']=$row['header_layout'];
00745                                                 $temp[$row['uid']]['bodytext']=$row['bodytext'];
00746                                                 $temp[$row['uid']]['image']=$row['image'];
00747 
00748                                                 $temp[$row['uid']]['sectionIndex_uid']=$row['uid'];
00749                                         }
00750                                 }
00751                         } else {        // Default:
00752                                 $temp = $this->sys_page->getMenu($this->id,'*',$altSortField);          // gets the menu
00753                         }
00754 
00755                         $c=0;
00756                         $c_b=0;
00757                         $minItems = intval($this->mconf['minItems'] ? $this->mconf['minItems'] : $this->conf['minItems']);
00758                         $maxItems = intval($this->mconf['maxItems'] ? $this->mconf['maxItems'] : $this->conf['maxItems']);
00759                         $begin = tslib_cObj::calc($this->mconf['begin'] ? $this->mconf['begin'] : $this->conf['begin']);
00760 
00761                         $banUidArray=array();
00762                         if (trim($this->conf['excludeUidList']))        {
00763                                 $banUidArray = t3lib_div::intExplode(',', $this->conf['excludeUidList']);
00764                         }
00765 
00766                                 // Fill in the menuArr with elements that should go into the menu:
00767                         $this->menuArr = Array();
00768                         foreach($temp as $data) {
00769                                 $spacer = (t3lib_div::inList($this->spacerIDList,$data['doktype']) || !strcmp($data['ITEM_STATE'],'SPC')) ? 1 : 0;              // if item is a spacer, $spacer is set
00770                                 if ($this->filterMenuPages($data, $banUidArray, $spacer))       {
00771                                         $c_b++;
00772                                         if ($begin<=$c_b)       {               // If the beginning item has been reached.
00773                                                 $this->menuArr[$c] = $data;
00774                                                 $this->menuArr[$c]['isSpacer'] = $spacer;
00775                                                 $c++;
00776                                                 if ($maxItems && $c>=$maxItems) {
00777                                                         break;
00778                                                 }
00779                                         }
00780                                 }
00781                         }
00782 
00783                                 // Fill in fake items, if min-items is set.
00784                         if ($minItems)  {
00785                                 while($c<$minItems)     {
00786                                         $this->menuArr[$c] = Array(
00787                                                 'title' => '...',
00788                                                 'uid' => $GLOBALS['TSFE']->id
00789                                         );
00790                                         $c++;
00791                                 }
00792                         }
00793                                 // Setting number of menu items
00794                         $GLOBALS['TSFE']->register['count_menuItems'] = count($this->menuArr);
00795                                 //      Passing the menuArr through a user defined function:
00796                         if ($this->mconf['itemArrayProcFunc'])  {
00797                                 if (!is_array($this->parentMenuArr)) {$this->parentMenuArr=array();}
00798                                 $this->menuArr = $this->userProcess('itemArrayProcFunc',$this->menuArr);
00799                         }
00800                         $this->hash = md5(serialize($this->menuArr).serialize($this->mconf).serialize($this->tmpl->rootLine).serialize($this->MP_array));
00801 
00802                         $serData = $this->sys_page->getHash($this->hash, 60*60*24);
00803                         if (!$serData)  {
00804                                 $this->generate();
00805                                 $this->sys_page->storeHash($this->hash, serialize($this->result),'MENUDATA');
00806                         } else {
00807                                 $this->result=unserialize($serData);
00808                         }
00809                 }
00810         }
00811 
00822         function includeMakeMenu($conf,$altSortField)   {
00823                 $incFile = $GLOBALS['TSFE']->tmpl->getFileName($conf['file']);
00824                 if ($incFile && $GLOBALS['TSFE']->checkFileInclude($incFile))   {
00825                         include($incFile);
00826                 }
00827                 return is_array($menuItemsArray) ? $menuItemsArray : array();
00828         }
00829 
00838         function filterMenuPages(&$data,$banUidArray,$spacer)   {
00839 
00840                 if ($data['_SAFE'])     return TRUE;
00841 
00842                 $uid = $data['uid'];
00843                 if ($this->mconf['SPC'] || !$spacer)    {       // If the spacer-function is not enabled, spacers will not enter the $menuArr
00844                         if (!t3lib_div::inList($this->doktypeExcludeList,$data['doktype']))     {               // Page may not be 'not_in_menu' or 'Backend User Section'
00845                                 if (!$data['nav_hide']) {       // Not hidden in navigation
00846                                         if (!t3lib_div::inArray($banUidArray,$uid))     {       // not in banned uid's
00847 
00848                                                         // Checks if the default language version can be shown:
00849                                                         // Block page is set, if l18n_cfg allows plus: 1) Either default language or 2) another language but NO overlay record set for page!
00850                                                 $blockPage = $data['l18n_cfg']&1 && (!$GLOBALS['TSFE']->sys_language_uid || ($GLOBALS['TSFE']->sys_language_uid && !$data['_PAGES_OVERLAY']));
00851                                                 if (!$blockPage)        {
00852 
00853                                                                 // Checking if a page should be shown in the menu depending on whether a translation exists:
00854                                                         $tok = TRUE;
00855                                                         if ($GLOBALS['TSFE']->sys_language_uid && $data['l18n_cfg']&2)  {       // There is an alternative language active AND the current page requires a translation:
00856                                                                 if (!$data['_PAGES_OVERLAY'])   {
00857                                                                         $tok = FALSE;
00858                                                                 }
00859                                                         }
00860 
00861                                                                 // Continue if token is true:
00862                                                         if ($tok)       {
00863 
00864                                                                         // Checking if "&L" should be modified so links to non-accessible pages will not happen.
00865                                                                 if ($this->conf['protectLvar']) {
00866                                                                         $Lvar = intval(t3lib_div::_GP('L'));
00867                                                                         if (($this->conf['protectLvar']=='all' || $data['l18n_cfg']&2) && $Lvar!=$GLOBALS['TSFE']->sys_language_uid)    {       // page cannot be access in locaization and Lvar is different than sys_language uid - this means we must check!
00868                                                                                 $olRec = $GLOBALS['TSFE']->sys_page->getPageOverlay($data['uid'], $Lvar);
00869                                                                                 if (!count($olRec))     {
00870                                                                                                 // If no pages_language_overlay record then page can NOT be accessed in the language pointed to by "&L" and therefore we protect the link by setting "&L=0"
00871                                                                                         $data['_ADD_GETVARS'].= '&L=0';
00872                                                                                 }
00873                                                                         }
00874                                                                 }
00875 
00876                                                                 return TRUE;
00877                                                         }
00878                                                 }
00879                                         }
00880                                 }
00881                         }
00882                 }
00883         }
00884 
00894         function procesItemStates($splitCount)  {
00895 
00896                         // Prepare normal settings
00897                 if (!is_array($this->mconf['NO.']) && $this->mconf['NO'])       $this->mconf['NO.']=array();    // Setting a blank array if NO=1 and there are no properties.
00898                 $NOconf = $this->tmpl->splitConfArray($this->mconf['NO.'],$splitCount);
00899 
00900                         // Prepare rollOver settings, overriding normal settings
00901                 $ROconf=array();
00902                 if ($this->mconf['RO']) {
00903                         $ROconf = $this->tmpl->splitConfArray($this->mconf['RO.'],$splitCount);
00904                 }
00905 
00906                         // Prepare IFSUB settings, overriding normal settings
00907                         // IFSUB is true if there exist submenu items to the current item
00908                 if ($this->mconf['IFSUB'])      {
00909                         $IFSUBinit = 0; // Flag: If $IFSUB is generated
00910                         reset($NOconf);
00911                         while (list($key,$val)=each($NOconf))   {
00912                                 if ($this->isItemState('IFSUB',$key))   {
00913                                         if (!$IFSUBinit)        {       // if this is the first IFSUB element, we must generate IFSUB.
00914                                                 $IFSUBconf = $this->tmpl->splitConfArray($this->mconf['IFSUB.'],$splitCount);
00915                                                 if ($this->mconf['IFSUBRO'])    {
00916                                                         $IFSUBROconf = $this->tmpl->splitConfArray($this->mconf['IFSUBRO.'],$splitCount);
00917                                                 }
00918                                                 $IFSUBinit = 1;
00919                                         }
00920                                         $NOconf[$key] = $IFSUBconf[$key];               // Substitute normal with ifsub
00921                                         if ($ROconf)    {       // If rollOver on normal, we must apply a state for rollOver on the active
00922                                                 $ROconf[$key] = $IFSUBROconf[$key] ? $IFSUBROconf[$key] : $IFSUBconf[$key];             // If RollOver on active then apply this
00923                                         }
00924                                 }
00925                         }
00926                 }
00927                         // Prepare active settings, overriding normal settings
00928                 if ($this->mconf['ACT'])        {
00929                         $ACTinit = 0;   // Flag: If $ACT is generated
00930                         reset($NOconf);
00931                         while (list($key,$val)=each($NOconf))   {       // Find active
00932                                 if ($this->isItemState('ACT',$key))     {
00933                                         if (!$ACTinit)  {       // if this is the first active, we must generate ACT.
00934                                                 $ACTconf = $this->tmpl->splitConfArray($this->mconf['ACT.'],$splitCount);
00935                                                         // Prepare active rollOver settings, overriding normal active settings
00936                                                 if ($this->mconf['ACTRO'])      {
00937                                                         $ACTROconf = $this->tmpl->splitConfArray($this->mconf['ACTRO.'],$splitCount);
00938                                                 }
00939                                                 $ACTinit = 1;
00940                                         }
00941                                         $NOconf[$key] = $ACTconf[$key];         // Substitute normal with active
00942                                         if ($ROconf)    {       // If rollOver on normal, we must apply a state for rollOver on the active
00943                                                 $ROconf[$key] = $ACTROconf[$key] ? $ACTROconf[$key] : $ACTconf[$key];           // If RollOver on active then apply this
00944                                         }
00945                                 }
00946                         }
00947                 }
00948                         // Prepare active/IFSUB settings, overriding normal settings
00949                         // ACTIFSUB is true if there exist submenu items to the current item and the current item is active
00950                 if ($this->mconf['ACTIFSUB'])   {
00951                         $ACTIFSUBinit = 0;      // Flag: If $ACTIFSUB is generated
00952                         reset($NOconf);
00953                         while (list($key,$val)=each($NOconf))   {       // Find active
00954                                 if ($this->isItemState('ACTIFSUB',$key))        {
00955                                         if (!$ACTIFSUBinit)     {       // if this is the first active, we must generate ACTIFSUB.
00956                                                 $ACTIFSUBconf = $this->tmpl->splitConfArray($this->mconf['ACTIFSUB.'],$splitCount);
00957                                                         // Prepare active rollOver settings, overriding normal active settings
00958                                                 if ($this->mconf['ACTIFSUBRO']) {
00959                                                         $ACTIFSUBROconf = $this->tmpl->splitConfArray($this->mconf['ACTIFSUBRO.'],$splitCount);
00960                                                 }
00961                                                 $ACTIFSUBinit = 1;
00962                                         }
00963                                         $NOconf[$key] = $ACTIFSUBconf[$key];            // Substitute normal with active
00964                                         if ($ROconf)    {       // If rollOver on normal, we must apply a state for rollOver on the active
00965                                                 $ROconf[$key] = $ACTIFSUBROconf[$key] ? $ACTIFSUBROconf[$key] : $ACTIFSUBconf[$key];            // If RollOver on active then apply this
00966                                         }
00967                                 }
00968                         }
00969                 }
00970                         // Prepare CUR (current) settings, overriding normal settings
00971                         // CUR is true if the current page equals the item here!
00972                 if ($this->mconf['CUR'])        {
00973                         $CURinit = 0;   // Flag: If $CUR is generated
00974                         reset($NOconf);
00975                         while (list($key,$val)=each($NOconf))   {
00976                                 if ($this->isItemState('CUR',$key))     {
00977                                         if (!$CURinit)  {       // if this is the first 'current', we must generate CUR. Basically this control is just inherited from the other implementations as current would only exist one time and thats it (unless you use special-features of HMENU)
00978                                                 $CURconf = $this->tmpl->splitConfArray($this->mconf['CUR.'],$splitCount);
00979                                                 if ($this->mconf['CURRO'])      {
00980                                                         $CURROconf = $this->tmpl->splitConfArray($this->mconf['CURRO.'],$splitCount);
00981                                                 }
00982                                                 $CURinit = 1;
00983                                         }
00984                                         $NOconf[$key] = $CURconf[$key];         // Substitute normal with current
00985                                         if ($ROconf)    {       // If rollOver on normal, we must apply a state for rollOver on the active
00986                                                 $ROconf[$key] = $CURROconf[$key] ? $CURROconf[$key] : $CURconf[$key];           // If RollOver on active then apply this
00987                                         }
00988                                 }
00989                         }
00990                 }
00991                         // Prepare active settings, overriding normal settings
00992                 if ($this->mconf['USR'])        {
00993                         $USRinit = 0;   // Flag: If $USR is generated
00994                         reset($NOconf);
00995                         while (list($key,$val)=each($NOconf))   {       // Find active
00996                                 if ($this->isItemState('USR',$key))     {
00997                                         if (!$USRinit)  {       // if this is the first active, we must generate USR.
00998                                                 $USRconf = $this->tmpl->splitConfArray($this->mconf['USR.'],$splitCount);
00999                                                         // Prepare active rollOver settings, overriding normal active settings
01000                                                 if ($this->mconf['USRRO'])      {
01001                                                         $USRROconf = $this->tmpl->splitConfArray($this->mconf['USRRO.'],$splitCount);
01002                                                 }
01003                                                 $USRinit = 1;
01004                                         }
01005                                         $NOconf[$key] = $USRconf[$key];         // Substitute normal with active
01006                                         if ($ROconf)    {       // If rollOver on normal, we must apply a state for rollOver on the active
01007                                                 $ROconf[$key] = $USRROconf[$key] ? $USRROconf[$key] : $USRconf[$key];           // If RollOver on active then apply this
01008                                         }
01009                                 }
01010                         }
01011                 }
01012                         // Prepare spacer settings, overriding normal settings
01013                 if ($this->mconf['SPC'])        {
01014                         $SPCinit = 0;   // Flag: If $SPC is generated
01015                         reset($NOconf);
01016                         while (list($key,$val)=each($NOconf))   {       // Find spacers
01017                                 if ($this->isItemState('SPC',$key))     {
01018                                         if (!$SPCinit)  {       // if this is the first spacer, we must generate SPC.
01019                                                 $SPCconf = $this->tmpl->splitConfArray($this->mconf['SPC.'],$splitCount);
01020                                                 $SPCinit = 1;
01021                                         }
01022                                         $NOconf[$key] = $SPCconf[$key];         // Substitute normal with spacer
01023                                 }
01024                         }
01025                 }
01026                         // Prepare Userdefined settings
01027                 if ($this->mconf['USERDEF1'])   {
01028                         $USERDEF1init = 0;      // Flag: If $USERDEF1 is generated
01029                         reset($NOconf);
01030                         while (list($key,$val)=each($NOconf))   {       // Find active
01031                                 if ($this->isItemState('USERDEF1',$key))        {
01032                                         if (!$USERDEF1init)     {       // if this is the first active, we must generate USERDEF1.
01033                                                 $USERDEF1conf = $this->tmpl->splitConfArray($this->mconf['USERDEF1.'],$splitCount);
01034                                                         // Prepare active rollOver settings, overriding normal active settings
01035                                                 if ($this->mconf['USERDEF1RO']) {
01036                                                         $USERDEF1ROconf = $this->tmpl->splitConfArray($this->mconf['USERDEF1RO.'],$splitCount);
01037                                                 }
01038                                                 $USERDEF1init = 1;
01039                                         }
01040                                         $NOconf[$key] = $USERDEF1conf[$key];            // Substitute normal with active
01041                                         if ($ROconf)    {       // If rollOver on normal, we must apply a state for rollOver on the active
01042                                                 $ROconf[$key] = $USERDEF1ROconf[$key] ? $USERDEF1ROconf[$key] : $USERDEF1conf[$key];            // If RollOver on active then apply this
01043                                         }
01044                                 }
01045                         }
01046                 }
01047                         // Prepare Userdefined settings
01048                 if ($this->mconf['USERDEF2'])   {
01049                         $USERDEF2init = 0;      // Flag: If $USERDEF2 is generated
01050                         reset($NOconf);
01051                         while (list($key,$val)=each($NOconf))   {       // Find active
01052                                 if ($this->isItemState('USERDEF2',$key))        {
01053                                         if (!$USERDEF2init)     {       // if this is the first active, we must generate USERDEF2.
01054                                                 $USERDEF2conf = $this->tmpl->splitConfArray($this->mconf['USERDEF2.'],$splitCount);
01055                                                         // Prepare active rollOver settings, overriding normal active settings
01056                                                 if ($this->mconf['USERDEF2RO']) {
01057                                                         $USERDEF2ROconf = $this->tmpl->splitConfArray($this->mconf['USERDEF2RO.'],$splitCount);
01058                                                 }
01059                                                 $USERDEF2init = 1;
01060                                         }
01061                                         $NOconf[$key] = $USERDEF2conf[$key];            // Substitute normal with active
01062                                         if ($ROconf)    {       // If rollOver on normal, we must apply a state for rollOver on the active
01063                                                 $ROconf[$key] = $USERDEF2ROconf[$key] ? $USERDEF2ROconf[$key] : $USERDEF2conf[$key];            // If RollOver on active then apply this
01064                                         }
01065                                 }
01066                         }
01067                 }
01068 
01069                 return array($NOconf,$ROconf);
01070         }
01071 
01082         function link($key,$altTarget='',$typeOverride='') {
01083 
01084                         // Mount points:
01085                 $MP_var = $this->getMPvar($key);
01086                 $MP_params = $MP_var ? '&MP='.rawurlencode($MP_var) : '';
01087 
01088                         // Setting override ID
01089                 if ($this->mconf['overrideId'] || $this->menuArr[$key]['overrideId'])   {
01090                         $overrideArray = array();
01091                                 // If a user script returned the value overrideId in the menu array we use that as page id
01092                         $overrideArray['uid'] = $this->mconf['overrideId']?$this->mconf['overrideId']:$this->menuArr[$key]['overrideId'];
01093                         $overrideArray['alias'] = '';
01094                         $MP_params = '';        // clear MP parameters since ID was changed.
01095                 } else {
01096                         $overrideArray='';
01097                 }
01098 
01099                         // Setting main target:
01100                 $mainTarget = $altTarget ? $altTarget : $this->mconf['target'];
01101 
01102                         // Creating link:
01103                 if ($this->mconf['collapse'] && $this->isActive($this->menuArr[$key]['uid'], $this->getMPvar($key)))    {
01104                         $thePage = $this->sys_page->getPage($this->menuArr[$key]['pid']);
01105                         $LD = $this->tmpl->linkData($thePage,$mainTarget,'','',$overrideArray, $this->mconf['addParams'].$MP_params.$this->menuArr[$key]['_ADD_GETVARS'], $typeOverride);
01106                 } else {
01107                         $LD = $this->tmpl->linkData($this->menuArr[$key],$mainTarget,'','',$overrideArray, $this->mconf['addParams'].$MP_params.$this->menuArr[$key]['_ADD_GETVARS'], $typeOverride);
01108                 }
01109 
01110                         // Overriding URL / Target if set to do so:
01111                 if ($this->menuArr[$key]['_OVERRIDE_HREF'])     {
01112                         $LD['totalURL'] = $this->menuArr[$key]['_OVERRIDE_HREF'];
01113                         if ($this->menuArr[$key]['_OVERRIDE_TARGET'])   $LD['target'] = $this->menuArr[$key]['_OVERRIDE_TARGET'];
01114                 }
01115 
01116                         // OnClick open in windows.
01117                 $onClick='';
01118                 if ($this->mconf['JSWindow'])   {
01119                         $conf=$this->mconf['JSWindow.'];
01120                         $url=$LD['totalURL'];
01121                         $LD['totalURL'] = '#';
01122                         $onClick= 'openPic(\''.$GLOBALS['TSFE']->baseUrlWrap($url).'\',\''.($conf['newWindow']?md5($url):'theNewPage').'\',\''.$conf['params'].'\'); return false;';
01123                         $GLOBALS['TSFE']->setJS('openPic');
01124                 }
01125 
01126                         // out:
01127                 $list = array();
01128                 $list['HREF'] = strlen($LD['totalURL']) ? $LD['totalURL'] : $GLOBALS['TSFE']->baseUrl;  // Added this check: What it does is to enter the baseUrl (if set, which it should for "realurl" based sites) as URL if the calculated value is empty. The problem is that no link is generated with a blank URL and blank URLs might appear when the realurl encoding is used and a link to the frontpage is generated.
01129                 $list['TARGET'] = $LD['target'];
01130                 $list['onClick'] = $onClick;
01131 
01132                 return $list;
01133         }
01134 
01142         function subMenu($uid)  {
01143 
01144                         // Setting alternative menu item array if _SUB_MENU has been defined in the current ->menuArr
01145                 $altArray = '';
01146                 if (is_array($this->menuArr[$this->I['key']]['_SUB_MENU']) && count($this->menuArr[$this->I['key']]['_SUB_MENU']))      {
01147                         $altArray = $this->menuArr[$this->I['key']]['_SUB_MENU'];
01148                 }
01149 
01150                         // Make submenu if the page is the next active
01151                 if ($this->subLevelClass && ($this->mconf['expAll'] || $this->isNext($uid, $this->getMPvar($this->I['key'])) || is_array($altArray)) && !$this->mconf['sectionIndex'])  {
01152                         $submenu = t3lib_div::makeInstance('tslib_'.$this->subLevelClass);
01153                         $submenu->entryLevel = $this->entryLevel+1;
01154                         $submenu->rL_uidRegister = $this->rL_uidRegister;
01155                         $submenu->MP_array = $this->MP_array;
01156                         if ($this->menuArr[$this->I['key']]['_MP_PARAM'])       {
01157                                 $submenu->MP_array[] = $this->menuArr[$this->I['key']]['_MP_PARAM'];
01158                         }
01159 
01160                                 // especially scripts that build the submenu needs the parent data
01161                         $submenu->parentMenuArr = $this->menuArr;
01162 
01163                                 // Setting alternativeMenuTempArray (will be effective only if an array)
01164                         if (is_array($altArray))        {
01165                                 $submenu->alternativeMenuTempArray = $altArray;
01166                         }
01167 
01168                         if ($submenu->start($this->tmpl, $this->sys_page, $uid, $this->conf, $this->menuNumber+1))      {
01169                                 $submenu->makeMenu();
01170                                 return $submenu->writeMenu();
01171                         }
01172                 }
01173         }
01174 
01184         function isNext($uid, $MPvar='')        {
01185 
01186                         // Check for always active PIDs:
01187                 if (count($this->alwaysActivePIDlist) && in_array($uid,$this->alwaysActivePIDlist))     {
01188                         return TRUE;
01189                 }
01190 
01191                 $testUid = $uid.($MPvar?':'.$MPvar:'');
01192                 if ($uid && $testUid==$this->nextActive)        {
01193                         return TRUE;
01194                 }
01195         }
01196 
01205         function isActive($uid, $MPvar='')      {
01206 
01207                         // Check for always active PIDs:
01208                 if (count($this->alwaysActivePIDlist) && in_array($uid,$this->alwaysActivePIDlist))     {
01209                         return TRUE;
01210                 }
01211 
01212                 $testUid = $uid.($MPvar?':'.$MPvar:'');
01213                 if ($uid && in_array('ITEM:'.$testUid, $this->rL_uidRegister))  {
01214                         return TRUE;
01215                 }
01216         }
01217 
01226         function isCurrent($uid, $MPvar='')     {
01227                 $testUid = $uid.($MPvar?':'.$MPvar:'');
01228                 if ($uid && !strcmp(end($this->rL_uidRegister),'ITEM:'.$testUid))       {
01229                         return TRUE;
01230         }
01231         }
01232 
01241         function isSubMenu($uid)        {
01242 
01243                         // Looking for a mount-pid for this UID since if that exists we should look for a subpages THERE and not in the input $uid;
01244                 $mount_info = $this->sys_page->getMountPointInfo($uid);
01245                 if (is_array($mount_info))      {
01246                         $uid = $mount_info['mount_pid'];
01247                 }
01248 
01249                 $recs = $this->sys_page->getMenu($uid,'uid,pid,doktype,mount_pid,mount_pid_ol');
01250                 foreach($recs as $theRec)       {
01251                         if (!t3lib_div::inList($this->doktypeExcludeList,$theRec['doktype']) && !$theRec['nav_hide'])   {       // If a menu item seems to be another type than 'Not in menu', then return true (there were items!)
01252                                 return TRUE;
01253                         }
01254                 }
01255         }
01256 
01266         function isItemState($kind,$key)        {
01267                 $natVal=0;
01268                 if ($this->menuArr[$key]['ITEM_STATE']) {               // If any value is set for ITEM_STATE the normal evaluation is discarded
01269                         if (!strcmp($this->menuArr[$key]['ITEM_STATE'],$kind))  {$natVal=1;}
01270                 } else {
01271                         switch($kind)   {
01272                                 case 'SPC':
01273                                         $natVal = $this->menuArr[$key]['isSpacer'];
01274                                 break;
01275                                 case 'IFSUB':
01276                                         $natVal = $this->isSubMenu($this->menuArr[$key]['uid']);
01277                                 break;
01278                                 case 'ACT':
01279                                         $natVal = $this->isActive($this->menuArr[$key]['uid'], $this->getMPvar($key));
01280                                 break;
01281                                 case 'ACTIFSUB':
01282                                         $natVal = $this->isActive($this->menuArr[$key]['uid'], $this->getMPvar($key)) && $this->isSubMenu($this->menuArr[$key]['uid']);
01283                                 break;
01284                                 case 'CUR':
01285                                         $natVal = $this->isCurrent($this->menuArr[$key]['uid'], $this->getMPvar($key));
01286                                 break;
01287                                 case 'USR':
01288                                         $natVal = $this->menuArr[$key]['fe_group'];
01289                                 break;
01290                         }
01291                 }
01292 
01293                 return $natVal;
01294         }
01295 
01303         function accessKey($title)      {
01304                         // The global array ACCESSKEY is used to globally control if letters are already used!!
01305                 $result = Array();
01306 
01307                 $titleLen = strlen($title);
01308                 for ($a=0;$a<$titleLen;$a++)    {
01309                         $key = strtoupper(trim(substr($title,$a,1)));
01310                         if ($key && !isset($GLOBALS['TSFE']->accessKey[$key]))  {
01311                                 $GLOBALS['TSFE']->accessKey[$key]=1;
01312                                 $result['code'] = ' accesskey="'.$key.'"';
01313                                 $result['alt'] = ' (ALT+'.$key.')';
01314                                 break;
01315                         }
01316                 }
01317                 return $result;
01318         }
01319 
01329         function userProcess($mConfKey,$passVar)        {
01330                 if ($this->mconf[$mConfKey])    {
01331                         $funcConf = $this->mconf[$mConfKey.'.'];
01332                         $funcConf['parentObj']=&$this;
01333                         $passVar = $GLOBALS['TSFE']->cObj->callUserFunction($this->mconf[$mConfKey], $funcConf, $passVar);
01334                 }
01335                 return $passVar;
01336         }
01337 
01344         function setATagParts() {
01345                 $this->I['A1'] = '<a '.t3lib_div::implodeAttributes($this->I['linkHREF'],1).$this->I['val']['ATagParams'].$this->I['addATagParams'].$this->I['accessKey']['code'].'>';
01346                 $this->I['A2'] = '</a>';
01347         }
01348 
01357         function getPageTitle($title,$nav_title)        {
01358                 return strcmp(trim($nav_title),'') ? $nav_title : $title;
01359         }
01360 
01369         function getMPvar($key) {
01370                 if ($GLOBALS['TYPO3_CONF_VARS']['FE']['enable_mount_pids'])     {
01371                         $localMP_array = $this->MP_array;
01372                         if ($this->menuArr[$key]['_MP_PARAM'])  $localMP_array[] = $this->menuArr[$key]['_MP_PARAM'];   // NOTICE: "_MP_PARAM" is allowed to be a commalist of PID pairs!
01373                         $MP_params = count($localMP_array) ? implode(',',$localMP_array) : '';
01374                         return $MP_params;
01375                 }
01376         }
01377 
01384         function getDoktypeExcludeWhere() {
01385                 return $this->doktypeExcludeList ? ' AND pages.doktype NOT IN ('.$this->doktypeExcludeList.')' : '';
01386         }
01387 
01388 }
01389 
01390 
01391 
01392 
01393 
01394 
01395 
01396 
01397 
01398 
01399 
01400 
01401 
01402 
01403 
01404 
01405 
01406 
01407 
01416 class tslib_tmenu extends tslib_menu {
01417 
01425         function generate()     {
01426                 $splitCount = count($this->menuArr);
01427                 if ($splitCount)        {
01428                         list($NOconf) = $this->procesItemStates($splitCount);
01429                 }
01430                 if ($this->mconf['debugItemConf'])      {echo '<h3>$NOconf:</h3>';      debug($NOconf); }
01431                 $this->result = $NOconf;
01432         }
01433 
01441         function writeMenu()    {
01442                 if (is_array($this->result) && count($this->result))    {
01443                         $this->WMcObj =t3lib_div::makeInstance('tslib_cObj');   // Create new tslib_cObj for our use
01444                         $this->WMresult='';
01445                         $this->INPfixMD5 = substr(md5(microtime().'tmenu'),0,4);
01446                         $this->WMmenuItems = count($this->result);
01447                         $this->extProc_init();
01448                         reset($this->result);
01449                         while (list($key,$val)=each($this->result))     {
01450                                 $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']++;
01451                                 $GLOBALS['TSFE']->register['count_MENUOBJ']++;
01452 
01453                                 $this->I=array();
01454                                 $this->WMcObj->start($this->menuArr[$key],'pages');             // Initialize the cObj with the page record of the menu item
01455                                 $this->I['key'] = $key;
01456                                 $this->I['INPfix']= $this->imgNameNotRandom?'':'_'.$this->INPfixMD5.'_'.$key;
01457                                 $this->I['val'] = $val;
01458                                 $this->I['title'] = $this->WMcObj->stdWrap($this->getPageTitle($this->menuArr[$key]['title'],$this->menuArr[$key]['nav_title']),$this->I['val']['stdWrap.']);
01459                                 $this->I['uid'] = $this->menuArr[$key]['uid'];
01460                                 $this->I['mount_pid'] = $this->menuArr[$key]['mount_pid'];
01461                                 $this->I['pid'] = $this->menuArr[$key]['pid'];
01462                                 $this->I['spacer'] = $this->menuArr[$key]['isSpacer'];
01463 
01464                                         // Make link tag
01465                                 $this->I['val']['ATagParams'] = $this->I['val']['ATagParams'] ? ' '.$this->I['val']['ATagParams'] : '';
01466                                 $this->I['linkHREF'] =  $this->link($key,$this->I['val']['altTarget'],$this->mconf['forceTypeValue']);
01467 
01468                                         // Title attribute of links:
01469                                 $titleAttrValue = $this->WMcObj->stdWrap($this->I['val']['ATagTitle'],$this->I['val']['ATagTitle.']);
01470                                 if (strlen($titleAttrValue))    {
01471                                         $this->I['linkHREF']['title'] = $titleAttrValue;
01472                                 }
01473 
01474                                         // Setting "blurlink()" function:
01475                                 if (!$this->mconf['noBlur'])    {
01476                                         $this->I['linkHREF']['onFocus']='blurLink(this);';
01477                                 }
01478 
01479                                         // Make link:
01480                                 if ($this->I['val']['RO'])      {
01481                                         $this->I['theName'] = $this->imgNamePrefix.$this->I['uid'].$this->I['INPfix'];
01482                                         $over='';
01483                                         $out ='';
01484                                         if ($this->I['val']['beforeROImg'])     {
01485                                                 $over.= $this->WMfreezePrefix."over('".$this->I['theName']."before');";
01486                                                 $out.= $this->WMfreezePrefix."out('".$this->I['theName']."before');";
01487                                         }
01488                                         if ($this->I['val']['afterROImg'])      {
01489                                                 $over.= $this->WMfreezePrefix."over('".$this->I['theName']."after');";
01490                                                 $out.= $this->WMfreezePrefix."out('".$this->I['theName']."after');";
01491                                         }
01492                                         $this->I['linkHREF']['onMouseover']=$over;
01493                                         $this->I['linkHREF']['onMouseout']=$out;
01494                                         if ($over || $out)      $GLOBALS['TSFE']->setJS('mouseOver');
01495 
01496                                                 // Change background color:
01497                                         if ($this->I['val']['RO_chBgColor'])    {
01498                                                 $this->addJScolorShiftFunction();
01499                                                 $chBgP = t3lib_div::trimExplode('|',$this->I['val']['RO_chBgColor']);
01500                                                 $this->I['linkHREF']['onMouseover'].="changeBGcolor('".$chBgP[2].$this->I['uid']."','".$chBgP[0]."');";
01501                                                 $this->I['linkHREF']['onMouseout'].="changeBGcolor('".$chBgP[2].$this->I['uid']."','".$chBgP[1]."');";
01502                                         }
01503 
01504                                         $this->extProc_RO($key);
01505                                 }
01506 
01507 
01508                                         // Calling extra processing function
01509                                 $this->extProc_beforeLinking($key);
01510 
01511                                         // Compile link tag
01512                                 if (!$this->I['val']['doNotLinkIt']) {$this->I['val']['doNotLinkIt']=0;}
01513                                 if (!$this->I['spacer'] && $this->I['val']['doNotLinkIt']!=1)   {
01514                                         $this->setATagParts();
01515                                 } else {
01516                                         $this->I['A1'] = '';
01517                                         $this->I['A2'] = '';
01518                                 }
01519 
01520                                         // ATAGBeforeWrap processing:
01521                                 if ($this->I['val']['ATagBeforeWrap'])  {
01522                                         $wrapPartsBefore = explode('|',$this->I['val']['linkWrap']);
01523                                         $wrapPartsAfter = array('','');
01524                                 } else {
01525                                         $wrapPartsBefore = array('','');
01526                                         $wrapPartsAfter = explode('|',$this->I['val']['linkWrap']);
01527                                 }
01528                                 if ($this->I['val']['stdWrap2'] || isset($this->I['val']['stdWrap2.'])) {
01529                                         $wrapPartsStdWrap = explode($this->I['val']['stdWrap2']?$this->I['val']['stdWrap2']:'|',$this->WMcObj->stdWrap('|',$this->I['val']['stdWrap2.']));
01530                                 } else {$wrapPartsStdWrap = array('','');}
01531 
01532                                         // Make before, middle and after parts
01533                                 $this->I['parts'] = array();
01534                                 $this->I['parts']['before']=$this->getBeforeAfter('before');
01535                                 $this->I['parts']['stdWrap2_begin']=$wrapPartsStdWrap[0];
01536                                 if (!$this->I['val']['doNotShowLink']) {
01537                                         $this->I['parts']['notATagBeforeWrap_begin'] = $wrapPartsAfter[0];
01538                                         $this->I['parts']['ATag_begin'] = $this->I['A1'];
01539                                         $this->I['parts']['ATagBeforeWrap_begin'] = $wrapPartsBefore[0];
01540                                         $this->I['parts']['title'] = $this->I['title'];
01541                                         $this->I['parts']['ATagBeforeWrap_end'] = $wrapPartsBefore[1];
01542                                         $this->I['parts']['ATag_end'] = $this->I['A2'];
01543                                         $this->I['parts']['notATagBeforeWrap_end'] = $wrapPartsAfter[1];
01544                                 }
01545                                 $this->I['parts']['stdWrap2_end']=$wrapPartsStdWrap[1];
01546                                 $this->I['parts']['after']=$this->getBeforeAfter('after');
01547 
01548                                         // Passing I to a user function
01549                                 if ($this->mconf['IProcFunc'])  {
01550                                         $this->I = $this->userProcess('IProcFunc',$this->I);
01551                                 }
01552 
01553                                         // Merge parts + beforeAllWrap
01554                                 $this->I['theItem']= implode('',$this->I['parts']);
01555                                 $this->I['theItem']= $this->extProc_beforeAllWrap($this->I['theItem'],$key);
01556 
01557                                         // allWrap:
01558                                 $allWrap = $this->WMcObj->stdWrap($this->I['val']['allWrap'],$this->I['val']['allWrap.']);
01559                                 $this->I['theItem'] = $this->tmpl->wrap($this->I['theItem'],$allWrap);
01560 
01561                                 if ($this->I['val']['subst_elementUid'])        $this->I['theItem'] = str_replace('{elementUid}',$this->I['uid'],$this->I['theItem']);
01562 
01563                                         // allStdWrap:
01564                                 if (is_array($this->I['val']['allStdWrap.']))   {
01565                                         $this->I['theItem'] = $this->WMcObj->stdWrap($this->I['theItem'],$this->I['val']['allStdWrap.']);
01566                                 }
01567 
01568                                         // Calling extra processing function
01569                                 $this->extProc_afterLinking($key);
01570                         }
01571                         return $this->extProc_finish();
01572                 }
01573         }
01574 
01582         function getBeforeAfter($pref)  {
01583                 $res = '';
01584                 if ($imgInfo = $this->WMcObj->getImgResource($this->I['val'][$pref.'Img'],$this->I['val'][$pref.'Img.']))       {
01585                         $imgInfo[3] = t3lib_div::png_to_gif_by_imagemagick($imgInfo[3]);
01586                         if ($this->I['val']['RO'] && $this->I['val'][$pref.'ROImg'] && !$this->I['spacer'])     {
01587                                 $imgROInfo = $this->WMcObj->getImgResource($this->I['val'][$pref.'ROImg'],$this->I['val'][$pref.'ROImg.']);
01588                                 $imgROInfo[3] = t3lib_div::png_to_gif_by_imagemagick($imgROInfo[3]);
01589                                 if ($imgROInfo) {
01590                                         $theName = $this->imgNamePrefix.$this->I['uid'].$this->I['INPfix'].$pref;
01591                                         $name = ' name="'.$theName.'"';
01592                                         $GLOBALS['TSFE']->JSImgCode.= chr(10).$theName.'_n=new Image(); '.$theName.'_n.src = "'.$GLOBALS['TSFE']->absRefPrefix.$imgInfo[3].'"; ';
01593                                         $GLOBALS['TSFE']->JSImgCode.= chr(10).$theName.'_h=new Image(); '.$theName.'_h.src = "'.$GLOBALS['TSFE']->absRefPrefix.$imgROInfo[3].'"; ';
01594                                 }
01595                         }
01596                         $GLOBALS['TSFE']->imagesOnPage[]=$imgInfo[3];
01597                         $res='<img src="'.$GLOBALS['TSFE']->absRefPrefix.$imgInfo[3].'" width="'.$imgInfo[0].'" height="'.$imgInfo[1].'"'.$name.($this->I['val'][$pref.'ImgTagParams']?" ".$this->I['val'][$pref.'ImgTagParams']:'').' border="0"';
01598                         if (!strstr($res,'alt="'))      $res.=' alt=""';        // Adding alt attribute if not set.
01599                         $res.=' />';
01600                         if ($this->I['val'][$pref.'ImgLink'])   {$res=$this->I['A1'].$res.$this->I['A2'];}
01601                 }
01602                 return $this->tmpl->wrap($res.$this->WMcObj->stdWrap($this->I['val'][$pref],$this->I['val'][$pref.'.']), $this->I['val'][$pref.'Wrap']);
01603         }
01604 
01612         function addJScolorShiftFunction()      {
01613                 $GLOBALS['TSFE']->additionalJavaScript['TMENU:changeBGcolor()']='
01614                         function changeBGcolor(id,color) {      //
01615                                 if (document.getElementById && document.getElementById(id))     {
01616                                         document.getElementById(id).style.background = color;
01617                                         return true;
01618                                 } else if (document.layers && document.layers[id]) {
01619                                 document.layers[id].bgColor = color;
01620                                         return true;
01621                             }
01622                         }
01623                 ';
01624         }
01625 
01634         function extProc_init() {
01635         }
01636 
01645         function extProc_RO($key)       {
01646         }
01647 
01656         function extProc_beforeLinking($key)    {
01657         }
01658 
01668         function extProc_afterLinking($key)     {
01669                         // Add part to the accumulated result + fetch submenus
01670                 if (!$this->I['spacer'])        {
01671                         $this->I['theItem'].= $this->subMenu($this->I['uid']);
01672                 }
01673                 $this->WMresult.= $this->I['val']['wrapItemAndSub'] ? $this->tmpl->wrap($this->I['theItem'],$this->I['val']['wrapItemAndSub']) : $this->I['theItem'];
01674         }
01675 
01685         function extProc_beforeAllWrap($item,$key)      {
01686                 return $item;
01687         }
01688 
01696         function extProc_finish()       {
01697                 return $this->tmpl->wrap($this->WMresult,$this->mconf['wrap']).$this->WMextraScript;
01698         }
01699 }
01700 
01701 
01702 
01703 
01704 
01705 
01706 
01707 
01708 
01709 
01710 
01711 
01712 
01713 
01714 
01715 
01716 
01717 
01718 
01719 
01720 
01721 
01722 
01723 
01732 class tslib_gmenu extends tslib_menu {
01733 
01741         function generate()     {
01742                 $splitCount = count($this->menuArr);
01743                 if ($splitCount)        {
01744                         list($NOconf,$ROconf) = $this->procesItemStates($splitCount);
01745 
01746                                 //store initial count value
01747                         $temp_HMENU_MENUOBJ = $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'];
01748                         $temp_MENUOBJ = $GLOBALS['TSFE']->register['count_MENUOBJ'];
01749                                 // Now we generate the giffiles:
01750                         $this->makeGifs($NOconf,'NO');
01751                                 // store count from NO obj
01752                         $tempcnt_HMENU_MENUOBJ = $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'];
01753                         $tempcnt_MENUOBJ = $GLOBALS['TSFE']->register['count_MENUOBJ'];
01754 
01755                         if ($this->mconf['debugItemConf'])      {echo '<h3>$NOconf:</h3>';      debug($NOconf); }
01756                         if ($ROconf)    {               // RollOver
01757                                         //start recount for rollover with initial values
01758                                 $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']= $temp_HMENU_MENUOBJ;
01759                                 $GLOBALS['TSFE']->register['count_MENUOBJ']= $temp_MENUOBJ;
01760                                 $this->makeGifs($ROconf,'RO');
01761                                 if ($this->mconf['debugItemConf'])      {echo '<h3>$ROconf:</h3>';      debug($ROconf); }
01762                         }
01763                                 // use count from NO obj
01764                         $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'] = $tempcnt_HMENU_MENUOBJ;
01765                         $GLOBALS['TSFE']->register['count_MENUOBJ'] = $tempcnt_MENUOBJ;
01766                 }
01767         }
01768 
01779         function makeGifs($conf, $resKey)       {
01780                 $isGD = $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'];
01781 
01782                 if (!is_array($conf)) {
01783                         $conf = Array();
01784                 }
01785 
01786                 $totalWH=array();
01787                 $items = count($conf);
01788                 if ($isGD)      {
01789                                 // generate the gif-files. the $menuArr is filled with some values like output_w, output_h, output_file
01790                         $Hcounter = 0;
01791                         $Wcounter = 0;
01792                         $Hobjs = $this->mconf['applyTotalH'];
01793                         if ($Hobjs)     {$Hobjs = t3lib_div::intExplode(',',$Hobjs);}
01794                         $Wobjs = $this->mconf['applyTotalW'];
01795                         if ($Wobjs)     {$Wobjs = t3lib_div::intExplode(',',$Wobjs);}
01796                         $minDim = $this->mconf['min'];
01797                         if ($minDim) {$minDim = tslib_cObj::calcIntExplode(',',$minDim.',');}
01798                         $maxDim = $this->mconf['max'];
01799                         if ($maxDim) {$maxDim = tslib_cObj::calcIntExplode(',',$maxDim.',');}
01800 
01801                         if ($minDim)    {
01802                                 $conf[$items]=$conf[$items-1];
01803                                 $this->menuArr[$items]=Array();
01804                                 $items = count($conf);
01805                         }
01806 
01807                         // TOTAL width
01808                         if ($this->mconf['useLargestItemX'] || $this->mconf['useLargestItemY'] || $this->mconf['distributeX'] || $this->mconf['distributeY'])   {
01809                                 $totalWH = $this->findLargestDims($conf,$items,$Hobjs,$Wobjs,$minDim,$maxDim);
01810                         }
01811                 }
01812 
01813                 $c=0;
01814                 $maxFlag=0;
01815                 $distributeAccu=array('H'=>0,'W'=>0);
01816                 reset($conf);
01817                 while (list($key,$val)=each($conf))     {
01818                         $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']++;
01819                         $GLOBALS['TSFE']->register['count_MENUOBJ']++;
01820 
01821                         if ($items==($c+1) && $minDim)  {
01822                                 $Lobjs = $this->mconf['removeObjectsOfDummy'];
01823                                 if ($Lobjs)     {
01824                                         $Lobjs = t3lib_div::intExplode(',',$Lobjs);
01825                                         reset($Lobjs);
01826                                         while(list(,$remItem)=each($Lobjs))     {
01827                                                 unset($val[$remItem]);
01828                                                 unset($val[$remItem.'.']);
01829                                         }
01830                                 }
01831 
01832                                 $flag =0;
01833                                 $tempXY = explode(',',$val['XY']);
01834                                 if ($Wcounter<$minDim[0])       {$tempXY[0]=$minDim[0]-$Wcounter; $flag=1;}
01835                                 if ($Hcounter<$minDim[1])       {$tempXY[1]=$minDim[1]-$Hcounter; $flag=1;}
01836                                 $val['XY'] = implode(',',$tempXY);
01837                                 if (!$flag){break;}
01838                         }
01839                         $c++;
01840 
01841 
01842                         if ($isGD)      {
01843                                         // Pre-working the item
01844                                 $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder');
01845                                 $gifCreator->init();
01846                                 $gifCreator->start($val,$this->menuArr[$key]);
01847 
01848                                         // If useLargestItemH/W is specified
01849                                 if (count($totalWH) && ($this->mconf['useLargestItemX'] || $this->mconf['useLargestItemY']))    {
01850                                         $tempXY = explode(',',$gifCreator->setup['XY']);
01851                                         if ($this->mconf['useLargestItemX'])    {$tempXY[0] = max($totalWH['W']);}
01852                                         if ($this->mconf['useLargestItemY'])    {$tempXY[1] = max($totalWH['H']);}
01853                                                 // regenerate the new values...
01854                                         $val['XY'] = implode(',',$tempXY);
01855                                         $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder');
01856                                         $gifCreator->init();
01857                                         $gifCreator->start($val,$this->menuArr[$key]);
01858                                 }
01859 
01860                                         // If distributeH/W is specified
01861                                 if (count($totalWH) && ($this->mconf['distributeX'] || $this->mconf['distributeY']))    {
01862                                         $tempXY = explode(',',$gifCreator->setup['XY']);
01863 
01864                                         if ($this->mconf['distributeX'])        {
01865                                                 $diff = $this->mconf['distributeX']-$totalWH['W_total']-$distributeAccu['W'];
01866                                                 $compensate = round($diff /($items-$c+1));
01867                                                 $distributeAccu['W']+=$compensate;
01868                                                 $tempXY[0] = $totalWH['W'][$key]+$compensate;
01869                                         }
01870                                         if ($this->mconf['distributeY'])        {
01871                                                 $diff = $this->mconf['distributeY']-$totalWH['H_total']-$distributeAccu['H'];
01872                                                 $compensate = round($diff /($items-$c+1));
01873                                                 $distributeAccu['H']+=$compensate;
01874                                                 $tempXY[1] = $totalWH['H'][$key]+$compensate;
01875                                         }
01876                                                 // regenerate the new values...
01877                                         $val['XY'] = implode(',',$tempXY);
01878                                         $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder');
01879                                         $gifCreator->init();
01880                                         $gifCreator->start($val,$this->menuArr[$key]);
01881                                 }
01882 
01883                                         // If max dimensions are specified
01884                                 if ($maxDim)    {
01885                                         $tempXY = explode(',',$val['XY']);
01886                                         if ($maxDim[0] && $Wcounter+$gifCreator->XY[0]>=$maxDim[0])     {$tempXY[0]==$maxDim[0]-$Wcounter; $maxFlag=1;}
01887                                         if ($maxDim[1] && $Hcounter+$gifCreator->XY[1]>=$maxDim[1])     {$tempXY[1]=$maxDim[1]-$Hcounter; $maxFlag=1;}
01888                                         if ($maxFlag)   {
01889                                                 $val['XY'] = implode(',',$tempXY);
01890                                                 $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder');
01891                                                 $gifCreator->init();
01892                                                 $gifCreator->start($val,$this->menuArr[$key]);
01893                                         }
01894                                 }
01895 
01896 
01897 
01898 
01899                                 // displace
01900                                 if ($Hobjs)     {
01901                                         reset($Hobjs);
01902                                         while(list(,$index)=each($Hobjs))       {
01903                                                 if ($gifCreator->setup[$index] && $gifCreator->setup[$index.'.'])       {
01904                                                         $oldOffset = explode(',',$gifCreator->setup[$index.'.']['offset']);
01905                                                         $gifCreator->setup[$index.'.']['offset'] = implode(',',$gifCreator->applyOffset($oldOffset,Array(0,-$Hcounter)));
01906                                                 }
01907                                         }
01908                                 }
01909 
01910                                 if ($Wobjs)     {
01911                                         reset($Wobjs);
01912                                         while(list(,$index)=each($Wobjs))       {
01913                                                 if ($gifCreator->setup[$index] && $gifCreator->setup[$index.'.'])       {
01914                                                         $oldOffset = explode(',',$gifCreator->setup[$index.'.']['offset']);
01915                                                         $gifCreator->setup[$index.'.']['offset'] = implode(',',$gifCreator->applyOffset($oldOffset,Array(-$Wcounter,0)));
01916                                                 }
01917                                         }
01918                                 }
01919                         }
01920 
01921                                 // Finding alternative GIF names if any (by altImgResource)
01922                         $gifFileName='';
01923                         if ($conf[$key]['altImgResource'] || is_array($conf[$key]['altImgResource.']))  {
01924                                 if (!is_object($cObj)) {$cObj=t3lib_div::makeInstance('tslib_cObj');}
01925                                 $cObj->start($this->menuArr[$key],'pages');
01926                                 $altImgInfo = $cObj->getImgResource($conf[$key]['altImgResource'],$conf[$key]['altImgResource.']);
01927                                 $gifFileName=$altImgInfo[3];
01928                         }
01929 
01930                                 // If an alternative name was NOT given, find the GIFBUILDER name.
01931                         if (!$gifFileName && $isGD)     {
01932                                 $gifCreator->createTempSubDir('menu/');
01933                                 $gifFileName = $gifCreator->fileName('menu/');
01934                         }
01935 
01936                                 // Generation of image file:
01937                         if (@file_exists($gifFileName)) {               // File exists
01938                                 $info = @getimagesize($gifFileName);
01939                                 $this->result[$resKey][$key]['output_w']=intval($info[0]);
01940                                 $this->result[$resKey][$key]['output_h']=intval($info[1]);
01941                                 $this->result[$resKey][$key]['output_file']=$gifFileName;
01942                         } elseif ($isGD) {              // file is generated
01943                                 $gifCreator->make();
01944                                 $this->result[$resKey][$key]['output_w']=$gifCreator->w;
01945                                 $this->result[$resKey][$key]['output_h']=$gifCreator->h;
01946                                 $this->result[$resKey][$key]['output_file'] = $gifFileName;
01947                                 $gifCreator->output($this->result[$resKey][$key]['output_file']);
01948                                 $gifCreator->destroy();
01949                         }
01950                         $this->result[$resKey][$key]['output_file'] = t3lib_div::png_to_gif_by_imagemagick($this->result[$resKey][$key]['output_file']);
01951                         $this->result[$resKey][$key]['noLink']=$conf[$key]['noLink'];
01952                         $this->result[$resKey][$key]['altTarget']=$conf[$key]['altTarget'];
01953                         $this->result[$resKey][$key]['imgParams']=$conf[$key]['imgParams'];
01954                         $this->result[$resKey][$key]['ATagTitle'] = $conf[$key]['ATagTitle'];
01955                         $this->result[$resKey][$key]['ATagTitle.'] = $conf[$key]['ATagTitle.'];
01956                         $this->result[$resKey][$key]['wrap'] = $conf[$key]['wrap'];
01957                         $this->result[$resKey][$key]['allWrap'] = $conf[$key]['allWrap'];
01958                         $this->result[$resKey][$key]['allWrap.'] = $conf[$key]['allWrap.'];
01959                         $this->result[$resKey][$key]['subst_elementUid'] = $conf[$key]['subst_elementUid'];
01960                         $this->result[$resKey][$key]['allStdWrap.'] = $conf[$key]['allStdWrap.'];
01961 
01962                         $Hcounter+=$this->result[$resKey][$key]['output_h'];            // counter is increased
01963                         $Wcounter+=$this->result[$resKey][$key]['output_w'];            // counter is increased
01964 
01965                         if ($maxFlag){break;}
01966                 }
01967         }
01968 
01984         function findLargestDims($conf,$items,$Hobjs,$Wobjs,$minDim,$maxDim)    {
01985                 $totalWH = array(
01986                         'W' => array(),
01987                         'H' => array(),
01988                         'W_total' => 0,
01989                         'H_total' => 0
01990                 );
01991 
01992                 $Hcounter = 0;
01993                 $Wcounter = 0;
01994                 $c=0;
01995                 $maxFlag=0;
01996                 reset($conf);
01997                 while (list($key,$val)=each($conf))     {
01998                         // SAME CODE AS makeGifs()! BEGIN
01999                         if ($items==($c+1) && $minDim)  {
02000                                 $Lobjs = $this->mconf['removeObjectsOfDummy'];
02001                                 if ($Lobjs)     {
02002                                         $Lobjs = t3lib_div::intExplode(',',$Lobjs);
02003                                         reset($Lobjs);
02004                                         while(list(,$remItem)=each($Lobjs))     {
02005                                                 unset($val[$remItem]);
02006                                                 unset($val[$remItem.'.']);
02007                                         }
02008                                 }
02009 
02010                                 $flag =0;
02011                                 $tempXY = explode(',',$val['XY']);
02012                                 if ($Wcounter<$minDim[0])       {$tempXY[0]=$minDim[0]-$Wcounter; $flag=1;}
02013                                 if ($Hcounter<$minDim[1])       {$tempXY[1]=$minDim[1]-$Hcounter; $flag=1;}
02014                                 $val['XY'] = implode(',',$tempXY);
02015                                 if (!$flag){break;}
02016                         }
02017                         $c++;
02018 
02019                         $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder');
02020                         $gifCreator->init();
02021                         $gifCreator->start($val,$this->menuArr[$key]);
02022                         if ($maxDim)    {
02023                                 $tempXY = explode(',',$val['XY']);
02024                                 if ($maxDim[0] && $Wcounter+$gifCreator->XY[0]>=$maxDim[0])     {$tempXY[0]==$maxDim[0]-$Wcounter; $maxFlag=1;}
02025                                 if ($maxDim[1] && $Hcounter+$gifCreator->XY[1]>=$maxDim[1])     {$tempXY[1]=$maxDim[1]-$Hcounter; $maxFlag=1;}
02026                                 if ($maxFlag)   {
02027                                         $val['XY'] = implode(',',$tempXY);
02028                                         $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder');
02029                                         $gifCreator->init();
02030                                         $gifCreator->start($val,$this->menuArr[$key]);
02031                                 }
02032                         }
02033                         // SAME CODE AS makeGifs()! END
02034 
02035                                 // Setting the width/height
02036                         $totalWH['W'][$key]=$gifCreator->XY[0];
02037                         $totalWH['H'][$key]=$gifCreator->XY[1];
02038                         $totalWH['W_total']+=$gifCreator->XY[0];
02039                         $totalWH['H_total']+=$gifCreator->XY[1];
02040                                 // ---- //
02041 
02042                         $Hcounter+=$gifCreator->XY[1];          // counter is increased
02043                         $Wcounter+=$gifCreator->XY[0];          // counter is increased
02044 
02045                         if ($maxFlag){break;}
02046                 }
02047                 return $totalWH;
02048         }
02049 
02056         function writeMenu()    {
02057                 if (is_array($this->menuArr) && is_array($this->result) && count($this->result) && is_array($this->result['NO']))       {
02058                         $this->WMcObj = t3lib_div::makeInstance('tslib_cObj');  // Create new tslib_cObj for our use
02059                         $this->WMresult='';
02060                         $this->INPfixMD5 = substr(md5(microtime().$this->GMENU_fixKey),0,4);
02061                         $this->WMmenuItems = count($this->result['NO']);
02062                         $this->extProc_init();
02063                         for ($key=0;$key<$this->WMmenuItems;$key++)     {
02064                                 if ($this->result['NO'][$key]['output_file'])   {
02065                                         $this->WMcObj->start($this->menuArr[$key],'pages');             // Initialize the cObj with the page record of the menu item
02066 
02067                                         $this->I =array();
02068                                         $this->I['key'] = $key;
02069                                         $this->I['INPfix']= $this->imgNameNotRandom?'':'_'.$this->INPfixMD5.'_'.$key;
02070                                         $this->I['val'] = $this->result['NO'][$key];
02071                                         $this->I['title'] = $this->getPageTitle($this->menuArr[$key]['title'],$this->menuArr[$key]['nav_title']);
02072                                         $this->I['uid'] = $this->menuArr[$key]['uid'];
02073                                         $this->I['mount_pid'] = $this->menuArr[$key]['mount_pid'];
02074                                         $this->I['pid'] = $this->menuArr[$key]['pid'];
02075                                         $this->I['spacer'] = $this->menuArr[$key]['isSpacer'];
02076                                         if (!$this->I['uid'] && !$this->menuArr[$key]['_OVERRIDE_HREF']) {$this->I['spacer']=1;}
02077                                         $this->I['noLink'] = ($this->I['spacer'] || $this->I['val']['noLink'] || !count($this->menuArr[$key]));         // !count($this->menuArr[$key]) means that this item is a dummyItem
02078                                         $this->I['name']='';
02079 
02080                                                 // Get link.
02081                                         $this->I['linkHREF'] = $this->link($key,$this->I['val']['altTarget'],$this->mconf['forceTypeValue']);
02082                                                 // Title attribute of links:
02083                                         $titleAttrValue = $this->WMcObj->stdWrap($this->I['val']['ATagTitle'],$this->I['val']['ATagTitle.']);
02084                                         if (strlen($titleAttrValue))    {
02085                                                 $this->I['linkHREF']['title'] = $titleAttrValue;
02086                                         }
02087                                                 // Setting "blurlink()" function:
02088                                         if (!$this->mconf['noBlur'])    {
02089                                                 $this->I['linkHREF']['onFocus']='blurLink(this);';
02090                                         }
02091 
02092                                                 // Set rollover
02093                                         if ($this->result['RO'][$key] && !$this->I['noLink'])   {
02094                                                 $this->I['theName'] = $this->imgNamePrefix.$this->I['uid'].$this->I['INPfix'];
02095                                                 $this->I['name'] = ' name="'.$this->I["theName"].'"';
02096                                                 $this->I['linkHREF']['onMouseover']=$this->WMfreezePrefix.'over(\''.$this->I['theName'].'\');';
02097                                                 $this->I['linkHREF']['onMouseout']=$this->WMfreezePrefix.'out(\''.$this->I['theName'].'\');';
02098                                                 $GLOBALS['TSFE']->JSImgCode.= chr(10).$this->I['theName'].'_n=new Image(); '.$this->I['theName'].'_n.src = "'.$GLOBALS['TSFE']->absRefPrefix.$this->I['val']['output_file'].'"; ';
02099                                                 $GLOBALS['TSFE']->JSImgCode.= chr(10).$this->I['theName'].'_h=new Image(); '.$this->I['theName'].'_h.src = "'.$GLOBALS['TSFE']->absRefPrefix.$this->result['RO'][$key]['output_file'].'"; ';
02100                                                 $GLOBALS['TSFE']->imagesOnPage[]=$this->result['RO'][$key]['output_file'];
02101                                                 $GLOBALS['TSFE']->setJS('mouseOver');
02102                                                 $this->extProc_RO($key);
02103                                         }
02104                                                 // Set access key
02105                                         if ($this->mconf['accessKey'])  {
02106                                                 $this->I['accessKey'] = $this->accessKey($this->I['title']);
02107                                         } else {
02108                                                 $this->I['accessKey']=Array();
02109                                         }
02110 
02111                                                 // Set altText
02112                                         $this->I['altText'] = $this->mconf['disableAltText'] ? '' : $this->I['title'].$this->I['accessKey']['alt'];
02113 
02114                                                 // Calling extra processing function
02115                                         $this->extProc_beforeLinking($key);
02116 
02117                                                 // Set linking
02118                                         if (!$this->I['noLink'])        {
02119                                                 $this->setATagParts();
02120                                         } else {
02121                                                 $this->I['A1'] = '';
02122                                                 $this->I['A2'] = '';
02123                                         }
02124                                         $this->I['IMG'] = '<img src="'.$GLOBALS['TSFE']->absRefPrefix.$this->I['val']['output_file'].'" width="'.$this->I['val']['output_w'].'" height="'.$this->I['val']['output_h'].'" border="0" alt="'.htmlspecialchars($this->I['altText']).'"'.$this->I['name'].($this->I['val']['imgParams']?' '.$this->I['val']['imgParams']:'').' />';
02125 
02126                                                 // Make before, middle and after parts
02127                                         $this->I['parts'] = array();
02128                                         $this->I['parts']['ATag_begin'] = $this->I['A1'];
02129                                         $this->I['parts']['image'] = $this->I['IMG'];
02130                                         $this->I['parts']['ATag_end'] = $this->I['A2'];
02131 
02132                                                 // Passing I to a user function
02133                                         if ($this->mconf['IProcFunc'])  {
02134                                                 $this->I = $this->userProcess('IProcFunc',$this->I);
02135                                         }
02136 
02137                                                 // Putting the item together.
02138                                                 // Merge parts + beforeAllWrap
02139                                         $this->I['theItem']= implode('',$this->I['parts']);
02140                                         $this->I['theItem']= $this->extProc_beforeAllWrap($this->I['theItem'],$key);
02141 
02142                                                 // wrap:
02143                                         $this->I['theItem']= $this->tmpl->wrap($this->I['theItem'],$this->I['val']['wrap']);
02144 
02145                                                 // allWrap:
02146                                         $allWrap = $this->WMcObj->stdWrap($this->I['val']['allWrap'],$this->I['val']['allWrap.']);
02147                                         $this->I['theItem'] = $this->tmpl->wrap($this->I['theItem'],$allWrap);
02148 
02149                                         if ($this->I['val']['subst_elementUid'])        $this->I['theItem'] = str_replace('{elementUid}',$this->I['uid'],$this->I['theItem']);
02150 
02151                                                 // allStdWrap:
02152                                         if (is_array($this->I['val']['allStdWrap.']))   {
02153                                                 $this->I['theItem'] = $this->WMcObj->stdWrap($this->I['theItem'],$this->I['val']['allStdWrap.']);
02154                                         }
02155 
02156                                         $GLOBALS['TSFE']->imagesOnPage[]=$this->I['val']['output_file'];
02157 
02158                                         $this->extProc_afterLinking($key);
02159                                 }
02160                         }
02161                         return $this->extProc_finish();
02162                 }
02163         }
02164 
02173         function extProc_init() {
02174         }
02175 
02184         function extProc_RO($key)       {
02185         }
02186 
02195         function extProc_beforeLinking($key)    {
02196         }
02197 
02208         function extProc_afterLinking($key)     {
02209                 $this->WMresult.=$this->I['theItem'];
02210                 if (!$this->I['spacer'])        {
02211                         $this->WMresult.= $this->subMenu($this->I['uid']);
02212                 }
02213         }
02214 
02215 
02225         function extProc_beforeAllWrap($item,$key)      {
02226                 return $item;
02227         }
02228 
02236         function extProc_finish()       {
02237                 return $this->tmpl->wrap($this->WMresult,$this->mconf['wrap']).$this->WMextraScript;
02238         }
02239 }
02240 
02241 
02242 
02243 
02244 
02245 
02246 
02247 
02248 
02249 
02250 
02251 
02252 
02253 
02254 
02255 
02256 
02257 
02258 
02259 
02260 
02261 
02270 class tslib_imgmenu extends tslib_menu {
02271 
02279         function generate()     {
02280                 $splitCount = count($this->menuArr);
02281                 if ($splitCount)        {
02282                         list($NOconf) = $this->procesItemStates($splitCount);
02283                 }
02284                 if ($this->mconf['debugItemConf'])      {echo '<h3>$NOconf:</h3>';      debug($NOconf); }
02285                 $this->makeImageMap($NOconf);
02286         }
02287 
02297         function makeImageMap($conf)    {
02298                 if (!is_array($conf)) {
02299                         $conf = Array();
02300                 }
02301                 if (is_array($this->mconf['main.']))    {
02302                         $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder');
02303                         $gifCreator->init();
02304 
02305                         $itemsConf = $conf;
02306                         $conf = $this->mconf['main.'];
02307                         if (is_array($conf))    {
02308                                 $gifObjCount = 0;
02309 
02310                                 $sKeyArray=t3lib_TStemplate::sortedKeyList($conf);
02311                                 $gifObjCount=intval(end($sKeyArray));
02312 
02313                                 $lastOriginal = $gifObjCount;
02314 
02315                                         // Now we add graphical objects to the gifbuilder-setup
02316                                 reset($itemsConf);
02317                                 $waArr = Array();
02318                                 while (list($key,$val)=each($itemsConf))        {
02319                                         if (is_array($val))     {
02320                                                 $gifObjCount++;
02321                                                 $waArr[$key]['free']=$gifObjCount;
02322 
02323                                                 $sKeyArray=t3lib_TStemplate::sortedKeyList($val);
02324 
02325                                                 foreach($sKeyArray as $theKey)  {
02326                                                         $theValue=$val[$theKey];
02327 
02328 
02329                                                         if (intval($theKey) && $theValArr=$val[$theKey.'.'])    {
02330                                                                 $cObjData = $this->menuArr[$key] ? $this->menuArr[$key] : Array();
02331 
02332                                                                 $gifObjCount++;
02333                                                                 if ($theValue=='TEXT') {
02334                                                                         $waArr[$key]['textNum']=$gifObjCount;
02335 
02336                                                                         $gifCreator->data = $cObjData;
02337                                                                         $theValArr = $gifCreator->checkTextObj($theValArr);
02338                                                                         unset($theValArr['text.']);     // if this is not done it seems that imageMaps will be rendered wrong!!
02339                                                                                 // check links
02340 
02341                                                                         $LD = $this->tmpl->linkData($this->menuArr[$key],$this->mconf['target'],'','',array(),'',$this->mconf['forceTypeValue']);
02342 
02343                                                                                 // Overriding URL / Target if set to do so:
02344                                                                         if ($this->menuArr[$key]['_OVERRIDE_HREF'])     {
02345                                                                                 $LD['totalURL'] = $this->menuArr[$key]['_OVERRIDE_HREF'];
02346                                                                                 if ($this->menuArr[$key]['_OVERRIDE_TARGET'])   $LD['target'] = $this->menuArr[$key]['_OVERRIDE_TARGET'];
02347                                                                         }
02348 
02349                                                                                 // Setting target/url for Image Map:
02350                                                                         if ($theValArr['imgMap.']['url']=='')   {
02351                                                                                 $theValArr['imgMap.']['url'] = $LD['totalURL'];
02352                                                                         }
02353                                                                         if ($theValArr['imgMap.']['target']=='')        {
02354                                                                                 $theValArr['imgMap.']['target'] = $LD['target'];
02355                                                                         }
02356                                                                         if ($theValArr['imgMap.']['noBlur']=='')        {
02357                                                                                 $theValArr['imgMap.']['noBlur'] = $this->mconf['noBlur'];
02358                                                                         }
02359                                                                         if (is_array($theValArr['imgMap.']['altText.']))        {
02360                                                                                 $cObj =t3lib_div::makeInstance('tslib_cObj');
02361                                                                                 $cObj->start($cObjData,'pages');
02362                                                                                 $theValArr['imgMap.']['altText'] = $cObj->stdWrap($theValArr['imgMap.']['altText'], $theValArr['imgMap.']['altText.']);
02363                                                                                 unset($theValArr['imgMap.']['altText.']);
02364                                                                 }
02365                                                                         if (is_array($theValArr['imgMap.']['titleText.']))      {
02366                                                                                 $cObj =t3lib_div::makeInstance('tslib_cObj');
02367                                                                                 $cObj->start($cObjData,'pages');
02368                                                                                 $theValArr['imgMap.']['titleText'] = $cObj->stdWrap($theValArr['imgMap.']['titleText'], $theValArr['imgMap.']['titleText.']);
02369                                                                                 unset($theValArr['imgMap.']['titleText.']);
02370                                                                         }
02371                                                                 }
02372                                                                         // This code goes one level in if the object is an image. If 'file' and/or 'mask' appears to be GIFBUILDER-objects, they are both searched for TEXT objects, and if a textobj is found, it's checked with the currently loaded record!!
02373                                                                 if ($theValue=='IMAGE') {
02374                                                                         if ($theValArr['file']=='GIFBUILDER')   {
02375                                                                                 $temp_sKeyArray=t3lib_TStemplate::sortedKeyList($theValArr['file.']);
02376                                                                                 reset($temp_sKeyArray);
02377                                                                                 while(list(,$temp_theKey)=each($temp_sKeyArray))        {
02378                                                                                         if ($theValArr['mask.'][$temp_theKey]=='TEXT')  {
02379                                                                                                 $gifCreator->data = $this->menuArr[$key] ? $this->menuArr[$key] : Array();
02380                                                                                                 $theValArr['mask.'][$temp_theKey.'.'] = $gifCreator->checkTextObj($theValArr['mask.'][$temp_theKey.'.']);
02381                                                                                                 unset($theValArr['mask.'][$temp_theKey.'.']['text.']);  // if this is not done it seems that imageMaps will be rendered wrong!!
02382                                                                                         }
02383                                                                                 }
02384                                                                         }
02385                                                                         if ($theValArr['mask']=='GIFBUILDER')   {
02386                                                                                 $temp_sKeyArray=t3lib_TStemplate::sortedKeyList($theValArr['mask.']);
02387                                                                                 reset($temp_sKeyArray);
02388                                                                                 while(list(,$temp_theKey)=each($temp_sKeyArray))        {
02389                                                                                         if ($theValArr['mask.'][$temp_theKey]=='TEXT')  {
02390                                                                                                 $gifCreator->data = $this->menuArr[$key] ? $this->menuArr[$key] : Array();
02391                                                                                                 $theValArr['mask.'][$temp_theKey.'.'] = $gifCreator->checkTextObj($theValArr['mask.'][$temp_theKey.'.']);
02392                                                                                                 unset($theValArr['mask.'][$temp_theKey.'.']['text.']);  // if this is not done it seems that imageMaps will be rendered wrong!!
02393                                                                                         }
02394                                                                                 }
02395                                                                         }
02396                                                                 }
02397 
02398                                                                         // Checks if disabled is set...
02399                                                                 $setObjFlag=1;
02400                                                                 if ($theValArr['if.'])  {
02401                                                                         $cObj =t3lib_div::makeInstance('tslib_cObj');
02402                                                                         $cObj->start($cObjData,'pages');
02403                                                                         if (!$cObj->checkIf($theValArr['if.'])) {
02404                                                                                 $setObjFlag=0;
02405                                                                         }
02406                                                                         unset($theValArr['if.']);
02407                                                                 }
02408                                                                         // Set the object!
02409                                                                 if ($setObjFlag)        {
02410                                                                         $conf[$gifObjCount] = $theValue;
02411                                                                         $conf[$gifObjCount.'.'] = $theValArr;
02412                                                                 }
02413                                                         }
02414                                                 }
02415                                         }
02416                                 }
02417 
02418                                 $gifCreator->start($conf,$GLOBALS['TSFE']->page);
02419                                         // calculations
02420 
02421                                 $sum=Array(0,0,0,0);
02422                                 reset($waArr);
02423                                 while (list($key,$val)=each($waArr))    {
02424                                         if ($dConf[$key] =$itemsConf[$key]['distrib'])  {
02425                                                 $textBB = $gifCreator->objBB[$val['textNum']];
02426                                                 $dConf[$key] = str_replace('textX',$textBB[0],$dConf[$key]);
02427                                                 $dConf[$key] = str_replace('textY',$textBB[1],$dConf[$key]);
02428                                                 $dConf[$key] = t3lib_div::intExplode(',',$gifCreator->calcOffset($dConf[$key]));
02429                                         }
02430                                 }
02431                                 $workArea = t3lib_div::intExplode(',',$gifCreator->calcOffset($this->mconf['dWorkArea']));
02432                                 reset($waArr);
02433                                 while (list($key,$val)=each($waArr))    {
02434                                         $index = $val['free'];
02435                                         $gifCreator->setup[$index] = 'WORKAREA';
02436                                         $workArea[2] = $dConf[$key][2] ? $dConf[$key][2] : $dConf[$key][0];
02437                                         $workArea[3] = $dConf[$key][3] ? $dConf[$key][3] : $dConf[$key][1];
02438 
02439                                         $gifCreator->setup[$index.'.']['set'] = implode(',',$workArea);
02440                                         $workArea[0]+=$dConf[$key][0];
02441                                         $workArea[1]+=$dConf[$key][1];
02442                                 }
02443 
02444                                 if ($this->mconf['debugRenumberedObject'])      {echo '<h3>Renumbered GIFBUILDER object:</h3>'; debug($gifCreator->setup);}
02445 
02446                                 $gifCreator->createTempSubDir('menu/');
02447                                 $gifFileName = $gifCreator->fileName('menu/');
02448 
02449                                         // Gets the ImageMap from the cache...
02450                                 $imgHash = md5($gifFileName);
02451                                 $imgMap = $this->sys_page->getHash($imgHash, 0);
02452 
02453                                 if ($imgMap && @file_exists($gifFileName))      {               // File exists
02454                                         $info = @getimagesize($gifFileName);
02455                                         $w=$info[0];
02456                                         $h=$info[1];
02457                                 } else {                // file is generated
02458                                         $gifCreator->make();
02459                                         $w=$gifCreator->w;
02460                                         $h=$gifCreator->h;
02461                                         $gifCreator->output($gifFileName);
02462                                         $gifCreator->destroy();
02463                                         $imgMap=$gifCreator->map;
02464                                         $this->sys_page->storeHash($imgHash, $imgMap, 'MENU IMAGEMAP');
02465                                 }
02466                                 $imgMap.=$this->mconf['imgMapExtras'];
02467 
02468                                 $gifFileName = t3lib_div::png_to_gif_by_imagemagick($gifFileName);
02469                                 $this->result = Array('output_file'=>$gifFileName, 'output_w'=>$w, 'output_h'=>$h, 'imgMap'=>$imgMap);
02470                         }
02471                 }
02472         }
02473 
02480         function writeMenu()    {
02481                 if ($this->result)      {
02482                         $res = $this->result;
02483                         $menuName = 'menu_'.t3lib_div::shortMD5($res['imgMap']);        // shortMD5 260900
02484                         $result = '<img src="'.$GLOBALS['TSFE']->absRefPrefix.$res['output_file'].'" width="'.$res['output_w'].'" height="'.$res['output_h'].'" usemap="#'.$menuName.'" border="0" '.$this->mconf['params'];
02485                         if (!strstr($result,'alt="'))   $result.=' alt="Menu Image Map"';       // Adding alt attribute if not set.
02486                         $result.= ' /><map name="'.$menuName.'" id="'.$menuName.'">'.$res['imgMap'].'</map>';
02487 
02488                         $GLOBALS['TSFE']->imagesOnPage[]=$res['output_file'];
02489 
02490                         return $this->tmpl->wrap($result,$this->mconf['wrap']);
02491                 }
02492         }
02493 }
02494 
02495 
02496 
02497 
02498 
02499 
02500 
02501 
02502 
02503 
02504 
02505 
02506 
02507 
02508 
02509 
02510 
02511 
02512 
02513 
02514 
02523 class tslib_jsmenu extends tslib_menu {
02524 
02530         function generate()     {
02531         }
02532 
02538         function writeMenu()    {
02539                 if ($this->id)  {
02540                                 // Making levels:
02541                         $levels = t3lib_div::intInRange($this->mconf['levels'],1,5);
02542                         $this->levels = $levels;
02543                         $this->JSVarName='eid';
02544                         $this->JSMenuName= $this->mconf['menuName'] ? $this->mconf['menuName'] : 'JSmenu';
02545 
02546                         $JScode="\n var ".$this->JSMenuName." = new JSmenu(".$levels.",'".$this->JSMenuName."Form');";
02547 
02548                         for ($a=1;$a<=$levels;$a++)     {
02549                                 $JScode.="\n var ".$this->JSVarName.$a."=0;";
02550                         }
02551                         $JScode.= $this->generate_level($levels,1,$this->id,$this->menuArr,$this->MP_array)."\n";
02552 
02553                         $GLOBALS['TSFE']->additionalHeaderData['JSMenuCode']='<script type="text/javascript" src="'.$GLOBALS['TSFE']->absRefPrefix.'t3lib/jsfunc.menu.js"></script>';
02554                         $GLOBALS['TSFE']->JSCode.=$JScode;
02555 
02556                                 // Printing:
02557                         $allFormCode="";
02558                         for ($a=1;$a<=$this->levels;$a++)       {
02559                                 $formCode='';
02560                                 $levelConf = $this->mconf[$a.'.'];
02561                                 $length = $levelConf['width'] ? $levelConf['width'] : 14;
02562                                 $lenghtStr='';
02563                                 for ($b=0;$b<$length;$b++)      {
02564                                         $lenghtStr.='_';
02565                                 }
02566                                 $height = $levelConf['elements'] ? $levelConf['elements'] : 5;
02567 
02568                                 $formCode.= '<select name="selector'.$a.'" onchange="'.$this->JSMenuName.'.act('.$a.');"'.($levelConf['additionalParams']?' '.$levelConf['additionalParams']:'').'>';
02569                                 for ($b=0;$b<$height;$b++)      {
02570                                         $formCode.= '<option value="0">';
02571                                         if ($b==0)      {
02572                                                 $formCode.= $lenghtStr;
02573                                         }
02574                                         $formCode.='</option>';
02575                                 }
02576                                 $formCode.= '</select>';
02577                                 $allFormCode.=$this->tmpl->wrap($formCode,$levelConf['wrap']);
02578                         }
02579                         $formCode = $this->tmpl->wrap($allFormCode,$this->mconf['wrap']);
02580 
02581                         $formCode= '<form action="" method="post" style="margin: 0 0 0 0;" name="'.$this->JSMenuName.'Form">'.$formCode.'</form>';
02582                         $formCode.='<script type="text/javascript"> /*<![CDATA[*/ '.$this->JSMenuName.'.writeOut(1,'.$this->JSMenuName.'.openID,1); /*]]>*/ </script>';
02583                         return $this->tmpl->wrap($formCode,$this->mconf['wrapAfterTags']);
02584                 }
02585         }
02586 
02599         function generate_level($levels,$count,$pid,$menuItemArray='',$MP_array=array())        {
02600                 $levelConf = $this->mconf[$count.'.'];
02601 
02602                         // Translate PID to a mount page, if any:
02603                 $mount_info = $this->sys_page->getMountPointInfo($pid);
02604                 if (is_array($mount_info))      {
02605                         $MP_array[] = $mount_info['MPvar'];
02606                         $pid = $mount_info['mount_pid'];
02607                 }
02608 
02609                         // Set "&MP=" var:
02610                 $MP_var = implode(',',$MP_array);
02611                 $MP_params = $MP_var ? '&MP='.rawurlencode($MP_var) : '';
02612 
02613                         // UIDs to ban:
02614                 $banUidArray=array();
02615                 if (trim($this->conf['excludeUidList']))        {
02616                         $banUidArray = t3lib_div::intExplode(',', $this->conf['excludeUidList']);
02617                 }
02618 
02619                         // Initializing variables:
02620                 $var = $this->JSVarName;
02621                 $menuName = $this->JSMenuName;
02622                 $parent = $count==1 ? 0 : $var.($count-1);
02623                 $prev=0;
02624                 $c=0;
02625 
02626                 $menuItems = is_array($menuItemArray) ? $menuItemArray : $this->sys_page->getMenu($pid);
02627                 foreach($menuItems as $uid => $data)    {
02628                         $spacer = (t3lib_div::inList($this->spacerIDList,$data['doktype'])?1:0);                // if item is a spacer, $spacer is set
02629                         if ($this->mconf['SPC'] || !$spacer)    {       // If the spacer-function is not enabled, spacers will not enter the $menuArr
02630                                 if (!t3lib_div::inList($this->doktypeExcludeList,$data['doktype']) && !$data['nav_hide'] && !t3lib_div::inArray($banUidArray,$uid))     {               // Page may not be 'not_in_menu' or 'Backend User Section' + not in banned uid's
02631                                         if ($count<$levels)     {
02632                                                 $addLines = $this->generate_level($levels,$count+1,$data['uid'],'',$MP_array);
02633                                         } else {
02634                                                 $addLines = '';
02635                                         }
02636                                         $title=rawurlencode($data['title']);
02637                                         $url='';
02638                                         $target='';
02639                                         if ((!$addLines && !$levelConf['noLink']) || $levelConf['alwaysLink']) {
02640                                                 $LD = $this->tmpl->linkData($data,$this->mconf['target'],'','',array(),$MP_params,$this->mconf['forceTypeValue']);
02641                                                 $url = rawurlencode($LD['totalURL']);
02642                                                 $target = rawurlencode($LD['target']);
02643                                         }
02644                                         $codeLines.="\n".$var.$count."=".$menuName.".add(".$parent.",".$prev.",0,'".$title."','".$GLOBALS['TSFE']->baseUrlWrap($url)."','".$target."');";
02645                                                 // If the active one should be chosen...
02646                                         $active = ($levelConf['showActive'] && $data['uid'] == $this->tmpl->rootLine[$count]['uid']);
02647                                                 // If the first item should be shown
02648                                         $first = (!$c && $levelConf['showFirst']);
02649                                                 // do it...
02650                                         if ($active || $first)  {
02651                                                 if ($count==1)  {
02652                                                         $codeLines.="\n".$menuName.".openID = ".$var.$count.";";
02653                                                 } else {
02654                                                         $codeLines.="\n".$menuName.".entry[".$parent."].openID = ".$var.$count.";";
02655                                                 }
02656                                         }
02657                                                 // Add submenu...
02658                                         $codeLines.=$addLines;
02659 
02660                                         $prev=$var.$count;
02661                                         $c++;
02662                                 }
02663                         }
02664                 }
02665                 if ($this->mconf['firstLabelGeneral'] && !$levelConf['firstLabel'])     {
02666                         $levelConf['firstLabel'] = $this->mconf['firstLabelGeneral'];
02667         }
02668                 if ($levelConf['firstLabel'] && $codeLines)     {
02669                         $codeLines.="\n".$menuName.".defTopTitle[".$count."] = unescape('".rawurlencode($levelConf['firstLabel'])."');";
02670 }
02671                 return $codeLines;
02672         }
02673 }
02674 
02675 
02676 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_menu.php'])      {
02677         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_menu.php']);
02678 }
02679 
02680 ?>


Généré par Les spécialistes TYPO3 avec  doxygen 1.4.6