*** empty log message ***
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / class.tslib_menu.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Generating navigation / menus from TypoScript
29 *
30 * This file contains five classes, four of which are extensions to the main class, tslib_menu.
31 * The main class, tslib_menu, is also extended by other external PHP scripts such as the GMENU_LAYERS and GMENU_FOLDOUT scripts which creates pop-up menus.
32 * Notice that extension classes (like "tslib_tmenu") must have their suffix (here "tmenu") listed in $this->tmpl->menuclasses - otherwise they cannot be instantiated.
33 *
34 * $Id$
35 * Revised for TYPO3 3.6 June/2003 by Kasper Skaarhoj
36 * XHTML compliant
37 *
38 * @author Kasper Skaarhoj <kasper@typo3.com>
39 */
40 /**
41 * [CLASS/FUNCTION INDEX of SCRIPT]
42 *
43 *
44 *
45 * 141: class tslib_menu
46 * 183: function start(&$tmpl,&$sys_page,$id,$conf,$menuNumber)
47 * 294: function makeMenu()
48 * 774: function includeMakeMenu($conf,$altSortField)
49 * 791: function procesItemStates($splitCount)
50 * 978: function link($key,$altTarget='',$typeOverride='')
51 * 1032: function subMenu($uid)
52 * 1074: function isNext($uid, $MPvar='')
53 * 1089: function isActive($uid, $MPvar='')
54 * 1104: function isCurrent($uid, $MPvar='')
55 * 1119: function isSubMenu($uid)
56 * 1144: function isItemState($kind,$key)
57 * 1181: function accessKey($title)
58 * 1207: function userProcess($mConfKey,$passVar)
59 * 1222: function setATagParts()
60 * 1235: function getPageTitle($title,$nav_title)
61 * 1247: function getMPvar($key)
62 *
63 *
64 * 1283: class tslib_tmenu extends tslib_menu
65 * 1292: function generate()
66 * 1308: function writeMenu()
67 * 1438: function getBeforeAfter($pref)
68 * 1468: function addJScolorShiftFunction()
69 * 1490: function extProc_init()
70 * 1501: function extProc_RO($key)
71 * 1512: function extProc_beforeLinking($key)
72 * 1524: function extProc_afterLinking($key)
73 * 1541: function extProc_beforeAllWrap($item,$key)
74 * 1552: function extProc_finish()
75 *
76 *
77 * 1588: class tslib_gmenu extends tslib_menu
78 * 1597: function generate()
79 * 1635: function makeGifs($conf, $resKey)
80 * 1832: function findLargestDims($conf,$items,$Hobjs,$Wobjs,$minDim,$maxDim)
81 * 1904: function writeMenu()
82 * 2002: function extProc_init()
83 * 2013: function extProc_RO($key)
84 * 2024: function extProc_beforeLinking($key)
85 * 2037: function extProc_afterLinking($key)
86 * 2053: function extProc_beforeAllWrap($item,$key)
87 * 2064: function extProc_finish()
88 *
89 *
90 * 2098: class tslib_imgmenu extends tslib_menu
91 * 2107: function generate()
92 * 2125: function makeImageMap($conf)
93 * 2294: function writeMenu()
94 *
95 *
96 * 2337: class tslib_jsmenu extends tslib_menu
97 * 2344: function generate()
98 * 2352: function writeMenu()
99 * 2413: function generate_level($levels,$count,$pid,$menuItemArray='',$MP_array=array())
100 *
101 * TOTAL FUNCTIONS: 42
102 * (This index is automatically created/updated by the extension "extdeveval")
103 *
104 */
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123 /**
124 * Base class. The HMENU content object uses this (or more precisely one of the extension classes).
125 * Amoung others the class generates an array of menuitems. Thereafter functions from the subclasses are called.
126 * The class is ALWAYS used through extension classes (like tslib_gmenu or tslib_tmenu which are classics) and
127 *
128 * Example of usage (from tslib_cObj):
129 *
130 * $menu = t3lib_div::makeInstance('tslib_'.$cls);
131 * $menu->parent_cObj = $this;
132 * $menu->start($GLOBALS['TSFE']->tmpl,$GLOBALS['TSFE']->sys_page,'',$conf,1);
133 * $menu->makeMenu();
134 * $content.=$menu->writeMenu();
135 *
136 * @author Kasper Skaarhoj <kasper@typo3.com>
137 * @package TYPO3
138 * @subpackage tslib
139 * @see tslib_cObj::HMENU()
140 */
141 class tslib_menu {
142 var $menuNumber = 1; // tells you which menu-number this is. This is important when getting data from the setup
143 var $entryLevel = 0; // 0 = rootFolder
144 var $subLevelClass = ''; // Points to the menu-class, that should be used for the next level
145 var $spacerIDList = '199'; // The doktype-number that defines a spacer
146 var $doktypeExcludeList = '5,6'; // doktypes that define which should not be included in a menu
147 var $imgNamePrefix = 'img';
148 var $imgNameNotRandom=0;
149 var $debug = 0;
150 var $parent_cObj =''; // Loaded with the parent cObj-object when a new HMENU is made
151 var $GMENU_fixKey='gmenu';
152 var $MP_array=array(); // accumulation of mount point data
153
154 // internal
155 var $conf = Array(); // HMENU configuration
156 var $mconf = Array(); // xMENU configuration (TMENU, GMENU etc)
157 var $tmpl; // template-object
158 var $sys_page; // sys_page-object
159 var $id; // The base page-id of the menu.
160 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.
161 var $menuArr; // The array of menuItems which is built
162 var $hash;
163 var $result = Array();
164 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)
165 var $INPfixMD5;
166 var $I;
167 var $WMresult;
168 var $WMfreezePrefix;
169 var $WMmenuItems;
170 var $WMextraScript;
171 var $alternativeMenuTempArray=''; // Can be set to contain menu item arrays for sub-levels.
172
173 /**
174 * The initialization of the object. This just sets some internal variables.
175 *
176 * @param object The $GLOBALS['TSFE']->tmpl object
177 * @param object The $GLOBALS['TSFE']->sys_page object
178 * @param integer A starting point page id. This should probably be blank since the 'entryLevel' value will be used then.
179 * @param array The TypoScript configuration for the HMENU cObject
180 * @param integer Menu number; 1,2,3. Should probably be '1'
181 * @return boolean Returns true on success
182 * @see tslib_cObj::HMENU()
183 */
184 function start(&$tmpl,&$sys_page,$id,$conf,$menuNumber) {
185
186 // Init:
187 $this->conf = $conf;
188 $this->menuNumber = $menuNumber;
189 $this->mconf = $conf[$this->menuNumber.'.'];
190 $this->debug=$GLOBALS['TSFE']->debug;
191
192 // Sets the internal vars. $tmpl MUST be the template-object. $sys_page MUST be the sys_page object
193 if ($this->conf[$this->menuNumber] && is_object($tmpl) && is_object($sys_page)) {
194 $this->tmpl = &$tmpl;
195 $this->sys_page = &$sys_page;
196
197 // 'not in menu' doktypes
198 if($this->conf['excludeDoktypes']) {
199 $this->doktypeExcludeList = $GLOBALS['TYPO3_DB']->cleanIntList($this->conf['excludeDoktypes']);
200 }
201 if($this->conf['includeNotInMenu']) {
202 $exclDoktypeArr=t3lib_div::trimExplode(',',$this->doktypeExcludeList,1);
203 $exclDoktypeArr=t3lib_div::removeArrayEntryByValue($exclDoktypeArr,'5');
204 $this->doktypeExcludeList=implode(',',$exclDoktypeArr);
205 }
206
207 // EntryLevel
208 $this->entryLevel = tslib_cObj::getKey ($conf['entryLevel'],$this->tmpl->rootLine);
209
210 // Set parent page: If $id not stated with start() then the base-id will be found from rootLine[$this->entryLevel]
211 if ($id) { // Called as the next level in a menu. It is assumed that $this->MP_array is set from parent menu.
212 $this->id = intval($id);
213 } else { // This is a BRAND NEW menu, first level. So we take ID from rootline and also find MP_array (mount points)
214 $this->id = intval($this->tmpl->rootLine[$this->entryLevel]['uid']);
215
216 // Traverse rootline to build MP_array of pages BEFORE the entryLevel
217 // (MP var for ->id is picked up in the next part of the code...)
218 foreach($this->tmpl->rootLine as $entryLevel => $levelRec) {
219 // For overlaid mount points, set the variable right now:
220 if ($levelRec['_MP_PARAM'] && $levelRec['_MOUNT_OL']) {
221 $this->MP_array[] = $levelRec['_MP_PARAM'];
222 }
223 // Break when entry level is reached:
224 if ($entryLevel>=$this->entryLevel) break;
225
226 // For normal mount points, set the variable for next level.
227 if ($levelRec['_MP_PARAM'] && !$levelRec['_MOUNT_OL']) {
228 $this->MP_array[] = $levelRec['_MP_PARAM'];
229 }
230 }
231 }
232
233 // Return false if no page ID was set (thus no menu of subpages can be made).
234 if ($this->id<=0) {
235 return FALSE;
236 }
237
238 // Check if page is a mount point, and if so set id and MP_array
239 // (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...)
240 $mount_info = $this->sys_page->getMountPointInfo($this->id);
241 if (is_array($mount_info)) {
242 $this->MP_array[] = $mount_info['MPvar'];
243 $this->id = $mount_info['mount_pid'];
244 }
245
246 // Gather list of page uids in root line (for "isActive" evaluation). Also adds the MP params in the path so Mount Points are respected.
247 // (List is specific for this rootline, so it may be supplied from parent menus for speed...)
248 if (!is_array($this->rL_uidRegister)) {
249 $rl_MParray = array();
250 foreach($this->tmpl->rootLine as $v_rl) {
251 // For overlaid mount points, set the variable right now:
252 if ($v_rl['_MP_PARAM'] && $v_rl['_MOUNT_OL']) {
253 $rl_MParray[] = $v_rl['_MP_PARAM'];
254 }
255
256 // Add to register:
257 $this->rL_uidRegister[] = 'ITEM:'.$v_rl['uid'].(count($rl_MParray) ? ':'.implode(',',$rl_MParray) : '');
258
259 // For normal mount points, set the variable for next level.
260 if ($v_rl['_MP_PARAM'] && !$v_rl['_MOUNT_OL']) {
261 $rl_MParray[] = $v_rl['_MP_PARAM'];
262 }
263 }
264 }
265
266 // 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
267 // Notice: The automatic expansion of a menu is designed to work only when no "special" modes are used.
268 if (is_array($this->tmpl->rootLine[$this->entryLevel+$this->menuNumber])) {
269 $nextMParray = $this->MP_array;
270 if ($this->tmpl->rootLine[$this->entryLevel+$this->menuNumber]['_MOUNT_OL']) { // In overlay mode, add next level MPvars as well:
271 $nextMParray[] = $this->tmpl->rootLine[$this->entryLevel+$this->menuNumber]['_MP_PARAM'];
272 }
273 $this->nextActive = $this->tmpl->rootLine[$this->entryLevel+$this->menuNumber]['uid'].
274 (count($nextMParray)?':'.implode(',',$nextMParray):'');
275 } else {
276 $this->nextActive = '';
277 }
278
279 // imgNamePrefix
280 if ($this->mconf['imgNamePrefix']) {
281 $this->imgNamePrefix=$this->mconf['imgNamePrefix'];
282 }
283 $this->imgNameNotRandom = $this->mconf['imgNameNotRandom'];
284
285 // subLevelClass
286 $cls = strtolower($this->conf[$this->menuNumber+1]);
287 if ($cls && t3lib_div::inList($this->tmpl->menuclasses,$cls)) {
288 $this->subLevelClass = $cls;
289 }
290 $retVal = TRUE;
291 } else {
292 $GLOBALS['TT']->setTSlogMessage('ERROR in menu',3);
293 $retVal = FALSE;
294 }
295 return $retVal;
296 }
297
298 /**
299 * Creates the menu in the internal variables, ready for output.
300 * Basically this will read the page records needed and fill in the internal $this->menuArr
301 * Based on a hash of this array and some other variables the $this->result variable will be loaded either from cache OR by calling the generate() method of the class to create the menu for real.
302 *
303 * @return void
304 */
305 function makeMenu() {
306 if ($this->id) {
307 $temp = array();
308 $altSortFieldValue = trim($this->mconf['alternativeSortingField']);
309 $altSortField = $altSortFieldValue ? $altSortFieldValue : 'sorting';
310 if ($this->menuNumber==1 && $this->conf['special']) { // ... only for the FIRST level of a HMENU
311 $value = $this->conf['special.']['value'];
312
313 switch($this->conf['special']) {
314 case 'userdefined':
315 $temp = $this->includeMakeMenu($this->conf['special.'],$altSortField);
316 break;
317 case 'userfunction':
318 $temp = $this->parent_cObj->callUserFunction(
319 $this->conf['special.']['userFunc'],
320 array_merge($this->conf['special.'],array('_altSortField'=>$altSortField)),
321 ''
322 );
323 if (!is_array($temp)) $temp=array();
324 break;
325 case 'directory':
326 if ($value=='') {
327 $value=$GLOBALS['TSFE']->page['uid'];
328 }
329 $items=t3lib_div::intExplode(',',$value);
330
331 foreach($items as $id) {
332 $MP = $this->tmpl->getFromMPmap($id);
333
334 // Checking if a page is a mount page and if so, change the ID and set the MP var properly.
335 $mount_info = $this->sys_page->getMountPointInfo($id);
336 if (is_array($mount_info)) {
337 if ($mount_info['overlay']) { // Overlays should already have their full MPvars calculated:
338 $MP = $this->tmpl->getFromMPmap($mount_info['mount_pid']);
339 $MP = $MP ? $MP : $mount_info['MPvar'];
340 } else {
341 $MP = ($MP ? $MP.',' : '').$mount_info['MPvar'];
342 }
343 $id = $mount_info['mount_pid'];
344 }
345
346 // Get sub-pages:
347 $res = $GLOBALS['TSFE']->cObj->exec_getQuery('pages',Array('pidInList'=>$id,'orderBy'=>$altSortField));
348 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
349
350 // Keep mount point?
351 $mount_info = $this->sys_page->getMountPointInfo($row['uid'], $row);
352 if (is_array($mount_info) && $mount_info['overlay']) { // There is a valid mount point.
353 $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!
354 if (count($mp_row)) {
355 $row = $mp_row;
356 $row['_MP_PARAM'] = $mount_info['MPvar'];
357 } 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!
358 }
359
360 // Add external MP params, then the row:
361 if (is_array($row)) {
362 if ($MP) $row['_MP_PARAM'] = $MP.($row['_MP_PARAM'] ? ','.$row['_MP_PARAM'] : '');
363 $temp[$row['uid']] = $this->sys_page->getPageOverlay($row);
364 }
365 }
366 }
367 break;
368 case 'list':
369 if ($value=='') {
370 $value=$this->id;
371 }
372 $loadDB = t3lib_div::makeInstance('FE_loadDBGroup');
373 $loadDB->start($value, 'pages');
374 $loadDB->additionalWhere['pages']=tslib_cObj::enableFields('pages');
375 $loadDB->getFromDB();
376
377 foreach($loadDB->itemArray as $val) {
378 $MP = $this->tmpl->getFromMPmap($val['id']);
379
380 // Keep mount point?
381 $mount_info = $this->sys_page->getMountPointInfo($val['id']);
382 if (is_array($mount_info) && $mount_info['overlay']) { // There is a valid mount point.
383 $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!
384 if (count($mp_row)) {
385 $row = $mp_row;
386 $row['_MP_PARAM'] = $mount_info['MPvar'];
387
388 if ($mount_info['overlay']) { // Overlays should already have their full MPvars calculated:
389 $MP = $this->tmpl->getFromMPmap($mount_info['mount_pid']);
390 if ($MP) unset($row['_MP_PARAM']);
391 }
392
393 } 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!
394 } else {
395 $row = $loadDB->results['pages'][$val['id']];
396 }
397
398 // Add external MP params, then the row:
399 if (is_array($row)) {
400 if ($MP) $row['_MP_PARAM'] = $MP.($row['_MP_PARAM'] ? ','.$row['_MP_PARAM'] : '');
401 $temp[] = $this->sys_page->getPageOverlay($row);
402 }
403 }
404 break;
405 case 'updated':
406 if ($value=='') {
407 $value=$GLOBALS['TSFE']->page['uid'];
408 }
409 $items=t3lib_div::intExplode(',',$value);
410 if (t3lib_div::testInt($this->conf['special.']['depth'])) {
411 $depth = t3lib_div::intInRange($this->conf['special.']['depth'],1,20); // Tree depth
412 } else {
413 $depth=20;
414 }
415 $limit = t3lib_div::intInRange($this->conf['special.']['limit'],0,100); // max number of items
416 $maxAge = intval(tslib_cObj::calc($this->conf['special.']['maxAge']));
417 if (!$limit) $limit=10;
418 $mode = $this->conf['special.']['mode']; // *'auto', 'manual', 'tstamp'
419 // Get id's
420 $id_list_arr = Array();
421
422 foreach($items as $id) {
423 $bA = t3lib_div::intInRange($this->conf['special.']['beginAtLevel'],0,100);
424 $id_list_arr[] = tslib_cObj::getTreeList(-1*$id,$depth-1+$bA,$bA-1);
425 }
426 $id_list = implode($id_list_arr, ',');
427 // Get sortField (mode)
428 switch($mode) {
429 case 'starttime':
430 $sortField = 'starttime';
431 break;
432 case 'lastUpdated':
433 case 'manual':
434 $sortField = 'lastUpdated';
435 break;
436 case 'tstamp':
437 $sortField = 'tstamp';
438 break;
439 case 'crdate':
440 $sortField = 'crdate';
441 break;
442 default:
443 $sortField = 'SYS_LASTCHANGED';
444 break;
445 }
446 // Get
447 $extraWhere = ' AND pages.nav_hide=0'.$this->getDoktypeExcludeWhere();
448
449 if ($this->conf['special.']['excludeNoSearchPages']) {
450 $extraWhere.= ' AND pages.no_search=0';
451 }
452 if ($maxAge>0) {
453 $extraWhere.=' AND '.$sortField.'>'.($GLOBALS['SIM_EXEC_TIME']-$maxAge);
454 }
455
456 $res = $GLOBALS['TSFE']->cObj->exec_getQuery('pages',Array('pidInList'=>'0', 'uidInList'=>$id_list, 'where'=>$sortField.'>=0'.$extraWhere, 'orderBy'=>($altSortFieldValue ? $altSortFieldValue : $sortField.' desc'),'max'=>$limit));
457 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
458 $temp[$row['uid']]=$this->sys_page->getPageOverlay($row);
459 }
460 break;
461 case 'keywords':
462 list($value)=t3lib_div::intExplode(',',$value);
463 if (!$value) {
464 $value=$GLOBALS['TSFE']->page['uid'];
465 }
466 if ($this->conf['special.']['setKeywords'] || $this->conf['special.']['setKeywords.']) {
467 $kw = $this->parent_cObj->stdWrap($this->conf['special.']['setKeywords'], $this->conf['special.']['setKeywords.']);
468 } else {
469 $value_rec=$this->sys_page->getPage($value); // The page record of the 'value'.
470
471 $kfieldSrc = $this->conf['special.']['keywordsField.']['sourceField'] ? $this->conf['special.']['keywordsField.']['sourceField'] : 'keywords';
472 $kw = trim(tslib_cObj::keywords($value_rec[$kfieldSrc])); // keywords.
473 }
474
475 $mode = $this->conf['special.']['mode']; // *'auto', 'manual', 'tstamp'
476 switch($mode) {
477 case 'starttime':
478 $sortField = 'starttime';
479 break;
480 case 'lastUpdated':
481 case 'manual':
482 $sortField = 'lastUpdated';
483 break;
484 case 'tstamp':
485 $sortField = 'tstamp';
486 break;
487 case 'crdate':
488 $sortField = 'crdate';
489 break;
490 default:
491 $sortField = 'SYS_LASTCHANGED';
492 break;
493 }
494
495 // depth, limit, extra where
496 if (t3lib_div::testInt($this->conf['special.']['depth'])) {
497 $depth = t3lib_div::intInRange($this->conf['special.']['depth'],0,20); // Tree depth
498 } else {
499 $depth=20;
500 }
501 $limit = t3lib_div::intInRange($this->conf['special.']['limit'],0,100); // max number of items
502 $extraWhere = ' AND pages.uid!='.$value.' AND pages.nav_hide=0'.$this->getDoktypeExcludeWhere();
503 if ($this->conf['special.']['excludeNoSearchPages']) {
504 $extraWhere.= ' AND pages.no_search=0';
505 }
506 // start point
507 $eLevel = tslib_cObj::getKey (intval($this->conf['special.']['entryLevel']),$this->tmpl->rootLine);
508 $startUid = intval($this->tmpl->rootLine[$eLevel]['uid']);
509
510 // which field is for keywords
511 $kfield = 'keywords';
512 if ( $this->conf['special.']['keywordsField'] ) {
513 list($kfield) = explode(' ',trim ($this->conf['special.']['keywordsField']));
514 }
515
516 // If there are keywords and the startuid is present.
517 if ($kw && $startUid) {
518 $bA = t3lib_div::intInRange($this->conf['special.']['beginAtLevel'],0,100);
519 $id_list=tslib_cObj::getTreeList(-1*$startUid,$depth-1+$bA,$bA-1);
520
521 $kwArr = explode(',',$kw);
522 foreach($kwArr as $word) {
523 $word = trim($word);
524 if ($word) {
525 $keyWordsWhereArr[] = $kfield.' LIKE "%'.$GLOBALS['TYPO3_DB']->quoteStr($word, 'pages').'%"';
526 }
527 }
528 $res = $GLOBALS['TSFE']->cObj->exec_getQuery('pages',Array('pidInList'=>'0', 'uidInList'=>$id_list, 'where'=>'('.implode($keyWordsWhereArr,' OR ').')'.$extraWhere, 'orderBy'=>($altSortFieldValue ? $altSortFieldValue : $sortField.' desc'),'max'=>$limit));
529 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
530 $temp[$row['uid']]=$this->sys_page->getPageOverlay($row);
531 }
532 }
533 break;
534 case 'rootline':
535 $begin_end = explode('|',$this->conf['special.']['range']);
536 if (!t3lib_div::testInt($begin_end[0])) {intval($begin_end[0]);}
537 if (!t3lib_div::testInt($begin_end[1])) {$begin_end[1]=-1;}
538
539 $beginKey = tslib_cObj::getKey ($begin_end[0],$this->tmpl->rootLine);
540 $endKey = tslib_cObj::getKey ($begin_end[1],$this->tmpl->rootLine);
541 if ($endKey<$beginKey) {$endKey=$beginKey;}
542
543 $rl_MParray = array();
544 foreach($this->tmpl->rootLine as $k_rl => $v_rl) {
545 // For overlaid mount points, set the variable right now:
546 if ($v_rl['_MP_PARAM'] && $v_rl['_MOUNT_OL']) {
547 $rl_MParray[] = $v_rl['_MP_PARAM'];
548 }
549 // Traverse rootline:
550 if ($k_rl>=$beginKey && $k_rl<=$endKey) {
551 $temp_key=$k_rl;
552 $temp[$temp_key]=$this->sys_page->getPage($v_rl['uid']);
553 if (count($temp[$temp_key])) {
554 if (!$temp[$temp_key]['target']) { // If there are no specific target for the page, put the level specific target on.
555 $temp[$temp_key]['target'] = $this->conf['special.']['targets.'][$k_rl];
556 $temp[$temp_key]['_MP_PARAM'] = implode(',',$rl_MParray);
557 }
558 } else unset($temp[$temp_key]);
559 }
560 // For normal mount points, set the variable for next level.
561 if ($v_rl['_MP_PARAM'] && !$v_rl['_MOUNT_OL']) {
562 $rl_MParray[] = $v_rl['_MP_PARAM'];
563 }
564 }
565 break;
566 case 'browse':
567 list($value)=t3lib_div::intExplode(',',$value);
568 if (!$value) {
569 $value=$GLOBALS['TSFE']->page['uid'];
570 }
571 if ($value!=$this->tmpl->rootLine[0]['uid']) { // Will not work out of rootline
572 $recArr=array();
573 $value_rec=$this->sys_page->getPage($value); // The page record of the 'value'.
574 if ($value_rec['pid']) { // 'up' page cannot be outside rootline
575 $recArr['up']=$this->sys_page->getPage($value_rec['pid']); // The page record of 'up'.
576 }
577 if ($recArr['up']['pid'] && $value_rec['pid']!=$this->tmpl->rootLine[0]['uid']) { // If the 'up' item was NOT level 0 in rootline...
578 $recArr['index']=$this->sys_page->getPage($recArr['up']['pid']); // The page record of "index".
579 }
580
581 // prev / next is found
582 $prevnext_menu = $this->sys_page->getMenu($value_rec['pid'],'*',$altSortField);
583 $lastKey=0;
584 $nextActive=0;
585 reset($prevnext_menu);
586 while(list($k_b,$v_b)=each($prevnext_menu)) {
587 if ($nextActive) {
588 $recArr['next']=$v_b;
589 $nextActive=0;
590 }
591 if ($v_b['uid']==$value) {
592 if ($lastKey) {
593 $recArr['prev']=$prevnext_menu[$lastKey];
594 }
595 $nextActive=1;
596 }
597 $lastKey=$k_b;
598 }
599 reset($prevnext_menu);
600 $recArr['first']=pos($prevnext_menu);
601 end($prevnext_menu);
602 $recArr['last']=pos($prevnext_menu);
603
604 // prevsection / nextsection is found
605 if (is_array($recArr['index'])) { // You can only do this, if there is a valid page two levels up!
606 $prevnextsection_menu = $this->sys_page->getMenu($recArr['index']['uid'],'*',$altSortField);
607 $lastKey=0;
608 $nextActive=0;
609 reset($prevnextsection_menu);
610 while(list($k_b,$v_b)=each($prevnextsection_menu)) {
611 if ($nextActive) {
612 $sectionRec_temp = $this->sys_page->getMenu($v_b['uid'],'*',$altSortField);
613 if (count($sectionRec_temp)) {
614 reset($sectionRec_temp);
615 $recArr['nextsection']=pos($sectionRec_temp);
616 end ($sectionRec_temp);
617 $recArr['nextsection_last']=pos($sectionRec_temp);
618 $nextActive=0;
619 }
620 }
621 if ($v_b['uid']==$value_rec['pid']) {
622 if ($lastKey) {
623 $sectionRec_temp = $this->sys_page->getMenu($prevnextsection_menu[$lastKey]['uid'],'*',$altSortField);
624 if (count($sectionRec_temp)) {
625 reset($sectionRec_temp);
626 $recArr['prevsection']=pos($sectionRec_temp);
627 end ($sectionRec_temp);
628 $recArr['prevsection_last']=pos($sectionRec_temp);
629 }
630 }
631 $nextActive=1;
632 }
633 $lastKey=$k_b;
634 }
635 }
636 if ($this->conf['special.']['items.']['prevnextToSection']) {
637 if (!is_array($recArr['prev']) && is_array($recArr['prevsection_last'])) {
638 $recArr['prev']=$recArr['prevsection_last'];
639 }
640 if (!is_array($recArr['next']) && is_array($recArr['nextsection'])) {
641 $recArr['next']=$recArr['nextsection'];
642 }
643 }
644
645 $items = explode('|',$this->conf['special.']['items']);
646 $c=0;
647 while(list($k_b,$v_b)=each($items)) {
648 $v_b=strtolower(trim($v_b));
649 if (intval($this->conf['special.'][$v_b.'.']['uid'])) {
650 $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
651 }
652 if (is_array($recArr[$v_b])) {
653 $temp[$c]=$recArr[$v_b];
654 if ($this->conf['special.'][$v_b.'.']['target']) {
655 $temp[$c]['target']=$this->conf['special.'][$v_b.'.']['target'];
656 }
657 if (is_array($this->conf['special.'][$v_b.'.']['fields.'])) {
658 reset($this->conf['special.'][$v_b.'.']['fields.']);
659 while(list($fk,$val)=each($this->conf['special.'][$v_b.'.']['fields.'])) {
660 $temp[$c][$fk]=$val;
661 }
662 }
663 $c++;
664 }
665 }
666 }
667 break;
668 }
669 } elseif (is_array($this->alternativeMenuTempArray)) { // Setting $temp array if not level 1.
670 $temp = $this->alternativeMenuTempArray;
671 } elseif ($this->mconf['sectionIndex']) {
672 if ($GLOBALS['TSFE']->sys_language_uid && count($this->sys_page->getPageOverlay($this->id))) {
673 $sys_language_uid = intval($GLOBALS['TSFE']->sys_language_uid);
674 } else $sys_language_uid=0;
675
676 $selectSetup = Array(
677 'pidInList'=>$this->id,
678 'orderBy'=>$altSortField,
679 'where' => 'colPos=0 AND sys_language_uid='.$sys_language_uid,
680 'andWhere' => 'sectionIndex!=0'
681 );
682 switch($this->mconf['sectionIndex.']['type']) {
683 case 'all':
684 unset($selectSetup['andWhere']);
685 break;
686 case 'header':
687 $selectSetup['andWhere']='header_layout!=100 AND header!=""';
688 break;
689 }
690 $basePageRow=$this->sys_page->getPage($this->id);
691 if (is_array($basePageRow)) {
692 $res = $GLOBALS['TSFE']->cObj->exec_getQuery('tt_content', $selectSetup);
693 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
694 $temp[$row['uid']]=$basePageRow;
695 $temp[$row['uid']]['title']=$row['header'];
696 $temp[$row['uid']]['subtitle']=$row['subheader'];
697 $temp[$row['uid']]['starttime']=$row['starttime'];
698 $temp[$row['uid']]['endtime']=$row['endtime'];
699 $temp[$row['uid']]['fe_group']=$row['fe_group'];
700 $temp[$row['uid']]['media']=$row['media'];
701
702 $temp[$row['uid']]['header_layout']=$row['header_layout'];
703 $temp[$row['uid']]['bodytext']=$row['bodytext'];
704 $temp[$row['uid']]['image']=$row['image'];
705
706 $temp[$row['uid']]['sectionIndex_uid']=$row['uid'];
707 }
708 }
709 } else { // Default:
710 $temp = $this->sys_page->getMenu($this->id,'*',$altSortField); // gets the menu
711 }
712
713 $c=0;
714 $c_b=0;
715 $minItems = intval($this->mconf['minItems'] ? $this->mconf['minItems'] : $this->conf['minItems']);
716 $maxItems = intval($this->mconf['maxItems'] ? $this->mconf['maxItems'] : $this->conf['maxItems']);
717 $begin = tslib_cObj::calc($this->mconf['begin'] ? $this->mconf['begin'] : $this->conf['begin']);
718
719 $banUidArray=array();
720 if (trim($this->conf['excludeUidList'])) {
721 $banUidArray = t3lib_div::intExplode(',', $this->conf['excludeUidList']);
722 }
723
724 // Fill in the menuArr with elements that should go into the menu:
725 $this->menuArr = Array();
726 foreach($temp as $data) {
727 $spacer = t3lib_div::inList($this->spacerIDList,$data['doktype']) ? 1 : 0; // if item is a spacer, $spacer is set
728 if ($this->filterMenuPages($data, $banUidArray, $spacer)) {
729 $c_b++;
730 if ($begin<=$c_b) { // If the beginning item has been reached.
731 $this->menuArr[$c] = $data;
732 $this->menuArr[$c]['isSpacer'] = $spacer;
733 $c++;
734 if ($maxItems && $c>=$maxItems) {
735 break;
736 }
737 }
738 }
739 }
740
741 // Fill in fake items, if min-items is set.
742 if ($minItems) {
743 while($c<$minItems) {
744 $this->menuArr[$c] = Array(
745 'title' => '...',
746 'uid' => $GLOBALS['TSFE']->id
747 );
748 $c++;
749 }
750 }
751 // Setting number of menu items
752 $GLOBALS['TSFE']->register['count_menuItems'] = count($this->menuArr);
753 // Passing the menuArr through a user defined function:
754 if ($this->mconf['itemArrayProcFunc']) {
755 if (!is_array($this->parentMenuArr)) {$this->parentMenuArr=array();}
756 $this->menuArr = $this->userProcess('itemArrayProcFunc',$this->menuArr);
757 }
758 $this->hash = md5(serialize($this->menuArr).serialize($this->mconf).serialize($this->tmpl->rootLine).serialize($this->MP_array));
759
760 $serData = $this->sys_page->getHash($this->hash, 60*60*24);
761 if (!$serData) {
762 $this->generate();
763 $this->sys_page->storeHash($this->hash, serialize($this->result),'MENUDATA');
764 } else {
765 $this->result=unserialize($serData);
766 }
767 }
768 }
769
770 /**
771 * Includes the PHP script defined for the HMENU special type "userdefined".
772 * This script is supposed to populate the array $menuItemsArray with a set of page records comprising the menu.
773 * The "userdefined" type is depreciated since "userfunction" has arrived since and is a better choice for many reasons (like using classes/functions for rendering the menu)
774 *
775 * @param array TypoScript parameters for "special.". In particular the property "file" is reserved and specifies the file to include. Seems like any other property can be used freely by the script.
776 * @param string The sorting field. Can be used from the script in the $incFile.
777 * @return array An array with the menu items
778 * @access private
779 */
780 function includeMakeMenu($conf,$altSortField) {
781 $incFile = $GLOBALS['TSFE']->tmpl->getFileName($conf['file']);
782 if ($incFile && $GLOBALS['TSFE']->checkFileInclude($incFile)) {
783 include($incFile);
784 }
785 return is_array($menuItemsArray) ? $menuItemsArray : array();
786 }
787
788 /**
789 * Checks if a page is OK to include in the final menu item array. Pages can be excluded if the doktype is wrong, if they are hidden in navigation, have a uid in the list of banned uids etc.
790 *
791 * @param array Array of menu items
792 * @param array Array of page uids which are to be excluded
793 * @param boolean If set, then the page is a spacer.
794 * @return boolean Returns true if the page can be safely included.
795 */
796 function filterMenuPages($data,$banUidArray,$spacer) {
797 $uid = $data['uid'];
798 if ($this->mconf['SPC'] || !$spacer) { // If the spacer-function is not enabled, spacers will not enter the $menuArr
799 if (!t3lib_div::inList($this->doktypeExcludeList,$data['doktype'])) { // Page may not be 'not_in_menu' or 'Backend User Section'
800 if (!$data['nav_hide']) { // Not hidden in navigation
801 if (!t3lib_div::inArray($banUidArray,$uid)) { // not in banned uid's
802 if (!(!$GLOBALS['TSFE']->sys_language_uid && $data['l18n_cfg']&1)) { // Checks if the default language version can be shown:
803
804 // Checking if a page should be shown in the menu depending on whether a translation exists:
805 $tok = TRUE;
806 if ($GLOBALS['TSFE']->sys_language_uid && $data['l18n_cfg']&2) { // There is an alternative language active AND the current page requires a translation:
807 $olRec = $GLOBALS['TSFE']->sys_page->getPageOverlay($data['uid'], $GLOBALS['TSFE']->sys_language_uid);
808 if (!count($olRec)) {
809 $tok = FALSE;
810 }
811 }
812
813 // Continue if token is true:
814 if ($tok) {
815 return TRUE;
816 }
817 }
818 }
819 }
820 }
821 }
822 }
823
824 /**
825 * Generating the per-menu-item configuration arrays based on the settings for item states (NO, RO, ACT, CUR etc) set in ->mconf (config for the current menu object)
826 * Basically it will produce an individual array for each menu item based on the item states. BUT in addition the "optionSplit" syntax for the values is ALSO evaluated here so that all property-values are "option-splitted" and the output will thus be resolved.
827 * Is called from the "generate" functions in the extension classes. The function is processor intensive due to the option split feature in particular. But since the generate function is not always called (since the ->result array may be cached, see makeMenu) it doesn't hurt so badly.
828 *
829 * @param integer Number of menu items in the menu
830 * @return array An array with two keys: array($NOconf,$ROconf) - where $NOconf contains the resolved configuration for each item when NOT rolled-over and $ROconf contains the ditto for the mouseover state (if any)
831 * @access private
832 */
833 function procesItemStates($splitCount) {
834
835 // Prepare normal settings
836 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.
837 $NOconf = $this->tmpl->splitConfArray($this->mconf['NO.'],$splitCount);
838
839 // Prepare rollOver settings, overriding normal settings
840 $ROconf=array();
841 if ($this->mconf['RO']) {
842 $ROconf = $this->tmpl->splitConfArray($this->mconf['RO.'],$splitCount);
843 }
844
845 // Prepare IFSUB settings, overriding normal settings
846 // IFSUB is true if there exist submenu items to the current item
847 if ($this->mconf['IFSUB']) {
848 $IFSUBinit = 0; // Flag: If $IFSUB is generated
849 reset($NOconf);
850 while (list($key,$val)=each($NOconf)) {
851 if ($this->isItemState('IFSUB',$key)) {
852 if (!$IFSUBinit) { // if this is the first IFSUB element, we must generate IFSUB.
853 $IFSUBconf = $this->tmpl->splitConfArray($this->mconf['IFSUB.'],$splitCount);
854 if ($this->mconf['IFSUBRO']) {
855 $IFSUBROconf = $this->tmpl->splitConfArray($this->mconf['IFSUBRO.'],$splitCount);
856 }
857 $IFSUBinit = 1;
858 }
859 $NOconf[$key] = $IFSUBconf[$key]; // Substitute normal with ifsub
860 if ($ROconf) { // If rollOver on normal, we must apply a state for rollOver on the active
861 $ROconf[$key] = $IFSUBROconf[$key] ? $IFSUBROconf[$key] : $IFSUBconf[$key]; // If RollOver on active then apply this
862 }
863 }
864 }
865 }
866 // Prepare active settings, overriding normal settings
867 if ($this->mconf['ACT']) {
868 $ACTinit = 0; // Flag: If $ACT is generated
869 reset($NOconf);
870 while (list($key,$val)=each($NOconf)) { // Find active
871 if ($this->isItemState('ACT',$key)) {
872 if (!$ACTinit) { // if this is the first active, we must generate ACT.
873 $ACTconf = $this->tmpl->splitConfArray($this->mconf['ACT.'],$splitCount);
874 // Prepare active rollOver settings, overriding normal active settings
875 if ($this->mconf['ACTRO']) {
876 $ACTROconf = $this->tmpl->splitConfArray($this->mconf['ACTRO.'],$splitCount);
877 }
878 $ACTinit = 1;
879 }
880 $NOconf[$key] = $ACTconf[$key]; // Substitute normal with active
881 if ($ROconf) { // If rollOver on normal, we must apply a state for rollOver on the active
882 $ROconf[$key] = $ACTROconf[$key] ? $ACTROconf[$key] : $ACTconf[$key]; // If RollOver on active then apply this
883 }
884 }
885 }
886 }
887 // Prepare active/IFSUB settings, overriding normal settings
888 // ACTIFSUB is true if there exist submenu items to the current item and the current item is active
889 if ($this->mconf['ACTIFSUB']) {
890 $ACTIFSUBinit = 0; // Flag: If $ACTIFSUB is generated
891 reset($NOconf);
892 while (list($key,$val)=each($NOconf)) { // Find active
893 if ($this->isItemState('ACTIFSUB',$key)) {
894 if (!$ACTIFSUBinit) { // if this is the first active, we must generate ACTIFSUB.
895 $ACTIFSUBconf = $this->tmpl->splitConfArray($this->mconf['ACTIFSUB.'],$splitCount);
896 // Prepare active rollOver settings, overriding normal active settings
897 if ($this->mconf['ACTIFSUBRO']) {
898 $ACTIFSUBROconf = $this->tmpl->splitConfArray($this->mconf['ACTIFSUBRO.'],$splitCount);
899 }
900 $ACTIFSUBinit = 1;
901 }
902 $NOconf[$key] = $ACTIFSUBconf[$key]; // Substitute normal with active
903 if ($ROconf) { // If rollOver on normal, we must apply a state for rollOver on the active
904 $ROconf[$key] = $ACTIFSUBROconf[$key] ? $ACTIFSUBROconf[$key] : $ACTIFSUBconf[$key]; // If RollOver on active then apply this
905 }
906 }
907 }
908 }
909 // Prepare CUR (current) settings, overriding normal settings
910 // CUR is true if the current page equals the item here!
911 if ($this->mconf['CUR']) {
912 $CURinit = 0; // Flag: If $CUR is generated
913 reset($NOconf);
914 while (list($key,$val)=each($NOconf)) {
915 if ($this->isItemState('CUR',$key)) {
916 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)
917 $CURconf = $this->tmpl->splitConfArray($this->mconf['CUR.'],$splitCount);
918 if ($this->mconf['CURRO']) {
919 $CURROconf = $this->tmpl->splitConfArray($this->mconf['CURRO.'],$splitCount);
920 }
921 $CURinit = 1;
922 }
923 $NOconf[$key] = $CURconf[$key]; // Substitute normal with current
924 if ($ROconf) { // If rollOver on normal, we must apply a state for rollOver on the active
925 $ROconf[$key] = $CURROconf[$key] ? $CURROconf[$key] : $CURconf[$key]; // If RollOver on active then apply this
926 }
927 }
928 }
929 }
930 // Prepare active settings, overriding normal settings
931 if ($this->mconf['USR']) {
932 $USRinit = 0; // Flag: If $USR is generated
933 reset($NOconf);
934 while (list($key,$val)=each($NOconf)) { // Find active
935 if ($this->isItemState('USR',$key)) {
936 if (!$USRinit) { // if this is the first active, we must generate USR.
937 $USRconf = $this->tmpl->splitConfArray($this->mconf['USR.'],$splitCount);
938 // Prepare active rollOver settings, overriding normal active settings
939 if ($this->mconf['USRRO']) {
940 $USRROconf = $this->tmpl->splitConfArray($this->mconf['USRRO.'],$splitCount);
941 }
942 $USRinit = 1;
943 }
944 $NOconf[$key] = $USRconf[$key]; // Substitute normal with active
945 if ($ROconf) { // If rollOver on normal, we must apply a state for rollOver on the active
946 $ROconf[$key] = $USRROconf[$key] ? $USRROconf[$key] : $USRconf[$key]; // If RollOver on active then apply this
947 }
948 }
949 }
950 }
951 // Prepare spacer settings, overriding normal settings
952 if ($this->mconf['SPC']) {
953 $SPCinit = 0; // Flag: If $SPC is generated
954 reset($NOconf);
955 while (list($key,$val)=each($NOconf)) { // Find spacers
956 if ($this->isItemState('SPC',$key)) {
957 if (!$SPCinit) { // if this is the first spacer, we must generate SPC.
958 $SPCconf = $this->tmpl->splitConfArray($this->mconf['SPC.'],$splitCount);
959 $SPCinit = 1;
960 }
961 $NOconf[$key] = $SPCconf[$key]; // Substitute normal with spacer
962 }
963 }
964 }
965 // Prepare Userdefined settings
966 if ($this->mconf['USERDEF1']) {
967 $USERDEF1init = 0; // Flag: If $USERDEF1 is generated
968 reset($NOconf);
969 while (list($key,$val)=each($NOconf)) { // Find active
970 if ($this->isItemState('USERDEF1',$key)) {
971 if (!$USERDEF1init) { // if this is the first active, we must generate USERDEF1.
972 $USERDEF1conf = $this->tmpl->splitConfArray($this->mconf['USERDEF1.'],$splitCount);
973 // Prepare active rollOver settings, overriding normal active settings
974 if ($this->mconf['USERDEF1RO']) {
975 $USERDEF1ROconf = $this->tmpl->splitConfArray($this->mconf['USERDEF1RO.'],$splitCount);
976 }
977 $USERDEF1init = 1;
978 }
979 $NOconf[$key] = $USERDEF1conf[$key]; // Substitute normal with active
980 if ($ROconf) { // If rollOver on normal, we must apply a state for rollOver on the active
981 $ROconf[$key] = $USERDEF1ROconf[$key] ? $USERDEF1ROconf[$key] : $USERDEF1conf[$key]; // If RollOver on active then apply this
982 }
983 }
984 }
985 }
986 // Prepare Userdefined settings
987 if ($this->mconf['USERDEF2']) {
988 $USERDEF2init = 0; // Flag: If $USERDEF2 is generated
989 reset($NOconf);
990 while (list($key,$val)=each($NOconf)) { // Find active
991 if ($this->isItemState('USERDEF2',$key)) {
992 if (!$USERDEF2init) { // if this is the first active, we must generate USERDEF2.
993 $USERDEF2conf = $this->tmpl->splitConfArray($this->mconf['USERDEF2.'],$splitCount);
994 // Prepare active rollOver settings, overriding normal active settings
995 if ($this->mconf['USERDEF2RO']) {
996 $USERDEF2ROconf = $this->tmpl->splitConfArray($this->mconf['USERDEF2RO.'],$splitCount);
997 }
998 $USERDEF2init = 1;
999 }
1000 $NOconf[$key] = $USERDEF2conf[$key]; // Substitute normal with active
1001 if ($ROconf) { // If rollOver on normal, we must apply a state for rollOver on the active
1002 $ROconf[$key] = $USERDEF2ROconf[$key] ? $USERDEF2ROconf[$key] : $USERDEF2conf[$key]; // If RollOver on active then apply this
1003 }
1004 }
1005 }
1006 }
1007
1008 return array($NOconf,$ROconf);
1009 }
1010
1011 /**
1012 * Creates the URL, target and onclick values for the menu item link. Returns them in an array as key/value pairs for <A>-tag attributes
1013 * This function doesn't care about the url, because if we let the url be redirected, it will be logged in the stat!!!
1014 *
1015 * @param integer Pointer to a key in the $this->menuArr array where the value for that key represents the menu item we are linking to (page record)
1016 * @param string Alternative target
1017 * @param integer Alternative type
1018 * @return array Returns an array with A-tag attributes as key/value pairs (HREF, TARGET and onClick)
1019 * @access private
1020 */
1021 function link($key,$altTarget='',$typeOverride='') {
1022
1023 // Mount points:
1024 $MP_var = $this->getMPvar($key);
1025 $MP_params = $MP_var ? '&MP='.rawurlencode($MP_var) : '';
1026
1027 // Setting override ID
1028 if ($this->mconf['overrideId'] || $this->menuArr[$key]['overrideId']) {
1029 $overrideArray = array();
1030 // If a user script returned the value overrideId in the menu array we use that as page id
1031 $overrideArray['uid'] = $this->mconf['overrideId']?$this->mconf['overrideId']:$this->menuArr[$key]['overrideId'];
1032 $overrideArray['alias'] = '';
1033 $MP_params = ''; // clear MP parameters since ID was changed.
1034 } else {
1035 $overrideArray='';
1036 }
1037
1038 // Setting main target:
1039 $mainTarget = $altTarget ? $altTarget : $this->mconf['target'];
1040
1041 // Creating link:
1042 if ($this->mconf['collapse'] && $this->isActive($this->menuArr[$key]['uid'], $this->getMPvar($key))) {
1043 $thePage = $this->sys_page->getPage($this->menuArr[$key]['pid']);
1044 $LD = $this->tmpl->linkData($thePage,$mainTarget,'','',$overrideArray, $this->mconf['addParams'].$MP_params, $typeOverride);
1045 } else {
1046 $LD = $this->tmpl->linkData($this->menuArr[$key],$mainTarget,'','',$overrideArray, $this->mconf['addParams'].$MP_params, $typeOverride);
1047 }
1048
1049 // Overriding URL / Target if set to do so:
1050 if ($this->menuArr[$key]['_OVERRIDE_HREF']) {
1051 $LD['totalURL'] = $this->menuArr[$key]['_OVERRIDE_HREF'];
1052 if ($this->menuArr[$key]['_OVERRIDE_TARGET']) $LD['target'] = $this->menuArr[$key]['_OVERRIDE_TARGET'];
1053 }
1054
1055 // OnClick open in windows.
1056 $onClick='';
1057 if ($this->mconf['JSWindow']) {
1058 $conf=$this->mconf['JSWindow.'];
1059 $url=$LD['totalURL'];
1060 $LD['totalURL'] = '#';
1061 $onClick= 'openPic(\''.$url.'\',\''.($conf['newWindow']?md5($url):'theNewPage').'\',\''.$conf['params'].'\'); return false;';
1062 $GLOBALS['TSFE']->setJS('openPic');
1063 }
1064 // out:
1065 $list = array();
1066 $list['HREF']=$LD['totalURL'];
1067 $list['TARGET']=$LD['target'];
1068 $list['onClick']=$onClick;
1069
1070 return $list;
1071 }
1072
1073 /**
1074 * Creates a submenu level to the current level - if configured for.
1075 *
1076 * @param integer Page id of the current page for which a submenu MAY be produced (if conditions are met)
1077 * @return string HTML content of the submenu
1078 * @access private
1079 */
1080 function subMenu($uid) {
1081
1082 // Setting alternative menu item array if _SUB_MENU has been defined in the current ->menuArr
1083 $altArray = '';
1084 if (is_array($this->menuArr[$this->I['key']]['_SUB_MENU']) && count($this->menuArr[$this->I['key']]['_SUB_MENU'])) {
1085 $altArray = $this->menuArr[$this->I['key']]['_SUB_MENU'];
1086 }
1087
1088 // Make submenu if the page is the next active
1089 if ($this->subLevelClass && ($this->mconf['expAll'] || $this->isNext($uid, $this->getMPvar($this->I['key'])) || is_array($altArray)) && !$this->mconf['sectionIndex']) {
1090 $submenu = t3lib_div::makeInstance('tslib_'.$this->subLevelClass);
1091 $submenu->entryLevel = $this->entryLevel+1;
1092 $submenu->rL_uidRegister = $this->rL_uidRegister;
1093 $submenu->MP_array = $this->MP_array;
1094 if ($this->menuArr[$this->I['key']]['_MP_PARAM']) {
1095 $submenu->MP_array[] = $this->menuArr[$this->I['key']]['_MP_PARAM'];
1096 }
1097
1098 // especially scripts that build the submenu needs the parent data
1099 $submenu->parentMenuArr = $this->menuArr;
1100
1101 // Setting alternativeMenuTempArray (will be effective only if an array)
1102 if (is_array($altArray)) {
1103 $submenu->alternativeMenuTempArray = $altArray;
1104 }
1105
1106 if ($submenu->start($this->tmpl, $this->sys_page, $uid, $this->conf, $this->menuNumber+1)) {
1107 $submenu->makeMenu();
1108 return $submenu->writeMenu();
1109 }
1110 }
1111 }
1112
1113 /**
1114 * Returns true if the page with UID $uid is the NEXT page in root line (which means a submenu should be drawn)
1115 *
1116 * @param integer Page uid to evaluate.
1117 * @param string MPvar for the current position of item.
1118 * @return boolean True if page with $uid is active
1119 * @access private
1120 * @see subMenu()
1121 */
1122 function isNext($uid, $MPvar='') {
1123 $testUid = $uid.($MPvar?':'.$MPvar:'');
1124 if ($uid && $testUid==$this->nextActive) {
1125 return TRUE;
1126 }
1127 }
1128
1129 /**
1130 * Returns true if the page with UID $uid is active (in the current rootline)
1131 *
1132 * @param integer Page uid to evaluate.
1133 * @param string MPvar for the current position of item.
1134 * @return boolean True if page with $uid is active
1135 * @access private
1136 */
1137 function isActive($uid, $MPvar='') {
1138 $testUid = $uid.($MPvar?':'.$MPvar:'');
1139 if ($uid && in_array('ITEM:'.$testUid, $this->rL_uidRegister)) {
1140 return TRUE;
1141 }
1142 }
1143
1144 /**
1145 * Returns true if the page with UID $uid is the CURRENT page (equals $GLOBALS['TSFE']->id)
1146 *
1147 * @param integer Page uid to evaluate.
1148 * @param string MPvar for the current position of item.
1149 * @return boolean True if page $uid = $GLOBALS['TSFE']->id
1150 * @access private
1151 */
1152 function isCurrent($uid, $MPvar='') {
1153 $testUid = $uid.($MPvar?':'.$MPvar:'');
1154 if ($uid && !strcmp(end($this->rL_uidRegister),'ITEM:'.$testUid)) {
1155 return TRUE;
1156 }
1157 }
1158
1159 /**
1160 * Returns true if there is a submenu with items for the page id, $uid
1161 * Used by the item states "IFSUB" and "ACTIFSUB" to check if there is a submenu
1162 *
1163 * @param integer Page uid for which to search for a submenu
1164 * @return boolean Returns true if there was a submenu with items found
1165 * @access private
1166 */
1167 function isSubMenu($uid) {
1168
1169 // 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;
1170 $mount_info = $this->sys_page->getMountPointInfo($uid);
1171 if (is_array($mount_info)) {
1172 $uid = $mount_info['mount_pid'];
1173 }
1174
1175 $recs = $this->sys_page->getMenu($uid,'uid,pid,doktype,mount_pid,mount_pid_ol');
1176 foreach($recs as $theRec) {
1177 if (!t3lib_div::inList($this->doktypeExcludeList,$theRec['doktype']) && !$theRec['nav_hide']) { // If a menu item seems to be another type than 'Not in menu', then return true (there were items!)
1178 return TRUE;
1179 }
1180 }
1181 }
1182
1183 /**
1184 * Used by procesItemStates() to evaluate if a menu item (identified by $key) is in a certain state.
1185 *
1186 * @param string The item state to evaluate (SPC, IFSUB, ACT etc... but no xxxRO states of course)
1187 * @param integer Key pointing to menu item from ->menuArr
1188 * @return boolean True (integer!=0) if match, otherwise false (=0, zero)
1189 * @access private
1190 * @see procesItemStates()
1191 */
1192 function isItemState($kind,$key) {
1193 $natVal=0;
1194 if ($this->menuArr[$key]['ITEM_STATE']) { // If any value is set for ITEM_STATE the normal evaluation is discarded
1195 if (!strcmp($this->menuArr[$key]['ITEM_STATE'],$kind)) {$natVal=1;}
1196 } else {
1197 switch($kind) {
1198 case 'SPC':
1199 $natVal = $this->menuArr[$key]['isSpacer'];
1200 break;
1201 case 'IFSUB':
1202 $natVal = $this->isSubMenu($this->menuArr[$key]['uid']);
1203 break;
1204 case 'ACT':
1205 $natVal = $this->isActive($this->menuArr[$key]['uid'], $this->getMPvar($key));
1206 break;
1207 case 'ACTIFSUB':
1208 $natVal = $this->isActive($this->menuArr[$key]['uid'], $this->getMPvar($key)) && $this->isSubMenu($this->menuArr[$key]['uid']);
1209 break;
1210 case 'CUR':
1211 $natVal = $this->isCurrent($this->menuArr[$key]['uid'], $this->getMPvar($key));
1212 break;
1213 case 'USR':
1214 $natVal = $this->menuArr[$key]['fe_group'];
1215 break;
1216 }
1217 }
1218
1219 return $natVal;
1220 }
1221
1222 /**
1223 * Creates an access-key for a GMENU menu item based on the menu item titles first letter
1224 *
1225 * @param string Menu item title.
1226 * @return array Returns an array with keys "code" ("accesskey" attribute for the img-tag) and "alt" (text-addition to the "alt" attribute) if an access key was defined. Otherwise array was empty
1227 * @access private
1228 */
1229 function accessKey($title) {
1230 // The global array ACCESSKEY is used to globally control if letters are already used!!
1231 $result = Array();
1232
1233 $titleLen = strlen($title);
1234 for ($a=0;$a<$titleLen;$a++) {
1235 $key = strtoupper(trim(substr($title,$a,1)));
1236 if ($key && !isset($GLOBALS['TSFE']->accessKey[$key])) {
1237 $GLOBALS['TSFE']->accessKey[$key]=1;
1238 $result['code'] = ' accesskey="'.$key.'"';
1239 $result['alt'] = ' (ALT+'.$key.')';
1240 break;
1241 }
1242 }
1243 return $result;
1244 }
1245
1246 /**
1247 * Calls a user function for processing of internal data.
1248 * Used for the properties "IProcFunc" and "itemArrayProcFunc"
1249 *
1250 * @param string Key pointing for the property in the current ->mconf array holding possibly parameters to pass along to the function/method. Currently the keys used are "IProcFunc" and "itemArrayProcFunc".
1251 * @param mixed A variable to pass to the user function and which should be returned again from the user function. The idea is that the user function modifies this variable according to what you want to achieve and then returns it. For "itemArrayProcFunc" this variable is $this->menuArr, for "IProcFunc" it is $this->I
1252 * @return mixed The processed $passVar
1253 * @access private
1254 */
1255 function userProcess($mConfKey,$passVar) {
1256 if ($this->mconf[$mConfKey]) {
1257 $funcConf = $this->mconf[$mConfKey.'.'];
1258 $funcConf['parentObj']=&$this;
1259 $passVar = $GLOBALS['TSFE']->cObj->callUserFunction($this->mconf[$mConfKey], $funcConf, $passVar);
1260 }
1261 return $passVar;
1262 }
1263
1264 /**
1265 * Creates the <A> tag parts for the current item (in $this->I, [A1] and [A2]) based on other information in this array (like $this->I['linkHREF'])
1266 *
1267 * @return void
1268 * @access private
1269 */
1270 function setATagParts() {
1271 $this->I['A1'] = '<a '.t3lib_div::implodeAttributes($this->I['linkHREF'],1).$this->I['val']['ATagParams'].$this->I['addATagParams'].$this->I['accessKey']['code'].'>';
1272 $this->I['A2'] = '</a>';
1273 }
1274
1275 /**
1276 * Returns the title for the navigation
1277 *
1278 * @param string The current page title
1279 * @param string The current value of the naviation title
1280 * @return string Returns the navigation title if it is NOT blank, otherwise the page title.
1281 * @access private
1282 */
1283 function getPageTitle($title,$nav_title) {
1284 return strcmp(trim($nav_title),'') ? $nav_title : $title;
1285 }
1286
1287 /**
1288 * Return MPvar string for entry $key in ->menuArr
1289 *
1290 * @param integer Pointer to element in ->menuArr
1291 * @param string Implode token.
1292 * @return string MP vars for element.
1293 * @see link()
1294 */
1295 function getMPvar($key) {
1296 if ($GLOBALS['TYPO3_CONF_VARS']['FE']['enable_mount_pids']) {
1297 $localMP_array = $this->MP_array;
1298 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!
1299 $MP_params = count($localMP_array) ? implode(',',$localMP_array) : '';
1300 return $MP_params;
1301 }
1302 }
1303
1304 /**
1305 * Returns where clause part to exclude 'not in menu' pages
1306 *
1307 * @return string where clause part.
1308 * @access private
1309 */
1310 function getDoktypeExcludeWhere() {
1311 return $this->doktypeExcludeList ? ' AND pages.doktype NOT IN ('.$this->doktypeExcludeList.')' : '';
1312 }
1313
1314 }
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334 /**
1335 * Extension class creating text based menus
1336 *
1337 * @author Kasper Skaarhoj <kasper@typo3.com>
1338 * @package TYPO3
1339 * @subpackage tslib
1340 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=387&cHash=73a3116ab8
1341 */
1342 class tslib_tmenu extends tslib_menu {
1343
1344 /**
1345 * Calls procesItemStates() so that the common configuration for the menu items are resolved into individual configuration per item.
1346 * Sets the result for the new "normal state" in $this->result
1347 *
1348 * @return void
1349 * @see tslib_menu::procesItemStates()
1350 */
1351 function generate() {
1352 $splitCount = count($this->menuArr);
1353 if ($splitCount) {
1354 list($NOconf) = $this->procesItemStates($splitCount);
1355 }
1356 if ($this->mconf['debugItemConf']) {echo '<h3>$NOconf:</h3>'; debug($NOconf); }
1357 $this->result = $NOconf;
1358 }
1359
1360 /**
1361 * Traverses the ->result array of menu items configuration (made by ->generate()) and renders each item.
1362 * During the execution of this function many internal methods prefixed "extProc_" from this class is called and many of these are for now dummy functions. But they can be used for processing as they are used by the TMENU_LAYERS
1363 * An instance of tslib_cObj is also made and for each menu item rendered it is loaded with the record for that page so that any stdWrap properties that applies will have the current menu items record available.
1364 *
1365 * @return string The HTML for the menu (returns result through $this->extProc_finish(); )
1366 */
1367 function writeMenu() {
1368 if (is_array($this->result) && count($this->result)) {
1369 $this->WMcObj =t3lib_div::makeInstance('tslib_cObj'); // Create new tslib_cObj for our use
1370 $this->WMresult='';
1371 $this->INPfixMD5 = substr(md5(microtime().'tmenu'),0,4);
1372 $this->WMmenuItems = count($this->result);
1373 $this->extProc_init();
1374 reset($this->result);
1375 while (list($key,$val)=each($this->result)) {
1376 $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']++;
1377 $GLOBALS['TSFE']->register['count_MENUOBJ']++;
1378
1379 $this->I=array();
1380 $this->WMcObj->start($this->menuArr[$key],'pages'); // Initialize the cObj with the page record of the menu item
1381 $this->I['key'] = $key;
1382 $this->I['INPfix']= $this->imgNameNotRandom?'':'_'.$this->INPfixMD5.'_'.$key;
1383 $this->I['val'] = $val;
1384 $this->I['title'] = $this->WMcObj->stdWrap($this->getPageTitle($this->menuArr[$key]['title'],$this->menuArr[$key]['nav_title']),$this->I['val']['stdWrap.']);
1385 $this->I['uid'] = $this->menuArr[$key]['uid'];
1386 $this->I['mount_pid'] = $this->menuArr[$key]['mount_pid'];
1387 $this->I['pid'] = $this->menuArr[$key]['pid'];
1388 $this->I['spacer'] = $this->menuArr[$key]['isSpacer'];
1389
1390 // Make link tag
1391 $this->I['val']['ATagParams'] = $this->I['val']['ATagParams'] ? ' '.$this->I['val']['ATagParams'] : '';
1392 $this->I['linkHREF'] = $this->link($key,$this->I['val']['altTarget'],$this->mconf['forceTypeValue']);
1393
1394 // Title attribute of links:
1395 $titleAttrValue = $this->WMcObj->stdWrap($this->I['val']['ATagTitle'],$this->I['val']['ATagTitle.']);
1396 if (strlen($titleAttrValue)) {
1397 $this->I['linkHREF']['title'] = $titleAttrValue;
1398 }
1399
1400 // Setting "blurlink()" function:
1401 if (!$this->mconf['noBlur']) {
1402 $this->I['linkHREF']['onFocus']='blurLink(this);';
1403 }
1404
1405 // Make link:
1406 if ($this->I['val']['RO']) {
1407 $this->I['theName'] = $this->imgNamePrefix.$this->I['uid'].$this->I['INPfix'];
1408 $over='';
1409 $out ='';
1410 if ($this->I['val']['beforeROImg']) {
1411 $over.= $this->WMfreezePrefix."over('".$this->I['theName']."before');";
1412 $out.= $this->WMfreezePrefix."out('".$this->I['theName']."before');";
1413 }
1414 if ($this->I['val']['afterROImg']) {
1415 $over.= $this->WMfreezePrefix."over('".$this->I['theName']."after');";
1416 $out.= $this->WMfreezePrefix."out('".$this->I['theName']."after');";
1417 }
1418 $this->I['linkHREF']['onMouseover']=$over;
1419 $this->I['linkHREF']['onMouseout']=$out;
1420 if ($over || $out) $GLOBALS['TSFE']->setJS('mouseOver');
1421
1422 // Change background color:
1423 if ($this->I['val']['RO_chBgColor']) {
1424 $this->addJScolorShiftFunction();
1425 $chBgP = t3lib_div::trimExplode('|',$this->I['val']['RO_chBgColor']);
1426 $this->I['linkHREF']['onMouseover'].="changeBGcolor('".$chBgP[2].$this->I['uid']."','".$chBgP[0]."');";
1427 $this->I['linkHREF']['onMouseout'].="changeBGcolor('".$chBgP[2].$this->I['uid']."','".$chBgP[1]."');";
1428 }
1429
1430 $this->extProc_RO($key);
1431 }
1432
1433
1434
1435 // Calling extra processing function
1436 $this->extProc_beforeLinking($key);
1437
1438 // Compile link tag
1439 if (!$this->I['val']['doNotLinkIt']) {$this->I['val']['doNotLinkIt']=0;}
1440 if (!$this->I['val']['isSpacer'] && $this->I['val']['doNotLinkIt']!=1) {
1441 $this->setATagParts();
1442 } else {
1443 $this->I['A1'] = '';
1444 $this->I['A2'] = '';
1445 }
1446
1447 // ATAGBeforeWrap processing:
1448 if ($this->I['val']['ATagBeforeWrap']) {
1449 $wrapPartsBefore = explode('|',$this->I['val']['linkWrap']);
1450 $wrapPartsAfter = array('','');
1451 } else {
1452 $wrapPartsBefore = array('','');
1453 $wrapPartsAfter = explode('|',$this->I['val']['linkWrap']);
1454 }
1455 if ($this->I['val']['stdWrap2'] || isset($this->I['val']['stdWrap2.'])) {
1456 $wrapPartsStdWrap = explode($this->I['val']['stdWrap2']?$this->I['val']['stdWrap2']:'|',$this->WMcObj->stdWrap('|',$this->I['val']['stdWrap2.']));
1457 } else {$wrapPartsStdWrap = array('','');}
1458
1459 // Make before, middle and after parts
1460 $this->I['parts'] = array();
1461 $this->I['parts']['before']=$this->getBeforeAfter('before');
1462 $this->I['parts']['stdWrap2_begin']=$wrapPartsStdWrap[0];
1463 if (!$this->I['val']['doNotShowLink']) {
1464 $this->I['parts']['notATagBeforeWrap_begin'] = $wrapPartsAfter[0];
1465 $this->I['parts']['ATag_begin'] = $this->I['A1'];
1466 $this->I['parts']['ATagBeforeWrap_begin'] = $wrapPartsBefore[0];
1467 $this->I['parts']['title'] = $this->I['title'];
1468 $this->I['parts']['ATagBeforeWrap_end'] = $wrapPartsBefore[1];
1469 $this->I['parts']['ATag_end'] = $this->I['A2'];
1470 $this->I['parts']['notATagBeforeWrap_end'] = $wrapPartsAfter[1];
1471 }
1472 $this->I['parts']['stdWrap2_end']=$wrapPartsStdWrap[1];
1473 $this->I['parts']['after']=$this->getBeforeAfter('after');
1474
1475 // Passing I to a user function
1476 if ($this->mconf['IProcFunc']) {
1477 $this->I = $this->userProcess('IProcFunc',$this->I);
1478 }
1479
1480 // Merge parts + beforeAllWrap
1481 $this->I['theItem']= implode('',$this->I['parts']);
1482 $this->I['theItem']= $this->extProc_beforeAllWrap($this->I['theItem'],$key);
1483
1484 // allWrap:
1485 $allWrap = $this->WMcObj->stdWrap($this->I['val']['allWrap'],$this->I['val']['allWrap.']);
1486 $this->I['theItem'] = $this->tmpl->wrap($this->I['theItem'],$allWrap);
1487
1488 if ($this->I['val']['subst_elementUid']) $this->I['theItem'] = str_replace('{elementUid}',$this->I['uid'],$this->I['theItem']);
1489
1490 // allStdWrap:
1491 if (is_array($this->I['val']['allStdWrap.'])) {
1492 $this->I['theItem'] = $this->WMcObj->stdWrap($this->I['theItem'],$this->I['val']['allStdWrap.']);
1493 }
1494
1495 // Calling extra processing function
1496 $this->extProc_afterLinking($key);
1497 }
1498 return $this->extProc_finish();
1499 }
1500 }
1501
1502 /**
1503 * Generates the before* and after* images for TMENUs
1504 *
1505 * @param string Can be "before" or "after" and determines which kind of image to create (basically this is the prefix of the TypoScript properties that are read from the ->I['val'] array
1506 * @return string The resulting HTML of the image, if any.
1507 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=388&cHash=a7486044cd
1508 */
1509 function getBeforeAfter($pref) {
1510 $res = '';
1511 if ($imgInfo = $this->WMcObj->getImgResource($this->I['val'][$pref.'Img'],$this->I['val'][$pref.'Img.'])) {
1512 $imgInfo[3] = t3lib_div::png_to_gif_by_imagemagick($imgInfo[3]);
1513 if ($this->I['val']['RO'] && $this->I['val'][$pref.'ROImg'] && !$this->I['val']['isSpacer']) {
1514 $imgROInfo = $this->WMcObj->getImgResource($this->I['val'][$pref.'ROImg'],$this->I['val'][$pref.'ROImg.']);
1515 $imgROInfo[3] = t3lib_div::png_to_gif_by_imagemagick($imgROInfo[3]);
1516 if ($imgROInfo) {
1517 $theName = $this->imgNamePrefix.$this->I['uid'].$this->I['INPfix'].$pref;
1518 $name = ' name="'.$theName.'"';
1519 $GLOBALS['TSFE']->JSImgCode.= chr(10).$theName.'_n=new Image(); '.$theName.'_n.src = "'.$GLOBALS['TSFE']->absRefPrefix.$imgInfo[3].'"; ';
1520 $GLOBALS['TSFE']->JSImgCode.= chr(10).$theName.'_h=new Image(); '.$theName.'_h.src = "'.$GLOBALS['TSFE']->absRefPrefix.$imgROInfo[3].'"; ';
1521 }
1522 }
1523 $GLOBALS['TSFE']->imagesOnPage[]=$imgInfo[3];
1524 $res='<img src="'.$GLOBALS['TSFE']->absRefPrefix.$imgInfo[3].'" width="'.$imgInfo[0].'" height="'.$imgInfo[1].'"'.$name.($this->I['val'][$pref.'ImgTagParams']?" ".$this->I['val'][$pref.'ImgTagParams']:'').' border="0"';
1525 if (!strstr($res,'alt="')) $res.=' alt=""'; // Adding alt attribute if not set.
1526 $res.=' />';
1527 if ($this->I['val'][$pref.'ImgLink']) {$res=$this->I['A1'].$res.$this->I['A2'];}
1528 }
1529 return $this->tmpl->wrap($res.$this->WMcObj->stdWrap($this->I['val'][$pref],$this->I['val'][$pref.'.']), $this->I['val'][$pref.'Wrap']);
1530 }
1531
1532 /**
1533 * Adds a JavaScript function to the $GLOBALS['TSFE']->additionalJavaScript array
1534 *
1535 * @return void
1536 * @access private
1537 * @see writeMenu()
1538 */
1539 function addJScolorShiftFunction() {
1540 $GLOBALS['TSFE']->additionalJavaScript['TMENU:changeBGcolor()']='
1541 function changeBGcolor(id,color) { //
1542 if (document.getElementById && document.getElementById(id)) {
1543 document.getElementById(id).style.background = color;
1544 return true;
1545 } else if (document.layers && document.layers[id]) {
1546 document.layers[id].bgColor = color;
1547 return true;
1548 }
1549 }
1550 ';
1551 }
1552
1553 /**
1554 * Called right before the traversing of $this->result begins.
1555 * Can be used for various initialization
1556 *
1557 * @return void
1558 * @access private
1559 * @see writeMenu(), tslib_tmenu_layers::extProc_init()
1560 */
1561 function extProc_init() {
1562 }
1563
1564 /**
1565 * Called after all processing for RollOver of an element has been done.
1566 *
1567 * @param integer Pointer to $this->menuArr[$key] where the current menu element record is found
1568 * @return void
1569 * @access private
1570 * @see writeMenu(), tslib_tmenu_layers::extProc_RO()
1571 */
1572 function extProc_RO($key) {
1573 }
1574
1575 /**
1576 * Called right before the creation of the link for the menu item
1577 *
1578 * @param integer Pointer to $this->menuArr[$key] where the current menu element record is found
1579 * @return void
1580 * @access private
1581 * @see writeMenu(), tslib_tmenu_layers::extProc_beforeLinking()
1582 */
1583 function extProc_beforeLinking($key) {
1584 }
1585
1586 /**
1587 * Called right after the creation of links for the menu item. This is also the last function call before the while-loop traversing menu items goes to the next item.
1588 * This function MUST set $this->WMresult.=[HTML for menu item] to add the generated menu item to the internal accumulation of items.
1589 *
1590 * @param integer Pointer to $this->menuArr[$key] where the current menu element record is found
1591 * @return void
1592 * @access private
1593 * @see writeMenu(), tslib_tmenu_layers::extProc_afterLinking()
1594 */
1595 function extProc_afterLinking($key) {
1596 // Add part to the accumulated result + fetch submenus
1597 if (!$this->I['spacer']) {
1598 $this->I['theItem'].= $this->subMenu($this->I['uid']);
1599 }
1600 $this->WMresult.= $this->I['val']['wrapItemAndSub'] ? $this->tmpl->wrap($this->I['theItem'],$this->I['val']['wrapItemAndSub']) : $this->I['theItem'];
1601 }
1602
1603 /**
1604 * Called before the "allWrap" happens on the menu item.
1605 *
1606 * @param string The current content of the menu item, $this->I['theItem'], passed along.
1607 * @param integer Pointer to $this->menuArr[$key] where the current menu element record is found
1608 * @return string The modified version of $item, going back into $this->I['theItem']
1609 * @access private
1610 * @see writeMenu(), tslib_tmenu_layers::extProc_beforeAllWrap()
1611 */
1612 function extProc_beforeAllWrap($item,$key) {
1613 return $item;
1614 }
1615
1616 /**
1617 * Called before the writeMenu() function returns (only if a menu was generated)
1618 *
1619 * @return string The total menu content should be returned by this function
1620 * @access private
1621 * @see writeMenu(), tslib_tmenu_layers::extProc_finish()
1622 */
1623 function extProc_finish() {
1624 return $this->tmpl->wrap($this->WMresult,$this->mconf['wrap']).$this->WMextraScript;
1625 }
1626 }
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651 /**
1652 * Extension class creating graphic based menus (PNG or GIF files)
1653 *
1654 * @author Kasper Skaarhoj <kasper@typo3.com>
1655 * @package TYPO3
1656 * @subpackage tslib
1657 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=384&cHash=93a7644cba
1658 */
1659 class tslib_gmenu extends tslib_menu {
1660
1661 /**
1662 * Calls procesItemStates() so that the common configuration for the menu items are resolved into individual configuration per item.
1663 * Calls makeGifs() for all "normal" items and if configured for, also the "rollover" items.
1664 *
1665 * @return void
1666 * @see tslib_menu::procesItemStates(), makeGifs()
1667 */
1668 function generate() {
1669 $splitCount = count($this->menuArr);
1670 if ($splitCount) {
1671 list($NOconf,$ROconf) = $this->procesItemStates($splitCount);
1672
1673 //store initial count value
1674 $temp_HMENU_MENUOBJ = $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'];
1675 $temp_MENUOBJ = $GLOBALS['TSFE']->register['count_MENUOBJ'];
1676 // Now we generate the giffiles:
1677 $this->makeGifs($NOconf,'NO');
1678 // store count from NO obj
1679 $tempcnt_HMENU_MENUOBJ = $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'];
1680 $tempcnt_MENUOBJ = $GLOBALS['TSFE']->register['count_MENUOBJ'];
1681
1682 if ($this->mconf['debugItemConf']) {echo '<h3>$NOconf:</h3>'; debug($NOconf); }
1683 if ($ROconf) { // RollOver
1684 //start recount for rollover with initial values
1685 $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']= $temp_HMENU_MENUOBJ;
1686 $GLOBALS['TSFE']->register['count_MENUOBJ']= $temp_MENUOBJ;
1687 $this->makeGifs($ROconf,'RO');
1688 if ($this->mconf['debugItemConf']) {echo '<h3>$ROconf:</h3>'; debug($ROconf); }
1689 }
1690 // use count from NO obj
1691 $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'] = $tempcnt_HMENU_MENUOBJ;
1692 $GLOBALS['TSFE']->register['count_MENUOBJ'] = $tempcnt_MENUOBJ;
1693 }
1694 }
1695
1696 /**
1697 * Will traverse input array with configuratoin per-item and create corresponding GIF files for the menu.
1698 * The data of the files are stored in $this->result
1699 *
1700 * @param array Array with configuration for each item.
1701 * @param string Type of images: normal ("NO") or rollover ("RO"). Valid values are "NO" and "RO"
1702 * @return void
1703 * @access private
1704 * @see generate()
1705 */
1706 function makeGifs($conf, $resKey) {
1707 $isGD = $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'];
1708
1709 if (!is_array($conf)) {
1710 $conf = Array();
1711 }
1712
1713 $totalWH=array();
1714 $items = count($conf);
1715 if ($isGD) {
1716 // generate the gif-files. the $menuArr is filled with some values like output_w, output_h, output_file
1717 $Hcounter = 0;
1718 $Wcounter = 0;
1719 $Hobjs = $this->mconf['applyTotalH'];
1720 if ($Hobjs) {$Hobjs = t3lib_div::intExplode(',',$Hobjs);}
1721 $Wobjs = $this->mconf['applyTotalW'];
1722 if ($Wobjs) {$Wobjs = t3lib_div::intExplode(',',$Wobjs);}
1723 $minDim = $this->mconf['min'];
1724 if ($minDim) {$minDim = tslib_cObj::calcIntExplode(',',$minDim.',');}
1725 $maxDim = $this->mconf['max'];
1726 if ($maxDim) {$maxDim = tslib_cObj::calcIntExplode(',',$maxDim.',');}
1727
1728 if ($minDim) {
1729 $conf[$items]=$conf[$items-1];
1730 $this->menuArr[$items]=Array();
1731 $items = count($conf);
1732 }
1733
1734 // TOTAL width
1735 if ($this->mconf['useLargestItemX'] || $this->mconf['useLargestItemY'] || $this->mconf['distributeX'] || $this->mconf['distributeY']) {
1736 $totalWH = $this->findLargestDims($conf,$items,$Hobjs,$Wobjs,$minDim,$maxDim);
1737 }
1738 }
1739
1740 $c=0;
1741 $maxFlag=0;
1742 $distributeAccu=array('H'=>0,'W'=>0);
1743 reset($conf);
1744 while (list($key,$val)=each($conf)) {
1745 $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']++;
1746 $GLOBALS['TSFE']->register['count_MENUOBJ']++;
1747
1748 if ($items==($c+1) && $minDim) {
1749 $Lobjs = $this->mconf['removeObjectsOfDummy'];
1750 if ($Lobjs) {
1751 $Lobjs = t3lib_div::intExplode(',',$Lobjs);
1752 reset($Lobjs);
1753 while(list(,$remItem)=each($Lobjs)) {
1754 unset($val[$remItem]);
1755 unset($val[$remItem.'.']);
1756 }
1757 }
1758
1759 $flag =0;
1760 $tempXY = explode(',',$val['XY']);
1761 if ($Wcounter<$minDim[0]) {$tempXY[0]=$minDim[0]-$Wcounter; $flag=1;}
1762 if ($Hcounter<$minDim[1]) {$tempXY[1]=$minDim[1]-$Hcounter; $flag=1;}
1763 $val['XY'] = implode($tempXY,',');
1764 if (!$flag){break;}
1765 }
1766 $c++;
1767
1768
1769 if ($isGD) {
1770 // Pre-working the item
1771 $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder');
1772 $gifCreator->init();
1773 $gifCreator->start($val,$this->menuArr[$key]);
1774
1775 // If useLargestItemH/W is specified
1776 if (count($totalWH) && ($this->mconf['useLargestItemX'] || $this->mconf['useLargestItemY'])) {
1777 $tempXY = explode(',',$gifCreator->setup['XY']);
1778 if ($this->mconf['useLargestItemX']) {$tempXY[0] = max($totalWH['W']);}
1779 if ($this->mconf['useLargestItemY']) {$tempXY[1] = max($totalWH['H']);}
1780 // regenerate the new values...
1781 $val['XY'] = implode($tempXY,',');
1782 $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder');
1783 $gifCreator->init();
1784 $gifCreator->start($val,$this->menuArr[$key]);
1785 }
1786
1787 // If distributeH/W is specified
1788 if (count($totalWH) && ($this->mconf['distributeX'] || $this->mconf['distributeY'])) {
1789 $tempXY = explode(',',$gifCreator->setup['XY']);
1790
1791 if ($this->mconf['distributeX']) {
1792 $diff = $this->mconf['distributeX']-$totalWH['W_total']-$distributeAccu['W'];
1793 $compensate = round($diff /($items-$c+1));
1794 $distributeAccu['W']+=$compensate;
1795 $tempXY[0] = $totalWH['W'][$key]+$compensate;
1796 }
1797 if ($this->mconf['distributeY']) {
1798 $diff = $this->mconf['distributeY']-$totalWH['H_total']-$distributeAccu['H'];
1799 $compensate = round($diff /($items-$c+1));
1800 $distributeAccu['H']+=$compensate;
1801 $tempXY[1] = $totalWH['H'][$key]+$compensate;
1802 }
1803 // regenerate the new values...
1804 $val['XY'] = implode($tempXY,',');
1805 $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder');
1806 $gifCreator->init();
1807 $gifCreator->start($val,$this->menuArr[$key]);
1808 }
1809
1810 // If max dimensions are specified
1811 if ($maxDim) {
1812 $tempXY = explode(',',$val['XY']);
1813 if ($maxDim[0] && $Wcounter+$gifCreator->XY[0]>=$maxDim[0]) {$tempXY[0]==$maxDim[0]-$Wcounter; $maxFlag=1;}
1814 if ($maxDim[1] && $Hcounter+$gifCreator->XY[1]>=$maxDim[1]) {$tempXY[1]=$maxDim[1]-$Hcounter; $maxFlag=1;}
1815 if ($maxFlag) {
1816 $val['XY'] = implode($tempXY,',');
1817 $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder');
1818 $gifCreator->init();
1819 $gifCreator->start($val,$this->menuArr[$key]);
1820 }
1821 }
1822
1823
1824
1825
1826 // displace
1827 if ($Hobjs) {
1828 reset($Hobjs);
1829 while(list(,$index)=each($Hobjs)) {
1830 if ($gifCreator->setup[$index] && $gifCreator->setup[$index.'.']) {
1831 $oldOffset = explode(',',$gifCreator->setup[$index.'.']['offset']);
1832 $gifCreator->setup[$index.'.']['offset'] = implode($gifCreator->applyOffset($oldOffset,Array(0,-$Hcounter)), ',');
1833 }
1834 }
1835 }
1836
1837 if ($Wobjs) {
1838 reset($Wobjs);
1839 while(list(,$index)=each($Wobjs)) {
1840 if ($gifCreator->setup[$index] && $gifCreator->setup[$index.'.']) {
1841 $oldOffset = explode(',',$gifCreator->setup[$index.'.']['offset']);
1842 $gifCreator->setup[$index.'.']['offset'] = implode($gifCreator->applyOffset($oldOffset,Array(-$Wcounter,0)), ',');
1843 }
1844 }
1845 }
1846 }
1847
1848 // Finding alternative GIF names if any (by altImgResource)
1849 $gifFileName='';
1850 if ($conf[$key]['altImgResource'] || is_array($conf[$key]['altImgResource.'])) {
1851 if (!is_object($cObj)) {$cObj=t3lib_div::makeInstance('tslib_cObj');}
1852 $cObj->start($this->menuArr[$key],'pages');
1853 $altImgInfo = $cObj->getImgResource($conf[$key]['altImgResource'],$conf[$key]['altImgResource.']);
1854 $gifFileName=$altImgInfo[3];
1855 }
1856
1857 // If an alternative name was NOT given, find the GIFBUILDER name.
1858 if (!$gifFileName && $isGD) {
1859 $gifCreator->createTempSubDir('menu/');
1860 $gifFileName = $gifCreator->fileName('menu/');
1861 }
1862
1863 // Generation of image file:
1864 if (@file_exists($gifFileName)) { // File exists
1865 $info = @getimagesize($gifFileName);
1866 $this->result[$resKey][$key]['output_w']=intval($info[0]);
1867 $this->result[$resKey][$key]['output_h']=intval($info[1]);
1868 $this->result[$resKey][$key]['output_file']=$gifFileName;
1869 } elseif ($isGD) { // file is generated
1870 $gifCreator->make();
1871 $this->result[$resKey][$key]['output_w']=$gifCreator->w;
1872 $this->result[$resKey][$key]['output_h']=$gifCreator->h;
1873 $this->result[$resKey][$key]['output_file'] = $gifFileName;
1874 $gifCreator->output($this->result[$resKey][$key]['output_file']);
1875 $gifCreator->destroy();
1876 }
1877 $this->result[$resKey][$key]['output_file'] = t3lib_div::png_to_gif_by_imagemagick($this->result[$resKey][$key]['output_file']);
1878 $this->result[$resKey][$key]['noLink']=$conf[$key]['noLink'];
1879 $this->result[$resKey][$key]['altTarget']=$conf[$key]['altTarget'];
1880 $this->result[$resKey][$key]['imgParams']=$conf[$key]['imgParams'];
1881 $this->result[$resKey][$key]['ATagTitle'] = $conf[$key]['ATagTitle'];
1882 $this->result[$resKey][$key]['ATagTitle.'] = $conf[$key]['ATagTitle.'];
1883 $this->result[$resKey][$key]['wrap'] = $conf[$key]['wrap'];
1884 $this->result[$resKey][$key]['allWrap'] = $conf[$key]['allWrap'];
1885 $this->result[$resKey][$key]['allWrap.'] = $conf[$key]['allWrap.'];
1886 $this->result[$resKey][$key]['subst_elementUid'] = $conf[$key]['subst_elementUid'];
1887 $this->result[$resKey][$key]['allStdWrap.'] = $conf[$key]['allStdWrap.'];
1888
1889 $Hcounter+=$this->result[$resKey][$key]['output_h']; // counter is increased
1890 $Wcounter+=$this->result[$resKey][$key]['output_w']; // counter is increased
1891
1892 if ($maxFlag){break;}
1893 }
1894 }
1895
1896 /**
1897 * Function searching for the largest width and height of the menu items to be generated.
1898 * Uses some of the same code as makeGifs and even instantiates some gifbuilder objects BUT does not render the images - only reading out which width they would have.
1899 * Remember to upgrade the code in here if the makeGifs function is updated.
1900 *
1901 * @param array Same configuration array as passed to makeGifs()
1902 * @param integer The number of menu items
1903 * @param array Array with "applyTotalH" numbers
1904 * @param array Array with "applyTotalW" numbers
1905 * @param array Array with "min" x/y
1906 * @param array Array with "max" x/y
1907 * @return array Array with keys "H" and "W" which are in themselves arrays with the heights and widths of menu items inside. This can be used to find the max/min size of the menu items.
1908 * @access private
1909 * @see makeGifs()
1910 */
1911 function findLargestDims($conf,$items,$Hobjs,$Wobjs,$minDim,$maxDim) {
1912 $totalWH = array(
1913 'W' => array(),
1914 'H' => array(),
1915 'W_total' => 0,
1916 'H_total' => 0
1917 );
1918
1919 $Hcounter = 0;
1920 $Wcounter = 0;
1921 $c=0;
1922 $maxFlag=0;
1923 reset($conf);
1924 while (list($key,$val)=each($conf)) {
1925 // SAME CODE AS makeGifs()! BEGIN
1926 if ($items==($c+1) && $minDim) {
1927 $Lobjs = $this->mconf['removeObjectsOfDummy'];
1928 if ($Lobjs) {
1929 $Lobjs = t3lib_div::intExplode(',',$Lobjs);
1930 reset($Lobjs);
1931 while(list(,$remItem)=each($Lobjs)) {
1932 unset($val[$remItem]);
1933 unset($val[$remItem.'.']);
1934 }
1935 }
1936
1937 $flag =0;
1938 $tempXY = explode(',',$val['XY']);
1939 if ($Wcounter<$minDim[0]) {$tempXY[0]=$minDim[0]-$Wcounter; $flag=1;}
1940 if ($Hcounter<$minDim[1]) {$tempXY[1]=$minDim[1]-$Hcounter; $flag=1;}
1941 $val['XY'] = implode($tempXY,',');
1942 if (!$flag){break;}
1943 }
1944 $c++;
1945
1946 $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder');
1947 $gifCreator->init();
1948 $gifCreator->start($val,$this->menuArr[$key]);
1949 if ($maxDim) {
1950 $tempXY = explode(',',$val['XY']);
1951 if ($maxDim[0] && $Wcounter+$gifCreator->XY[0]>=$maxDim[0]) {$tempXY[0]==$maxDim[0]-$Wcounter; $maxFlag=1;}
1952 if ($maxDim[1] && $Hcounter+$gifCreator->XY[1]>=$maxDim[1]) {$tempXY[1]=$maxDim[1]-$Hcounter; $maxFlag=1;}
1953 if ($maxFlag) {
1954 $val['XY'] = implode($tempXY,',');
1955 $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder');
1956 $gifCreator->init();
1957 $gifCreator->start($val,$this->menuArr[$key]);
1958 }
1959 }
1960 // SAME CODE AS makeGifs()! END
1961
1962 // Setting the width/height
1963 $totalWH['W'][$key]=$gifCreator->XY[0];
1964 $totalWH['H'][$key]=$gifCreator->XY[1];
1965 $totalWH['W_total']+=$gifCreator->XY[0];
1966 $totalWH['H_total']+=$gifCreator->XY[1];
1967 // ---- //
1968
1969 $Hcounter+=$gifCreator->XY[1]; // counter is increased
1970 $Wcounter+=$gifCreator->XY[0]; // counter is increased
1971
1972 if ($maxFlag){break;}
1973 }
1974 return $totalWH;
1975 }
1976
1977 /**
1978 * Traverses the ->result['NO'] array of menu items configuration (made by ->generate()) and renders the HTML of each item (the images themselves was made with makeGifs() before this. See ->generate())
1979 * During the execution of this function many internal methods prefixed "extProc_" from this class is called and many of these are for now dummy functions. But they can be used for processing as they are used by the GMENU_LAYERS
1980 *
1981 * @return string The HTML for the menu (returns result through $this->extProc_finish(); )
1982 */
1983 function writeMenu() {
1984 if (is_array($this->menuArr) && is_array($this->result) && count($this->result) && is_array($this->result['NO'])) {
1985 $this->WMcObj = t3lib_div::makeInstance('tslib_cObj'); // Create new tslib_cObj for our use
1986 $this->WMresult='';
1987 $this->INPfixMD5 = substr(md5(microtime().$this->GMENU_fixKey),0,4);
1988 $this->WMmenuItems = count($this->result['NO']);
1989 $this->extProc_init();
1990 for ($key=0;$key<$this->WMmenuItems;$key++) {
1991 if ($this->result['NO'][$key]['output_file']) {
1992 $this->WMcObj->start($this->menuArr[$key],'pages'); // Initialize the cObj with the page record of the menu item
1993
1994 $this->I =array();
1995 $this->I['key'] = $key;
1996 $this->I['INPfix']= $this->imgNameNotRandom?'':'_'.$this->INPfixMD5.'_'.$key;
1997 $this->I['val'] = $this->result['NO'][$key];
1998 $this->I['title'] = $this->getPageTitle($this->menuArr[$key]['title'],$this->menuArr[$key]['nav_title']);
1999 $this->I['uid'] = $this->menuArr[$key]['uid'];
2000 $this->I['mount_pid'] = $this->menuArr[$key]['mount_pid'];
2001 $this->I['pid'] = $this->menuArr[$key]['pid'];
2002 $this->I['spacer'] = $this->menuArr[$key]['isSpacer'];
2003 if (!$this->I['uid'] && !$this->menuArr[$key]['_OVERRIDE_HREF']) {$this->I['spacer']=1;}
2004 $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
2005 $this->I['name']='';
2006
2007 // Get link.
2008 $this->I['linkHREF'] = $this->link($key,$this->I['val']['altTarget'],$this->mconf['forceTypeValue']);
2009 // Title attribute of links:
2010 $titleAttrValue = $this->WMcObj->stdWrap($this->I['val']['ATagTitle'],$this->I['val']['ATagTitle.']);
2011 if (strlen($titleAttrValue)) {
2012 $this->I['linkHREF']['title'] = $titleAttrValue;
2013 }
2014 // Setting "blurlink()" function:
2015 if (!$this->mconf['noBlur']) {
2016 $this->I['linkHREF']['onFocus']='blurLink(this);';
2017 }
2018
2019 // Set rollover
2020 if ($this->result['RO'][$key] && !$this->I['noLink']) {
2021 $this->I['theName'] = $this->imgNamePrefix.$this->I['uid'].$this->I['INPfix'];
2022 $this->I['name'] = ' name="'.$this->I["theName"].'"';
2023 $this->I['linkHREF']['onMouseover']=$this->WMfreezePrefix.'over(\''.$this->I['theName'].'\');';
2024 $this->I['linkHREF']['onMouseout']=$this->WMfreezePrefix.'out(\''.$this->I['theName'].'\');';
2025 $GLOBALS['TSFE']->JSImgCode.= chr(10).$this->I['theName'].'_n=new Image(); '.$this->I['theName'].'_n.src = "'.$GLOBALS['TSFE']->absRefPrefix.$this->I['val']['output_file'].'"; ';
2026 $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'].'"; ';
2027 $GLOBALS['TSFE']->imagesOnPage[]=$this->result['RO'][$key]['output_file'];
2028 $GLOBALS['TSFE']->setJS('mouseOver');
2029 $this->extProc_RO($key);
2030 }
2031 // Set access key
2032 if ($this->mconf['accessKey']) {
2033 $this->I['accessKey'] = $this->accessKey($this->I['title']);
2034 } else {
2035 $this->I['accessKey']=Array();
2036 }
2037
2038 // Set altText
2039 $this->I['altText'] = $this->mconf['disableAltText'] ? '' : $this->I['title'].$this->I['accessKey']['alt'];
2040
2041 // Calling extra processing function
2042 $this->extProc_beforeLinking($key);
2043
2044 // Set linking
2045 if (!$this->I['noLink']) {
2046 $this->setATagParts();
2047 } else {
2048 $this->I['A1'] = '';
2049 $this->I['A2'] = '';
2050 }
2051 $this->I['IMG'] = '<img src="'.$GLOBALS['TSFE']->absRefPrefix.$this->I['val']['output_file'].'" width="'.$this->I['val']['output_w'].'" height="'.$this->I['val']['output_h'].'" border="0" alt="'.htmlspecialchars($this->I['altText']).'"'.$this->I['name'].($this->I['val']['imgParams']?' '.$this->I['val']['imgParams']:'').' />';
2052
2053 // Make before, middle and after parts
2054 $this->I['parts'] = array();
2055 $this->I['parts']['ATag_begin'] = $this->I['A1'];
2056 $this->I['parts']['image'] = $this->I['IMG'];
2057 $this->I['parts']['ATag_end'] = $this->I['A2'];
2058
2059 // Passing I to a user function
2060 if ($this->mconf['IProcFunc']) {
2061 $this->I = $this->userProcess('IProcFunc',$this->I);
2062 }
2063
2064 // Putting the item together.
2065 // Merge parts + beforeAllWrap
2066 $this->I['theItem']= implode('',$this->I['parts']);
2067 $this->I['theItem']= $this->extProc_beforeAllWrap($this->I['theItem'],$key);
2068
2069 // wrap:
2070 $this->I['theItem']= $this->tmpl->wrap($this->I['theItem'],$this->I['val']['wrap']);
2071
2072 // allWrap:
2073 $allWrap = $this->WMcObj->stdWrap($this->I['val']['allWrap'],$this->I['val']['allWrap.']);
2074 $this->I['theItem'] = $this->tmpl->wrap($this->I['theItem'],$allWrap);
2075
2076 if ($this->I['val']['subst_elementUid']) $this->I['theItem'] = str_replace('{elementUid}',$this->I['uid'],$this->I['theItem']);
2077
2078 // allStdWrap:
2079 if (is_array($this->I['val']['allStdWrap.'])) {
2080 $this->I['theItem'] = $this->WMcObj->stdWrap($this->I['theItem'],$this->I['val']['allStdWrap.']);
2081 }
2082
2083 $GLOBALS['TSFE']->imagesOnPage[]=$this->I['val']['output_file'];
2084
2085 $this->extProc_afterLinking($key);
2086 }
2087 }
2088 return $this->extProc_finish();
2089 }
2090 }
2091
2092 /**
2093 * Called right before the traversing of $this->result begins.
2094 * Can be used for various initialization
2095 *
2096 * @return void
2097 * @access private
2098 * @see writeMenu(), tslib_gmenu_layers::extProc_init()
2099 */
2100 function extProc_init() {
2101 }
2102
2103 /**
2104 * Called after all processing for RollOver of an element has been done.
2105 *
2106 * @param integer Pointer to $this->menuArr[$key] where the current menu element record is found OR $this->result['RO'][$key] where the configuration for that elements RO version is found!
2107 * @return void
2108 * @access private
2109 * @see writeMenu(), tslib_gmenu_layers::extProc_RO()
2110 */
2111 function extProc_RO($key) {
2112 }
2113
2114 /**
2115 * Called right before the creation of the link for the menu item
2116 *
2117 * @param integer Pointer to $this->menuArr[$key] where the current menu element record is found
2118 * @return void
2119 * @access private
2120 * @see writeMenu(), tslib_gmenu_layers::extProc_beforeLinking()
2121 */
2122 function extProc_beforeLinking($key) {
2123 }
2124
2125 /**
2126 * Called right after the creation of links for the menu item. This is also the last function call before the for-loop traversing menu items goes to the next item.
2127 * This function MUST set $this->WMresult.=[HTML for menu item] to add the generated menu item to the internal accumulation of items.
2128 * Further this calls the subMenu function in the parent class to create any submenu there might be.
2129 *
2130 * @param integer Pointer to $this->menuArr[$key] where the current menu element record is found
2131 * @return void
2132 * @access private
2133 * @see writeMenu(), tslib_gmenu_layers::extProc_afterLinking(), tslib_menu::subMenu()
2134 */
2135 function extProc_afterLinking($key) {
2136 $this->WMresult.=$this->I['theItem'];
2137 if (!$this->I['spacer']) {
2138 $this->WMresult.= $this->subMenu($this->I['uid']);
2139 }
2140 }
2141
2142
2143 /**
2144 * Called before the "wrap" happens on the menu item.
2145 *
2146 * @param string The current content of the menu item, $this->I['theItem'], passed along.
2147 * @param integer Pointer to $this->menuArr[$key] where the current menu element record is found
2148 * @return string The modified version of $item, going back into $this->I['theItem']
2149 * @access private
2150 * @see writeMenu(), tslib_gmenu_layers::extProc_beforeAllWrap()
2151 */
2152 function extProc_beforeAllWrap($item,$key) {
2153 return $item;
2154 }
2155
2156 /**
2157 * Called before the writeMenu() function returns (only if a menu was generated)
2158 *
2159 * @return string The total menu content should be returned by this function
2160 * @access private
2161 * @see writeMenu(), tslib_gmenu_layers::extProc_finish()
2162 */
2163 function extProc_finish() {
2164 return $this->tmpl->wrap($this->WMresult,$this->mconf['wrap']).$this->WMextraScript;
2165 }
2166 }
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189 /**
2190 * ImageMap based menus
2191 *
2192 * @author Kasper Skaarhoj <kasper@typo3.com>
2193 * @package TYPO3
2194 * @subpackage tslib
2195 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=389&cHash=fcf18c5d9f
2196 */
2197 class tslib_imgmenu extends tslib_menu {
2198
2199 /**
2200 * Calls procesItemStates() so that the common configuration for the menu items are resolved into individual configuration per item.
2201 * Calls makeImageMap() to generate the image map image-file
2202 *
2203 * @return void
2204 * @see tslib_menu::procesItemStates(), makeImageMap()
2205 */
2206 function generate() {
2207 $splitCount = count($this->menuArr);
2208 if ($splitCount) {
2209 list($NOconf) = $this->procesItemStates($splitCount);
2210 }
2211 if ($this->mconf['debugItemConf']) {echo '<h3>$NOconf:</h3>'; debug($NOconf); }
2212 $this->makeImageMap($NOconf);
2213 }
2214
2215 /**
2216 * Will traverse input array with configuratoin per-item and create corresponding GIF files for the menu.
2217 * The data of the files are stored in $this->result
2218 *
2219 * @param array Array with configuration for each item.
2220 * @return void
2221 * @access private
2222 * @see generate()
2223 */
2224 function makeImageMap($conf) {
2225 if (!is_array($conf)) {
2226 $conf = Array();
2227 }
2228 if (is_array($this->mconf['main.'])) {
2229 $gifCreator = t3lib_div::makeInstance('tslib_gifBuilder');
2230 $gifCreator->init();
2231
2232 $itemsConf = $conf;
2233 $conf = $this->mconf['main.'];
2234 if (is_array($conf)) {
2235 $gifObjCount = 0;
2236
2237 $sKeyArray=t3lib_TStemplate::sortedKeyList($conf);
2238 $gifObjCount=intval(end($sKeyArray));
2239
2240 $lastOriginal = $gifObjCount;
2241
2242 // Now we add graphical objects to the gifbuilder-setup
2243 reset($itemsConf);
2244 $waArr = Array();
2245 while (list($key,$val)=each($itemsConf)) {
2246 if (is_array($val)) {
2247 $gifObjCount++;
2248 $waArr[$key]['free']=$gifObjCount;
2249
2250 $sKeyArray=t3lib_TStemplate::sortedKeyList($val);
2251
2252 foreach($sKeyArray as $theKey) {
2253 $theValue=$val[$theKey];
2254
2255
2256 if (intval($theKey) && $theValArr=$val[$theKey.'.']) {
2257 $cObjData = $this->menuArr[$key] ? $this->menuArr[$key] : Array();
2258
2259 $gifObjCount++;
2260 if ($theValue=='TEXT') {
2261 $waArr[$key]['textNum']=$gifObjCount;
2262
2263 $gifCreator->data = $cObjData;
2264 $theValArr = $gifCreator->checkTextObj($theValArr);
2265 unset($theValArr['text.']); // if this is not done it seems that imageMaps will be rendered wrong!!
2266 // check links
2267
2268 $LD = $this->tmpl->linkData($this->menuArr[$key],$this->mconf['target'],'','',array(),'',$this->mconf['forceTypeValue']);
2269
2270 // Overriding URL / Target if set to do so:
2271 if ($this->menuArr[$key]['_OVERRIDE_HREF']) {
2272 $LD['totalURL'] = $this->menuArr[$key]['_OVERRIDE_HREF'];
2273 if ($this->menuArr[$key]['_OVERRIDE_TARGET']) $LD['target'] = $this->menuArr[$key]['_OVERRIDE_TARGET'];
2274 }
2275
2276 // Setting target/url for Image Map:
2277 if ($theValArr['imgMap.']['url']=='') {
2278 $theValArr['imgMap.']['url'] = $LD['totalURL'];
2279 }
2280 if ($theValArr['imgMap.']['target']=='') {
2281 $theValArr['imgMap.']['target'] = $LD['target'];
2282 }
2283 if ($theValArr['imgMap.']['noBlur']=='') {
2284 $theValArr['imgMap.']['noBlur'] = $this->mconf['noBlur'];
2285 }
2286 if (is_array($theValArr['imgMap.']['altText.'])) {
2287 $cObj =t3lib_div::makeInstance('tslib_cObj');
2288 $cObj->start($cObjData,'pages');
2289 $theValArr['imgMap.']['altText'] = $cObj->stdWrap($theValArr['imgMap.']['altText'], $theValArr['imgMap.']['altText.']);
2290 unset($theValArr['imgMap.']['altText.']);
2291 }
2292 if (is_array($theValArr['imgMap.']['titleText.'])) {
2293 $cObj =t3lib_div::makeInstance('tslib_cObj');
2294 $cObj->start($cObjData,'pages');
2295 $theValArr['imgMap.']['titleText'] = $cObj->stdWrap($theValArr['imgMap.']['titleText'], $theValArr['imgMap.']['titleText.']);
2296 unset($theValArr['imgMap.']['titleText.']);
2297 }
2298 }
2299 // 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!!
2300 if ($theValue=='IMAGE') {
2301 if ($theValArr['file']=='GIFBUILDER') {
2302 $temp_sKeyArray=t3lib_TStemplate::sortedKeyList($theValArr['file.']);
2303 reset($temp_sKeyArray);
2304 while(list(,$temp_theKey)=each($temp_sKeyArray)) {
2305 if ($theValArr['mask.'][$temp_theKey]=='TEXT') {
2306 $gifCreator->data = $this->menuArr[$key] ? $this->menuArr[$key] : Array();
2307 $theValArr['mask.'][$temp_theKey.'.'] = $gifCreator->checkTextObj($theValArr['mask.'][$temp_theKey.'.']);
2308 unset($theValArr['mask.'][$temp_theKey.'.']['text.']); // if this is not done it seems that imageMaps will be rendered wrong!!
2309 }
2310 }
2311 }
2312 if ($theValArr['mask']=='GIFBUILDER') {
2313 $temp_sKeyArray=t3lib_TStemplate::sortedKeyList($theValArr['mask.']);
2314 reset($temp_sKeyArray);
2315 while(list(,$temp_theKey)=each($temp_sKeyArray)) {
2316 if ($theValArr['mask.'][$temp_theKey]=='TEXT') {
2317 $gifCreator->data = $this->menuArr[$key] ? $this->menuArr[$key] : Array();
2318 $theValArr['mask.'][$temp_theKey.'.'] = $gifCreator->checkTextObj($theValArr['mask.'][$temp_theKey.'.']);
2319 unset($theValArr['mask.'][$temp_theKey.'.']['text.']); // if this is not done it seems that imageMaps will be rendered wrong!!
2320 }
2321 }
2322 }
2323 }
2324
2325 // Checks if disabled is set...
2326 $setObjFlag=1;
2327 if ($theValArr['if.']) {
2328 $cObj =t3lib_div::makeInstance('tslib_cObj');
2329 $cObj->start($cObjData,'pages');
2330 if (!$cObj->checkIf($theValArr['if.'])) {
2331 $setObjFlag=0;
2332 }
2333 unset($theValArr['if.']);
2334 }
2335 // Set the object!
2336 if ($setObjFlag) {
2337 $conf[$gifObjCount] = $theValue;
2338 $conf[$gifObjCount.'.'] = $theValArr;
2339 }
2340 }
2341 }
2342 }
2343 }
2344
2345 $gifCreator->start($conf,$GLOBALS['TSFE']->page);
2346 // calculations
2347
2348 $sum=Array(0,0,0,0);
2349 reset($waArr);
2350 while (list($key,$val)=each($waArr)) {
2351 if ($dConf[$key] =$itemsConf[$key]['distrib']) {
2352 $textBB = $gifCreator->objBB[$val['textNum']];
2353 $dConf[$key] = str_replace('textX',$textBB[0],$dConf[$key]);
2354 $dConf[$key] = str_replace('textY',$textBB[1],$dConf[$key]);
2355 $dConf[$key] = t3lib_div::intExplode(',',$gifCreator->calcOffset($dConf[$key]));
2356 }
2357 }
2358 $workArea = t3lib_div::intExplode(',',$gifCreator->calcOffset($this->mconf['dWorkArea']));
2359 reset($waArr);
2360 while (list($key,$val)=each($waArr)) {
2361 $index = $val['free'];
2362 $gifCreator->setup[$index] = 'WORKAREA';
2363 $workArea[2] = $dConf[$key][2] ? $dConf[$key][2] : $dConf[$key][0];
2364 $workArea[3] = $dConf[$key][3] ? $dConf[$key][3] : $dConf[$key][1];
2365
2366 $gifCreator->setup[$index.'.']['set'] = implode($workArea,',');
2367 $workArea[0]+=$dConf[$key][0];
2368 $workArea[1]+=$dConf[$key][1];
2369 }
2370
2371 if ($this->mconf['debugRenumberedObject']) {echo '<h3>Renumbered GIFBUILDER object:</h3>'; debug($gifCreator->setup);}
2372
2373 $gifCreator->createTempSubDir('menu/');
2374 $gifFileName = $gifCreator->fileName('menu/');
2375
2376 // Gets the ImageMap from the cache...
2377 $imgHash = md5($gifFileName);
2378 $imgMap = $this->sys_page->getHash($imgHash, 0);
2379
2380 if ($imgMap && @file_exists($gifFileName)) { // File exists
2381 $info = @getimagesize($gifFileName);
2382 $w=$info[0];
2383 $h=$info[1];
2384 } else { // file is generated
2385 $gifCreator->make();
2386 $w=$gifCreator->w;
2387 $h=$gifCreator->h;
2388 $gifCreator->output($gifFileName);
2389 $gifCreator->destroy();
2390 $imgMap=$gifCreator->map;
2391 $this->sys_page->storeHash($imgHash, $imgMap, 'MENU IMAGEMAP');
2392 }
2393 $imgMap.=$this->mconf['imgMapExtras'];
2394
2395 $gifFileName = t3lib_div::png_to_gif_by_imagemagick($gifFileName);
2396 $this->result = Array('output_file'=>$gifFileName, 'output_w'=>$w, 'output_h'=>$h, 'imgMap'=>$imgMap);
2397 }
2398 }
2399 }
2400
2401 /**
2402 * Returns the HTML for the image map menu.
2403 * If ->result is true it will create the HTML for the image map menu.
2404 *
2405 * @return string The HTML for the menu
2406 */
2407 function writeMenu() {
2408 if ($this->result) {
2409 $res = $this->result;
2410 $menuName = 'menu_'.t3lib_div::shortMD5($res['imgMap']); // shortMD5 260900
2411 $result = '<img src="'.$GLOBALS['TSFE']->absRefPrefix.$res['output_file'].'" width="'.$res['output_w'].'" height="'.$res['output_h'].'" usemap="#'.$menuName.'" border="0" '.$this->mconf['params'];
2412 if (!strstr($result,'alt="')) $result.=' alt="Menu Image Map"'; // Adding alt attribute if not set.
2413 $result.= ' /><map name="'.$menuName.'" id="'.$menuName.'">'.$res['imgMap'].'</map>';
2414
2415 $GLOBALS['TSFE']->imagesOnPage[]=$res['output_file'];
2416
2417 return $this->tmpl->wrap($result,$this->mconf['wrap']);
2418 }
2419 }
2420 }
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442 /**
2443 * JavaScript/Selectorbox based menus
2444 *
2445 * @author Kasper Skaarhoj <kasper@typo3.com>
2446 * @package TYPO3
2447 * @subpackage tslib
2448 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=391&cHash=563435abbc
2449 */
2450 class tslib_jsmenu extends tslib_menu {
2451
2452 /**
2453 * Dummy. Should do nothing, because we don't use the result-array here!
2454 *
2455 * @return void
2456 */
2457 function generate() {
2458 }
2459
2460 /**
2461 * Creates the HTML (mixture of a <form> and a JavaScript section) for the JavaScript menu (basically an array of selector boxes with onchange handlers)
2462 *
2463 * @return string The HTML code for the menu
2464 */
2465 function writeMenu() {
2466 if ($this->id) {
2467 // Making levels:
2468 $levels = t3lib_div::intInRange($this->mconf['levels'],1,5);
2469 $this->levels = $levels;
2470 $this->JSVarName='eid';
2471 $this->JSMenuName= $this->mconf['menuName'] ? $this->mconf['menuName'] : 'JSmenu';
2472
2473 $JScode="\n var ".$this->JSMenuName." = new JSmenu(".$levels.",'".$this->JSMenuName."Form');";
2474
2475 for ($a=1;$a<=$levels;$a++) {
2476 $JScode.="\n var ".$this->JSVarName.$a."=0;";
2477 }
2478 $JScode.= $this->generate_level($levels,1,$this->id,$this->menuArr,$this->MP_array)."\n";
2479
2480 $GLOBALS['TSFE']->additionalHeaderData['JSMenuCode']='<script type="text/javascript" src="'.$GLOBALS['TSFE']->absRefPrefix.'t3lib/jsfunc.menu.js"></script>';
2481 $GLOBALS['TSFE']->JSCode.=$JScode;
2482
2483 // Printing:
2484 $allFormCode="";
2485 for ($a=1;$a<=$this->levels;$a++) {
2486 $formCode='';
2487 $levelConf = $this->mconf[$a.'.'];
2488 $length = $levelConf['width'] ? $levelConf['width'] : 14;
2489 $lenghtStr='';
2490 for ($b=0;$b<$length;$b++) {
2491 $lenghtStr.='_';
2492 }
2493 $height = $levelConf['elements'] ? $levelConf['elements'] : 5;
2494
2495 $formCode.= '<select name="selector'.$a.'" onchange="'.$this->JSMenuName.'.act('.$a.');"'.($levelConf['additionalParams']?' '.$levelConf['additionalParams']:'').'>';
2496 for ($b=0;$b<$height;$b++) {
2497 $formCode.= '<option value="0">';
2498 if ($b==0) {
2499 $formCode.= $lenghtStr;
2500 }
2501 $formCode.='</option>';
2502 }
2503 $formCode.= '</select>';
2504 $allFormCode.=$this->tmpl->wrap($formCode,$levelConf['wrap']);
2505 }
2506 $formCode = $this->tmpl->wrap($allFormCode,$this->mconf['wrap']);
2507
2508 $formCode= '<form action="" method="post" style="margin: 0 0 0 0;" name="'.$this->JSMenuName.'Form">'.$formCode.'</form>';
2509 $formCode.='<script type="text/javascript"> /*<![CDATA[*/ '.$this->JSMenuName.'.writeOut(1,'.$this->JSMenuName.'.openID,1); /*]]>*/ </script>';
2510 return $this->tmpl->wrap($formCode,$this->mconf['wrapAfterTags']);
2511 }
2512 }
2513
2514 /**
2515 * Generates a number of lines of JavaScript code for a menu level.
2516 * Calls itself recursively for additional levels.
2517 *
2518 * @param integer Number of levels to generate
2519 * @param integer Current level being generated - and if this number is less than $levels it will call itself recursively with $count incremented
2520 * @param integer Page id of the starting point.
2521 * @param array $this->menuArr passed along
2522 * @param array Previous MP vars
2523 * @return string JavaScript code lines.
2524 * @access private
2525 */
2526 function generate_level($levels,$count,$pid,$menuItemArray='',$MP_array=array()) {
2527 $levelConf = $this->mconf[$count.'.'];
2528
2529 // Translate PID to a mount page, if any:
2530 $mount_info = $this->sys_page->getMountPointInfo($pid);
2531 if (is_array($mount_info)) {
2532 $MP_array[] = $mount_info['MPvar'];
2533 $pid = $mount_info['mount_pid'];
2534 }
2535
2536 // Set "&MP=" var:
2537 $MP_var = implode(',',$MP_array);
2538 $MP_params = $MP_var ? '&MP='.rawurlencode($MP_var) : '';
2539
2540 // UIDs to ban:
2541 $banUidArray=array();
2542 if (trim($this->conf['excludeUidList'])) {
2543 $banUidArray = t3lib_div::intExplode(',', $this->conf['excludeUidList']);
2544 }
2545
2546 // Initializing variables:
2547 $var = $this->JSVarName;
2548 $menuName = $this->JSMenuName;
2549 $parent = $count==1 ? 0 : $var.($count-1);
2550 $prev=0;
2551 $c=0;
2552
2553 $menuItems = is_array($menuItemArray) ? $menuItemArray : $this->sys_page->getMenu($pid);
2554 foreach($menuItems as $uid => $data) {
2555 $spacer = (t3lib_div::inList($this->spacerIDList,$data['doktype'])?1:0); // if item is a spacer, $spacer is set
2556 if ($this->mconf['SPC'] || !$spacer) { // If the spacer-function is not enabled, spacers will not enter the $menuArr
2557 if (!t3lib_div::inList($this->doktypeExcludeList,$data['doktype']) && !$data['nav_hide'] && !t3lib_div::inArray($banUidArray,$uid)) { // Page may not be 'not_in_menu' or 'Backend User Section' + not in banned uid's
2558 if ($count<$levels) {
2559 $addLines = $this->generate_level($levels,$count+1,$data['uid'],'',$MP_array);
2560 } else {
2561 $addLines = '';
2562 }
2563 $title=rawurlencode($data['title']);
2564 $url='';
2565 $target='';
2566 if ((!$addLines && !$levelConf['noLink']) || $levelConf['alwaysLink']) {
2567 $LD = $this->tmpl->linkData($data,$this->mconf['target'],'','',array(),$MP_params,$this->mconf['forceTypeValue']);
2568 $url = rawurlencode($LD['totalURL']);
2569 $target = rawurlencode($LD['target']);
2570 }
2571 $codeLines.="\n".$var.$count."=".$menuName.".add(".$parent.",".$prev.",0,'".$title."','".$url."','".$target."');";
2572 // If the active one should be chosen...
2573 $active = ($levelConf['showActive'] && $data['uid'] == $this->tmpl->rootLine[$count]['uid']);
2574 // If the first item should be shown
2575 $first = (!$c && $levelConf['showFirst']);
2576 // do it...
2577 if ($active || $first) {
2578 if ($count==1) {
2579 $codeLines.="\n".$menuName.".openID = ".$var.$count.";";
2580 } else {
2581 $codeLines.="\n".$menuName.".entry[".$parent."].openID = ".$var.$count.";";
2582 }
2583 }
2584 // Add submenu...
2585 $codeLines.=$addLines;
2586
2587 $prev=$var.$count;
2588 $c++;
2589 }
2590 }
2591 }
2592 if ($this->mconf['firstLabelGeneral'] && !$levelConf['firstLabel']) {
2593 $levelConf['firstLabel'] = $this->mconf['firstLabelGeneral'];
2594 }
2595 if ($levelConf['firstLabel'] && $codeLines) {
2596 $codeLines.="\n".$menuName.".defTopTitle[".$count."] = unescape('".rawurlencode($levelConf['firstLabel'])."');";
2597 }
2598 return $codeLines;
2599 }
2600 }
2601
2602
2603 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_menu.php']) {
2604 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_menu.php']);
2605 }
2606
2607 ?>