Documentation TYPO3 par Ameos

class.tslib_menu.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00145 class tslib_menu {
00146         var $menuNumber = 1;                            // tells you which menu-number this is. This is important when getting data from the setup
00147         var $entryLevel = 0;                            // 0 = rootFolder
00148         var $spacerIDList = '199';                      // The doktype-number that defines a spacer
00149         var $doktypeExcludeList = '5,6';                        // doktypes that define which should not be included in a menu
00150         var $alwaysActivePIDlist=array();
00151         var $imgNamePrefix = 'img';
00152         var $imgNameNotRandom=0;
00153         var $debug = 0;
00154         var $parent_cObj;                               // Loaded with the parent cObj-object when a new HMENU is made
00155         var $GMENU_fixKey='gmenu';
00156         var $MP_array=array();                          // accumulation of mount point data
00157 
00158                 // internal
00159         var $conf = Array();                            // HMENU configuration
00160         var $mconf = Array();                           // xMENU configuration (TMENU, GMENU etc)
00161         var $tmpl;              // template-object
00162         var $sys_page;  // sys_page-object
00163         var $id;                                                        // The base page-id of the menu.
00164         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.
00165         var $menuArr;   // The array of menuItems which is built
00166         var $hash;
00167         var $result = Array();
00168         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)
00169         var $INPfixMD5;
00170         var $I;
00171         var $WMresult;
00172         var $WMfreezePrefix;
00173         var $WMmenuItems;
00174         var $WMsubmenuObjSuffixes;
00175         var $WMextraScript;
00176         var $alternativeMenuTempArray='';               // Can be set to contain menu item arrays for sub-levels.
00177         var $nameAttribute = 'name';                    // Will be 'id' in XHTML-mode
00178 
00191         function start(&$tmpl,&$sys_page,$id,$conf,$menuNumber,$objSuffix='')   {
00192 
00193                         // Init:
00194                 $this->conf = $conf;
00195                 $this->menuNumber = $menuNumber;
00196                 $this->mconf = $conf[$this->menuNumber.$objSuffix.'.'];
00197                 $this->debug=$GLOBALS['TSFE']->debug;
00198 
00199                         // In XHTML there is no "name" attribute anymore
00200                 switch ($GLOBALS['TSFE']->xhtmlDoctype) {
00201                         case 'xhtml_strict':
00202                         case 'xhtml_11':
00203                         case 'xhtml_2':
00204                                 $this->nameAttribute = 'id';
00205                                 break;
00206                         default:
00207                                 $this->nameAttribute = 'name';
00208                                 break;
00209                 }
00210 
00211                         // Sets the internal vars. $tmpl MUST be the template-object. $sys_page MUST be the sys_page object
00212                 if ($this->conf[$this->menuNumber.$objSuffix] && is_object($tmpl) && is_object($sys_page))      {
00213                         $this->tmpl = &$tmpl;
00214                         $this->sys_page = &$sys_page;
00215 
00216                                 // alwaysActivePIDlist initialized:
00217                         if (trim($this->conf['alwaysActivePIDlist']))   {
00218                                 $this->alwaysActivePIDlist = t3lib_div::intExplode(',', $this->conf['alwaysActivePIDlist']);
00219                         }
00220 
00221                                 // 'not in menu' doktypes
00222                         if($this->conf['excludeDoktypes']) {
00223                                 $this->doktypeExcludeList = $GLOBALS['TYPO3_DB']->cleanIntList($this->conf['excludeDoktypes']);
00224                         }
00225                         if($this->conf['includeNotInMenu']) {
00226                                 $exclDoktypeArr = t3lib_div::trimExplode(',',$this->doktypeExcludeList,1);
00227                                 $exclDoktypeArr = t3lib_div::removeArrayEntryByValue($exclDoktypeArr,'5');
00228                                 $this->doktypeExcludeList = implode(',',$exclDoktypeArr);
00229                         }
00230 
00231                                 // EntryLevel
00232                         $this->entryLevel = tslib_cObj::getKey ($conf['entryLevel'],$this->tmpl->rootLine);
00233 
00234                                 // Set parent page: If $id not stated with start() then the base-id will be found from rootLine[$this->entryLevel]
00235                         if ($id)        {       // Called as the next level in a menu. It is assumed that $this->MP_array is set from parent menu.
00236                                 $this->id = intval($id);
00237                         } else {        // This is a BRAND NEW menu, first level. So we take ID from rootline and also find MP_array (mount points)
00238                                 $this->id = intval($this->tmpl->rootLine[$this->entryLevel]['uid']);
00239 
00240                                         // Traverse rootline to build MP_array of pages BEFORE the entryLevel
00241                                         // (MP var for ->id is picked up in the next part of the code...)
00242                                 foreach($this->tmpl->rootLine as $entryLevel => $levelRec)      {
00243                                                 // For overlaid mount points, set the variable right now:
00244                                         if ($levelRec['_MP_PARAM'] && $levelRec['_MOUNT_OL'])   {
00245                                                 $this->MP_array[] = $levelRec['_MP_PARAM'];
00246                         }
00247                                                 // Break when entry level is reached:
00248                                         if ($entryLevel>=$this->entryLevel)     break;
00249 
00250                                                 // For normal mount points, set the variable for next level.
00251                                         if ($levelRec['_MP_PARAM'] && !$levelRec['_MOUNT_OL'])  {
00252                                                 $this->MP_array[] = $levelRec['_MP_PARAM'];
00253                                         }
00254                                 }
00255                         }
00256 
00257                                 // Return false if no page ID was set (thus no menu of subpages can be made).
00258                         if ($this->id<=0)       {
00259                                 return FALSE;
00260                         }
00261 
00262                                 // Check if page is a mount point, and if so set id and MP_array
00263                                 // (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...)
00264                         $mount_info = $this->sys_page->getMountPointInfo($this->id);
00265                         if (is_array($mount_info))      {
00266                                 $this->MP_array[] = $mount_info['MPvar'];
00267                                 $this->id = $mount_info['mount_pid'];
00268                         }
00269 
00270                                 // Gather list of page uids in root line (for "isActive" evaluation). Also adds the MP params in the path so Mount Points are respected.
00271                                 // (List is specific for this rootline, so it may be supplied from parent menus for speed...)
00272                         if (!is_array($this->rL_uidRegister))   {
00273                                 $rl_MParray = array();
00274                                 foreach($this->tmpl->rootLine as $v_rl) {
00275                                                 // For overlaid mount points, set the variable right now:
00276                                         if ($v_rl['_MP_PARAM'] && $v_rl['_MOUNT_OL'])   {
00277                                                 $rl_MParray[] = $v_rl['_MP_PARAM'];
00278                                         }
00279 
00280                                                 // Add to register:
00281                                         $this->rL_uidRegister[] = 'ITEM:'.$v_rl['uid'].(count($rl_MParray) ? ':'.implode(',',$rl_MParray) : '');
00282 
00283                                                 // For normal mount points, set the variable for next level.
00284                                         if ($v_rl['_MP_PARAM'] && !$v_rl['_MOUNT_OL'])  {
00285                                                 $rl_MParray[] = $v_rl['_MP_PARAM'];
00286                                         }
00287                                 }
00288                         }
00289 
00290                                 // 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
00291                                 // Notice: The automatic expansion of a menu is designed to work only when no "special" modes are used.
00292                         if (is_array($this->tmpl->rootLine[$this->entryLevel+$this->menuNumber]))       {
00293                                 $nextMParray = $this->MP_array;
00294                                 if ($this->tmpl->rootLine[$this->entryLevel+$this->menuNumber]['_MOUNT_OL'])    {       // In overlay mode, add next level MPvars as well:
00295                                         $nextMParray[] = $this->tmpl->rootLine[$this->entryLevel+$this->menuNumber]['_MP_PARAM'];
00296                                 }
00297                                 $this->nextActive = $this->tmpl->rootLine[$this->entryLevel+$this->menuNumber]['uid'].
00298                                                                                 (count($nextMParray)?':'.implode(',',$nextMParray):'');
00299                         } else {
00300                                 $this->nextActive = '';
00301                         }
00302 
00303                                 // imgNamePrefix
00304                         if ($this->mconf['imgNamePrefix']) {
00305                                 $this->imgNamePrefix=$this->mconf['imgNamePrefix'];
00306                         }
00307                         $this->imgNameNotRandom = $this->mconf['imgNameNotRandom'];
00308 
00309                         $retVal = TRUE;
00310                 } else {
00311                         $GLOBALS['TT']->setTSlogMessage('ERROR in menu',3);
00312                         $retVal = FALSE;
00313                 }
00314                 return $retVal;
00315         }
00316 
00324         function makeMenu()     {
00325                 if ($this->id)  {
00326 
00327                                 // Initializing showAccessRestrictedPages
00328                         if ($this->mconf['showAccessRestrictedPages'])  {
00329                                         // SAVING where_groupAccess
00330                                 $SAVED_where_groupAccess = $this->sys_page->where_groupAccess;
00331                                 $this->sys_page->where_groupAccess = '';        // Temporarily removing fe_group checking!
00332                         }
00333 
00334                                 // Begin production of menu:
00335                         $temp = array();
00336                         $altSortFieldValue = trim($this->mconf['alternativeSortingField']);
00337                         $altSortField = $altSortFieldValue ? $altSortFieldValue : 'sorting';
00338                         if ($this->menuNumber==1 && $this->conf['special'])     {               // ... only for the FIRST level of a HMENU
00339                                 $value = $this->conf['special.']['value'];
00340 
00341                                 switch($this->conf['special'])  {
00342                                         case 'userdefined':
00343                                                 $temp = $this->includeMakeMenu($this->conf['special.'],$altSortField);
00344                                         break;
00345                                         case 'userfunction':
00346                                                 $temp = $this->parent_cObj->callUserFunction(
00347                                                         $this->conf['special.']['userFunc'],
00348                                                         array_merge($this->conf['special.'],array('_altSortField'=>$altSortField)),
00349                                                         ''
00350                                                 );
00351                                                 if (!is_array($temp))   $temp=array();
00352                                         break;
00353                                         case 'language':
00354                                                 $temp = array();
00355 
00356                                                         // Getting current page record NOT overlaid by any translation:
00357                                                 $currentPageWithNoOverlay = $this->sys_page->getRawRecord('pages',$GLOBALS['TSFE']->page['uid']);
00358 
00359                                                         // Traverse languages set up:
00360                                                 $languageItems = t3lib_div::intExplode(',',$value);
00361                                                 foreach($languageItems as $sUid)        {
00362                                                                 // Find overlay record:
00363                                                         if ($sUid)      {
00364                                                                 $lRecs = $this->sys_page->getPageOverlay($GLOBALS['TSFE']->page['uid'],$sUid);
00365                                                         } else $lRecs=array();
00366                                                                 // Checking if the "disabled" state should be set.
00367                                                         if (
00368                                                                                 (t3lib_div::hideIfNotTranslated($GLOBALS['TSFE']->page['l18n_cfg']) && $sUid && !count($lRecs)) // Blocking for all translations?
00369                                                                         || ($GLOBALS['TSFE']->page['l18n_cfg']&1 && (!$sUid || !count($lRecs))) // Blocking default translation?
00370                                                                         || (!$this->conf['special.']['normalWhenNoLanguage'] && $sUid && !count($lRecs))
00371                                                                 )       {
00372                                                                 $iState = $GLOBALS['TSFE']->sys_language_uid==$sUid ? 'USERDEF2' : 'USERDEF1';
00373                                                         } else {
00374                                                                 $iState = $GLOBALS['TSFE']->sys_language_uid==$sUid ? 'ACT' : 'NO';
00375                                                         }
00376 
00377                                                         if ($this->conf['addQueryString'])      {
00378                                                                 $getVars = $this->parent_cObj->getQueryArguments($this->conf['addQueryString.'],array('L'=>$sUid),true);
00379                                                         } else {
00380                                                                 $getVars = '&L='.$sUid;
00381                                                         }
00382 
00383                                                                 // Adding menu item:
00384                                                         $temp[] = array_merge(
00385                                                                 array_merge($currentPageWithNoOverlay, $lRecs),
00386                                                                 array(
00387                                                                         'ITEM_STATE' => $iState,
00388                                                                         '_ADD_GETVARS' => $getVars,
00389                                                                         '_SAFE' => TRUE
00390                                                                 )
00391                                                         );
00392                                                 }
00393                                         break;
00394                                         case 'directory':
00395                                                 if ($value=='') {
00396                                                         $value=$GLOBALS['TSFE']->page['uid'];
00397                                                 }
00398                                                 $items=t3lib_div::intExplode(',',$value);
00399 
00400                                                 foreach($items as $id)  {
00401                                                         $MP = $this->tmpl->getFromMPmap($id);
00402 
00403                                                                 // Checking if a page is a mount page and if so, change the ID and set the MP var properly.
00404                                                         $mount_info = $this->sys_page->getMountPointInfo($id);
00405                                                         if (is_array($mount_info))      {
00406                                                                 if ($mount_info['overlay'])     {       // Overlays should already have their full MPvars calculated:
00407                                                                         $MP = $this->tmpl->getFromMPmap($mount_info['mount_pid']);
00408                                                                         $MP = $MP ? $MP : $mount_info['MPvar'];
00409                                                                 } else {
00410                                                                         $MP = ($MP ? $MP.',' : '').$mount_info['MPvar'];
00411                                                                 }
00412                                                                 $id = $mount_info['mount_pid'];
00413                                                         }
00414 
00415                                                                 // Get sub-pages:
00416                                                         $res = $GLOBALS['TSFE']->cObj->exec_getQuery('pages',Array('pidInList'=>$id,'orderBy'=>$altSortField));
00417                                                         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))      {
00418                                                                 $GLOBALS['TSFE']->sys_page->versionOL('pages',$row);
00419 
00420                                                                 if (is_array($row))     {
00421                                                                                 // Keep mount point?
00422                                                                         $mount_info = $this->sys_page->getMountPointInfo($row['uid'], $row);
00423                                                                         if (is_array($mount_info) && $mount_info['overlay'])    {       // There is a valid mount point.
00424                                                                                 $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!
00425                                                                                 if (count($mp_row))     {
00426                                                                                         $row = $mp_row;
00427                                                                                         $row['_MP_PARAM'] = $mount_info['MPvar'];
00428                                                                                 } 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!
00429                                                                         }
00430 
00431                                                                                 // Add external MP params, then the row:
00432                                                                         if (is_array($row))     {
00433                                                                                 if ($MP)        $row['_MP_PARAM'] = $MP.($row['_MP_PARAM'] ? ','.$row['_MP_PARAM'] : '');
00434                                                                                 $temp[$row['uid']] = $this->sys_page->getPageOverlay($row);
00435                                                                         }
00436                                                                 }
00437                                                         }
00438                                                 }
00439                                         break;
00440                                         case 'list':
00441                                                 if ($value=='') {
00442                                                         $value=$this->id;
00443                                                 }
00444                                                 $loadDB = t3lib_div::makeInstance('FE_loadDBGroup');
00445                                                 $loadDB->start($value, 'pages');
00446                                                 $loadDB->additionalWhere['pages']=tslib_cObj::enableFields('pages');
00447                                                 $loadDB->getFromDB();
00448 
00449                                                 foreach($loadDB->itemArray as $val)     {
00450                                                         $MP = $this->tmpl->getFromMPmap($val['id']);
00451 
00452                                                                 // Keep mount point?
00453                                                         $mount_info = $this->sys_page->getMountPointInfo($val['id']);
00454                                                         if (is_array($mount_info) && $mount_info['overlay'])    {       // There is a valid mount point.
00455                                                                 $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!
00456                                                                 if (count($mp_row))     {
00457                                                                         $row = $mp_row;
00458                                                                         $row['_MP_PARAM'] = $mount_info['MPvar'];
00459 
00460                                                                         if ($mount_info['overlay'])     {       // Overlays should already have their full MPvars calculated:
00461                                                                                 $MP = $this->tmpl->getFromMPmap($mount_info['mount_pid']);
00462                                                                                 if ($MP) unset($row['_MP_PARAM']);
00463                                                                         }
00464                                                                 } 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!
00465                                                         } else {
00466                                                                 $row = $loadDB->results['pages'][$val['id']];
00467                                                         }
00468 
00469                                                                 // Add external MP params, then the row:
00470                                                         if (is_array($row))     {
00471                                                                 if ($MP)        $row['_MP_PARAM'] = $MP.($row['_MP_PARAM'] ? ','.$row['_MP_PARAM'] : '');
00472                                                                 $temp[] = $this->sys_page->getPageOverlay($row);
00473                                                         }
00474                                                 }
00475                                         break;
00476                                         case 'updated':
00477                                                 if ($value=='') {
00478                                                         $value=$GLOBALS['TSFE']->page['uid'];
00479                                                 }
00480                                                 $items=t3lib_div::intExplode(',',$value);
00481                                                 if (t3lib_div::testInt($this->conf['special.']['depth']))       {
00482                                                         $depth = t3lib_div::intInRange($this->conf['special.']['depth'],1,20);          // Tree depth
00483                                                 } else {
00484                                                         $depth=20;
00485                                                 }
00486                                                 $limit = t3lib_div::intInRange($this->conf['special.']['limit'],0,100); // max number of items
00487                                                 $maxAge = intval(tslib_cObj::calc($this->conf['special.']['maxAge']));
00488                                                 if (!$limit)    $limit=10;
00489                                                 $mode = $this->conf['special.']['mode'];        // *'auto', 'manual', 'tstamp'
00490                                                         // Get id's
00491                                                 $id_list_arr = Array();
00492 
00493                                                 foreach($items as $id)  {
00494                                                         $bA = t3lib_div::intInRange($this->conf['special.']['beginAtLevel'],0,100);
00495                                                         $id_list_arr[] = tslib_cObj::getTreeList(-1*$id,$depth-1+$bA,$bA-1);
00496                                                 }
00497                                                 $id_list = implode(',',$id_list_arr);
00498                                                         // Get sortField (mode)
00499                                                 switch($mode)   {
00500                                                         case 'starttime':
00501                                                                 $sortField = 'starttime';
00502                                                         break;
00503                                                         case 'lastUpdated':
00504                                                         case 'manual':
00505                                                                 $sortField = 'lastUpdated';
00506                                                         break;
00507                                                         case 'tstamp':
00508                                                                 $sortField = 'tstamp';
00509                                                         break;
00510                                                         case 'crdate':
00511                                                                 $sortField = 'crdate';
00512                                                         break;
00513                                                         default:
00514                                                                 $sortField = 'SYS_LASTCHANGED';
00515                                                         break;
00516                                                 }
00517                                                         // Get
00518                                                 $extraWhere = ($this->conf['includeNotInMenu'] ? '' : ' AND pages.nav_hide=0').$this->getDoktypeExcludeWhere();
00519 
00520                                                 if ($this->conf['special.']['excludeNoSearchPages']) {
00521                                                         $extraWhere.= ' AND pages.no_search=0';
00522                                                 }
00523                                                 if ($maxAge>0)  {
00524                                                         $extraWhere.=' AND '.$sortField.'>'.($GLOBALS['SIM_EXEC_TIME']-$maxAge);
00525                                                 }
00526 
00527                                                 $res = $GLOBALS['TSFE']->cObj->exec_getQuery('pages',Array('pidInList'=>'0', 'uidInList'=>$id_list, 'where'=>$sortField.'>=0'.$extraWhere, 'orderBy'=>($altSortFieldValue ? $altSortFieldValue : $sortField.' desc'),'max'=>$limit));
00528                                                 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))      {
00529                                                         $GLOBALS['TSFE']->sys_page->versionOL('pages',$row);
00530                                                         if (is_array($row))     {
00531                                                                 $temp[$row['uid']]=$this->sys_page->getPageOverlay($row);
00532                                                         }
00533                                                 }
00534                                         break;
00535                                         case 'keywords':
00536                                                 list($value)=t3lib_div::intExplode(',',$value);
00537                                                 if (!$value) {
00538                                                         $value=$GLOBALS['TSFE']->page['uid'];
00539                                                 }
00540                                                 if ($this->conf['special.']['setKeywords'] || $this->conf['special.']['setKeywords.']) {
00541                                                         $kw = $this->parent_cObj->stdWrap($this->conf['special.']['setKeywords'], $this->conf['special.']['setKeywords.']);
00542                                                 } else {
00543                                                         $value_rec=$this->sys_page->getPage($value);    // The page record of the 'value'.
00544 
00545                                                         $kfieldSrc = $this->conf['special.']['keywordsField.']['sourceField'] ? $this->conf['special.']['keywordsField.']['sourceField'] : 'keywords';
00546                                                         $kw = trim(tslib_cObj::keywords($value_rec[$kfieldSrc]));               // keywords.
00547                                                 }
00548 
00549                                                 $mode = $this->conf['special.']['mode'];        // *'auto', 'manual', 'tstamp'
00550                                                 switch($mode)   {
00551                                                         case 'starttime':
00552                                                                 $sortField = 'starttime';
00553                                                         break;
00554                                                         case 'lastUpdated':
00555                                                         case 'manual':
00556                                                                 $sortField = 'lastUpdated';
00557                                                         break;
00558                                                         case 'tstamp':
00559                                                                 $sortField = 'tstamp';
00560                                                         break;
00561                                                         case 'crdate':
00562                                                                 $sortField = 'crdate';
00563                                                         break;
00564                                                         default:
00565                                                                 $sortField = 'SYS_LASTCHANGED';
00566                                                         break;
00567                                                 }
00568 
00569                                                         // depth, limit, extra where
00570                                                 if (t3lib_div::testInt($this->conf['special.']['depth']))       {
00571                                                         $depth = t3lib_div::intInRange($this->conf['special.']['depth'],0,20);          // Tree depth
00572                                                 } else {
00573                                                         $depth=20;
00574                                                 }
00575                                                 $limit = t3lib_div::intInRange($this->conf['special.']['limit'],0,100); // max number of items
00576                                                 $extraWhere = ' AND pages.uid!='.$value.($this->conf['includeNotInMenu'] ? '' : ' AND pages.nav_hide=0').$this->getDoktypeExcludeWhere();
00577                                                 if ($this->conf['special.']['excludeNoSearchPages']) {
00578                                                         $extraWhere.= ' AND pages.no_search=0';
00579                                                 }
00580                                                         // start point
00581                                                 $eLevel = tslib_cObj::getKey (intval($this->conf['special.']['entryLevel']),$this->tmpl->rootLine);
00582                                                 $startUid = intval($this->tmpl->rootLine[$eLevel]['uid']);
00583 
00584                                                         // which field is for keywords
00585                                                 $kfield = 'keywords';
00586                                                 if ( $this->conf['special.']['keywordsField'] ) {
00587                                                         list($kfield) = explode(' ',trim ($this->conf['special.']['keywordsField']));
00588                                                 }
00589 
00590                                                         // If there are keywords and the startuid is present.
00591                                                 if ($kw && $startUid)   {
00592                                                         $bA = t3lib_div::intInRange($this->conf['special.']['beginAtLevel'],0,100);
00593                                                         $id_list=tslib_cObj::getTreeList(-1*$startUid,$depth-1+$bA,$bA-1);
00594 
00595                                                         $kwArr = explode(',',$kw);
00596                                                         foreach($kwArr as $word)        {
00597                                                                 $word = trim($word);
00598                                                                 if ($word)      {
00599                                                                         $keyWordsWhereArr[] = $kfield.' LIKE \'%'.$GLOBALS['TYPO3_DB']->quoteStr($word, 'pages').'%\'';
00600                                                                 }
00601                                                         }
00602                                                         $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));
00603                                                         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))      {
00604                                                                 $GLOBALS['TSFE']->sys_page->versionOL('pages',$row);
00605                                                                 if (is_array($row))     {
00606                                                                         $temp[$row['uid']]=$this->sys_page->getPageOverlay($row);
00607                                                                 }
00608                                                         }
00609                                                 }
00610                                         break;
00611                                         case 'rootline':
00612                                                 $begin_end = explode('|',$this->conf['special.']['range']);
00613                                                 if (!t3lib_div::testInt($begin_end[0])) {intval($begin_end[0]);}
00614                                                 if (!t3lib_div::testInt($begin_end[1])) {$begin_end[1]=-1;}
00615 
00616                                                 $beginKey = tslib_cObj::getKey ($begin_end[0],$this->tmpl->rootLine);
00617                                                 $endKey = tslib_cObj::getKey ($begin_end[1],$this->tmpl->rootLine);
00618                                                 if ($endKey<$beginKey)  {$endKey=$beginKey;}
00619 
00620                                                 $rl_MParray = array();
00621                                                 foreach($this->tmpl->rootLine as $k_rl => $v_rl)        {
00622                                                                 // For overlaid mount points, set the variable right now:
00623                                                         if ($v_rl['_MP_PARAM'] && $v_rl['_MOUNT_OL'])   {
00624                                                                 $rl_MParray[] = $v_rl['_MP_PARAM'];
00625                                                         }
00626                                                                 // Traverse rootline:
00627                                                         if ($k_rl>=$beginKey && $k_rl<=$endKey) {
00628                                                                 $temp_key=$k_rl;
00629                                                                 $temp[$temp_key]=$this->sys_page->getPage($v_rl['uid']);
00630                                                                 if (count($temp[$temp_key]))    {
00631                                                                         if (!$temp[$temp_key]['target'])        {       // If there are no specific target for the page, put the level specific target on.
00632                                                                                 $temp[$temp_key]['target'] = $this->conf['special.']['targets.'][$k_rl];
00633                                                                                 $temp[$temp_key]['_MP_PARAM'] = implode(',',$rl_MParray);
00634                                                                         }
00635                                                                 } else unset($temp[$temp_key]);
00636                                                         }
00637                                                                 // For normal mount points, set the variable for next level.
00638                                                         if ($v_rl['_MP_PARAM'] && !$v_rl['_MOUNT_OL'])  {
00639                                                                 $rl_MParray[] = $v_rl['_MP_PARAM'];
00640                                                 }
00641                                                 }
00642                                         break;
00643                                         case 'browse':
00644                                                 list($value)=t3lib_div::intExplode(',',$value);
00645                                                 if (!$value) {
00646                                                         $value=$GLOBALS['TSFE']->page['uid'];
00647                                                 }
00648                                                 if ($value!=$this->tmpl->rootLine[0]['uid'])    {       // Will not work out of rootline
00649                                                         $recArr=array();
00650                                                         $value_rec=$this->sys_page->getPage($value);    // The page record of the 'value'.
00651                                                         if ($value_rec['pid'])  {       // 'up' page cannot be outside rootline
00652                                                                 $recArr['up']=$this->sys_page->getPage($value_rec['pid']);      // The page record of 'up'.
00653                                                         }
00654                                                         if ($recArr['up']['pid'] && $value_rec['pid']!=$this->tmpl->rootLine[0]['uid']) {       // If the 'up' item was NOT level 0 in rootline...
00655                                                                 $recArr['index']=$this->sys_page->getPage($recArr['up']['pid']);        // The page record of "index".
00656                                                         }
00657 
00658                                                                 // prev / next is found
00659                                                         $prevnext_menu = $this->sys_page->getMenu($value_rec['pid'],'*',$altSortField);
00660                                                         $lastKey=0;
00661                                                         $nextActive=0;
00662                                                         reset($prevnext_menu);
00663                                                         while(list($k_b,$v_b)=each($prevnext_menu))     {
00664                                                                 if ($nextActive)        {
00665                                                                         $recArr['next']=$v_b;
00666                                                                         $nextActive=0;
00667                                                                 }
00668                                                                 if ($v_b['uid']==$value)        {
00669                                                                         if ($lastKey)   {
00670                                                                                 $recArr['prev']=$prevnext_menu[$lastKey];
00671                                                                         }
00672                                                                         $nextActive=1;
00673                                                                 }
00674                                                                 $lastKey=$k_b;
00675                                                         }
00676                                                         reset($prevnext_menu);
00677                                                         $recArr['first']=pos($prevnext_menu);
00678                                                         end($prevnext_menu);
00679                                                         $recArr['last']=pos($prevnext_menu);
00680 
00681                                                                 // prevsection / nextsection is found
00682                                                         if (is_array($recArr['index'])) {       // You can only do this, if there is a valid page two levels up!
00683                                                                 $prevnextsection_menu = $this->sys_page->getMenu($recArr['index']['uid'],'*',$altSortField);
00684                                                                 $lastKey=0;
00685                                                                 $nextActive=0;
00686                                                                 reset($prevnextsection_menu);
00687                                                                 while(list($k_b,$v_b)=each($prevnextsection_menu))      {
00688                                                                         if ($nextActive)        {
00689                                                                                 $sectionRec_temp = $this->sys_page->getMenu($v_b['uid'],'*',$altSortField);
00690                                                                                 if (count($sectionRec_temp))    {
00691                                                                                         reset($sectionRec_temp);
00692                                                                                         $recArr['nextsection']=pos($sectionRec_temp);
00693                                                                                         end ($sectionRec_temp);
00694                                                                                         $recArr['nextsection_last']=pos($sectionRec_temp);
00695                                                                                         $nextActive=0;
00696                                                                                 }
00697                                                                         }
00698                                                                         if ($v_b['uid']==$value_rec['pid'])     {
00699                                                                                 if ($lastKey)   {
00700                                                                                         $sectionRec_temp = $this->sys_page->getMenu($prevnextsection_menu[$lastKey]['uid'],'*',$altSortField);
00701                                                                                         if (count($sectionRec_temp))    {
00702                                                                                                 reset($sectionRec_temp);
00703                                                                                                 $recArr['prevsection']=pos($sectionRec_temp);
00704                                                                                                 end ($sectionRec_temp);
00705                                                                                                 $recArr['prevsection_last']=pos($sectionRec_temp);
00706                                                                                         }
00707                                                                                 }
00708                                                                                 $nextActive=1;
00709                                                                         }
00710                                                                         $lastKey=$k_b;
00711                                                                 }
00712                                                         }
00713                                                         if ($this->conf['special.']['items.']['prevnextToSection'])     {
00714                                                                 if (!is_array($recArr['prev']) && is_array($recArr['prevsection_last']))        {
00715                                                                         $recArr['prev']=$recArr['prevsection_last'];
00716                                                                 }
00717                                                                 if (!is_array($recArr['next']) && is_array($recArr['nextsection']))     {
00718                                                                         $recArr['next']=$recArr['nextsection'];
00719                                                                 }
00720                                                         }
00721 
00722                                                         $items = explode('|',$this->conf['special.']['items']);
00723                                                         $c=0;
00724                                                         while(list($k_b,$v_b)=each($items))     {
00725                                                                 $v_b=strtolower(trim($v_b));
00726                                                                 if (intval($this->conf['special.'][$v_b.'.']['uid']))   {
00727                                                                         $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
00728                                                                 }
00729                                                                 if (is_array($recArr[$v_b]))    {
00730                                                                         $temp[$c]=$recArr[$v_b];
00731                                                                         if ($this->conf['special.'][$v_b.'.']['target'])        {
00732                                                                                 $temp[$c]['target']=$this->conf['special.'][$v_b.'.']['target'];
00733                                                                         }
00734                                                                         if (is_array($this->conf['special.'][$v_b.'.']['fields.']))     {
00735                                                                                 reset($this->conf['special.'][$v_b.'.']['fields.']);
00736                                                                                 while(list($fk,$val)=each($this->conf['special.'][$v_b.'.']['fields.']))        {
00737                                                                                         $temp[$c][$fk]=$val;
00738                                                                                 }
00739                                                                         }
00740                                                                         $c++;
00741                                                                 }
00742                                                         }
00743                                                 }
00744                                         break;
00745                                 }
00746                         } elseif (is_array($this->alternativeMenuTempArray))    {       // Setting $temp array if not level 1.
00747                                 $temp = $this->alternativeMenuTempArray;
00748                         } elseif ($this->mconf['sectionIndex']) {
00749                                 if ($GLOBALS['TSFE']->sys_language_uid && count($this->sys_page->getPageOverlay($this->id)))    {
00750                                         $sys_language_uid = intval($GLOBALS['TSFE']->sys_language_uid);
00751                                 } else $sys_language_uid=0;
00752 
00753                                 $selectSetup = Array(
00754                                         'pidInList'=>$this->id,
00755                                         'orderBy'=>$altSortField,
00756                                         'where' => 'colPos=0 AND sys_language_uid='.$sys_language_uid,
00757                                         'andWhere' => 'sectionIndex!=0'
00758                                         );
00759                                 switch($this->mconf['sectionIndex.']['type'])   {
00760                                         case 'all':
00761                                                 unset($selectSetup['andWhere']);
00762                                         break;
00763                                         case 'header':
00764                                                 $selectSetup['andWhere']='header_layout!=100 AND header!=""';
00765                                         break;
00766                                 }
00767                                 $basePageRow=$this->sys_page->getPage($this->id);
00768                                 if (is_array($basePageRow))     {
00769                                         $res = $GLOBALS['TSFE']->cObj->exec_getQuery('tt_content',      $selectSetup);
00770                                         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))      {
00771                                                 $GLOBALS['TSFE']->sys_page->versionOL('tt_content',$row);
00772 
00773                                                 if (is_array($row))     {
00774                                                         $temp[$row['uid']] = $basePageRow;
00775                                                         $temp[$row['uid']]['title'] = $row['header'];
00776                                                         $temp[$row['uid']]['nav_title'] = $row['header'];
00777                                                         $temp[$row['uid']]['subtitle'] = $row['subheader'];
00778                                                         $temp[$row['uid']]['starttime'] = $row['starttime'];
00779                                                         $temp[$row['uid']]['endtime'] = $row['endtime'];
00780                                                         $temp[$row['uid']]['fe_group'] = $row['fe_group'];
00781                                                         $temp[$row['uid']]['media'] = $row['media'];
00782 
00783                                                         $temp[$row['uid']]['header_layout'] = $row['header_layout'];
00784                                                         $temp[$row['uid']]['bodytext'] = $row['bodytext'];
00785                                                         $temp[$row['uid']]['image'] = $row['image'];
00786 
00787                                                         $temp[$row['uid']]['sectionIndex_uid'] = $row['uid'];
00788                                                 }
00789                                         }
00790                                 }
00791                         } else {        // Default:
00792                                 $temp = $this->sys_page->getMenu($this->id,'*',$altSortField);          // gets the menu
00793                         }
00794 
00795                         $c=0;
00796                         $c_b=0;
00797                         $minItems = intval($this->mconf['minItems'] ? $this->mconf['minItems'] : $this->conf['minItems']);
00798                         $maxItems = intval($this->mconf['maxItems'] ? $this->mconf['maxItems'] : $this->conf['maxItems']);
00799                         $begin = tslib_cObj::calc($this->mconf['begin'] ? $this->mconf['begin'] : $this->conf['begin']);
00800 
00801                         $banUidArray = $this->getBannedUids();
00802 
00803                                 // Fill in the menuArr with elements that should go into the menu:
00804                         $this->menuArr = Array();
00805                         foreach($temp as $data) {
00806                                 $spacer = (t3lib_div::inList($this->spacerIDList,$data['doktype']) || !strcmp($data['ITEM_STATE'],'SPC')) ? 1 : 0;              // if item is a spacer, $spacer is set
00807                                 if ($this->filterMenuPages($data, $banUidArray, $spacer))       {
00808                                         $c_b++;
00809                                         if ($begin<=$c_b)       {               // If the beginning item has been reached.
00810                                                 $this->menuArr[$c] = $data;
00811                                                 $this->menuArr[$c]['isSpacer'] = $spacer;
00812                                                 $c++;
00813                                                 if ($maxItems && $c>=$maxItems) {
00814                                                         break;
00815                                                 }
00816                                         }
00817                                 }
00818                         }
00819 
00820                                 // Fill in fake items, if min-items is set.
00821                         if ($minItems)  {
00822                                 while($c<$minItems)     {
00823                                         $this->menuArr[$c] = Array(
00824                                                 'title' => '...',
00825                                                 'uid' => $GLOBALS['TSFE']->id
00826                                         );
00827                                         $c++;
00828                                 }
00829                         }
00830                                 // Setting number of menu items
00831                         $GLOBALS['TSFE']->register['count_menuItems'] = count($this->menuArr);
00832                                 //      Passing the menuArr through a user defined function:
00833                         if ($this->mconf['itemArrayProcFunc'])  {
00834                                 if (!is_array($this->parentMenuArr)) {$this->parentMenuArr=array();}
00835                                 $this->menuArr = $this->userProcess('itemArrayProcFunc',$this->menuArr);
00836                         }
00837                         $this->hash = md5(serialize($this->menuArr).serialize($this->mconf).serialize($this->tmpl->rootLine).serialize($this->MP_array));
00838 
00839                         $serData = $this->sys_page->getHash($this->hash, 60*60*24);
00840                         if (!$serData)  {
00841                                 $this->generate();
00842                                 $this->sys_page->storeHash($this->hash, serialize($this->result),'MENUDATA');
00843                         } else {
00844                                 $this->result = unserialize($serData);
00845                         }
00846 
00847                                 // End showAccessRestrictedPages
00848                         if ($this->mconf['showAccessRestrictedPages'])  {
00849                                         // RESTORING where_groupAccess
00850                                 $this->sys_page->where_groupAccess = $SAVED_where_groupAccess;
00851                         }
00852                 }
00853         }
00854 
00865         function includeMakeMenu($conf,$altSortField)   {
00866                 $incFile = $GLOBALS['TSFE']->tmpl->getFileName($conf['file']);
00867                 if ($incFile && $GLOBALS['TSFE']->checkFileInclude($incFile))   {
00868                         include($incFile);
00869                 }
00870                 return is_array($menuItemsArray) ? $menuItemsArray : array();
00871         }
00872 
00881         function filterMenuPages(&$data,$banUidArray,$spacer)   {
00882 
00883                 if ($data['_SAFE'])     return TRUE;
00884 
00885                 $uid = $data['uid'];
00886                 if ($this->mconf['SPC'] || !$spacer)    {       // If the spacer-function is not enabled, spacers will not enter the $menuArr
00887                         if (!t3lib_div::inList($this->doktypeExcludeList,$data['doktype']))     {               // Page may not be 'not_in_menu' or 'Backend User Section'
00888                                 if (!$data['nav_hide'] || $this->conf['includeNotInMenu'])      {       // Not hidden in navigation
00889                                         if (!t3lib_div::inArray($banUidArray,$uid))     {       // not in banned uid's
00890 
00891                                                         // Checks if the default language version can be shown:
00892                                                         // Block page is set, if l18n_cfg allows plus: 1) Either default language or 2) another language but NO overlay record set for page!
00893                                                 $blockPage = $data['l18n_cfg']&1 && (!$GLOBALS['TSFE']->sys_language_uid || ($GLOBALS['TSFE']->sys_language_uid && !$data['_PAGES_OVERLAY']));
00894                                                 if (!$blockPage)        {
00895 
00896                                                                 // Checking if a page should be shown in the menu depending on whether a translation exists:
00897                                                         $tok = TRUE;
00898                                                         if ($GLOBALS['TSFE']->sys_language_uid && t3lib_div::hideIfNotTranslated($data['l18n_cfg']))    {       // There is an alternative language active AND the current page requires a translation:
00899                                                                 if (!$data['_PAGES_OVERLAY'])   {
00900                                                                         $tok = FALSE;
00901                                                                 }
00902                                                         }
00903 
00904                                                                 // Continue if token is true:
00905                                                         if ($tok)       {
00906 
00907                                                                         // Checking if "&L" should be modified so links to non-accessible pages will not happen.
00908                                                                 if ($this->conf['protectLvar']) {
00909                                                                         $languageUid = intval($GLOBALS['TSFE']->config['config']['sys_language_uid']);
00910                                                                         if ($languageUid && ($this->conf['protectLvar']=='all' || t3lib_div::hideIfNotTranslated($data['l18n_cfg'])))   {
00911                                                                                 $olRec = $GLOBALS['TSFE']->sys_page->getPageOverlay($data['uid'], $languageUid);
00912                                                                                 if (!count($olRec))     {
00913                                                                                                 // 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"
00914                                                                                         $data['_ADD_GETVARS'].= '&L=0';
00915                                                                                 }
00916                                                                         }
00917                                                                 }
00918 
00919                                                                 return TRUE;
00920                                                         }
00921                                                 }
00922                                         }
00923                                 }
00924                         }
00925                 }
00926         }
00927 
00937         function procesItemStates($splitCount)  {
00938 
00939                         // Prepare normal settings
00940                 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.
00941                 $NOconf = $this->tmpl->splitConfArray($this->mconf['NO.'],$splitCount);
00942 
00943                         // Prepare rollOver settings, overriding normal settings
00944                 $ROconf=array();
00945                 if ($this->mconf['RO']) {
00946                         $ROconf = $this->tmpl->splitConfArray($this->mconf['RO.'],$splitCount);
00947                 }
00948 
00949                         // Prepare IFSUB settings, overriding normal settings
00950                         // IFSUB is true if there exist submenu items to the current item
00951                 if ($this->mconf['IFSUB'])      {
00952                         $IFSUBinit = 0; // Flag: If $IFSUB is generated
00953                         reset($NOconf);
00954                         while (list($key,$val)=each($NOconf))   {
00955                                 if ($this->isItemState('IFSUB',$key))   {
00956                                         if (!$IFSUBinit)        {       // if this is the first IFSUB element, we must generate IFSUB.
00957                                                 $IFSUBconf = $this->tmpl->splitConfArray($this->mconf['IFSUB.'],$splitCount);
00958                                                 if ($this->mconf['IFSUBRO'])    {
00959                                                         $IFSUBROconf = $this->tmpl->splitConfArray($this->mconf['IFSUBRO.'],$splitCount);
00960                                                 }
00961                                                 $IFSUBinit = 1;
00962                                         }
00963                                         $NOconf[$key] = $IFSUBconf[$key];               // Substitute normal with ifsub
00964                                         if ($ROconf)    {       // If rollOver on normal, we must apply a state for rollOver on the active
00965                                                 $ROconf[$key] = $IFSUBROconf[$key] ? $IFSUBROconf[$key] : $IFSUBconf[$key];             // If RollOver on active then apply this
00966                                         }
00967                                 }
00968                         }
00969                 }
00970                         // Prepare active settings, overriding normal settings
00971                 if ($this->mconf['ACT'])        {
00972                         $ACTinit = 0;   // Flag: If $ACT is generated
00973                         reset($NOconf);
00974                         while (list($key,$val)=each($NOconf))   {       // Find active
00975                                 if ($this->isItemState('ACT',$key))     {
00976                                         if (!$ACTinit)  {       // if this is the first 'active', we must generate ACT.
00977                                                 $ACTconf = $this->tmpl->splitConfArray($this->mconf['ACT.'],$splitCount);
00978                                                         // Prepare active rollOver settings, overriding normal active settings
00979                                                 if ($this->mconf['ACTRO'])      {
00980                                                         $ACTROconf = $this->tmpl->splitConfArray($this->mconf['ACTRO.'],$splitCount);
00981                                                 }
00982                                                 $ACTinit = 1;
00983                                         }
00984                                         $NOconf[$key] = $ACTconf[$key];         // Substitute normal with active
00985                                         if ($ROconf)    {       // If rollOver on normal, we must apply a state for rollOver on the active
00986                                                 $ROconf[$key] = $ACTROconf[$key] ? $ACTROconf[$key] : $ACTconf[$key];           // If RollOver on active then apply this
00987                                         }
00988                                 }
00989                         }
00990                 }
00991                         // Prepare ACT (active)/IFSUB settings, overriding normal settings
00992                         // ACTIFSUB is true if there exist submenu items to the current item and the current item is active
00993                 if ($this->mconf['ACTIFSUB'])   {
00994                         $ACTIFSUBinit = 0;      // Flag: If $ACTIFSUB is generated
00995                         reset($NOconf);
00996                         while (list($key,$val)=each($NOconf))   {       // Find active
00997                                 if ($this->isItemState('ACTIFSUB',$key))        {
00998                                         if (!$ACTIFSUBinit)     {       // if this is the first 'active', we must generate ACTIFSUB.
00999                                                 $ACTIFSUBconf = $this->tmpl->splitConfArray($this->mconf['ACTIFSUB.'],$splitCount);
01000                                                         // Prepare active rollOver settings, overriding normal active settings
01001                                                 if ($this->mconf['ACTIFSUBRO']) {
01002                                                         $ACTIFSUBROconf = $this->tmpl->splitConfArray($this->mconf['ACTIFSUBRO.'],$splitCount);
01003                                                 }
01004                                                 $ACTIFSUBinit = 1;
01005                                         }
01006                                         $NOconf[$key] = $ACTIFSUBconf[$key];            // Substitute normal with active
01007                                         if ($ROconf)    {       // If rollOver on normal, we must apply a state for rollOver on the active
01008                                                 $ROconf[$key] = $ACTIFSUBROconf[$key] ? $ACTIFSUBROconf[$key] : $ACTIFSUBconf[$key];            // If RollOver on active then apply this
01009                                         }
01010                                 }
01011                         }
01012                 }
01013                         // Prepare CUR (current) settings, overriding normal settings
01014                         // CUR is true if the current page equals the item here!
01015                 if ($this->mconf['CUR'])        {
01016                         $CURinit = 0;   // Flag: If $CUR is generated
01017                         reset($NOconf);
01018                         while (list($key,$val)=each($NOconf))   {
01019                                 if ($this->isItemState('CUR',$key))     {
01020                                         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)
01021                                                 $CURconf = $this->tmpl->splitConfArray($this->mconf['CUR.'],$splitCount);
01022                                                 if ($this->mconf['CURRO'])      {
01023                                                         $CURROconf = $this->tmpl->splitConfArray($this->mconf['CURRO.'],$splitCount);
01024                                                 }
01025                                                 $CURinit = 1;
01026                                         }
01027                                         $NOconf[$key] = $CURconf[$key];         // Substitute normal with current
01028                                         if ($ROconf)    {       // If rollOver on normal, we must apply a state for rollOver on the active
01029                                                 $ROconf[$key] = $CURROconf[$key] ? $CURROconf[$key] : $CURconf[$key];           // If RollOver on active then apply this
01030                                         }
01031                                 }
01032                         }
01033                 }
01034                         // Prepare CUR (current)/IFSUB settings, overriding normal settings
01035                         // CURIFSUB is true if there exist submenu items to the current item and the current page equals the item here!
01036                 if ($this->mconf['CURIFSUB'])   {
01037                         $CURIFSUBinit = 0;      // Flag: If $CURIFSUB is generated
01038                         reset($NOconf);
01039                         while (list($key,$val)=each($NOconf))   {
01040                                 if ($this->isItemState('CURIFSUB',$key))        {
01041                                         if (!$CURIFSUBinit)     {       // if this is the first 'current', we must generate CURIFSUB.
01042                                                 $CURIFSUBconf = $this->tmpl->splitConfArray($this->mconf['CURIFSUB.'],$splitCount);
01043                                                         // Prepare current rollOver settings, overriding normal current settings
01044                                                 if ($this->mconf['CURIFSUBRO']) {
01045                                                         $CURIFSUBROconf = $this->tmpl->splitConfArray($this->mconf['CURIFSUBRO.'],$splitCount);
01046                                                 }
01047                                                 $CURIFSUBinit = 1;
01048                                         }
01049                                         $NOconf[$key] = $CURIFSUBconf[$key];            // Substitute normal with active
01050                                         if ($ROconf)    {       // If rollOver on normal, we must apply a state for rollOver on the current
01051                                                 $ROconf[$key] = $CURIFSUBROconf[$key] ? $CURIFSUBROconf[$key] : $CURIFSUBconf[$key];            // If RollOver on current then apply this
01052                                         }
01053                                 }
01054                         }
01055                 }
01056                         // Prepare active settings, overriding normal settings
01057                 if ($this->mconf['USR'])        {
01058                         $USRinit = 0;   // Flag: If $USR is generated
01059                         reset($NOconf);
01060                         while (list($key,$val)=each($NOconf))   {       // Find active
01061                                 if ($this->isItemState('USR',$key))     {
01062                                         if (!$USRinit)  {       // if this is the first active, we must generate USR.
01063                                                 $USRconf = $this->tmpl->splitConfArray($this->mconf['USR.'],$splitCount);
01064                                                         // Prepare active rollOver settings, overriding normal active settings
01065                                                 if ($this->mconf['USRRO'])      {
01066                                                         $USRROconf = $this->tmpl->splitConfArray($this->mconf['USRRO.'],$splitCount);
01067                                                 }
01068                                                 $USRinit = 1;
01069                                         }
01070                                         $NOconf[$key] = $USRconf[$key];         // Substitute normal with active
01071                                         if ($ROconf)    {       // If rollOver on normal, we must apply a state for rollOver on the active
01072                                                 $ROconf[$key] = $USRROconf[$key] ? $USRROconf[$key] : $USRconf[$key];           // If RollOver on active then apply this
01073                                         }
01074                                 }
01075                         }
01076                 }
01077                         // Prepare spacer settings, overriding normal settings
01078                 if ($this->mconf['SPC'])        {
01079                         $SPCinit = 0;   // Flag: If $SPC is generated
01080                         reset($NOconf);
01081                         while (list($key,$val)=each($NOconf))   {       // Find spacers
01082                                 if ($this->isItemState('SPC',$key))     {
01083                                         if (!$SPCinit)  {       // if this is the first spacer, we must generate SPC.
01084                                                 $SPCconf = $this->tmpl->splitConfArray($this->mconf['SPC.'],$splitCount);
01085                                                 $SPCinit = 1;
01086                                         }
01087                                         $NOconf[$key] = $SPCconf[$key];         // Substitute normal with spacer
01088                                 }
01089                         }
01090                 }
01091                         // Prepare Userdefined settings
01092                 if ($this->mconf['USERDEF1'])   {
01093                         $USERDEF1init = 0;      // Flag: If $USERDEF1 is generated
01094                         reset($NOconf);
01095                         while (list($key,$val)=each($NOconf))   {       // Find active
01096                                 if ($this->isItemState('USERDEF1',$key))        {
01097                                         if (!$USERDEF1init)     {       // if this is the first active, we must generate USERDEF1.
01098                                                 $USERDEF1conf = $this->tmpl->splitConfArray($this->mconf['USERDEF1.'],$splitCount);
01099                                                         // Prepare active rollOver settings, overriding normal active settings
01100                                                 if ($this->mconf['USERDEF1RO']) {
01101                                                         $USERDEF1ROconf = $this->tmpl->splitConfArray($this->mconf['USERDEF1RO.'],$splitCount);
01102                                                 }
01103                                                 $USERDEF1init = 1;
01104                                         }
01105                                         $NOconf[$key] = $USERDEF1conf[$key];            // Substitute normal with active
01106                                         if ($ROconf)    {       // If rollOver on normal, we must apply a state for rollOver on the active
01107                                                 $ROconf[$key] = $USERDEF1ROconf[$key] ? $USERDEF1ROconf[$key] : $USERDEF1conf[$key];            // If RollOver on active then apply this
01108                                         }
01109                                 }
01110                         }
01111                 }
01112                         // Prepare Userdefined settings
01113                 if ($this->mconf['USERDEF2'])   {
01114                         $USERDEF2init = 0;      // Flag: If $USERDEF2 is generated
01115                         reset($NOconf);
01116                         while (list($key,$val)=each($NOconf))   {       // Find active
01117                                 if ($this->isItemState('USERDEF2',$key))        {
01118                                         if (!$USERDEF2init)     {       // if this is the first active, we must generate USERDEF2.
01119                                                 $USERDEF2conf = $this->tmpl->splitConfArray($this->mconf['USERDEF2.'],$splitCount);
01120                                                         // Prepare active rollOver settings, overriding normal active settings
01121                                                 if ($this->mconf['USERDEF2RO']) {
01122                                                         $USERDEF2ROconf = $this->tmpl->splitConfArray($this->mconf['USERDEF2RO.'],$splitCount);
01123                                                 }
01124                                                 $USERDEF2init = 1;
01125                                         }
01126                                         $NOconf[$key] = $USERDEF2conf[$key];            // Substitute normal with active
01127                                         if ($ROconf)    {       // If rollOver on normal, we must apply a state for rollOver on the active
01128                                                 $ROconf[$key] = $USERDEF2ROconf[$key] ? $USERDEF2ROconf[$key] : $USERDEF2conf[$key];            // If RollOver on active then apply this
01129                                         }
01130                                 }
01131                         }
01132                 }
01133 
01134                 return array($NOconf,$ROconf);
01135         }
01136 
01147         function link($key,$altTarget='',$typeOverride='') {
01148 
01149                         // Mount points:
01150                 $MP_var = $this->getMPvar($key);
01151                 $MP_params = $MP_var ? '&MP='.rawurlencode($MP_var) : '';
01152 
01153                         // Setting override ID
01154                 if ($this->mconf['overrideId'] || $this->menuArr[$key]['overrideId'])   {
01155                         $overrideArray = array();
01156                                 // If a user script returned the value overrideId in the menu array we use that as page id
01157                         $overrideArray['uid'] = $this->mconf['overrideId']?$this->mconf['overrideId']:$this->menuArr[$key]['overrideId'];
01158                         $overrideArray['alias'] = '';
01159                         $MP_params = '';        // clear MP parameters since ID was changed.
01160                 } else {
01161                         $overrideArray='';
01162                 }
01163 
01164                         // Setting main target:
01165                 $mainTarget = $altTarget ? $altTarget : $this->mconf['target'];
01166 
01167                         // Creating link:
01168                 if ($this->mconf['collapse'] && $this->isActive($this->menuArr[$key]['uid'], $this->getMPvar($key)))    {
01169                         $thePage = $this->sys_page->getPage($this->menuArr[$key]['pid']);
01170                         $LD = $this->tmpl->linkData($thePage,$mainTarget,'','',$overrideArray, $this->mconf['addParams'].$MP_params.$this->menuArr[$key]['_ADD_GETVARS'], $typeOverride);
01171                 } else {
01172                         $LD = $this->tmpl->linkData($this->menuArr[$key],$mainTarget,'','',$overrideArray, $this->mconf['addParams'].$MP_params.$this->I['val']['additionalParams'].$this->menuArr[$key]['_ADD_GETVARS'], $typeOverride);
01173                 }
01174 
01175                         // Override URL if using "External URL" as doktype with a valid e-mail address:
01176                 if ($this->menuArr[$key]['doktype'] == 3 && $this->menuArr[$key]['urltype'] == 3 && t3lib_div::validEmail($this->menuArr[$key]['url'])) {
01177                                 // Create mailto-link using tslib_cObj::typolink (concerning spamProtectEmailAddresses):
01178                         $LD['totalURL'] = $this->parent_cObj->typoLink_URL(array('parameter' => $this->menuArr[$key]['url']));
01179                         $LD['target'] = '';
01180                 }
01181 
01182                         // Manipulation in case of access restricted pages:
01183                 $this->changeLinksForAccessRestrictedPages($LD,$this->menuArr[$key],$mainTarget,$typeOverride);
01184 
01185                         // Overriding URL / Target if set to do so:
01186                 if ($this->menuArr[$key]['_OVERRIDE_HREF'])     {
01187                         $LD['totalURL'] = $this->menuArr[$key]['_OVERRIDE_HREF'];
01188                         if ($this->menuArr[$key]['_OVERRIDE_TARGET'])   $LD['target'] = $this->menuArr[$key]['_OVERRIDE_TARGET'];
01189                 }
01190 
01191                         // OnClick open in windows.
01192                 $onClick='';
01193                 if ($this->mconf['JSWindow'])   {
01194                         $conf=$this->mconf['JSWindow.'];
01195                         $url=$LD['totalURL'];
01196                         $LD['totalURL'] = '#';
01197                         $onClick= 'openPic(\''.$GLOBALS['TSFE']->baseUrlWrap($url).'\',\''.($conf['newWindow']?md5($url):'theNewPage').'\',\''.$conf['params'].'\'); return false;';
01198                         $GLOBALS['TSFE']->setJS('openPic');
01199                 }
01200 
01201                         // out:
01202                 $list = array();
01203                 $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.
01204                 $list['TARGET'] = $LD['target'];
01205                 $list['onClick'] = $onClick;
01206 
01207                 return $list;
01208         }
01209 
01219         function changeLinksForAccessRestrictedPages(&$LD, $page, $mainTarget, $typeOverride)   {
01220 
01221                         // If access restricted pages should be shown in menus, change the link of such pages to link to a redirection page:
01222                 if ($this->mconf['showAccessRestrictedPages'] && $this->mconf['showAccessRestrictedPages']!=='NONE' && !$GLOBALS['TSFE']->checkPageGroupAccess($page))  {
01223                         $thePage = $this->sys_page->getPage($this->mconf['showAccessRestrictedPages']);
01224 
01225                         $addParams = $this->mconf['showAccessRestrictedPages.']['addParams'];
01226                         $addParams = str_replace('###RETURN_URL###',rawurlencode($LD['totalURL']),$addParams);
01227                         $addParams = str_replace('###PAGE_ID###',$page['uid'],$addParams);
01228                         $LD = $this->tmpl->linkData($thePage,$mainTarget,'','','', $addParams, $typeOverride);
01229                 }
01230         }
01231 
01240         function subMenu($uid, $objSuffix='')   {
01241 
01242                         // Setting alternative menu item array if _SUB_MENU has been defined in the current ->menuArr
01243                 $altArray = '';
01244                 if (is_array($this->menuArr[$this->I['key']]['_SUB_MENU']) && count($this->menuArr[$this->I['key']]['_SUB_MENU']))      {
01245                         $altArray = $this->menuArr[$this->I['key']]['_SUB_MENU'];
01246                 }
01247 
01248                         // Make submenu if the page is the next active
01249                 $cls = strtolower($this->conf[($this->menuNumber+1).$objSuffix]);
01250                 $subLevelClass = ($cls && t3lib_div::inList($this->tmpl->menuclasses,$cls)) ? $cls : '';
01251 
01252                 if ($subLevelClass && ($this->mconf['expAll'] || $this->isNext($uid, $this->getMPvar($this->I['key'])) || is_array($altArray)) && !$this->mconf['sectionIndex'])        {
01253                         $submenu = t3lib_div::makeInstance('tslib_'.$subLevelClass);
01254                         $submenu->entryLevel = $this->entryLevel+1;
01255                         $submenu->rL_uidRegister = $this->rL_uidRegister;
01256                         $submenu->MP_array = $this->MP_array;
01257                         if ($this->menuArr[$this->I['key']]['_MP_PARAM'])       {
01258                                 $submenu->MP_array[] = $this->menuArr[$this->I['key']]['_MP_PARAM'];
01259                         }
01260 
01261                                 // especially scripts that build the submenu needs the parent data
01262                         $submenu->parent_cObj = &$this->parent_cObj;
01263                         $submenu->parentMenuArr = $this->menuArr;
01264 
01265                                 // Setting alternativeMenuTempArray (will be effective only if an array)
01266                         if (is_array($altArray))        {
01267                                 $submenu->alternativeMenuTempArray = $altArray;
01268                         }
01269 
01270                         if ($submenu->start($this->tmpl, $this->sys_page, $uid, $this->conf, $this->menuNumber+1, $objSuffix))  {
01271                                 $submenu->makeMenu();
01272                                 return $submenu->writeMenu();
01273                         }
01274                 }
01275         }
01276 
01286         function isNext($uid, $MPvar='')        {
01287 
01288                         // Check for always active PIDs:
01289                 if (count($this->alwaysActivePIDlist) && in_array($uid,$this->alwaysActivePIDlist))     {
01290                         return TRUE;
01291                 }
01292 
01293                 $testUid = $uid.($MPvar?':'.$MPvar:'');
01294                 if ($uid && $testUid==$this->nextActive)        {
01295                         return TRUE;
01296                 }
01297         }
01298 
01307         function isActive($uid, $MPvar='')      {
01308 
01309                         // Check for always active PIDs:
01310                 if (count($this->alwaysActivePIDlist) && in_array($uid,$this->alwaysActivePIDlist))     {
01311                         return TRUE;
01312                 }
01313 
01314                 $testUid = $uid.($MPvar?':'.$MPvar:'');
01315                 if ($uid && in_array('ITEM:'.$testUid, $this->rL_uidRegister))  {
01316                         return TRUE;
01317                 }
01318         }
01319 
01328         function isCurrent($uid, $MPvar='')     {
01329                 $testUid = $uid.($MPvar?':'.$MPvar:'');
01330                 if ($uid && !strcmp(end($this->rL_uidRegister),'ITEM:'.$testUid))       {
01331                         return TRUE;
01332                 }
01333         }
01334 
01343         function isSubMenu($uid)        {
01344 
01345                         // 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;
01346                 $mount_info = $this->sys_page->getMountPointInfo($uid);
01347                 if (is_array($mount_info))      {
01348                         $uid = $mount_info['mount_pid'];
01349                 }
01350 
01351                 $recs = $this->sys_page->getMenu($uid,'uid,pid,doktype,mount_pid,mount_pid_ol,nav_hide,shortcut,shortcut_mode');
01352                 foreach($recs as $theRec)       {
01353                         if (!t3lib_div::inList($this->doktypeExcludeList,$theRec['doktype']) && (!$theRec['nav_hide'] || $this->conf['includeNotInMenu']))      {       // If a menu item seems to be another type than 'Not in menu', then return true (there were items!)
01354                                 return TRUE;
01355                         }
01356                 }
01357         }
01358 
01368         function isItemState($kind,$key)        {
01369                 $natVal=0;
01370                 if ($this->menuArr[$key]['ITEM_STATE']) {               // If any value is set for ITEM_STATE the normal evaluation is discarded
01371                         if (!strcmp($this->menuArr[$key]['ITEM_STATE'],$kind))  {$natVal=1;}
01372                 } else {
01373                         switch($kind)   {
01374                                 case 'SPC':
01375                                         $natVal = $this->menuArr[$key]['isSpacer'];
01376                                 break;
01377                                 case 'IFSUB':
01378                                         $natVal = $this->isSubMenu($this->menuArr[$key]['uid']);
01379                                 break;
01380                                 case 'ACT':
01381                                         $natVal = $this->isActive($this->menuArr[$key]['uid'], $this->getMPvar($key));
01382                                 break;
01383                                 case 'ACTIFSUB':
01384                                         $natVal = $this->isActive($this->menuArr[$key]['uid'], $this->getMPvar($key)) && $this->isSubMenu($this->menuArr[$key]['uid']);
01385                                 break;
01386                                 case 'CUR':
01387                                         $natVal = $this->isCurrent($this->menuArr[$key]['uid'], $this->getMPvar($key));
01388                                 break;
01389                                 case 'CURIFSUB':
01390                                         $natVal = $this->isCurrent($this->menuArr[$key]['uid'], $this->getMPvar($key)) && $this->isSubMenu($this->menuArr[$key]['uid']);
01391                                 break;
01392                                 case 'USR':
01393                                         $natVal = $this->menuArr[$key]['fe_group'];
01394                                 break;
01395                         }
01396                 }
01397 
01398                 return $natVal;
01399         }
01400 
01408         function accessKey($title)      {
01409                         // The global array ACCESSKEY is used to globally control if letters are already used!!
01410                 $result = Array();
01411 
01412                 $titleLen = strlen($title);
01413                 for ($a=0;$a<$titleLen;$a++)    {
01414                         $key = strtoupper(trim(substr($title,$a,1)));
01415                         if (preg_match('/[a-zA-Z]/', $key) && !isset($GLOBALS['TSFE']->accessKey[$key]))        {
01416                                 $GLOBALS['TSFE']->accessKey[$key]=1;
01417                                 $result['code'] = ' accesskey="'.$key.'"';
01418                                 $result['alt'] = ' (ALT+'.$key.')';
01419                                 break;
01420                         }
01421                 }
01422                 return $result;
01423         }
01424 
01434         function userProcess($mConfKey,$passVar)        {
01435                 if ($this->mconf[$mConfKey])    {
01436                         $funcConf = $this->mconf[$mConfKey.'.'];
01437                         $funcConf['parentObj']=&$this;
01438                         $passVar = $GLOBALS['TSFE']->cObj->callUserFunction($this->mconf[$mConfKey], $funcConf, $passVar);
01439                 }
01440                 return $passVar;
01441         }
01442 
01449         function setATagParts() {
01450                 $this->I['A1'] = '<a '.t3lib_div::implodeAttributes($this->I['linkHREF'],1).' '.$this->I['val']['ATagParams'].$this->I['accessKey']['code'].'>';
01451                 $this->I['A2'] = '</a>';
01452         }
01453 
01462         function getPageTitle($title,$nav_title)        {
01463                 return strcmp(trim($nav_title),'') ? $nav_title : $title;
01464         }
01465 
01474         function getMPvar($key) {
01475                 if ($GLOBALS['TYPO3_CONF_VARS']['FE']['enable_mount_pids'])     {
01476                         $localMP_array = $this->MP_array;
01477                         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!
01478                         $MP_params = count($localMP_array) ? implode(',',$localMP_array) : '';
01479                         return $MP_params;
01480                 }
01481         }
01482 
01489         function getDoktypeExcludeWhere() {
01490                 return $this->doktypeExcludeList ? ' AND pages.doktype NOT IN ('.$this->doktypeExcludeList.')' : '';
01491         }
01492 
01499         function getBannedUids() {
01500                 $banUidArray = array();
01501 
01502                 if (trim($this->conf['excludeUidList']))        {
01503                         $banUidList = str_replace('current', $GLOBALS['TSFE']->page['uid'], $this->conf['excludeUidList']);
01504                         $banUidArray = t3lib_div::intExplode(',', $banUidList);
01505                 }
01506 
01507                 return $banUidArray;
01508         }
01509 
01510 }
01511 
01512 
01513 
01514 
01515 
01516 
01517 
01518 
01519 
01520 
01521 
01522 
01523 
01524 
01525 
01526 
01527 
01528 
01529 
01538 class tslib_tmenu extends tslib_menu {
01539 
01547         function generate()     {
01548                 $splitCount = count($this->menuArr);
01549                 if ($splitCount)        {
01550                         list($NOconf) = $this->procesItemStates($splitCount);
01551                 }
01552                 if ($this->mconf['debugItemConf'])      {echo '<h3>$NOconf:</h3>';      debug($NOconf); }
01553                 $this->result = $NOconf;
01554         }
01555 
01563         function writeMenu()    {
01564                 if (is_array($this->result) && count($this->result))    {
01565                         $this->WMcObj = t3lib_div::makeInstance('tslib_cObj');  // Create new tslib_cObj for our use
01566                         $this->WMresult = '';
01567                         $this->INPfixMD5 = substr(md5(microtime().'tmenu'),0,4);
01568                         $this->WMmenuItems = count($this->result);
01569 
01570                         $this->WMsubmenuObjSuffixes = $this->tmpl->splitConfArray(array('sOSuffix'=>$this->mconf['submenuObjSuffixes']),$this->WMmenuItems);
01571 
01572                         $this->extProc_init();
01573                         reset($this->result);
01574                         while (list($key,$val)=each($this->result))     {
01575                                 $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']++;
01576                                 $GLOBALS['TSFE']->register['count_MENUOBJ']++;
01577 
01578                                 $this->WMcObj->start($this->menuArr[$key],'pages');             // Initialize the cObj with the page record of the menu item
01579 
01580                                 $this->I = array();
01581                                 $this->I['key'] = $key;
01582                                 $this->I['INPfix'] = $this->imgNameNotRandom?'':'_'.$this->INPfixMD5.'_'.$key;
01583                                 $this->I['val'] = $val;
01584                                 $this->I['title'] = $this->WMcObj->stdWrap($this->getPageTitle($this->menuArr[$key]['title'],$this->menuArr[$key]['nav_title']),$this->I['val']['stdWrap.']);
01585                                 $this->I['uid'] = $this->menuArr[$key]['uid'];
01586                                 $this->I['mount_pid'] = $this->menuArr[$key]['mount_pid'];
01587                                 $this->I['pid'] = $this->menuArr[$key]['pid'];
01588                                 $this->I['spacer'] = $this->menuArr[$key]['isSpacer'];
01589 
01590                                         // Set access key
01591                                 if ($this->mconf['accessKey'])  {
01592                                         $this->I['accessKey'] = $this->accessKey($this->I['title']);
01593                                 } else {
01594                                         $this->I['accessKey'] = Array();
01595                                 }
01596 
01597                                         // Make link tag
01598                                 $this->I['val']['ATagParams'] = $this->WMcObj->getATagParams($this->I['val']);
01599                                 $this->I['val']['additionalParams'] = $this->WMcObj->stdWrap($this->I['val']['additionalParams'],$this->I['val']['additionalParams.']);
01600                                 $this->I['linkHREF'] = $this->link($key,$this->I['val']['altTarget'],$this->mconf['forceTypeValue']);
01601 
01602                                         // Title attribute of links:
01603                                 $titleAttrValue = $this->WMcObj->stdWrap($this->I['val']['ATagTitle'],$this->I['val']['ATagTitle.']).$this->I['accessKey']['alt'];
01604                                 if (strlen($titleAttrValue))    {
01605                                         $this->I['linkHREF']['title'] = $titleAttrValue;
01606                                 }
01607 
01608                                         // Setting "blurlink()" function:
01609                                 if (!$this->mconf['noBlur'])    {
01610                                         $this->I['linkHREF']['onFocus']='blurLink(this);';
01611                                 }
01612 
01613                                         // Make link:
01614                                 if ($this->I['val']['RO'])      {
01615                                         $this->I['theName'] = $this->imgNamePrefix.$this->I['uid'].$this->I['INPfix'];
01616                                         $over='';
01617                                         $out ='';
01618                                         if ($this->I['val']['beforeROImg'])     {
01619                                                 $over.= $this->WMfreezePrefix."over('".$this->I['theName']."before');";
01620                                                 $out.= $this->WMfreezePrefix."out('".$this->I['theName']."before');";
01621                                         }
01622                                         if ($this->I['val']['afterROImg'])      {
01623                                                 $over.= $this->WMfreezePrefix."over('".$this->I['theName']."after');";
01624                                                 $out.= $this->WMfreezePrefix."out('".$this->I['theName']."after');";
01625                                         }
01626                                         $this->I['linkHREF']['onMouseover']=$over;
01627                                         $this->I['linkHREF']['onMouseout']=$out;
01628                                         if ($over || $out)      $GLOBALS['TSFE']->setJS('mouseOver');
01629 
01630                                                 // Change background color:
01631                                         if ($this->I['val']['RO_chBgColor'])    {
01632                                                 $this->addJScolorShiftFunction();
01633                                                 $chBgP = t3lib_div::trimExplode('|',$this->I['val']['RO_chBgColor']);
01634                                                 $this->I['linkHREF']['onMouseover'].="changeBGcolor('".$chBgP[2].$this->I['uid']."','".$chBgP[0]."');";
01635                                                 $this->I['linkHREF']['onMouseout'].="changeBGcolor('".$chBgP[2].$this->I['uid']."','".$chBgP[1]."');";
01636                                         }
01637 
01638                                         $this->extProc_RO($key);
01639                                 }
01640 
01641 
01642                                         // Calling extra processing function
01643                                 $this->extProc_beforeLinking($key);
01644 
01645                                         // Compile link tag
01646                                 if (!$this->I['val']['doNotLinkIt']) {$this->I['val']['doNotLinkIt']=0;}
01647                                 if (!$this->I['spacer'] && $this->I['val']['doNotLinkIt']!=1)   {
01648                                         $this->setATagParts();
01649                                 } else {
01650                                         $this->I['A1'] = '';
01651                                         $this->I['A2'] = '';
01652                                 }
01653 
01654                                         // ATagBeforeWrap processing:
01655                                 if ($this->I['val']['ATagBeforeWrap'])  {
01656                                         $wrapPartsBefore = explode('|',$this->I['val']['linkWrap']);
01657                                         $wrapPartsAfter = array('','');
01658                                 } else {
01659                                         $wrapPartsBefore = array('','');
01660                                         $wrapPartsAfter = explode('|',$this->I['val']['linkWrap']);
01661                                 }
01662                                 if ($this->I['val']['stdWrap2'] || isset($this->I['val']['stdWrap2.'])) {
01663                                         $wrapPartsStdWrap = explode($this->I['val']['stdWrap2']?$this->I['val']['stdWrap2']:'|',$this->WMcObj->stdWrap('|',$this->I['val']['stdWrap2.']));
01664                                 } else {$wrapPartsStdWrap = array('','');}
01665 
01666                                         // Make before, middle and after parts
01667                                 $this->I['parts'] = array();
01668                                 $this->I['parts']['before']=$this->getBeforeAfter('before');
01669                                 $this->I['parts']['stdWrap2_begin']=$wrapPartsStdWrap[0];
01670                                 if (!$this->I['val']['doNotShowLink']) {
01671                                         $this->I['parts']['notATagBeforeWrap_begin'] = $wrapPartsAfter[0];
01672                                         $this->I['parts']['ATag_begin'] = $this->I['A1'];
01673                                         $this->I['parts']['ATagBeforeWrap_begin'] = $wrapPartsBefore[0];
01674                                         $this->I['parts']['title'] = $this->I['title'];
01675                                         $this->I['parts']['ATagBeforeWrap_end'] = $wrapPartsBefore[1];
01676                                         $this->I['parts']['ATag_end'] = $this->I['A2'];
01677                                         $this->I['parts']['notATagBeforeWrap_end'] = $wrapPartsAfter[1];
01678                                 }
01679                                 $this->I['parts']['stdWrap2_end']=$wrapPartsStdWrap[1];
01680                                 $this->I['parts']['after']=$this->getBeforeAfter('after');
01681 
01682                                         // Passing I to a user function
01683                                 if ($this->mconf['IProcFunc'])  {
01684                                         $this->I = $this->userProcess('IProcFunc',$this->I);
01685                                 }
01686 
01687                                         // Merge parts + beforeAllWrap
01688                                 $this->I['theItem']= implode('',$this->I['parts']);
01689                                 $this->I['theItem']= $this->extProc_beforeAllWrap($this->I['theItem'],$key);
01690 
01691                                         // allWrap:
01692                                 $allWrap = $this->WMcObj->stdWrap($this->I['val']['allWrap'],$this->I['val']['allWrap.']);
01693                                 $this->I['theItem'] = $this->tmpl->wrap($this->I['theItem'],$allWrap);
01694 
01695                                 if ($this->I['val']['subst_elementUid'])        $this->I['theItem'] = str_replace('{elementUid}',$this->I['uid'],$this->I['theItem']);
01696 
01697                                         // allStdWrap:
01698                                 if (is_array($this->I['val']['allStdWrap.']))   {
01699                                         $this->I['theItem'] = $this->WMcObj->stdWrap($this->I['theItem'],$this->I['val']['allStdWrap.']);
01700                                 }
01701 
01702                                         // Calling extra processing function
01703                                 $this->extProc_afterLinking($key);
01704                         }
01705                         return $this->extProc_finish();
01706                 }
01707         }
01708 
01716         function getBeforeAfter($pref)  {
01717                 $res = '';
01718                 if ($imgInfo = $this->WMcObj->getImgResource($this->I['val'][$pref.'Img'],$this->I['val'][$pref.'Img.']))       {
01719                         $imgInfo[3] = t3lib_div::png_to_gif_by_imagemagick($imgInfo[3]);
01720                         if ($this->I['val']['RO'] && $this->I['val'][$pref.'ROImg'] && !$this->I['spacer'])     {
01721                                 $imgROInfo = $this->WMcObj->getImgResource($this->I['val'][$pref.'ROImg'],$this->I['val'][$pref.'ROImg.']);
01722                                 $imgROInfo[3] = t3lib_div::png_to_gif_by_imagemagick($imgROInfo[3]);
01723                                 if ($imgROInfo) {
01724                                         $theName = $this->imgNamePrefix.$this->I['uid'].$this->I['INPfix'].$pref;
01725                                         $name = ' '.$this->nameAttribute.'="'.$theName.'"';
01726                                         $GLOBALS['TSFE']->JSImgCode.= chr(10).$theName.'_n=new Image(); '.$theName.'_n.src = "'.$GLOBALS['TSFE']->absRefPrefix.$imgInfo[3].'"; ';
01727                                         $GLOBALS['TSFE']->JSImgCode.= chr(10).$theName.'_h=new Image(); '.$theName.'_h.src = "'.$GLOBALS['TSFE']->absRefPrefix.$imgROInfo[3].'"; ';
01728                                 }
01729                         }
01730                         $GLOBALS['TSFE']->imagesOnPage[]=$imgInfo[3];
01731                         $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']:'').tslib_cObj::getBorderAttr('border="0"');
01732                         if (!strstr($res,'alt="'))      $res.=' alt=""';        // Adding alt attribute if not set.
01733                         $res.=' />';
01734                         if ($this->I['val'][$pref.'ImgLink'])   {$res=$this->I['A1'].$res.$this->I['A2'];}
01735                 }
01736                 return $this->tmpl->wrap($res.$this->WMcObj->stdWrap($this->I['val'][$pref],$this->I['val'][$pref.'.']), $this->I['val'][$pref.'Wrap']);
01737         }
01738 
01746         function addJScolorShiftFunction()      {
01747                 $GLOBALS['TSFE']->additionalJavaScript['TMENU:changeBGcolor()']='
01748                         function changeBGcolor(id,color) {      //
01749                                 if (document.getElementById && document.getElementById(id))     {
01750                                         document.getElementById(id).style.background = color;
01751                                         return true;
01752                                 } else if (document.layers && document.layers[id]) {
01753                                 document.layers[id].bgColor = color;
01754                                         return true;
01755                             }
01756                         }
01757                 ';
01758         }
01759 
01768         function extProc_init() {
01769         }
01770 
01779         function extProc_RO($key)       {
01780         }
01781 
01790         function extProc_beforeLinking($key)    {
01791         }
01792 
01802         function extProc_afterLinking($key)     {
01803                         // Add part to the accumulated result + fetch submenus
01804                 if (!$this->I['spacer'])        {
01805                         $this->I['theItem'].= $this->subMenu($this->I['uid'], $this->WMsubmenuObjSuffixes[$key]['sOSuffix']);
01806                 }
01807                 $this->WMresult.= $this->I['val']['wrapItemAndSub'] ? $this->tmpl->wrap($this->I['theItem'],$this->I['val']['wrapItemAndSub']) : $this->I['theItem'];
01808         }
01809 
01819         function extProc_beforeAllWrap($item,$key)      {
01820                 return $item;
01821         }
01822 
01830         function extProc_finish()       {
01831                         // stdWrap:
01832                 if (is_array($this->mconf['stdWrap.'])) {
01833                         $this->WMresult = $this->WMcObj->stdWrap($this->WMresult,$this->mconf['stdWrap.']);
01834                 }
01835                 return $this->tmpl->wrap($this->WMresult,$this->mconf['wrap']).$this->WMextraScript;
01836         }
01837 }
01838 
01839 
01840 
01841 
01842 
01843 
01844 
01845 
01846 
01847 
01848 
01849 
01850 
01851 
01852 
01853 
01854 
01855 
01856 
01857 
01858 
01859 
01860 
01861 
01870 class tslib_gmenu extends tslib_menu {
01871 
01879         function generate()     {
01880                 $splitCount = count($this->menuArr);
01881                 if ($splitCount)        {
01882                         list($NOconf,$ROconf) = $this->procesItemStates($splitCount);
01883 
01884                                 //store initial count value
01885                         $temp_HMENU_MENUOBJ = $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'];
01886                         $temp_MENUOBJ = $GLOBALS['TSFE']->register['count_MENUOBJ'];
01887                                 // Now we generate the giffiles:
01888                         $this->makeGifs($NOconf,'NO');
01889                                 // store count from NO obj
01890                         $tempcnt_HMENU_MENUOBJ = $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'];
01891                         $tempcnt_MENUOBJ = $GLOBALS['TSFE']->register['count_MENUOBJ'];
01892 
01893                         if ($this->mconf['debugItemConf'])      {echo '<h3>$NOconf:</h3>';      debug($NOconf); }
01894                         if ($ROconf)    {               // RollOver
01895                                         //start recount for rollover with initial values
01896                                 $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']= $temp_HMENU_MENUOBJ;
01897                                 $GLOBALS['TSFE']->register['count_MENUOBJ']= $temp_MENUOBJ;
01898                                 $this->makeGifs($ROconf,'RO');
01899                                 if ($this->mconf['debugItemConf'])      {echo '<h3>$ROconf:</h3>';      debug($ROconf); }
01900                         }
01901                                 // use count from NO obj
01902                         $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'] = $tempcnt_HMENU_MENUOBJ;
01903                         $GLOBALS['TSFE']->register['count_MENUOBJ'] = $tempcnt_MENUOBJ;
01904                 }
01905         }
01906 
01917         function makeGifs($conf, $resKey)       {
01918                 $isGD = $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'];
01919 
01920                 if (!is_array($conf)) {
01921                         $conf = Array();
01922                 }
01923 
01924                 $totalWH=array();
01925                 $items = count($conf);
01926                 if ($isGD)      {
01927                                 // generate the gif-files. the $menuArr is filled with some values like output_w, output_h, output_file
01928                         $Hcounter = 0;
01929                         $Wcounter = 0;
01930                         $Hobjs = $this->mconf['applyTotalH'];
01931                         if ($Hobjs)     {$Hobjs = t3lib_div::intExplode(',',$Hobjs);}
01932                         $Wobjs = $this->mconf['applyTotalW'];
01933                         if ($Wobjs)     {$Wobjs = t3lib_div::intExplode(',',$Wobjs);}
01934                         $minDim = $this->mconf['min'];
01935                         if ($minDim) {$minDim = tslib_cObj::calcIntExplode(',',$minDim.',');}
01936                         $maxDim = $this->mconf['max'];
01937                         if ($maxDim) {$maxDim = tslib_cObj::calcIntExplode(',',$maxDim.',');}
01938 
01939                         if ($minDim)    {
01940                                 $conf[$items]=$conf[$items-1];
01941                                 $this->menuArr[$items]=Array();
01942                                 $items = count($conf);
01943                         }
01944 
01945                         // TOTAL width
01946                         if ($this->mconf['useLargestItemX'] || $this->mconf['useLargestItemY'] || $this->mconf['distributeX'] || $this->mconf['distributeY'])   {
01947                                 $totalWH = $this->findLargestDims($conf,$items,$Hobjs,$Wobjs,$minDim,$maxDim);
01948                         }
01949                 }
01950 
01951                 $c=0;
01952                 $maxFlag=0;
01953                 $distributeAccu=array('H'=>0,'W'=>0);
01954                 reset($conf);
01955                 while (list($key,$val)=each($conf))     {
01956                         $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']++;
01957                         $GLOBALS['TSFE']->register['count_MENUOBJ']++;
01958 
01959                         if ($items==($c+1) && $minDim)  {
01960                                 $Lobjs = $this->mconf['removeObjectsOfDummy'];
01961                                 if ($Lobjs)     {
01962                                         $Lobjs = t3lib_div::intExplode(',',$Lobjs);
01963                                         reset($Lobjs);
01964                                         while(list(,$remItem)=each($Lobjs))     {
01965                                                 unset($val[$remItem]);
01966                                                 unset($val[$remItem.'.']);
01967                                         }
01968                                 }
01969 
01970                                 $flag =0;
01971                                 $tempXY = explode(',',$val['XY']);
01972                                 if ($Wcounter<$minDim[0])       {$tempXY[0]=$minDim[0]-$Wcounter; $flag=1;}
01973                                 if ($Hcounter<$minDim[1])       {$tempXY[1]=$minDim[1]-$Hcounter; $flag=1;}
01974                                 $val['XY'] = implode(',',$tempXY);
01975                                 if (!$flag){break;}
01976                         }
01977                         $c++;
01978 
01979 
01980                         if ($isGD)      {
01981                                         // Pre-working the item
01982                                 $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder');
01983                                 $gifCreator->init();
01984                                 $gifCreator->start($val,$this->menuArr[$key]);
01985 
01986                                         // If useLargestItemH/W is specified
01987                                 if (count($totalWH) && ($this->mconf['useLargestItemX'] || $this->mconf['useLargestItemY']))    {
01988                                         $tempXY = explode(',',$gifCreator->setup['XY']);
01989                                         if ($this->mconf['useLargestItemX'])    {$tempXY[0] = max($totalWH['W']);}
01990                                         if ($this->mconf['useLargestItemY'])    {$tempXY[1] = max($totalWH['H']);}
01991                                                 // regenerate the new values...
01992                                         $val['XY'] = implode(',',$tempXY);
01993                                         $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder');
01994                                         $gifCreator->init();
01995                                         $gifCreator->start($val,$this->menuArr[$key]);
01996                                 }
01997 
01998                                         // If distributeH/W is specified
01999                                 if (count($totalWH) && ($this->mconf['distributeX'] || $this->mconf['distributeY']))    {
02000                                         $tempXY = explode(',',$gifCreator->setup['XY']);
02001 
02002                                         if ($this->mconf['distributeX'])        {
02003                                                 $diff = $this->mconf['distributeX']-$totalWH['W_total']-$distributeAccu['W'];
02004                                                 $compensate = round($diff /($items-$c+1));
02005                                                 $distributeAccu['W']+=$compensate;
02006                                                 $tempXY[0] = $totalWH['W'][$key]+$compensate;
02007                                         }
02008                                         if ($this->mconf['distributeY'])        {
02009                                                 $diff = $this->mconf['distributeY']-$totalWH['H_total']-$distributeAccu['H'];
02010                                                 $compensate = round($diff /($items-$c+1));
02011                                                 $distributeAccu['H']+=$compensate;
02012                                                 $tempXY[1] = $totalWH['H'][$key]+$compensate;
02013                                         }
02014                                                 // regenerate the new values...
02015                                         $val['XY'] = implode(',',$tempXY);
02016                                         $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder');
02017                                         $gifCreator->init();
02018                                         $gifCreator->start($val,$this->menuArr[$key]);
02019                                 }
02020 
02021                                         // If max dimensions are specified
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 
02034 
02035 
02036 
02037                                 // displace
02038                                 if ($Hobjs)     {
02039                                         reset($Hobjs);
02040                                         while(list(,$index)=each($Hobjs))       {
02041                                                 if ($gifCreator->setup[$index] && $gifCreator->setup[$index.'.'])       {
02042                                                         $oldOffset = explode(',',$gifCreator->setup[$index.'.']['offset']);
02043                                                         $gifCreator->setup[$index.'.']['offset'] = implode(',',$gifCreator->applyOffset($oldOffset,Array(0,-$Hcounter)));
02044                                                 }
02045                                         }
02046                                 }
02047 
02048                                 if ($Wobjs)     {
02049                                         reset($Wobjs);
02050                                         while(list(,$index)=each($Wobjs))       {
02051                                                 if ($gifCreator->setup[$index] && $gifCreator->setup[$index.'.'])       {
02052                                                         $oldOffset = explode(',',$gifCreator->setup[$index.'.']['offset']);
02053                                                         $gifCreator->setup[$index.'.']['offset'] = implode(',',$gifCreator->applyOffset($oldOffset,Array(-$Wcounter,0)));
02054                                                 }
02055                                         }
02056                                 }
02057                         }
02058 
02059                                 // Finding alternative GIF names if any (by altImgResource)
02060                         $gifFileName='';
02061                         if ($conf[$key]['altImgResource'] || is_array($conf[$key]['altImgResource.']))  {
02062                                 if (!is_object($cObj)) {$cObj=t3lib_div::makeInstance('tslib_cObj');}
02063                                 $cObj->start($this->menuArr[$key],'pages');
02064                                 $altImgInfo = $cObj->getImgResource($conf[$key]['altImgResource'],$conf[$key]['altImgResource.']);
02065                                 $gifFileName=$altImgInfo[3];
02066                         }
02067 
02068                                 // If an alternative name was NOT given, find the GIFBUILDER name.
02069                         if (!$gifFileName && $isGD)     {
02070                                 $gifCreator->createTempSubDir('menu/');
02071                                 $gifFileName = $gifCreator->fileName('menu/');
02072                         }
02073 
02074                         $this->result[$resKey][$key] = $conf[$key];
02075 
02076                                 // Generation of image file:
02077                         if (@file_exists($gifFileName)) {               // File exists
02078                                 $info = @getimagesize($gifFileName);
02079                                 $this->result[$resKey][$key]['output_w']=intval($info[0]);
02080                                 $this->result[$resKey][$key]['output_h']=intval($info[1]);
02081                                 $this->result[$resKey][$key]['output_file'] = $gifFileName;
02082                         } elseif ($isGD) {              // file is generated
02083                                 $gifCreator->make();
02084                                 $this->result[$resKey][$key]['output_w']=$gifCreator->w;
02085                                 $this->result[$resKey][$key]['output_h']=$gifCreator->h;
02086                                 $this->result[$resKey][$key]['output_file'] = $gifFileName;
02087                                 $gifCreator->output($this->result[$resKey][$key]['output_file']);
02088                                 $gifCreator->destroy();
02089                         }
02090 
02091                         $this->result[$resKey][$key]['output_file'] = t3lib_div::png_to_gif_by_imagemagick($this->result[$resKey][$key]['output_file']);
02092 
02093                         $Hcounter+=$this->result[$resKey][$key]['output_h'];            // counter is increased
02094                         $Wcounter+=$this->result[$resKey][$key]['output_w'];            // counter is increased
02095 
02096                         if ($maxFlag)   break;
02097                 }
02098         }
02099 
02115         function findLargestDims($conf,$items,$Hobjs,$Wobjs,$minDim,$maxDim)    {
02116                 $totalWH = array(
02117                         'W' => array(),
02118                         'H' => array(),
02119                         'W_total' => 0,
02120                         'H_total' => 0
02121                 );
02122 
02123                 $Hcounter = 0;
02124                 $Wcounter = 0;
02125                 $c=0;
02126                 $maxFlag=0;
02127                 reset($conf);
02128                 while (list($key,$val)=each($conf))     {
02129                         // SAME CODE AS makeGifs()! BEGIN
02130                         if ($items==($c+1) && $minDim)  {
02131                                 $Lobjs = $this->mconf['removeObjectsOfDummy'];
02132                                 if ($Lobjs)     {
02133                                         $Lobjs = t3lib_div::intExplode(',',$Lobjs);
02134                                         reset($Lobjs);
02135                                         while(list(,$remItem)=each($Lobjs))     {
02136                                                 unset($val[$remItem]);
02137                                                 unset($val[$remItem.'.']);
02138                                         }
02139                                 }
02140 
02141                                 $flag =0;
02142                                 $tempXY = explode(',',$val['XY']);
02143                                 if ($Wcounter<$minDim[0])       {$tempXY[0]=$minDim[0]-$Wcounter; $flag=1;}
02144                                 if ($Hcounter<$minDim[1])       {$tempXY[1]=$minDim[1]-$Hcounter; $flag=1;}
02145                                 $val['XY'] = implode(',',$tempXY);
02146                                 if (!$flag){break;}
02147                         }
02148                         $c++;
02149 
02150                         $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder');
02151                         $gifCreator->init();
02152                         $gifCreator->start($val,$this->menuArr[$key]);
02153                         if ($maxDim)    {
02154                                 $tempXY = explode(',',$val['XY']);
02155                                 if ($maxDim[0] && $Wcounter+$gifCreator->XY[0]>=$maxDim[0])     {$tempXY[0]==$maxDim[0]-$Wcounter; $maxFlag=1;}
02156                                 if ($maxDim[1] && $Hcounter+$gifCreator->XY[1]>=$maxDim[1])     {$tempXY[1]=$maxDim[1]-$Hcounter; $maxFlag=1;}
02157                                 if ($maxFlag)   {
02158                                         $val['XY'] = implode(',',$tempXY);
02159                                         $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder');
02160                                         $gifCreator->init();
02161                                         $gifCreator->start($val,$this->menuArr[$key]);
02162                                 }
02163                         }
02164                         // SAME CODE AS makeGifs()! END
02165 
02166                                 // Setting the width/height
02167                         $totalWH['W'][$key]=$gifCreator->XY[0];
02168                         $totalWH['H'][$key]=$gifCreator->XY[1];
02169                         $totalWH['W_total']+=$gifCreator->XY[0];
02170                         $totalWH['H_total']+=$gifCreator->XY[1];
02171                                 // ---- //
02172 
02173                         $Hcounter+=$gifCreator->XY[1];          // counter is increased
02174                         $Wcounter+=$gifCreator->XY[0];          // counter is increased
02175 
02176                         if ($maxFlag){break;}
02177                 }
02178                 return $totalWH;
02179         }
02180 
02187         function writeMenu()    {
02188                 if (is_array($this->menuArr) && is_array($this->result) && count($this->result) && is_array($this->result['NO']))       {
02189                         $this->WMcObj = t3lib_div::makeInstance('tslib_cObj');  // Create new tslib_cObj for our use
02190                         $this->WMresult = '';
02191                         $this->INPfixMD5 = substr(md5(microtime().$this->GMENU_fixKey),0,4);
02192                         $this->WMmenuItems = count($this->result['NO']);
02193 
02194                         $this->WMsubmenuObjSuffixes = $this->tmpl->splitConfArray(array('sOSuffix'=>$this->mconf['submenuObjSuffixes']),$this->WMmenuItems);
02195 
02196                         $this->extProc_init();
02197                         for ($key=0;$key<$this->WMmenuItems;$key++)     {
02198                                 if ($this->result['NO'][$key]['output_file'])   {
02199                                         $this->WMcObj->start($this->menuArr[$key],'pages');             // Initialize the cObj with the page record of the menu item
02200 
02201                                         $this->I = array();
02202                                         $this->I['key'] = $key;
02203                                         $this->I['INPfix']= $this->imgNameNotRandom?'':'_'.$this->INPfixMD5.'_'.$key;
02204                                         $this->I['val'] = $this->result['NO'][$key];
02205                                         $this->I['title'] = $this->getPageTitle($this->menuArr[$key]['title'],$this->menuArr[$key]['nav_title']);
02206                                         $this->I['uid'] = $this->menuArr[$key]['uid'];
02207                                         $this->I['mount_pid'] = $this->menuArr[$key]['mount_pid'];
02208                                         $this->I['pid'] = $this->menuArr[$key]['pid'];
02209                                         $this->I['spacer'] = $this->menuArr[$key]['isSpacer'];
02210                                         if (!$this->I['uid'] && !$this->menuArr[$key]['_OVERRIDE_HREF']) {$this->I['spacer']=1;}
02211                                         $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
02212                                         $this->I['name'] = '';
02213 
02214                                                 // Set access key
02215                                         if ($this->mconf['accessKey'])  {
02216                                                 $this->I['accessKey'] = $this->accessKey($this->I['title']);
02217                                         } else {
02218                                                 $this->I['accessKey'] = array();
02219                                         }
02220 
02221                                                 // Make link tag
02222                                         $this->I['val']['ATagParams'] = $this->WMcObj->getATagParams($this->I['val']);
02223                                         $this->I['val']['additionalParams'] = $this->WMcObj->stdWrap($this->I['val']['additionalParams'],$this->I['val']['additionalParams.']);
02224                                         $this->I['linkHREF'] = $this->link($key,$this->I['val']['altTarget'],$this->mconf['forceTypeValue']);
02225 
02226                                                 // Title attribute of links:
02227                                         $titleAttrValue = $this->WMcObj->stdWrap($this->I['val']['ATagTitle'],$this->I['val']['ATagTitle.']).$this->I['accessKey']['alt'];
02228                                         if (strlen($titleAttrValue))    {
02229                                                 $this->I['linkHREF']['title'] = $titleAttrValue;
02230                                         }
02231                                                 // Setting "blurlink()" function:
02232                                         if (!$this->mconf['noBlur'])    {
02233                                                 $this->I['linkHREF']['onFocus']='blurLink(this);';
02234                                         }
02235 
02236                                                 // Set rollover
02237                                         if ($this->result['RO'][$key] && !$this->I['noLink'])   {
02238                                                 $this->I['theName'] = $this->imgNamePrefix.$this->I['uid'].$this->I['INPfix'];
02239                                                 $this->I['name'] = ' '.$this->nameAttribute.'="'.$this->I["theName"].'"';
02240                                                 $this->I['linkHREF']['onMouseover']=$this->WMfreezePrefix.'over(\''.$this->I['theName'].'\');';
02241                                                 $this->I['linkHREF']['onMouseout']=$this->WMfreezePrefix.'out(\''.$this->I['theName'].'\');';
02242                                                 $GLOBALS['TSFE']->JSImgCode.= chr(10).$this->I['theName'].'_n=new Image(); '.$this->I['theName'].'_n.src = "'.$GLOBALS['TSFE']->absRefPrefix.$this->I['val']['output_file'].'"; ';
02243                                                 $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'].'"; ';
02244                                                 $GLOBALS['TSFE']->imagesOnPage[]=$this->result['RO'][$key]['output_file'];
02245                                                 $GLOBALS['TSFE']->setJS('mouseOver');
02246                                                 $this->extProc_RO($key);
02247                                         }
02248 
02249                                                 // Set altText
02250                                         $this->I['altText'] = $this->mconf['disableAltText'] ? '' : $this->I['title'].$this->I['accessKey']['alt'];
02251 
02252                                                 // Calling extra processing function
02253                                         $this->extProc_beforeLinking($key);
02254 
02255                                                 // Set linking
02256                                         if (!$this->I['noLink'])        {
02257                                                 $this->setATagParts();
02258                                         } else {
02259                                                 $this->I['A1'] = '';
02260                                                 $this->I['A2'] = '';
02261                                         }
02262                                         $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'].'" '.tslib_cObj::getBorderAttr('border="0"').' alt="'.htmlspecialchars($this->I['altText']).'"'.$this->I['name'].($this->I['val']['imgParams']?' '.$this->I['val']['imgParams']:'').' />';
02263 
02264                                                 // Make before, middle and after parts
02265                                         $this->I['parts'] = array();
02266                                         $this->I['parts']['ATag_begin'] = $this->I['A1'];
02267                                         $this->I['parts']['image'] = $this->I['IMG'];
02268                                         $this->I['parts']['ATag_end'] = $this->I['A2'];
02269 
02270                                                 // Passing I to a user function
02271                                         if ($this->mconf['IProcFunc'])  {
02272                                                 $this->I = $this->userProcess('IProcFunc',$this->I);
02273                                         }
02274 
02275                                                 // Putting the item together.
02276                                                 // Merge parts + beforeAllWrap
02277                                         $this->I['theItem']= implode('',$this->I['parts']);
02278                                         $this->I['theItem']= $this->extProc_beforeAllWrap($this->I['theItem'],$key);
02279 
02280                                                 // wrap:
02281                                         $this->I['theItem']= $this->tmpl->wrap($this->I['theItem'],$this->I['val']['wrap']);
02282 
02283                                                 // allWrap:
02284                                         $allWrap = $this->WMcObj->stdWrap($this->I['val']['allWrap'],$this->I['val']['allWrap.']);
02285                                         $this->I['theItem'] = $this->tmpl->wrap($this->I['theItem'],$allWrap);
02286 
02287                                         if ($this->I['val']['subst_elementUid'])        $this->I['theItem'] = str_replace('{elementUid}',$this->I['uid'],$this->I['theItem']);
02288 
02289                                                 // allStdWrap:
02290                                         if (is_array($this->I['val']['allStdWrap.']))   {
02291                                                 $this->I['theItem'] = $this->WMcObj->stdWrap($this->I['theItem'],$this->I['val']['allStdWrap.']);
02292                                         }
02293 
02294                                         $GLOBALS['TSFE']->imagesOnPage[]=$this->I['val']['output_file'];
02295 
02296                                         $this->extProc_afterLinking($key);
02297                                 }
02298                         }
02299                         return $this->extProc_finish();
02300                 }
02301         }
02302 
02311         function extProc_init() {
02312         }
02313 
02322         function extProc_RO($key)       {
02323         }
02324 
02333         function extProc_beforeLinking($key)    {
02334         }
02335 
02346         function extProc_afterLinking($key)     {
02347                 $this->WMresult.=$this->I['theItem'];
02348                 if (!$this->I['spacer'])        {
02349                         $this->WMresult.= $this->subMenu($this->I['uid'], $this->WMsubmenuObjSuffixes[$key]['sOSuffix']);
02350                 }
02351         }
02352 
02353 
02363         function extProc_beforeAllWrap($item,$key)      {
02364                 return $item;
02365         }
02366 
02374         function extProc_finish()       {
02375                         // stdWrap:
02376                 if (is_array($this->mconf['stdWrap.'])) {
02377                         $this->WMresult = $this->WMcObj->stdWrap($this->WMresult,$this->mconf['stdWrap.']);
02378                 }
02379                 return $this->tmpl->wrap($this->WMresult,$this->mconf['wrap']).$this->WMextraScript;
02380         }
02381 }
02382 
02383 
02384 
02385 
02386 
02387 
02388 
02389 
02390 
02391 
02392 
02393 
02394 
02395 
02396 
02397 
02398 
02399 
02400 
02401 
02402 
02403 
02412 class tslib_imgmenu extends tslib_menu {
02413 
02421         function generate()     {
02422                 $splitCount = count($this->menuArr);
02423                 if ($splitCount)        {
02424                         list($NOconf) = $this->procesItemStates($splitCount);
02425                 }
02426                 if ($this->mconf['debugItemConf'])      {echo '<h3>$NOconf:</h3>';      debug($NOconf); }
02427                 $this->makeImageMap($NOconf);
02428         }
02429 
02439         function makeImageMap($conf)    {
02440                 if (!is_array($conf)) {
02441                         $conf = Array();
02442                 }
02443                 if (is_array($this->mconf['main.']))    {
02444                         $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder');
02445                         $gifCreator->init();
02446 
02447                         $itemsConf = $conf;
02448                         $conf = $this->mconf['main.'];
02449                         if (is_array($conf))    {
02450                                 $gifObjCount = 0;
02451 
02452                                 $sKeyArray=t3lib_TStemplate::sortedKeyList($conf);
02453                                 $gifObjCount=intval(end($sKeyArray));
02454 
02455                                 $lastOriginal = $gifObjCount;
02456 
02457                                         // Now we add graphical objects to the gifbuilder-setup
02458                                 reset($itemsConf);
02459                                 $waArr = Array();
02460                                 while (list($key,$val)=each($itemsConf))        {
02461                                         if (is_array($val))     {
02462                                                 $gifObjCount++;
02463                                                 $waArr[$key]['free']=$gifObjCount;
02464 
02465                                                 $sKeyArray=t3lib_TStemplate::sortedKeyList($val);
02466 
02467                                                 foreach($sKeyArray as $theKey)  {
02468                                                         $theValue=$val[$theKey];
02469 
02470 
02471                                                         if (intval($theKey) && $theValArr=$val[$theKey.'.'])    {
02472                                                                 $cObjData = $this->menuArr[$key] ? $this->menuArr[$key] : Array();
02473 
02474                                                                 $gifObjCount++;
02475                                                                 if ($theValue=='TEXT') {
02476                                                                         $waArr[$key]['textNum']=$gifObjCount;
02477 
02478                                                                         $gifCreator->data = $cObjData;
02479                                                                         $theValArr = $gifCreator->checkTextObj($theValArr);
02480                                                                         unset($theValArr['text.']);     // if this is not done it seems that imageMaps will be rendered wrong!!
02481                                                                                 // check links
02482 
02483                                                                         $LD = $this->tmpl->linkData($this->menuArr[$key],$this->mconf['target'],'','',array(),'',$this->mconf['forceTypeValue']);
02484 
02485                                                                                 // If access restricted pages should be shown in menus, change the link of such pages to link to a redirection page:
02486                                                                         $this->changeLinksForAccessRestrictedPages($LD, $this->menuArr[$key], $this->mconf['target'], $this->mconf['forceTypeValue']);
02487 
02488                                                                                 // Overriding URL / Target if set to do so:
02489                                                                         if ($this->menuArr[$key]['_OVERRIDE_HREF'])     {
02490                                                                                 $LD['totalURL'] = $this->menuArr[$key]['_OVERRIDE_HREF'];
02491                                                                                 if ($this->menuArr[$key]['_OVERRIDE_TARGET'])   $LD['target'] = $this->menuArr[$key]['_OVERRIDE_TARGET'];
02492                                                                         }
02493 
02494                                                                                 // Setting target/url for Image Map:
02495                                                                         if ($theValArr['imgMap.']['url']=='')   {
02496                                                                                 $theValArr['imgMap.']['url'] = $LD['totalURL'];
02497                                                                         }
02498                                                                         if ($theValArr['imgMap.']['target']=='')        {
02499                                                                                 $theValArr['imgMap.']['target'] = $LD['target'];
02500                                                                         }
02501                                                                         if ($theValArr['imgMap.']['noBlur']=='')        {
02502                                                                                 $theValArr['imgMap.']['noBlur'] = $this->mconf['noBlur'];
02503                                                                         }
02504                                                                         if (is_array($theValArr['imgMap.']['altText.']))        {
02505                                                                                 $cObj =t3lib_div::makeInstance('tslib_cObj');
02506                                                                                 $cObj->start($cObjData,'pages');
02507                                                                                 $theValArr['imgMap.']['altText'] = $cObj->stdWrap($theValArr['imgMap.']['altText'], $theValArr['imgMap.']['altText.']);
02508                                                                                 unset($theValArr['imgMap.']['altText.']);
02509                                                                 }
02510                                                                         if (is_array($theValArr['imgMap.']['titleText.']))      {
02511                                                                                 $cObj =t3lib_div::makeInstance('tslib_cObj');
02512                                                                                 $cObj->start($cObjData,'pages');
02513                                                                                 $theValArr['imgMap.']['titleText'] = $cObj->stdWrap($theValArr['imgMap.']['titleText'], $theValArr['imgMap.']['titleText.']);
02514                                                                                 unset($theValArr['imgMap.']['titleText.']);
02515                                                                         }
02516                                                                 }
02517                                                                         // 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!!
02518                                                                 if ($theValue=='IMAGE') {
02519                                                                         if ($theValArr['file']=='GIFBUILDER')   {
02520                                                                                 $temp_sKeyArray=t3lib_TStemplate::sortedKeyList($theValArr['file.']);
02521                                                                                 reset($temp_sKeyArray);
02522                                                                                 while(list(,$temp_theKey)=each($temp_sKeyArray))        {
02523                                                                                         if ($theValArr['mask.'][$temp_theKey]=='TEXT')  {
02524                                                                                                 $gifCreator->data = $this->menuArr[$key] ? $this->menuArr[$key] : Array();
02525                                                                                                 $theValArr['mask.'][$temp_theKey.'.'] = $gifCreator->checkTextObj($theValArr['mask.'][$temp_theKey.'.']);
02526                                                                                                 unset($theValArr['mask.'][$temp_theKey.'.']['text.']);  // if this is not done it seems that imageMaps will be rendered wrong!!
02527                                                                                         }
02528                                                                                 }
02529                                                                         }
02530                                                                         if ($theValArr['mask']=='GIFBUILDER')   {
02531                                                                                 $temp_sKeyArray=t3lib_TStemplate::sortedKeyList($theValArr['mask.']);
02532                                                                                 reset($temp_sKeyArray);
02533                                                                                 while(list(,$temp_theKey)=each($temp_sKeyArray))        {
02534                                                                                         if ($theValArr['mask.'][$temp_theKey]=='TEXT')  {
02535                                                                                                 $gifCreator->data = $this->menuArr[$key] ? $this->menuArr[$key] : Array();
02536                                                                                                 $theValArr['mask.'][$temp_theKey.'.'] = $gifCreator->checkTextObj($theValArr['mask.'][$temp_theKey.'.']);
02537                                                                                                 unset($theValArr['mask.'][$temp_theKey.'.']['text.']);  // if this is not done it seems that imageMaps will be rendered wrong!!
02538                                                                                         }
02539                                                                                 }
02540                                                                         }
02541                                                                 }
02542 
02543                                                                         // Checks if disabled is set...
02544                                                                 $setObjFlag=1;
02545                                                                 if ($theValArr['if.'])  {
02546                                                                         $cObj =t3lib_div::makeInstance('tslib_cObj');
02547                                                                         $cObj->start($cObjData,'pages');
02548                                                                         if (!$cObj->checkIf($theValArr['if.'])) {
02549                                                                                 $setObjFlag=0;
02550                                                                         }
02551                                                                         unset($theValArr['if.']);
02552                                                                 }
02553                                                                         // Set the object!
02554                                                                 if ($setObjFlag)        {
02555                                                                         $conf[$gifObjCount] = $theValue;
02556                                                                         $conf[$gifObjCount.'.'] = $theValArr;
02557                                                                 }
02558                                                         }
02559                                                 }
02560                                         }
02561                                 }
02562 
02563                                 $gifCreator->start($conf,$GLOBALS['TSFE']->page);
02564                                         // calculations
02565 
02566                                 $sum=Array(0,0,0,0);
02567                                 reset($waArr);
02568                                 while (list($key,$val)=each($waArr))    {
02569                                         if ($dConf[$key] =$itemsConf[$key]['distrib'])  {
02570                                                 $textBB = $gifCreator->objBB[$val['textNum']];
02571                                                 $dConf[$key] = str_replace('textX',$textBB[0],$dConf[$key]);
02572                                                 $dConf[$key] = str_replace('textY',$textBB[1],$dConf[$key]);
02573                                                 $dConf[$key] = t3lib_div::intExplode(',',$gifCreator->calcOffset($dConf[$key]));
02574                                         }
02575                                 }
02576                                 $workArea = t3lib_div::intExplode(',',$gifCreator->calcOffset($this->mconf['dWorkArea']));
02577                                 reset($waArr);
02578                                 while (list($key,$val)=each($waArr))    {
02579                                         $index = $val['free'];
02580                                         $gifCreator->setup[$index] = 'WORKAREA';
02581                                         $workArea[2] = $dConf[$key][2] ? $dConf[$key][2] : $dConf[$key][0];
02582                                         $workArea[3] = $dConf[$key][3] ? $dConf[$key][3] : $dConf[$key][1];
02583 
02584                                         $gifCreator->setup[$index.'.']['set'] = implode(',',$workArea);
02585                                         $workArea[0]+=$dConf[$key][0];
02586                                         $workArea[1]+=$dConf[$key][1];
02587                                 }
02588 
02589                                 if ($this->mconf['debugRenumberedObject'])      {echo '<h3>Renumbered GIFBUILDER object:</h3>'; debug($gifCreator->setup);}
02590 
02591                                 $gifCreator->createTempSubDir('menu/');
02592                                 $gifFileName = $gifCreator->fileName('menu/');
02593 
02594                                         // Gets the ImageMap from the cache...
02595                                 $imgHash = md5($gifFileName);
02596                                 $imgMap = $this->sys_page->getHash($imgHash, 0);
02597 
02598                                 if ($imgMap && @file_exists($gifFileName))      {               // File exists
02599                                         $info = @getimagesize($gifFileName);
02600                                         $w=$info[0];
02601                                         $h=$info[1];
02602                                 } else {                // file is generated
02603                                         $gifCreator->make();
02604                                         $w=$gifCreator->w;
02605                                         $h=$gifCreator->h;
02606                                         $gifCreator->output($gifFileName);
02607                                         $gifCreator->destroy();
02608                                         $imgMap=$gifCreator->map;
02609                                         $this->sys_page->storeHash($imgHash, $imgMap, 'MENU IMAGEMAP');
02610                                 }
02611                                 $imgMap.=$this->mconf['imgMapExtras'];
02612 
02613                                 $gifFileName = t3lib_div::png_to_gif_by_imagemagick($gifFileName);
02614                                 $this->result = Array('output_file'=>$gifFileName, 'output_w'=>$w, 'output_h'=>$h, 'imgMap'=>$imgMap);
02615                         }
02616                 }
02617         }
02618 
02625         function writeMenu()    {
02626                 if ($this->result)      {
02627                         $res = &$this->result;
02628                         $menuName = 'menu_'.t3lib_div::shortMD5($res['imgMap']);        // shortMD5 260900
02629                         $result = '<img src="'.$GLOBALS['TSFE']->absRefPrefix.$res['output_file'].'" width="'.$res['output_w'].'" height="'.$res['output_h'].'" usemap="#'.$menuName.'" border="0" '.$this->mconf['params'];
02630                         if (!strstr($result,'alt="'))   $result.=' alt="Menu Image Map"';       // Adding alt attribute if not set.
02631                         $result.= ' /><map name="'.$menuName.'" id="'.$menuName.'">'.$res['imgMap'].'</map>';
02632 
02633                         $GLOBALS['TSFE']->imagesOnPage[]=$res['output_file'];
02634 
02635                         return $this->tmpl->wrap($result,$this->mconf['wrap']);
02636                 }
02637         }
02638 }
02639 
02640 
02641 
02642 
02643 
02644 
02645 
02646 
02647 
02648 
02649 
02650 
02651 
02652 
02653 
02654 
02655 
02656 
02657 
02658 
02659 
02668 class tslib_jsmenu extends tslib_menu {
02669 
02675         function generate()     {
02676         }
02677 
02683         function writeMenu()    {
02684                 if ($this->id)  {
02685                                 // Making levels:
02686                         $levels = t3lib_div::intInRange($this->mconf['levels'],1,5);
02687                         $this->levels = $levels;
02688                         $this->JSVarName='eid';
02689                         $this->JSMenuName= $this->mconf['menuName'] ? $this->mconf['menuName'] : 'JSmenu';
02690 
02691                         $JScode="\n var ".$this->JSMenuName." = new JSmenu(".$levels.",'".$this->JSMenuName."Form');";
02692 
02693                         for ($a=1;$a<=$levels;$a++)     {
02694                                 $JScode.="\n var ".$this->JSVarName.$a."=0;";
02695                         }
02696                         $JScode.= $this->generate_level($levels,1,$this->id,$this->menuArr,$this->MP_array)."\n";
02697 
02698                         $GLOBALS['TSFE']->additionalHeaderData['JSMenuCode']='<script type="text/javascript" src="'.$GLOBALS['TSFE']->absRefPrefix.'t3lib/jsfunc.menu.js"></script>';
02699                         $GLOBALS['TSFE']->JSCode.=$JScode;
02700 
02701                                 // Printing:
02702                         $allFormCode="";
02703                         for ($a=1;$a<=$this->levels;$a++)       {
02704                                 $formCode='';
02705                                 $levelConf = $this->mconf[$a.'.'];
02706                                 $length = $levelConf['width'] ? $levelConf['width'] : 14;
02707                                 $lenghtStr='';
02708                                 for ($b=0;$b<$length;$b++)      {
02709                                         $lenghtStr.='_';
02710                                 }
02711                                 $height = $levelConf['elements'] ? $levelConf['elements'] : 5;
02712 
02713                                 $formCode.= '<select name="selector'.$a.'" onchange="'.$this->JSMenuName.'.act('.$a.');"'.($levelConf['additionalParams']?' '.$levelConf['additionalParams']:'').'>';
02714                                 for ($b=0;$b<$height;$b++)      {
02715                                         $formCode.= '<option value="0">';
02716                                         if ($b==0)      {
02717                                                 $formCode.= $lenghtStr;
02718                                         }
02719                                         $formCode.='</option>';
02720                                 }
02721                                 $formCode.= '</select>';
02722                                 $allFormCode.=$this->tmpl->wrap($formCode,$levelConf['wrap']);
02723                         }
02724                         $formCode = $this->tmpl->wrap($allFormCode,$this->mconf['wrap']);
02725 
02726                         $formCode= '<form action="" method="post" style="margin: 0 0 0 0;" name="'.$this->JSMenuName.'Form">'.$formCode.'</form>';
02727                         $formCode.='<script type="text/javascript"> /*<![CDATA[*/ '.$this->JSMenuName.'.writeOut(1,'.$this->JSMenuName.'.openID,1); /*]]>*/ </script>';
02728                         return $this->tmpl->wrap($formCode,$this->mconf['wrapAfterTags']);
02729                 }
02730         }
02731 
02744         function generate_level($levels,$count,$pid,$menuItemArray='',$MP_array=array())        {
02745                 $levelConf = $this->mconf[$count.'.'];
02746 
02747                         // Translate PID to a mount page, if any:
02748                 $mount_info = $this->sys_page->getMountPointInfo($pid);
02749                 if (is_array($mount_info))      {
02750                         $MP_array[] = $mount_info['MPvar'];
02751                         $pid = $mount_info['mount_pid'];
02752                 }
02753 
02754                         // Set "&MP=" var:
02755                 $MP_var = implode(',',$MP_array);
02756                 $MP_params = $MP_var ? '&MP='.rawurlencode($MP_var) : '';
02757 
02758                         // UIDs to ban:
02759                 $banUidArray = $this->getBannedUids();
02760 
02761                         // Initializing variables:
02762                 $var = $this->JSVarName;
02763                 $menuName = $this->JSMenuName;
02764                 $parent = $count==1 ? 0 : $var.($count-1);
02765                 $prev=0;
02766                 $c=0;
02767 
02768                 $menuItems = is_array($menuItemArray) ? $menuItemArray : $this->sys_page->getMenu($pid);
02769                 foreach($menuItems as $uid => $data)    {
02770                         $spacer = (t3lib_div::inList($this->spacerIDList,$data['doktype'])?1:0);                // if item is a spacer, $spacer is set
02771                         if ($this->mconf['SPC'] || !$spacer)    {       // If the spacer-function is not enabled, spacers will not enter the $menuArr
02772                                 if (!t3lib_div::inList($this->doktypeExcludeList,$data['doktype']) && (!$data['nav_hide'] || $this->conf['includeNotInMenu']) && !t3lib_div::inArray($banUidArray,$uid))        {               // Page may not be 'not_in_menu' or 'Backend User Section' + not in banned uid's
02773                                         if ($count<$levels)     {
02774                                                 $addLines = $this->generate_level($levels,$count+1,$data['uid'],'',$MP_array);
02775                                         } else {
02776                                                 $addLines = '';
02777                                         }
02778                                         $title=$data['title'];
02779                                         $url='';
02780                                         $target='';
02781                                         if ((!$addLines && !$levelConf['noLink']) || $levelConf['alwaysLink']) {
02782                                                 $LD = $this->tmpl->linkData($data,$this->mconf['target'],'','',array(),$MP_params,$this->mconf['forceTypeValue']);
02783 
02784                                                         // If access restricted pages should be shown in menus, change the link of such pages to link to a redirection page:
02785                                                 $this->changeLinksForAccessRestrictedPages($LD, $data, $this->mconf['target'], $this->mconf['forceTypeValue']);
02786 
02787                                                 $url = $LD['totalURL'];
02788                                                 $target = $LD['target'];
02789                                         }
02790                                         $codeLines.="\n".$var.$count."=".$menuName.".add(".$parent.",".$prev.",0,".t3lib_div::quoteJSvalue($title, true).",".t3lib_div::quoteJSvalue($GLOBALS['TSFE']->baseUrlWrap($url), true).",".t3lib_div::quoteJSvalue($target, true).");";
02791                                                 // If the active one should be chosen...
02792                                         $active = ($levelConf['showActive'] && $data['uid'] == $this->tmpl->rootLine[$count]['uid']);
02793                                                 // If the first item should be shown
02794                                         $first = (!$c && $levelConf['showFirst']);
02795                                                 // do it...
02796                                         if ($active || $first)  {
02797                                                 if ($count==1)  {
02798                                                         $codeLines.="\n".$menuName.".openID = ".$var.$count.";";
02799                                                 } else {
02800                                                         $codeLines.="\n".$menuName.".entry[".$parent."].openID = ".$var.$count.";";
02801                                                 }
02802                                         }
02803                                                 // Add submenu...
02804                                         $codeLines.=$addLines;
02805 
02806                                         $prev=$var.$count;
02807                                         $c++;
02808                                 }
02809                         }
02810                 }
02811                 if ($this->mconf['firstLabelGeneral'] && !$levelConf['firstLabel'])     {
02812                         $levelConf['firstLabel'] = $this->mconf['firstLabelGeneral'];
02813                 }
02814                 if ($levelConf['firstLabel'] && $codeLines)     {
02815                         $codeLines.= chr(10).$menuName.'.defTopTitle['.$count.'] = '.t3lib_div::quoteJSvalue($levelConf['firstLabel'], true).';';
02816                 }
02817                 return $codeLines;
02818         }
02819 }
02820 
02821 
02822 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_menu.php'])      {
02823         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_menu.php']);
02824 }
02825 
02826 ?>


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