Documentation TYPO3 par Ameos |
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 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->menuArr[$key]['_ADD_GETVARS'], $typeOverride); 01173 } 01174 01175 // Manipulation in case of access restricted pages: 01176 $this->changeLinksForAccessRestrictedPages($LD,$this->menuArr[$key],$mainTarget,$typeOverride); 01177 01178 // Overriding URL / Target if set to do so: 01179 if ($this->menuArr[$key]['_OVERRIDE_HREF']) { 01180 $LD['totalURL'] = $this->menuArr[$key]['_OVERRIDE_HREF']; 01181 if ($this->menuArr[$key]['_OVERRIDE_TARGET']) $LD['target'] = $this->menuArr[$key]['_OVERRIDE_TARGET']; 01182 } 01183 01184 // OnClick open in windows. 01185 $onClick=''; 01186 if ($this->mconf['JSWindow']) { 01187 $conf=$this->mconf['JSWindow.']; 01188 $url=$LD['totalURL']; 01189 $LD['totalURL'] = '#'; 01190 $onClick= 'openPic(\''.$GLOBALS['TSFE']->baseUrlWrap($url).'\',\''.($conf['newWindow']?md5($url):'theNewPage').'\',\''.$conf['params'].'\'); return false;'; 01191 $GLOBALS['TSFE']->setJS('openPic'); 01192 } 01193 01194 // out: 01195 $list = array(); 01196 $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. 01197 $list['TARGET'] = $LD['target']; 01198 $list['onClick'] = $onClick; 01199 01200 return $list; 01201 } 01202 01212 function changeLinksForAccessRestrictedPages(&$LD, $page, $mainTarget, $typeOverride) { 01213 01214 // If access restricted pages should be shown in menus, change the link of such pages to link to a redirection page: 01215 if ($this->mconf['showAccessRestrictedPages'] && $this->mconf['showAccessRestrictedPages']!=='NONE' && !$GLOBALS['TSFE']->checkPageGroupAccess($page)) { 01216 $thePage = $this->sys_page->getPage($this->mconf['showAccessRestrictedPages']); 01217 01218 $addParams = $this->mconf['showAccessRestrictedPages.']['addParams']; 01219 $addParams = str_replace('###RETURN_URL###',rawurlencode($LD['totalURL']),$addParams); 01220 $addParams = str_replace('###PAGE_ID###',$page['uid'],$addParams); 01221 $LD = $this->tmpl->linkData($thePage,$mainTarget,'','','', $addParams, $typeOverride); 01222 } 01223 } 01224 01233 function subMenu($uid, $objSuffix='') { 01234 01235 // Setting alternative menu item array if _SUB_MENU has been defined in the current ->menuArr 01236 $altArray = ''; 01237 if (is_array($this->menuArr[$this->I['key']]['_SUB_MENU']) && count($this->menuArr[$this->I['key']]['_SUB_MENU'])) { 01238 $altArray = $this->menuArr[$this->I['key']]['_SUB_MENU']; 01239 } 01240 01241 // Make submenu if the page is the next active 01242 $cls = strtolower($this->conf[($this->menuNumber+1).$objSuffix]); 01243 $subLevelClass = ($cls && t3lib_div::inList($this->tmpl->menuclasses,$cls)) ? $cls : ''; 01244 01245 if ($subLevelClass && ($this->mconf['expAll'] || $this->isNext($uid, $this->getMPvar($this->I['key'])) || is_array($altArray)) && !$this->mconf['sectionIndex']) { 01246 $submenu = t3lib_div::makeInstance('tslib_'.$subLevelClass); 01247 $submenu->entryLevel = $this->entryLevel+1; 01248 $submenu->rL_uidRegister = $this->rL_uidRegister; 01249 $submenu->MP_array = $this->MP_array; 01250 if ($this->menuArr[$this->I['key']]['_MP_PARAM']) { 01251 $submenu->MP_array[] = $this->menuArr[$this->I['key']]['_MP_PARAM']; 01252 } 01253 01254 // especially scripts that build the submenu needs the parent data 01255 $submenu->parentMenuArr = $this->menuArr; 01256 01257 // Setting alternativeMenuTempArray (will be effective only if an array) 01258 if (is_array($altArray)) { 01259 $submenu->alternativeMenuTempArray = $altArray; 01260 } 01261 01262 if ($submenu->start($this->tmpl, $this->sys_page, $uid, $this->conf, $this->menuNumber+1, $objSuffix)) { 01263 $submenu->makeMenu(); 01264 return $submenu->writeMenu(); 01265 } 01266 } 01267 } 01268 01278 function isNext($uid, $MPvar='') { 01279 01280 // Check for always active PIDs: 01281 if (count($this->alwaysActivePIDlist) && in_array($uid,$this->alwaysActivePIDlist)) { 01282 return TRUE; 01283 } 01284 01285 $testUid = $uid.($MPvar?':'.$MPvar:''); 01286 if ($uid && $testUid==$this->nextActive) { 01287 return TRUE; 01288 } 01289 } 01290 01299 function isActive($uid, $MPvar='') { 01300 01301 // Check for always active PIDs: 01302 if (count($this->alwaysActivePIDlist) && in_array($uid,$this->alwaysActivePIDlist)) { 01303 return TRUE; 01304 } 01305 01306 $testUid = $uid.($MPvar?':'.$MPvar:''); 01307 if ($uid && in_array('ITEM:'.$testUid, $this->rL_uidRegister)) { 01308 return TRUE; 01309 } 01310 } 01311 01320 function isCurrent($uid, $MPvar='') { 01321 $testUid = $uid.($MPvar?':'.$MPvar:''); 01322 if ($uid && !strcmp(end($this->rL_uidRegister),'ITEM:'.$testUid)) { 01323 return TRUE; 01324 } 01325 } 01326 01335 function isSubMenu($uid) { 01336 01337 // 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; 01338 $mount_info = $this->sys_page->getMountPointInfo($uid); 01339 if (is_array($mount_info)) { 01340 $uid = $mount_info['mount_pid']; 01341 } 01342 01343 $recs = $this->sys_page->getMenu($uid,'uid,pid,doktype,mount_pid,mount_pid_ol,nav_hide'); 01344 foreach($recs as $theRec) { 01345 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!) 01346 return TRUE; 01347 } 01348 } 01349 } 01350 01360 function isItemState($kind,$key) { 01361 $natVal=0; 01362 if ($this->menuArr[$key]['ITEM_STATE']) { // If any value is set for ITEM_STATE the normal evaluation is discarded 01363 if (!strcmp($this->menuArr[$key]['ITEM_STATE'],$kind)) {$natVal=1;} 01364 } else { 01365 switch($kind) { 01366 case 'SPC': 01367 $natVal = $this->menuArr[$key]['isSpacer']; 01368 break; 01369 case 'IFSUB': 01370 $natVal = $this->isSubMenu($this->menuArr[$key]['uid']); 01371 break; 01372 case 'ACT': 01373 $natVal = $this->isActive($this->menuArr[$key]['uid'], $this->getMPvar($key)); 01374 break; 01375 case 'ACTIFSUB': 01376 $natVal = $this->isActive($this->menuArr[$key]['uid'], $this->getMPvar($key)) && $this->isSubMenu($this->menuArr[$key]['uid']); 01377 break; 01378 case 'CUR': 01379 $natVal = $this->isCurrent($this->menuArr[$key]['uid'], $this->getMPvar($key)); 01380 break; 01381 case 'CURIFSUB': 01382 $natVal = $this->isCurrent($this->menuArr[$key]['uid'], $this->getMPvar($key)) && $this->isSubMenu($this->menuArr[$key]['uid']); 01383 break; 01384 case 'USR': 01385 $natVal = $this->menuArr[$key]['fe_group']; 01386 break; 01387 } 01388 } 01389 01390 return $natVal; 01391 } 01392 01400 function accessKey($title) { 01401 // The global array ACCESSKEY is used to globally control if letters are already used!! 01402 $result = Array(); 01403 01404 $titleLen = strlen($title); 01405 for ($a=0;$a<$titleLen;$a++) { 01406 $key = strtoupper(trim(substr($title,$a,1))); 01407 if (preg_match('/[a-zA-Z]/', $key) && !isset($GLOBALS['TSFE']->accessKey[$key])) { 01408 $GLOBALS['TSFE']->accessKey[$key]=1; 01409 $result['code'] = ' accesskey="'.$key.'"'; 01410 $result['alt'] = ' (ALT+'.$key.')'; 01411 break; 01412 } 01413 } 01414 return $result; 01415 } 01416 01426 function userProcess($mConfKey,$passVar) { 01427 if ($this->mconf[$mConfKey]) { 01428 $funcConf = $this->mconf[$mConfKey.'.']; 01429 $funcConf['parentObj']=&$this; 01430 $passVar = $GLOBALS['TSFE']->cObj->callUserFunction($this->mconf[$mConfKey], $funcConf, $passVar); 01431 } 01432 return $passVar; 01433 } 01434 01441 function setATagParts() { 01442 $this->I['A1'] = '<a '.t3lib_div::implodeAttributes($this->I['linkHREF'],1).$this->I['val']['ATagParams'].$this->I['addATagParams'].$this->I['accessKey']['code'].'>'; 01443 $this->I['A2'] = '</a>'; 01444 } 01445 01454 function getPageTitle($title,$nav_title) { 01455 return strcmp(trim($nav_title),'') ? $nav_title : $title; 01456 } 01457 01466 function getMPvar($key) { 01467 if ($GLOBALS['TYPO3_CONF_VARS']['FE']['enable_mount_pids']) { 01468 $localMP_array = $this->MP_array; 01469 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! 01470 $MP_params = count($localMP_array) ? implode(',',$localMP_array) : ''; 01471 return $MP_params; 01472 } 01473 } 01474 01481 function getDoktypeExcludeWhere() { 01482 return $this->doktypeExcludeList ? ' AND pages.doktype NOT IN ('.$this->doktypeExcludeList.')' : ''; 01483 } 01484 01491 function getBannedUids() { 01492 $banUidArray = array(); 01493 01494 if (trim($this->conf['excludeUidList'])) { 01495 $banUidList = str_replace('current', $GLOBALS['TSFE']->page['uid'], $this->conf['excludeUidList']); 01496 $banUidArray = t3lib_div::intExplode(',', $banUidList); 01497 } 01498 01499 return $banUidArray; 01500 } 01501 01502 } 01503 01504 01505 01506 01507 01508 01509 01510 01511 01512 01513 01514 01515 01516 01517 01518 01519 01520 01521 01530 class tslib_tmenu extends tslib_menu { 01531 01539 function generate() { 01540 $splitCount = count($this->menuArr); 01541 if ($splitCount) { 01542 list($NOconf) = $this->procesItemStates($splitCount); 01543 } 01544 if ($this->mconf['debugItemConf']) {echo '<h3>$NOconf:</h3>'; debug($NOconf); } 01545 $this->result = $NOconf; 01546 } 01547 01555 function writeMenu() { 01556 if (is_array($this->result) && count($this->result)) { 01557 $this->WMcObj =t3lib_div::makeInstance('tslib_cObj'); // Create new tslib_cObj for our use 01558 $this->WMresult=''; 01559 $this->INPfixMD5 = substr(md5(microtime().'tmenu'),0,4); 01560 $this->WMmenuItems = count($this->result); 01561 01562 $this->WMsubmenuObjSuffixes = $this->tmpl->splitConfArray(array('sOSuffix'=>$this->mconf['submenuObjSuffixes']),$this->WMmenuItems); 01563 01564 $this->extProc_init(); 01565 reset($this->result); 01566 while (list($key,$val)=each($this->result)) { 01567 $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']++; 01568 $GLOBALS['TSFE']->register['count_MENUOBJ']++; 01569 01570 $this->I=array(); 01571 $this->WMcObj->start($this->menuArr[$key],'pages'); // Initialize the cObj with the page record of the menu item 01572 $this->I['key'] = $key; 01573 $this->I['INPfix']= $this->imgNameNotRandom?'':'_'.$this->INPfixMD5.'_'.$key; 01574 $this->I['val'] = $val; 01575 $this->I['title'] = $this->WMcObj->stdWrap($this->getPageTitle($this->menuArr[$key]['title'],$this->menuArr[$key]['nav_title']),$this->I['val']['stdWrap.']); 01576 $this->I['uid'] = $this->menuArr[$key]['uid']; 01577 $this->I['mount_pid'] = $this->menuArr[$key]['mount_pid']; 01578 $this->I['pid'] = $this->menuArr[$key]['pid']; 01579 $this->I['spacer'] = $this->menuArr[$key]['isSpacer']; 01580 01581 // Make link tag 01582 $this->I['val']['ATagParams'] = $this->WMcObj->getATagParams($this->I['val'], 0); 01583 $this->I['linkHREF'] = $this->link($key,$this->I['val']['altTarget'],$this->mconf['forceTypeValue']); 01584 01585 // Title attribute of links: 01586 $titleAttrValue = $this->WMcObj->stdWrap($this->I['val']['ATagTitle'],$this->I['val']['ATagTitle.']); 01587 if (strlen($titleAttrValue)) { 01588 $this->I['linkHREF']['title'] = $titleAttrValue; 01589 } 01590 01591 // Setting "blurlink()" function: 01592 if (!$this->mconf['noBlur']) { 01593 $this->I['linkHREF']['onFocus']='blurLink(this);'; 01594 } 01595 01596 // Make link: 01597 if ($this->I['val']['RO']) { 01598 $this->I['theName'] = $this->imgNamePrefix.$this->I['uid'].$this->I['INPfix']; 01599 $over=''; 01600 $out =''; 01601 if ($this->I['val']['beforeROImg']) { 01602 $over.= $this->WMfreezePrefix."over('".$this->I['theName']."before');"; 01603 $out.= $this->WMfreezePrefix."out('".$this->I['theName']."before');"; 01604 } 01605 if ($this->I['val']['afterROImg']) { 01606 $over.= $this->WMfreezePrefix."over('".$this->I['theName']."after');"; 01607 $out.= $this->WMfreezePrefix."out('".$this->I['theName']."after');"; 01608 } 01609 $this->I['linkHREF']['onMouseover']=$over; 01610 $this->I['linkHREF']['onMouseout']=$out; 01611 if ($over || $out) $GLOBALS['TSFE']->setJS('mouseOver'); 01612 01613 // Change background color: 01614 if ($this->I['val']['RO_chBgColor']) { 01615 $this->addJScolorShiftFunction(); 01616 $chBgP = t3lib_div::trimExplode('|',$this->I['val']['RO_chBgColor']); 01617 $this->I['linkHREF']['onMouseover'].="changeBGcolor('".$chBgP[2].$this->I['uid']."','".$chBgP[0]."');"; 01618 $this->I['linkHREF']['onMouseout'].="changeBGcolor('".$chBgP[2].$this->I['uid']."','".$chBgP[1]."');"; 01619 } 01620 01621 $this->extProc_RO($key); 01622 } 01623 01624 01625 // Calling extra processing function 01626 $this->extProc_beforeLinking($key); 01627 01628 // Compile link tag 01629 if (!$this->I['val']['doNotLinkIt']) {$this->I['val']['doNotLinkIt']=0;} 01630 if (!$this->I['spacer'] && $this->I['val']['doNotLinkIt']!=1) { 01631 $this->setATagParts(); 01632 } else { 01633 $this->I['A1'] = ''; 01634 $this->I['A2'] = ''; 01635 } 01636 01637 // ATAGBeforeWrap processing: 01638 if ($this->I['val']['ATagBeforeWrap']) { 01639 $wrapPartsBefore = explode('|',$this->I['val']['linkWrap']); 01640 $wrapPartsAfter = array('',''); 01641 } else { 01642 $wrapPartsBefore = array('',''); 01643 $wrapPartsAfter = explode('|',$this->I['val']['linkWrap']); 01644 } 01645 if ($this->I['val']['stdWrap2'] || isset($this->I['val']['stdWrap2.'])) { 01646 $wrapPartsStdWrap = explode($this->I['val']['stdWrap2']?$this->I['val']['stdWrap2']:'|',$this->WMcObj->stdWrap('|',$this->I['val']['stdWrap2.'])); 01647 } else {$wrapPartsStdWrap = array('','');} 01648 01649 // Make before, middle and after parts 01650 $this->I['parts'] = array(); 01651 $this->I['parts']['before']=$this->getBeforeAfter('before'); 01652 $this->I['parts']['stdWrap2_begin']=$wrapPartsStdWrap[0]; 01653 if (!$this->I['val']['doNotShowLink']) { 01654 $this->I['parts']['notATagBeforeWrap_begin'] = $wrapPartsAfter[0]; 01655 $this->I['parts']['ATag_begin'] = $this->I['A1']; 01656 $this->I['parts']['ATagBeforeWrap_begin'] = $wrapPartsBefore[0]; 01657 $this->I['parts']['title'] = $this->I['title']; 01658 $this->I['parts']['ATagBeforeWrap_end'] = $wrapPartsBefore[1]; 01659 $this->I['parts']['ATag_end'] = $this->I['A2']; 01660 $this->I['parts']['notATagBeforeWrap_end'] = $wrapPartsAfter[1]; 01661 } 01662 $this->I['parts']['stdWrap2_end']=$wrapPartsStdWrap[1]; 01663 $this->I['parts']['after']=$this->getBeforeAfter('after'); 01664 01665 // Passing I to a user function 01666 if ($this->mconf['IProcFunc']) { 01667 $this->I = $this->userProcess('IProcFunc',$this->I); 01668 } 01669 01670 // Merge parts + beforeAllWrap 01671 $this->I['theItem']= implode('',$this->I['parts']); 01672 $this->I['theItem']= $this->extProc_beforeAllWrap($this->I['theItem'],$key); 01673 01674 // allWrap: 01675 $allWrap = $this->WMcObj->stdWrap($this->I['val']['allWrap'],$this->I['val']['allWrap.']); 01676 $this->I['theItem'] = $this->tmpl->wrap($this->I['theItem'],$allWrap); 01677 01678 if ($this->I['val']['subst_elementUid']) $this->I['theItem'] = str_replace('{elementUid}',$this->I['uid'],$this->I['theItem']); 01679 01680 // allStdWrap: 01681 if (is_array($this->I['val']['allStdWrap.'])) { 01682 $this->I['theItem'] = $this->WMcObj->stdWrap($this->I['theItem'],$this->I['val']['allStdWrap.']); 01683 } 01684 01685 // Calling extra processing function 01686 $this->extProc_afterLinking($key); 01687 } 01688 return $this->extProc_finish(); 01689 } 01690 } 01691 01699 function getBeforeAfter($pref) { 01700 $res = ''; 01701 if ($imgInfo = $this->WMcObj->getImgResource($this->I['val'][$pref.'Img'],$this->I['val'][$pref.'Img.'])) { 01702 $imgInfo[3] = t3lib_div::png_to_gif_by_imagemagick($imgInfo[3]); 01703 if ($this->I['val']['RO'] && $this->I['val'][$pref.'ROImg'] && !$this->I['spacer']) { 01704 $imgROInfo = $this->WMcObj->getImgResource($this->I['val'][$pref.'ROImg'],$this->I['val'][$pref.'ROImg.']); 01705 $imgROInfo[3] = t3lib_div::png_to_gif_by_imagemagick($imgROInfo[3]); 01706 if ($imgROInfo) { 01707 $theName = $this->imgNamePrefix.$this->I['uid'].$this->I['INPfix'].$pref; 01708 $name = ' '.$this->nameAttribute.'="'.$theName.'"'; 01709 $GLOBALS['TSFE']->JSImgCode.= chr(10).$theName.'_n=new Image(); '.$theName.'_n.src = "'.$GLOBALS['TSFE']->absRefPrefix.$imgInfo[3].'"; '; 01710 $GLOBALS['TSFE']->JSImgCode.= chr(10).$theName.'_h=new Image(); '.$theName.'_h.src = "'.$GLOBALS['TSFE']->absRefPrefix.$imgROInfo[3].'"; '; 01711 } 01712 } 01713 $GLOBALS['TSFE']->imagesOnPage[]=$imgInfo[3]; 01714 $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"'); 01715 if (!strstr($res,'alt="')) $res.=' alt=""'; // Adding alt attribute if not set. 01716 $res.=' />'; 01717 if ($this->I['val'][$pref.'ImgLink']) {$res=$this->I['A1'].$res.$this->I['A2'];} 01718 } 01719 return $this->tmpl->wrap($res.$this->WMcObj->stdWrap($this->I['val'][$pref],$this->I['val'][$pref.'.']), $this->I['val'][$pref.'Wrap']); 01720 } 01721 01729 function addJScolorShiftFunction() { 01730 $GLOBALS['TSFE']->additionalJavaScript['TMENU:changeBGcolor()']=' 01731 function changeBGcolor(id,color) { // 01732 if (document.getElementById && document.getElementById(id)) { 01733 document.getElementById(id).style.background = color; 01734 return true; 01735 } else if (document.layers && document.layers[id]) { 01736 document.layers[id].bgColor = color; 01737 return true; 01738 } 01739 } 01740 '; 01741 } 01742 01751 function extProc_init() { 01752 } 01753 01762 function extProc_RO($key) { 01763 } 01764 01773 function extProc_beforeLinking($key) { 01774 } 01775 01785 function extProc_afterLinking($key) { 01786 // Add part to the accumulated result + fetch submenus 01787 if (!$this->I['spacer']) { 01788 $this->I['theItem'].= $this->subMenu($this->I['uid'], $this->WMsubmenuObjSuffixes[$key]['sOSuffix']); 01789 } 01790 $this->WMresult.= $this->I['val']['wrapItemAndSub'] ? $this->tmpl->wrap($this->I['theItem'],$this->I['val']['wrapItemAndSub']) : $this->I['theItem']; 01791 } 01792 01802 function extProc_beforeAllWrap($item,$key) { 01803 return $item; 01804 } 01805 01813 function extProc_finish() { 01814 return $this->tmpl->wrap($this->WMresult,$this->mconf['wrap']).$this->WMextraScript; 01815 } 01816 } 01817 01818 01819 01820 01821 01822 01823 01824 01825 01826 01827 01828 01829 01830 01831 01832 01833 01834 01835 01836 01837 01838 01839 01840 01849 class tslib_gmenu extends tslib_menu { 01850 01858 function generate() { 01859 $splitCount = count($this->menuArr); 01860 if ($splitCount) { 01861 list($NOconf,$ROconf) = $this->procesItemStates($splitCount); 01862 01863 //store initial count value 01864 $temp_HMENU_MENUOBJ = $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']; 01865 $temp_MENUOBJ = $GLOBALS['TSFE']->register['count_MENUOBJ']; 01866 // Now we generate the giffiles: 01867 $this->makeGifs($NOconf,'NO'); 01868 // store count from NO obj 01869 $tempcnt_HMENU_MENUOBJ = $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']; 01870 $tempcnt_MENUOBJ = $GLOBALS['TSFE']->register['count_MENUOBJ']; 01871 01872 if ($this->mconf['debugItemConf']) {echo '<h3>$NOconf:</h3>'; debug($NOconf); } 01873 if ($ROconf) { // RollOver 01874 //start recount for rollover with initial values 01875 $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']= $temp_HMENU_MENUOBJ; 01876 $GLOBALS['TSFE']->register['count_MENUOBJ']= $temp_MENUOBJ; 01877 $this->makeGifs($ROconf,'RO'); 01878 if ($this->mconf['debugItemConf']) {echo '<h3>$ROconf:</h3>'; debug($ROconf); } 01879 } 01880 // use count from NO obj 01881 $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'] = $tempcnt_HMENU_MENUOBJ; 01882 $GLOBALS['TSFE']->register['count_MENUOBJ'] = $tempcnt_MENUOBJ; 01883 } 01884 } 01885 01896 function makeGifs($conf, $resKey) { 01897 $isGD = $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib']; 01898 01899 if (!is_array($conf)) { 01900 $conf = Array(); 01901 } 01902 01903 $totalWH=array(); 01904 $items = count($conf); 01905 if ($isGD) { 01906 // generate the gif-files. the $menuArr is filled with some values like output_w, output_h, output_file 01907 $Hcounter = 0; 01908 $Wcounter = 0; 01909 $Hobjs = $this->mconf['applyTotalH']; 01910 if ($Hobjs) {$Hobjs = t3lib_div::intExplode(',',$Hobjs);} 01911 $Wobjs = $this->mconf['applyTotalW']; 01912 if ($Wobjs) {$Wobjs = t3lib_div::intExplode(',',$Wobjs);} 01913 $minDim = $this->mconf['min']; 01914 if ($minDim) {$minDim = tslib_cObj::calcIntExplode(',',$minDim.',');} 01915 $maxDim = $this->mconf['max']; 01916 if ($maxDim) {$maxDim = tslib_cObj::calcIntExplode(',',$maxDim.',');} 01917 01918 if ($minDim) { 01919 $conf[$items]=$conf[$items-1]; 01920 $this->menuArr[$items]=Array(); 01921 $items = count($conf); 01922 } 01923 01924 // TOTAL width 01925 if ($this->mconf['useLargestItemX'] || $this->mconf['useLargestItemY'] || $this->mconf['distributeX'] || $this->mconf['distributeY']) { 01926 $totalWH = $this->findLargestDims($conf,$items,$Hobjs,$Wobjs,$minDim,$maxDim); 01927 } 01928 } 01929 01930 $c=0; 01931 $maxFlag=0; 01932 $distributeAccu=array('H'=>0,'W'=>0); 01933 reset($conf); 01934 while (list($key,$val)=each($conf)) { 01935 $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']++; 01936 $GLOBALS['TSFE']->register['count_MENUOBJ']++; 01937 01938 if ($items==($c+1) && $minDim) { 01939 $Lobjs = $this->mconf['removeObjectsOfDummy']; 01940 if ($Lobjs) { 01941 $Lobjs = t3lib_div::intExplode(',',$Lobjs); 01942 reset($Lobjs); 01943 while(list(,$remItem)=each($Lobjs)) { 01944 unset($val[$remItem]); 01945 unset($val[$remItem.'.']); 01946 } 01947 } 01948 01949 $flag =0; 01950 $tempXY = explode(',',$val['XY']); 01951 if ($Wcounter<$minDim[0]) {$tempXY[0]=$minDim[0]-$Wcounter; $flag=1;} 01952 if ($Hcounter<$minDim[1]) {$tempXY[1]=$minDim[1]-$Hcounter; $flag=1;} 01953 $val['XY'] = implode(',',$tempXY); 01954 if (!$flag){break;} 01955 } 01956 $c++; 01957 01958 01959 if ($isGD) { 01960 // Pre-working the item 01961 $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder'); 01962 $gifCreator->init(); 01963 $gifCreator->start($val,$this->menuArr[$key]); 01964 01965 // If useLargestItemH/W is specified 01966 if (count($totalWH) && ($this->mconf['useLargestItemX'] || $this->mconf['useLargestItemY'])) { 01967 $tempXY = explode(',',$gifCreator->setup['XY']); 01968 if ($this->mconf['useLargestItemX']) {$tempXY[0] = max($totalWH['W']);} 01969 if ($this->mconf['useLargestItemY']) {$tempXY[1] = max($totalWH['H']);} 01970 // regenerate the new values... 01971 $val['XY'] = implode(',',$tempXY); 01972 $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder'); 01973 $gifCreator->init(); 01974 $gifCreator->start($val,$this->menuArr[$key]); 01975 } 01976 01977 // If distributeH/W is specified 01978 if (count($totalWH) && ($this->mconf['distributeX'] || $this->mconf['distributeY'])) { 01979 $tempXY = explode(',',$gifCreator->setup['XY']); 01980 01981 if ($this->mconf['distributeX']) { 01982 $diff = $this->mconf['distributeX']-$totalWH['W_total']-$distributeAccu['W']; 01983 $compensate = round($diff /($items-$c+1)); 01984 $distributeAccu['W']+=$compensate; 01985 $tempXY[0] = $totalWH['W'][$key]+$compensate; 01986 } 01987 if ($this->mconf['distributeY']) { 01988 $diff = $this->mconf['distributeY']-$totalWH['H_total']-$distributeAccu['H']; 01989 $compensate = round($diff /($items-$c+1)); 01990 $distributeAccu['H']+=$compensate; 01991 $tempXY[1] = $totalWH['H'][$key]+$compensate; 01992 } 01993 // regenerate the new values... 01994 $val['XY'] = implode(',',$tempXY); 01995 $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder'); 01996 $gifCreator->init(); 01997 $gifCreator->start($val,$this->menuArr[$key]); 01998 } 01999 02000 // If max dimensions are specified 02001 if ($maxDim) { 02002 $tempXY = explode(',',$val['XY']); 02003 if ($maxDim[0] && $Wcounter+$gifCreator->XY[0]>=$maxDim[0]) {$tempXY[0]==$maxDim[0]-$Wcounter; $maxFlag=1;} 02004 if ($maxDim[1] && $Hcounter+$gifCreator->XY[1]>=$maxDim[1]) {$tempXY[1]=$maxDim[1]-$Hcounter; $maxFlag=1;} 02005 if ($maxFlag) { 02006 $val['XY'] = implode(',',$tempXY); 02007 $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder'); 02008 $gifCreator->init(); 02009 $gifCreator->start($val,$this->menuArr[$key]); 02010 } 02011 } 02012 02013 02014 02015 02016 // displace 02017 if ($Hobjs) { 02018 reset($Hobjs); 02019 while(list(,$index)=each($Hobjs)) { 02020 if ($gifCreator->setup[$index] && $gifCreator->setup[$index.'.']) { 02021 $oldOffset = explode(',',$gifCreator->setup[$index.'.']['offset']); 02022 $gifCreator->setup[$index.'.']['offset'] = implode(',',$gifCreator->applyOffset($oldOffset,Array(0,-$Hcounter))); 02023 } 02024 } 02025 } 02026 02027 if ($Wobjs) { 02028 reset($Wobjs); 02029 while(list(,$index)=each($Wobjs)) { 02030 if ($gifCreator->setup[$index] && $gifCreator->setup[$index.'.']) { 02031 $oldOffset = explode(',',$gifCreator->setup[$index.'.']['offset']); 02032 $gifCreator->setup[$index.'.']['offset'] = implode(',',$gifCreator->applyOffset($oldOffset,Array(-$Wcounter,0))); 02033 } 02034 } 02035 } 02036 } 02037 02038 // Finding alternative GIF names if any (by altImgResource) 02039 $gifFileName=''; 02040 if ($conf[$key]['altImgResource'] || is_array($conf[$key]['altImgResource.'])) { 02041 if (!is_object($cObj)) {$cObj=t3lib_div::makeInstance('tslib_cObj');} 02042 $cObj->start($this->menuArr[$key],'pages'); 02043 $altImgInfo = $cObj->getImgResource($conf[$key]['altImgResource'],$conf[$key]['altImgResource.']); 02044 $gifFileName=$altImgInfo[3]; 02045 } 02046 02047 // If an alternative name was NOT given, find the GIFBUILDER name. 02048 if (!$gifFileName && $isGD) { 02049 $gifCreator->createTempSubDir('menu/'); 02050 $gifFileName = $gifCreator->fileName('menu/'); 02051 } 02052 02053 // Generation of image file: 02054 if (@file_exists($gifFileName)) { // File exists 02055 $info = @getimagesize($gifFileName); 02056 $this->result[$resKey][$key]['output_w']=intval($info[0]); 02057 $this->result[$resKey][$key]['output_h']=intval($info[1]); 02058 $this->result[$resKey][$key]['output_file']=$gifFileName; 02059 } elseif ($isGD) { // file is generated 02060 $gifCreator->make(); 02061 $this->result[$resKey][$key]['output_w']=$gifCreator->w; 02062 $this->result[$resKey][$key]['output_h']=$gifCreator->h; 02063 $this->result[$resKey][$key]['output_file'] = $gifFileName; 02064 $gifCreator->output($this->result[$resKey][$key]['output_file']); 02065 $gifCreator->destroy(); 02066 } 02067 $this->result[$resKey][$key]['output_file'] = t3lib_div::png_to_gif_by_imagemagick($this->result[$resKey][$key]['output_file']); 02068 $this->result[$resKey][$key]['noLink']=$conf[$key]['noLink']; 02069 $this->result[$resKey][$key]['altTarget']=$conf[$key]['altTarget']; 02070 $this->result[$resKey][$key]['imgParams']=$conf[$key]['imgParams']; 02071 $this->result[$resKey][$key]['ATagTitle'] = $conf[$key]['ATagTitle']; 02072 $this->result[$resKey][$key]['ATagTitle.'] = $conf[$key]['ATagTitle.']; 02073 $this->result[$resKey][$key]['wrap'] = $conf[$key]['wrap']; 02074 $this->result[$resKey][$key]['allWrap'] = $conf[$key]['allWrap']; 02075 $this->result[$resKey][$key]['allWrap.'] = $conf[$key]['allWrap.']; 02076 $this->result[$resKey][$key]['subst_elementUid'] = $conf[$key]['subst_elementUid']; 02077 $this->result[$resKey][$key]['allStdWrap.'] = $conf[$key]['allStdWrap.']; 02078 02079 $Hcounter+=$this->result[$resKey][$key]['output_h']; // counter is increased 02080 $Wcounter+=$this->result[$resKey][$key]['output_w']; // counter is increased 02081 02082 if ($maxFlag){break;} 02083 } 02084 } 02085 02101 function findLargestDims($conf,$items,$Hobjs,$Wobjs,$minDim,$maxDim) { 02102 $totalWH = array( 02103 'W' => array(), 02104 'H' => array(), 02105 'W_total' => 0, 02106 'H_total' => 0 02107 ); 02108 02109 $Hcounter = 0; 02110 $Wcounter = 0; 02111 $c=0; 02112 $maxFlag=0; 02113 reset($conf); 02114 while (list($key,$val)=each($conf)) { 02115 // SAME CODE AS makeGifs()! BEGIN 02116 if ($items==($c+1) && $minDim) { 02117 $Lobjs = $this->mconf['removeObjectsOfDummy']; 02118 if ($Lobjs) { 02119 $Lobjs = t3lib_div::intExplode(',',$Lobjs); 02120 reset($Lobjs); 02121 while(list(,$remItem)=each($Lobjs)) { 02122 unset($val[$remItem]); 02123 unset($val[$remItem.'.']); 02124 } 02125 } 02126 02127 $flag =0; 02128 $tempXY = explode(',',$val['XY']); 02129 if ($Wcounter<$minDim[0]) {$tempXY[0]=$minDim[0]-$Wcounter; $flag=1;} 02130 if ($Hcounter<$minDim[1]) {$tempXY[1]=$minDim[1]-$Hcounter; $flag=1;} 02131 $val['XY'] = implode(',',$tempXY); 02132 if (!$flag){break;} 02133 } 02134 $c++; 02135 02136 $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder'); 02137 $gifCreator->init(); 02138 $gifCreator->start($val,$this->menuArr[$key]); 02139 if ($maxDim) { 02140 $tempXY = explode(',',$val['XY']); 02141 if ($maxDim[0] && $Wcounter+$gifCreator->XY[0]>=$maxDim[0]) {$tempXY[0]==$maxDim[0]-$Wcounter; $maxFlag=1;} 02142 if ($maxDim[1] && $Hcounter+$gifCreator->XY[1]>=$maxDim[1]) {$tempXY[1]=$maxDim[1]-$Hcounter; $maxFlag=1;} 02143 if ($maxFlag) { 02144 $val['XY'] = implode(',',$tempXY); 02145 $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder'); 02146 $gifCreator->init(); 02147 $gifCreator->start($val,$this->menuArr[$key]); 02148 } 02149 } 02150 // SAME CODE AS makeGifs()! END 02151 02152 // Setting the width/height 02153 $totalWH['W'][$key]=$gifCreator->XY[0]; 02154 $totalWH['H'][$key]=$gifCreator->XY[1]; 02155 $totalWH['W_total']+=$gifCreator->XY[0]; 02156 $totalWH['H_total']+=$gifCreator->XY[1]; 02157 // ---- // 02158 02159 $Hcounter+=$gifCreator->XY[1]; // counter is increased 02160 $Wcounter+=$gifCreator->XY[0]; // counter is increased 02161 02162 if ($maxFlag){break;} 02163 } 02164 return $totalWH; 02165 } 02166 02173 function writeMenu() { 02174 if (is_array($this->menuArr) && is_array($this->result) && count($this->result) && is_array($this->result['NO'])) { 02175 $this->WMcObj = t3lib_div::makeInstance('tslib_cObj'); // Create new tslib_cObj for our use 02176 $this->WMresult=''; 02177 $this->INPfixMD5 = substr(md5(microtime().$this->GMENU_fixKey),0,4); 02178 $this->WMmenuItems = count($this->result['NO']); 02179 02180 $this->WMsubmenuObjSuffixes = $this->tmpl->splitConfArray(array('sOSuffix'=>$this->mconf['submenuObjSuffixes']),$this->WMmenuItems); 02181 02182 $this->extProc_init(); 02183 for ($key=0;$key<$this->WMmenuItems;$key++) { 02184 if ($this->result['NO'][$key]['output_file']) { 02185 $this->WMcObj->start($this->menuArr[$key],'pages'); // Initialize the cObj with the page record of the menu item 02186 02187 $this->I =array(); 02188 $this->I['key'] = $key; 02189 $this->I['INPfix']= $this->imgNameNotRandom?'':'_'.$this->INPfixMD5.'_'.$key; 02190 $this->I['val'] = $this->result['NO'][$key]; 02191 $this->I['title'] = $this->getPageTitle($this->menuArr[$key]['title'],$this->menuArr[$key]['nav_title']); 02192 $this->I['uid'] = $this->menuArr[$key]['uid']; 02193 $this->I['mount_pid'] = $this->menuArr[$key]['mount_pid']; 02194 $this->I['pid'] = $this->menuArr[$key]['pid']; 02195 $this->I['spacer'] = $this->menuArr[$key]['isSpacer']; 02196 if (!$this->I['uid'] && !$this->menuArr[$key]['_OVERRIDE_HREF']) {$this->I['spacer']=1;} 02197 $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 02198 $this->I['name']=''; 02199 02200 // Set access key 02201 if ($this->mconf['accessKey']) { 02202 $this->I['accessKey'] = $this->accessKey($this->I['title']); 02203 } else { 02204 $this->I['accessKey']=Array(); 02205 } 02206 02207 // Get link. 02208 $this->I['linkHREF'] = $this->link($key,$this->I['val']['altTarget'],$this->mconf['forceTypeValue']); 02209 // Title attribute of links: 02210 $titleAttrValue = $this->WMcObj->stdWrap($this->I['val']['ATagTitle'],$this->I['val']['ATagTitle.']).$this->I['accessKey']['alt']; 02211 if (strlen($titleAttrValue)) { 02212 $this->I['linkHREF']['title'] = $titleAttrValue; 02213 } 02214 // Setting "blurlink()" function: 02215 if (!$this->mconf['noBlur']) { 02216 $this->I['linkHREF']['onFocus']='blurLink(this);'; 02217 } 02218 02219 // Set rollover 02220 if ($this->result['RO'][$key] && !$this->I['noLink']) { 02221 $this->I['theName'] = $this->imgNamePrefix.$this->I['uid'].$this->I['INPfix']; 02222 $this->I['name'] = ' '.$this->nameAttribute.'="'.$this->I["theName"].'"'; 02223 $this->I['linkHREF']['onMouseover']=$this->WMfreezePrefix.'over(\''.$this->I['theName'].'\');'; 02224 $this->I['linkHREF']['onMouseout']=$this->WMfreezePrefix.'out(\''.$this->I['theName'].'\');'; 02225 $GLOBALS['TSFE']->JSImgCode.= chr(10).$this->I['theName'].'_n=new Image(); '.$this->I['theName'].'_n.src = "'.$GLOBALS['TSFE']->absRefPrefix.$this->I['val']['output_file'].'"; '; 02226 $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'].'"; '; 02227 $GLOBALS['TSFE']->imagesOnPage[]=$this->result['RO'][$key]['output_file']; 02228 $GLOBALS['TSFE']->setJS('mouseOver'); 02229 $this->extProc_RO($key); 02230 } 02231 02232 // Set altText 02233 $this->I['altText'] = $this->mconf['disableAltText'] ? '' : $this->I['title'].$this->I['accessKey']['alt']; 02234 02235 // Calling extra processing function 02236 $this->extProc_beforeLinking($key); 02237 02238 // Set linking 02239 if (!$this->I['noLink']) { 02240 $this->setATagParts(); 02241 } else { 02242 $this->I['A1'] = ''; 02243 $this->I['A2'] = ''; 02244 } 02245 $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']:'').' />'; 02246 02247 // Make before, middle and after parts 02248 $this->I['parts'] = array(); 02249 $this->I['parts']['ATag_begin'] = $this->I['A1']; 02250 $this->I['parts']['image'] = $this->I['IMG']; 02251 $this->I['parts']['ATag_end'] = $this->I['A2']; 02252 02253 // Passing I to a user function 02254 if ($this->mconf['IProcFunc']) { 02255 $this->I = $this->userProcess('IProcFunc',$this->I); 02256 } 02257 02258 // Putting the item together. 02259 // Merge parts + beforeAllWrap 02260 $this->I['theItem']= implode('',$this->I['parts']); 02261 $this->I['theItem']= $this->extProc_beforeAllWrap($this->I['theItem'],$key); 02262 02263 // wrap: 02264 $this->I['theItem']= $this->tmpl->wrap($this->I['theItem'],$this->I['val']['wrap']); 02265 02266 // allWrap: 02267 $allWrap = $this->WMcObj->stdWrap($this->I['val']['allWrap'],$this->I['val']['allWrap.']); 02268 $this->I['theItem'] = $this->tmpl->wrap($this->I['theItem'],$allWrap); 02269 02270 if ($this->I['val']['subst_elementUid']) $this->I['theItem'] = str_replace('{elementUid}',$this->I['uid'],$this->I['theItem']); 02271 02272 // allStdWrap: 02273 if (is_array($this->I['val']['allStdWrap.'])) { 02274 $this->I['theItem'] = $this->WMcObj->stdWrap($this->I['theItem'],$this->I['val']['allStdWrap.']); 02275 } 02276 02277 $GLOBALS['TSFE']->imagesOnPage[]=$this->I['val']['output_file']; 02278 02279 $this->extProc_afterLinking($key); 02280 } 02281 } 02282 return $this->extProc_finish(); 02283 } 02284 } 02285 02294 function extProc_init() { 02295 } 02296 02305 function extProc_RO($key) { 02306 } 02307 02316 function extProc_beforeLinking($key) { 02317 } 02318 02329 function extProc_afterLinking($key) { 02330 $this->WMresult.=$this->I['theItem']; 02331 if (!$this->I['spacer']) { 02332 $this->WMresult.= $this->subMenu($this->I['uid'], $this->WMsubmenuObjSuffixes[$key]['sOSuffix']); 02333 } 02334 } 02335 02336 02346 function extProc_beforeAllWrap($item,$key) { 02347 return $item; 02348 } 02349 02357 function extProc_finish() { 02358 return $this->tmpl->wrap($this->WMresult,$this->mconf['wrap']).$this->WMextraScript; 02359 } 02360 } 02361 02362 02363 02364 02365 02366 02367 02368 02369 02370 02371 02372 02373 02374 02375 02376 02377 02378 02379 02380 02381 02382 02391 class tslib_imgmenu extends tslib_menu { 02392 02400 function generate() { 02401 $splitCount = count($this->menuArr); 02402 if ($splitCount) { 02403 list($NOconf) = $this->procesItemStates($splitCount); 02404 } 02405 if ($this->mconf['debugItemConf']) {echo '<h3>$NOconf:</h3>'; debug($NOconf); } 02406 $this->makeImageMap($NOconf); 02407 } 02408 02418 function makeImageMap($conf) { 02419 if (!is_array($conf)) { 02420 $conf = Array(); 02421 } 02422 if (is_array($this->mconf['main.'])) { 02423 $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder'); 02424 $gifCreator->init(); 02425 02426 $itemsConf = $conf; 02427 $conf = $this->mconf['main.']; 02428 if (is_array($conf)) { 02429 $gifObjCount = 0; 02430 02431 $sKeyArray=t3lib_TStemplate::sortedKeyList($conf); 02432 $gifObjCount=intval(end($sKeyArray)); 02433 02434 $lastOriginal = $gifObjCount; 02435 02436 // Now we add graphical objects to the gifbuilder-setup 02437 reset($itemsConf); 02438 $waArr = Array(); 02439 while (list($key,$val)=each($itemsConf)) { 02440 if (is_array($val)) { 02441 $gifObjCount++; 02442 $waArr[$key]['free']=$gifObjCount; 02443 02444 $sKeyArray=t3lib_TStemplate::sortedKeyList($val); 02445 02446 foreach($sKeyArray as $theKey) { 02447 $theValue=$val[$theKey]; 02448 02449 02450 if (intval($theKey) && $theValArr=$val[$theKey.'.']) { 02451 $cObjData = $this->menuArr[$key] ? $this->menuArr[$key] : Array(); 02452 02453 $gifObjCount++; 02454 if ($theValue=='TEXT') { 02455 $waArr[$key]['textNum']=$gifObjCount; 02456 02457 $gifCreator->data = $cObjData; 02458 $theValArr = $gifCreator->checkTextObj($theValArr); 02459 unset($theValArr['text.']); // if this is not done it seems that imageMaps will be rendered wrong!! 02460 // check links 02461 02462 $LD = $this->tmpl->linkData($this->menuArr[$key],$this->mconf['target'],'','',array(),'',$this->mconf['forceTypeValue']); 02463 02464 // If access restricted pages should be shown in menus, change the link of such pages to link to a redirection page: 02465 $this->changeLinksForAccessRestrictedPages($LD, $this->menuArr[$key], $this->mconf['target'], $this->mconf['forceTypeValue']); 02466 02467 // Overriding URL / Target if set to do so: 02468 if ($this->menuArr[$key]['_OVERRIDE_HREF']) { 02469 $LD['totalURL'] = $this->menuArr[$key]['_OVERRIDE_HREF']; 02470 if ($this->menuArr[$key]['_OVERRIDE_TARGET']) $LD['target'] = $this->menuArr[$key]['_OVERRIDE_TARGET']; 02471 } 02472 02473 // Setting target/url for Image Map: 02474 if ($theValArr['imgMap.']['url']=='') { 02475 $theValArr['imgMap.']['url'] = $LD['totalURL']; 02476 } 02477 if ($theValArr['imgMap.']['target']=='') { 02478 $theValArr['imgMap.']['target'] = $LD['target']; 02479 } 02480 if ($theValArr['imgMap.']['noBlur']=='') { 02481 $theValArr['imgMap.']['noBlur'] = $this->mconf['noBlur']; 02482 } 02483 if (is_array($theValArr['imgMap.']['altText.'])) { 02484 $cObj =t3lib_div::makeInstance('tslib_cObj'); 02485 $cObj->start($cObjData,'pages'); 02486 $theValArr['imgMap.']['altText'] = $cObj->stdWrap($theValArr['imgMap.']['altText'], $theValArr['imgMap.']['altText.']); 02487 unset($theValArr['imgMap.']['altText.']); 02488 } 02489 if (is_array($theValArr['imgMap.']['titleText.'])) { 02490 $cObj =t3lib_div::makeInstance('tslib_cObj'); 02491 $cObj->start($cObjData,'pages'); 02492 $theValArr['imgMap.']['titleText'] = $cObj->stdWrap($theValArr['imgMap.']['titleText'], $theValArr['imgMap.']['titleText.']); 02493 unset($theValArr['imgMap.']['titleText.']); 02494 } 02495 } 02496 // 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!! 02497 if ($theValue=='IMAGE') { 02498 if ($theValArr['file']=='GIFBUILDER') { 02499 $temp_sKeyArray=t3lib_TStemplate::sortedKeyList($theValArr['file.']); 02500 reset($temp_sKeyArray); 02501 while(list(,$temp_theKey)=each($temp_sKeyArray)) { 02502 if ($theValArr['mask.'][$temp_theKey]=='TEXT') { 02503 $gifCreator->data = $this->menuArr[$key] ? $this->menuArr[$key] : Array(); 02504 $theValArr['mask.'][$temp_theKey.'.'] = $gifCreator->checkTextObj($theValArr['mask.'][$temp_theKey.'.']); 02505 unset($theValArr['mask.'][$temp_theKey.'.']['text.']); // if this is not done it seems that imageMaps will be rendered wrong!! 02506 } 02507 } 02508 } 02509 if ($theValArr['mask']=='GIFBUILDER') { 02510 $temp_sKeyArray=t3lib_TStemplate::sortedKeyList($theValArr['mask.']); 02511 reset($temp_sKeyArray); 02512 while(list(,$temp_theKey)=each($temp_sKeyArray)) { 02513 if ($theValArr['mask.'][$temp_theKey]=='TEXT') { 02514 $gifCreator->data = $this->menuArr[$key] ? $this->menuArr[$key] : Array(); 02515 $theValArr['mask.'][$temp_theKey.'.'] = $gifCreator->checkTextObj($theValArr['mask.'][$temp_theKey.'.']); 02516 unset($theValArr['mask.'][$temp_theKey.'.']['text.']); // if this is not done it seems that imageMaps will be rendered wrong!! 02517 } 02518 } 02519 } 02520 } 02521 02522 // Checks if disabled is set... 02523 $setObjFlag=1; 02524 if ($theValArr['if.']) { 02525 $cObj =t3lib_div::makeInstance('tslib_cObj'); 02526 $cObj->start($cObjData,'pages'); 02527 if (!$cObj->checkIf($theValArr['if.'])) { 02528 $setObjFlag=0; 02529 } 02530 unset($theValArr['if.']); 02531 } 02532 // Set the object! 02533 if ($setObjFlag) { 02534 $conf[$gifObjCount] = $theValue; 02535 $conf[$gifObjCount.'.'] = $theValArr; 02536 } 02537 } 02538 } 02539 } 02540 } 02541 02542 $gifCreator->start($conf,$GLOBALS['TSFE']->page); 02543 // calculations 02544 02545 $sum=Array(0,0,0,0); 02546 reset($waArr); 02547 while (list($key,$val)=each($waArr)) { 02548 if ($dConf[$key] =$itemsConf[$key]['distrib']) { 02549 $textBB = $gifCreator->objBB[$val['textNum']]; 02550 $dConf[$key] = str_replace('textX',$textBB[0],$dConf[$key]); 02551 $dConf[$key] = str_replace('textY',$textBB[1],$dConf[$key]); 02552 $dConf[$key] = t3lib_div::intExplode(',',$gifCreator->calcOffset($dConf[$key])); 02553 } 02554 } 02555 $workArea = t3lib_div::intExplode(',',$gifCreator->calcOffset($this->mconf['dWorkArea'])); 02556 reset($waArr); 02557 while (list($key,$val)=each($waArr)) { 02558 $index = $val['free']; 02559 $gifCreator->setup[$index] = 'WORKAREA'; 02560 $workArea[2] = $dConf[$key][2] ? $dConf[$key][2] : $dConf[$key][0]; 02561 $workArea[3] = $dConf[$key][3] ? $dConf[$key][3] : $dConf[$key][1]; 02562 02563 $gifCreator->setup[$index.'.']['set'] = implode(',',$workArea); 02564 $workArea[0]+=$dConf[$key][0]; 02565 $workArea[1]+=$dConf[$key][1]; 02566 } 02567 02568 if ($this->mconf['debugRenumberedObject']) {echo '<h3>Renumbered GIFBUILDER object:</h3>'; debug($gifCreator->setup);} 02569 02570 $gifCreator->createTempSubDir('menu/'); 02571 $gifFileName = $gifCreator->fileName('menu/'); 02572 02573 // Gets the ImageMap from the cache... 02574 $imgHash = md5($gifFileName); 02575 $imgMap = $this->sys_page->getHash($imgHash, 0); 02576 02577 if ($imgMap && @file_exists($gifFileName)) { // File exists 02578 $info = @getimagesize($gifFileName); 02579 $w=$info[0]; 02580 $h=$info[1]; 02581 } else { // file is generated 02582 $gifCreator->make(); 02583 $w=$gifCreator->w; 02584 $h=$gifCreator->h; 02585 $gifCreator->output($gifFileName); 02586 $gifCreator->destroy(); 02587 $imgMap=$gifCreator->map; 02588 $this->sys_page->storeHash($imgHash, $imgMap, 'MENU IMAGEMAP'); 02589 } 02590 $imgMap.=$this->mconf['imgMapExtras']; 02591 02592 $gifFileName = t3lib_div::png_to_gif_by_imagemagick($gifFileName); 02593 $this->result = Array('output_file'=>$gifFileName, 'output_w'=>$w, 'output_h'=>$h, 'imgMap'=>$imgMap); 02594 } 02595 } 02596 } 02597 02604 function writeMenu() { 02605 if ($this->result) { 02606 $res = $this->result; 02607 $menuName = 'menu_'.t3lib_div::shortMD5($res['imgMap']); // shortMD5 260900 02608 $result = '<img src="'.$GLOBALS['TSFE']->absRefPrefix.$res['output_file'].'" width="'.$res['output_w'].'" height="'.$res['output_h'].'" usemap="#'.$menuName.'" border="0" '.$this->mconf['params']; 02609 if (!strstr($result,'alt="')) $result.=' alt="Menu Image Map"'; // Adding alt attribute if not set. 02610 $result.= ' /><map name="'.$menuName.'" id="'.$menuName.'">'.$res['imgMap'].'</map>'; 02611 02612 $GLOBALS['TSFE']->imagesOnPage[]=$res['output_file']; 02613 02614 return $this->tmpl->wrap($result,$this->mconf['wrap']); 02615 } 02616 } 02617 } 02618 02619 02620 02621 02622 02623 02624 02625 02626 02627 02628 02629 02630 02631 02632 02633 02634 02635 02636 02637 02638 02647 class tslib_jsmenu extends tslib_menu { 02648 02654 function generate() { 02655 } 02656 02662 function writeMenu() { 02663 if ($this->id) { 02664 // Making levels: 02665 $levels = t3lib_div::intInRange($this->mconf['levels'],1,5); 02666 $this->levels = $levels; 02667 $this->JSVarName='eid'; 02668 $this->JSMenuName= $this->mconf['menuName'] ? $this->mconf['menuName'] : 'JSmenu'; 02669 02670 $JScode="\n var ".$this->JSMenuName." = new JSmenu(".$levels.",'".$this->JSMenuName."Form');"; 02671 02672 for ($a=1;$a<=$levels;$a++) { 02673 $JScode.="\n var ".$this->JSVarName.$a."=0;"; 02674 } 02675 $JScode.= $this->generate_level($levels,1,$this->id,$this->menuArr,$this->MP_array)."\n"; 02676 02677 $GLOBALS['TSFE']->additionalHeaderData['JSMenuCode']='<script type="text/javascript" src="'.$GLOBALS['TSFE']->absRefPrefix.'t3lib/jsfunc.menu.js"></script>'; 02678 $GLOBALS['TSFE']->JSCode.=$JScode; 02679 02680 // Printing: 02681 $allFormCode=""; 02682 for ($a=1;$a<=$this->levels;$a++) { 02683 $formCode=''; 02684 $levelConf = $this->mconf[$a.'.']; 02685 $length = $levelConf['width'] ? $levelConf['width'] : 14; 02686 $lenghtStr=''; 02687 for ($b=0;$b<$length;$b++) { 02688 $lenghtStr.='_'; 02689 } 02690 $height = $levelConf['elements'] ? $levelConf['elements'] : 5; 02691 02692 $formCode.= '<select name="selector'.$a.'" onchange="'.$this->JSMenuName.'.act('.$a.');"'.($levelConf['additionalParams']?' '.$levelConf['additionalParams']:'').'>'; 02693 for ($b=0;$b<$height;$b++) { 02694 $formCode.= '<option value="0">'; 02695 if ($b==0) { 02696 $formCode.= $lenghtStr; 02697 } 02698 $formCode.='</option>'; 02699 } 02700 $formCode.= '</select>'; 02701 $allFormCode.=$this->tmpl->wrap($formCode,$levelConf['wrap']); 02702 } 02703 $formCode = $this->tmpl->wrap($allFormCode,$this->mconf['wrap']); 02704 02705 $formCode= '<form action="" method="post" style="margin: 0 0 0 0;" name="'.$this->JSMenuName.'Form">'.$formCode.'</form>'; 02706 $formCode.='<script type="text/javascript"> /*<![CDATA[*/ '.$this->JSMenuName.'.writeOut(1,'.$this->JSMenuName.'.openID,1); /*]]>*/ </script>'; 02707 return $this->tmpl->wrap($formCode,$this->mconf['wrapAfterTags']); 02708 } 02709 } 02710 02723 function generate_level($levels,$count,$pid,$menuItemArray='',$MP_array=array()) { 02724 $levelConf = $this->mconf[$count.'.']; 02725 02726 // Translate PID to a mount page, if any: 02727 $mount_info = $this->sys_page->getMountPointInfo($pid); 02728 if (is_array($mount_info)) { 02729 $MP_array[] = $mount_info['MPvar']; 02730 $pid = $mount_info['mount_pid']; 02731 } 02732 02733 // Set "&MP=" var: 02734 $MP_var = implode(',',$MP_array); 02735 $MP_params = $MP_var ? '&MP='.rawurlencode($MP_var) : ''; 02736 02737 // UIDs to ban: 02738 $banUidArray = $this->getBannedUids(); 02739 02740 // Initializing variables: 02741 $var = $this->JSVarName; 02742 $menuName = $this->JSMenuName; 02743 $parent = $count==1 ? 0 : $var.($count-1); 02744 $prev=0; 02745 $c=0; 02746 02747 $menuItems = is_array($menuItemArray) ? $menuItemArray : $this->sys_page->getMenu($pid); 02748 foreach($menuItems as $uid => $data) { 02749 $spacer = (t3lib_div::inList($this->spacerIDList,$data['doktype'])?1:0); // if item is a spacer, $spacer is set 02750 if ($this->mconf['SPC'] || !$spacer) { // If the spacer-function is not enabled, spacers will not enter the $menuArr 02751 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 02752 if ($count<$levels) { 02753 $addLines = $this->generate_level($levels,$count+1,$data['uid'],'',$MP_array); 02754 } else { 02755 $addLines = ''; 02756 } 02757 $title=$data['title']; 02758 $url=''; 02759 $target=''; 02760 if ((!$addLines && !$levelConf['noLink']) || $levelConf['alwaysLink']) { 02761 $LD = $this->tmpl->linkData($data,$this->mconf['target'],'','',array(),$MP_params,$this->mconf['forceTypeValue']); 02762 02763 // If access restricted pages should be shown in menus, change the link of such pages to link to a redirection page: 02764 $this->changeLinksForAccessRestrictedPages($LD, $data, $this->mconf['target'], $this->mconf['forceTypeValue']); 02765 02766 $url = $LD['totalURL']; 02767 $target = $LD['target']; 02768 } 02769 $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).");"; 02770 // If the active one should be chosen... 02771 $active = ($levelConf['showActive'] && $data['uid'] == $this->tmpl->rootLine[$count]['uid']); 02772 // If the first item should be shown 02773 $first = (!$c && $levelConf['showFirst']); 02774 // do it... 02775 if ($active || $first) { 02776 if ($count==1) { 02777 $codeLines.="\n".$menuName.".openID = ".$var.$count.";"; 02778 } else { 02779 $codeLines.="\n".$menuName.".entry[".$parent."].openID = ".$var.$count.";"; 02780 } 02781 } 02782 // Add submenu... 02783 $codeLines.=$addLines; 02784 02785 $prev=$var.$count; 02786 $c++; 02787 } 02788 } 02789 } 02790 if ($this->mconf['firstLabelGeneral'] && !$levelConf['firstLabel']) { 02791 $levelConf['firstLabel'] = $this->mconf['firstLabelGeneral']; 02792 } 02793 if ($levelConf['firstLabel'] && $codeLines) { 02794 $codeLines.= chr(10).$menuName.'.defTopTitle['.$count.'] = '.t3lib_div::quoteJSvalue($levelConf['firstLabel'], true).';'; 02795 } 02796 return $codeLines; 02797 } 02798 } 02799 02800 02801 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_menu.php']) { 02802 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_menu.php']); 02803 } 02804 02805 ?>