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