TYPO3 CMS  TYPO3_6-2
AbstractMenuContentObject.php
Go to the documentation of this file.
1 <?php
3 
20 
31 
32  // tells you which menu-number this is. This is important when getting data from the setup
36  public $menuNumber = 1;
37 
38  // 0 = rootFolder
42  public $entryLevel = 0;
43 
44  // The doktype-number that defines a spacer
48  public $spacerIDList = '199';
49 
50  // Doktypes that define which should not be included in a menu
54  public $doktypeExcludeList = '6';
55 
59  public $alwaysActivePIDlist = array();
60 
64  public $imgNamePrefix = 'img';
65 
69  public $imgNameNotRandom = 0;
70 
74  public $debug = 0;
75 
82  public $parent_cObj;
83 
87  public $GMENU_fixKey = 'gmenu';
88 
89  // accumulation of mount point data
93  public $MP_array = array();
94 
95  // internal
96  // HMENU configuration
100  public $conf = array();
101 
102  // xMENU configuration (TMENU, GMENU etc)
106  public $mconf = array();
107 
114  public $tmpl;
115 
122  public $sys_page;
123 
124  // The base page-id of the menu.
128  public $id;
129 
130  // Holds the page uid of the NEXT page in the root line from the page pointed to by entryLevel;
131  // Used to expand the menu automatically if in a certain root line.
135  public $nextActive;
136 
137  // The array of menuItems which is built
141  public $menuArr;
142 
146  public $hash;
147 
151  public $result = array();
152 
153  // Array: Is filled with an array of page uid numbers + RL parameters which are in the current
154  // root line (used to evaluate whether a menu item is in active state)
158  public $rL_uidRegister = '';
159 
163  public $INPfixMD5;
164 
168  public $I;
169 
173  public $WMresult;
174 
179 
183  public $WMmenuItems;
184 
189 
194 
195  // Can be set to contain menu item arrays for sub-levels.
200 
201  // Will be 'id' in XHTML-mode
205  public $nameAttribute = 'name';
206 
213  protected $useCacheHash = FALSE;
214 
228  public function start(&$tmpl, &$sys_page, $id, $conf, $menuNumber, $objSuffix = '') {
229  // Init:
230  $this->conf = $conf;
231  $this->menuNumber = $menuNumber;
232  $this->mconf = $conf[$this->menuNumber . $objSuffix . '.'];
233  $this->debug = $GLOBALS['TSFE']->debug;
234  // In XHTML there is no "name" attribute anymore
235  switch ($GLOBALS['TSFE']->xhtmlDoctype) {
236  case 'xhtml_strict':
237 
238  case 'xhtml_11':
239 
240  case 'xhtml_2':
241 
242  case 'html5':
243  $this->nameAttribute = 'id';
244  break;
245  default:
246  $this->nameAttribute = 'name';
247  }
248  // Sets the internal vars. $tmpl MUST be the template-object. $sys_page MUST be the sys_page object
249  if ($this->conf[$this->menuNumber . $objSuffix] && is_object($tmpl) && is_object($sys_page)) {
250  $this->tmpl = $tmpl;
251  $this->sys_page = $sys_page;
252  // alwaysActivePIDlist initialized:
253  if (trim($this->conf['alwaysActivePIDlist']) || isset($this->conf['alwaysActivePIDlist.'])) {
254  if (isset($this->conf['alwaysActivePIDlist.'])) {
255  $this->conf['alwaysActivePIDlist'] = $this->parent_cObj->stdWrap($this->conf['alwaysActivePIDlist'], $this->conf['alwaysActivePIDlist.']);
256  }
257  $this->alwaysActivePIDlist = GeneralUtility::intExplode(',', $this->conf['alwaysActivePIDlist']);
258  }
259  // 'not in menu' doktypes
260  if ($this->conf['excludeDoktypes']) {
261  $this->doktypeExcludeList = $GLOBALS['TYPO3_DB']->cleanIntList($this->conf['excludeDoktypes']);
262  }
263  // EntryLevel
264  $this->entryLevel = $this->parent_cObj->getKey(isset($conf['entryLevel.']) ? $this->parent_cObj->stdWrap($conf['entryLevel'], $conf['entryLevel.']) : $conf['entryLevel'], $this->tmpl->rootLine);
265  // Set parent page: If $id not stated with start() then the base-id will be found from rootLine[$this->entryLevel]
266  // Called as the next level in a menu. It is assumed that $this->MP_array is set from parent menu.
267  if ($id) {
268  $this->id = (int)$id;
269  } else {
270  // This is a BRAND NEW menu, first level. So we take ID from rootline and also find MP_array (mount points)
271  $this->id = (int)$this->tmpl->rootLine[$this->entryLevel]['uid'];
272  // Traverse rootline to build MP_array of pages BEFORE the entryLevel
273  // (MP var for ->id is picked up in the next part of the code...)
274  foreach ($this->tmpl->rootLine as $entryLevel => $levelRec) {
275  // For overlaid mount points, set the variable right now:
276  if ($levelRec['_MP_PARAM'] && $levelRec['_MOUNT_OL']) {
277  $this->MP_array[] = $levelRec['_MP_PARAM'];
278  }
279  // Break when entry level is reached:
280  if ($entryLevel >= $this->entryLevel) {
281  break;
282  }
283  // For normal mount points, set the variable for next level.
284  if ($levelRec['_MP_PARAM'] && !$levelRec['_MOUNT_OL']) {
285  $this->MP_array[] = $levelRec['_MP_PARAM'];
286  }
287  }
288  }
289  // Return FALSE if no page ID was set (thus no menu of subpages can be made).
290  if ($this->id <= 0) {
291  return FALSE;
292  }
293  // Check if page is a mount point, and if so set id and MP_array
294  // (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...)
295  $mount_info = $this->sys_page->getMountPointInfo($this->id);
296  if (is_array($mount_info)) {
297  $this->MP_array[] = $mount_info['MPvar'];
298  $this->id = $mount_info['mount_pid'];
299  }
300  // Gather list of page uids in root line (for "isActive" evaluation). Also adds the MP params in the path so Mount Points are respected.
301  // (List is specific for this rootline, so it may be supplied from parent menus for speed...)
302  if (!is_array($this->rL_uidRegister)) {
303  $rl_MParray = array();
304  foreach ($this->tmpl->rootLine as $v_rl) {
305  // For overlaid mount points, set the variable right now:
306  if ($v_rl['_MP_PARAM'] && $v_rl['_MOUNT_OL']) {
307  $rl_MParray[] = $v_rl['_MP_PARAM'];
308  }
309  // Add to register:
310  $this->rL_uidRegister[] = 'ITEM:' . $v_rl['uid'] . (count($rl_MParray) ? ':' . implode(',', $rl_MParray) : '');
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  // Set $directoryLevel so the following evalution of the nextActive will not return
318  // an invalid value if .special=directory was set
319  $directoryLevel = 0;
320  if ($this->conf['special'] == 'directory') {
321  $value = isset($this->conf['special.']['value.']) ? $this->parent_cObj->stdWrap($this->conf['special.']['value'], $this->conf['special.']['value.']) : $this->conf['special.']['value'];
322  if ($value == '') {
323  $value = $GLOBALS['TSFE']->page['uid'];
324  }
325  $directoryLevel = (int)$GLOBALS['TSFE']->tmpl->getRootlineLevel($value);
326  }
327  // 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
328  // Notice: The automatic expansion of a menu is designed to work only when no "special" modes (except "directory") are used.
329  $startLevel = $directoryLevel ?: $this->entryLevel;
330  $currentLevel = $startLevel + $this->menuNumber;
331  if (is_array($this->tmpl->rootLine[$currentLevel])) {
332  $nextMParray = $this->MP_array;
333  if (!count($nextMParray) && !$this->tmpl->rootLine[$currentLevel]['_MOUNT_OL'] && $currentLevel > 0) {
334  // Make sure to slide-down any mount point information (_MP_PARAM) to children records in the rootline
335  // otherwise automatic expansion will not work
336  $parentRecord = $this->tmpl->rootLine[$currentLevel - 1];
337  if (isset($parentRecord['_MP_PARAM'])) {
338  $nextMParray[] = $parentRecord['_MP_PARAM'];
339  }
340  }
341  // In overlay mode, add next level MPvars as well:
342  if ($this->tmpl->rootLine[$currentLevel]['_MOUNT_OL']) {
343  $nextMParray[] = $this->tmpl->rootLine[$currentLevel]['_MP_PARAM'];
344  }
345  $this->nextActive = $this->tmpl->rootLine[$currentLevel]['uid'] . (count($nextMParray) ? ':' . implode(',', $nextMParray) : '');
346  } else {
347  $this->nextActive = '';
348  }
349  // imgNamePrefix
350  if ($this->mconf['imgNamePrefix']) {
351  $this->imgNamePrefix = $this->mconf['imgNamePrefix'];
352  }
353  $this->imgNameNotRandom = $this->mconf['imgNameNotRandom'];
354  $retVal = TRUE;
355  } else {
356  $GLOBALS['TT']->setTSlogMessage('ERROR in menu', 3);
357  $retVal = FALSE;
358  }
359  return $retVal;
360  }
361 
370  public function makeMenu() {
371  if ($this->id) {
372  $this->useCacheHash = FALSE;
373 
374  // Initializing showAccessRestrictedPages
375  if ($this->mconf['showAccessRestrictedPages']) {
376  // SAVING where_groupAccess
377  $SAVED_where_groupAccess = $this->sys_page->where_groupAccess;
378  // Temporarily removing fe_group checking!
379  $this->sys_page->where_groupAccess = '';
380  }
381  // Begin production of menu:
382  $temp = array();
383  $altSortFieldValue = trim($this->mconf['alternativeSortingField']);
384  $altSortField = $altSortFieldValue ?: 'sorting';
385  // ... only for the FIRST level of a HMENU
386  if ($this->menuNumber == 1 && $this->conf['special']) {
387  $value = isset($this->conf['special.']['value.']) ? $this->parent_cObj->stdWrap($this->conf['special.']['value'], $this->conf['special.']['value.']) : $this->conf['special.']['value'];
388  switch ($this->conf['special']) {
389  case 'userfunction':
390  $temp = $this->parent_cObj->callUserFunction($this->conf['special.']['userFunc'], array_merge($this->conf['special.'], array('_altSortField' => $altSortField)), '');
391  if (!is_array($temp)) {
392  $temp = array();
393  }
394  break;
395  case 'language':
396  $temp = array();
397  // Getting current page record NOT overlaid by any translation:
398  $currentPageWithNoOverlay = $this->sys_page->getRawRecord('pages', $GLOBALS['TSFE']->page['uid']);
399  // Traverse languages set up:
401  foreach ($languageItems as $sUid) {
402  // Find overlay record:
403  if ($sUid) {
404  $lRecs = $this->sys_page->getPageOverlay($GLOBALS['TSFE']->page['uid'], $sUid);
405  } else {
406  $lRecs = array();
407  }
408  // Checking if the "disabled" state should be set.
409  if (GeneralUtility::hideIfNotTranslated($GLOBALS['TSFE']->page['l18n_cfg']) && $sUid && !count($lRecs) || GeneralUtility::hideIfDefaultLanguage($GLOBALS['TSFE']->page['l18n_cfg']) && (!$sUid || !count($lRecs)) || !$this->conf['special.']['normalWhenNoLanguage'] && $sUid && !count($lRecs)) {
410  $iState = $GLOBALS['TSFE']->sys_language_uid == $sUid ? 'USERDEF2' : 'USERDEF1';
411  } else {
412  $iState = $GLOBALS['TSFE']->sys_language_uid == $sUid ? 'ACT' : 'NO';
413  }
414  if ($this->conf['addQueryString']) {
415  $getVars = $this->parent_cObj->getQueryArguments($this->conf['addQueryString.'], array('L' => $sUid), TRUE);
416  $this->analyzeCacheHashRequirements($getVars);
417  } else {
418  $getVars = '&L=' . $sUid;
419  }
420  // Adding menu item:
421  $temp[] = array_merge(array_merge($currentPageWithNoOverlay, $lRecs), array(
422  'ITEM_STATE' => $iState,
423  '_ADD_GETVARS' => $getVars,
424  '_SAFE' => TRUE
425  ));
426  }
427  break;
428  case 'directory':
429  if ($value == '') {
430  $value = $GLOBALS['TSFE']->page['uid'];
431  }
432  $items = GeneralUtility::intExplode(',', $value);
433  foreach ($items as $id) {
434  $MP = $this->tmpl->getFromMPmap($id);
435  // Checking if a page is a mount page and if so, change the ID and set the MP var properly.
436  $mount_info = $this->sys_page->getMountPointInfo($id);
437  if (is_array($mount_info)) {
438  if ($mount_info['overlay']) {
439  // Overlays should already have their full MPvars calculated:
440  $MP = $this->tmpl->getFromMPmap($mount_info['mount_pid']);
441  $MP = $MP ? $MP : $mount_info['MPvar'];
442  } else {
443  $MP = ($MP ? $MP . ',' : '') . $mount_info['MPvar'];
444  }
445  $id = $mount_info['mount_pid'];
446  }
447  // Get sub-pages:
448  $res = $this->parent_cObj->exec_getQuery('pages', array('pidInList' => $id, 'orderBy' => $altSortField));
449  while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
450  $GLOBALS['TSFE']->sys_page->versionOL('pages', $row, TRUE);
451  if (is_array($row)) {
452  // Keep mount point?
453  $mount_info = $this->sys_page->getMountPointInfo($row['uid'], $row);
454  // There is a valid mount point.
455  if (is_array($mount_info) && $mount_info['overlay']) {
456  // Using "getPage" is OK since we need the check for enableFields
457  // AND for type 2 of mount pids we DO require a doktype < 200!
458  $mp_row = $this->sys_page->getPage($mount_info['mount_pid']);
459  if (count($mp_row)) {
460  $row = $mp_row;
461  $row['_MP_PARAM'] = $mount_info['MPvar'];
462  } else {
463  // If the mount point could not be fetched with respect
464  // to enableFields, unset the row so it does not become a part of the menu!
465  unset($row);
466  }
467  }
468  // Add external MP params, then the row:
469  if (is_array($row)) {
470  if ($MP) {
471  $row['_MP_PARAM'] = $MP . ($row['_MP_PARAM'] ? ',' . $row['_MP_PARAM'] : '');
472  }
473  $temp[$row['uid']] = $this->sys_page->getPageOverlay($row);
474  }
475  }
476  }
477  }
478  break;
479  case 'list':
480  if ($value == '') {
481  $value = $this->id;
482  }
483  $skippedEnableFields = array();
484  if (!empty($this->mconf['showAccessRestrictedPages'])) {
485  $skippedEnableFields = array('fe_group' => 1);
486  }
488  $loadDB = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\RelationHandler');
489  $loadDB->setFetchAllFields(TRUE);
490  $loadDB->start($value, 'pages');
491  $loadDB->additionalWhere['pages'] = $this->parent_cObj->enableFields('pages', FALSE, $skippedEnableFields);
492  $loadDB->getFromDB();
493  foreach ($loadDB->itemArray as $val) {
494  $MP = $this->tmpl->getFromMPmap($val['id']);
495  // Keep mount point?
496  $mount_info = $this->sys_page->getMountPointInfo($val['id']);
497  // There is a valid mount point.
498  if (is_array($mount_info) && $mount_info['overlay']) {
499  // Using "getPage" is OK since we need the check for enableFields
500  // AND for type 2 of mount pids we DO require a doktype < 200!
501  $mp_row = $this->sys_page->getPage($mount_info['mount_pid']);
502  if (count($mp_row)) {
503  $row = $mp_row;
504  $row['_MP_PARAM'] = $mount_info['MPvar'];
505  // Overlays should already have their full MPvars calculated
506  if ($mount_info['overlay']) {
507  $MP = $this->tmpl->getFromMPmap($mount_info['mount_pid']);
508  if ($MP) {
509  unset($row['_MP_PARAM']);
510  }
511  }
512  } else {
513  // If the mount point could not be fetched with respect to
514  // enableFields, unset the row so it does not become a part of the menu!
515  unset($row);
516  }
517  } else {
518  $row = $loadDB->results['pages'][$val['id']];
519  }
520  //Add versioning overlay for current page (to respect workspaces)
521  if (is_array($row)) {
522  $this->sys_page->versionOL('pages', $row, TRUE);
523  }
524  // Add external MP params, then the row:
525  if (is_array($row)) {
526  if ($MP) {
527  $row['_MP_PARAM'] = $MP . ($row['_MP_PARAM'] ? ',' . $row['_MP_PARAM'] : '');
528  }
529  $temp[] = $this->sys_page->getPageOverlay($row);
530  }
531  }
532  break;
533  case 'updated':
534  if ($value == '') {
535  $value = $GLOBALS['TSFE']->page['uid'];
536  }
537  $items = GeneralUtility::intExplode(',', $value);
538  if (MathUtility::canBeInterpretedAsInteger($this->conf['special.']['depth'])) {
539  $depth = MathUtility::forceIntegerInRange($this->conf['special.']['depth'], 1, 20);
540  } else {
541  $depth = 20;
542  }
543  // Max number of items
544  $limit = MathUtility::forceIntegerInRange($this->conf['special.']['limit'], 0, 100);
545  $maxAge = (int)$this->parent_cObj->calc($this->conf['special.']['maxAge']);
546  if (!$limit) {
547  $limit = 10;
548  }
549  // *'auto', 'manual', 'tstamp'
550  $mode = $this->conf['special.']['mode'];
551  // Get id's
552  $id_list_arr = array();
553  foreach ($items as $id) {
554  $bA = MathUtility::forceIntegerInRange($this->conf['special.']['beginAtLevel'], 0, 100);
555  $id_list_arr[] = $this->parent_cObj->getTreeList(-1 * $id, $depth - 1 + $bA, $bA - 1);
556  }
557  $id_list = implode(',', $id_list_arr);
558  // Get sortField (mode)
559  switch ($mode) {
560  case 'starttime':
561  $sortField = 'starttime';
562  break;
563  case 'lastUpdated':
564 
565  case 'manual':
566  $sortField = 'lastUpdated';
567  break;
568  case 'tstamp':
569  $sortField = 'tstamp';
570  break;
571  case 'crdate':
572  $sortField = 'crdate';
573  break;
574  default:
575  $sortField = 'SYS_LASTCHANGED';
576  }
577  // Get
578  $extraWhere = ($this->conf['includeNotInMenu'] ? '' : ' AND pages.nav_hide=0') . $this->getDoktypeExcludeWhere();
579  if ($this->conf['special.']['excludeNoSearchPages']) {
580  $extraWhere .= ' AND pages.no_search=0';
581  }
582  if ($maxAge > 0) {
583  $extraWhere .= ' AND ' . $sortField . '>' . ($GLOBALS['SIM_ACCESS_TIME'] - $maxAge);
584  }
585  $res = $this->parent_cObj->exec_getQuery('pages', array(
586  'pidInList' => '0',
587  'uidInList' => $id_list,
588  'where' => $sortField . '>=0' . $extraWhere,
589  'orderBy' => $altSortFieldValue ? $altSortFieldValue : $sortField . ' desc',
590  'max' => $limit
591  ));
592  while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
593  $GLOBALS['TSFE']->sys_page->versionOL('pages', $row, TRUE);
594  if (is_array($row)) {
595  $temp[$row['uid']] = $this->sys_page->getPageOverlay($row);
596  }
597  }
598  break;
599  case 'keywords':
600  list($value) = GeneralUtility::intExplode(',', $value);
601  if (!$value) {
602  $value = $GLOBALS['TSFE']->page['uid'];
603  }
604  if ($this->conf['special.']['setKeywords'] || $this->conf['special.']['setKeywords.']) {
605  $kw = isset($this->conf['special.']['setKeywords.']) ? $this->parent_cObj->stdWrap($this->conf['special.']['setKeywords'], $this->conf['special.']['setKeywords.']) : $this->conf['special.']['setKeywords'];
606  } else {
607  // The page record of the 'value'.
608  $value_rec = $this->sys_page->getPage($value);
609  $kfieldSrc = $this->conf['special.']['keywordsField.']['sourceField'] ? $this->conf['special.']['keywordsField.']['sourceField'] : 'keywords';
610  // keywords.
611  $kw = trim($this->parent_cObj->keywords($value_rec[$kfieldSrc]));
612  }
613  // *'auto', 'manual', 'tstamp'
614  $mode = $this->conf['special.']['mode'];
615  switch ($mode) {
616  case 'starttime':
617  $sortField = 'starttime';
618  break;
619  case 'lastUpdated':
620 
621  case 'manual':
622  $sortField = 'lastUpdated';
623  break;
624  case 'tstamp':
625  $sortField = 'tstamp';
626  break;
627  case 'crdate':
628  $sortField = 'crdate';
629  break;
630  default:
631  $sortField = 'SYS_LASTCHANGED';
632  }
633  // Depth, limit, extra where
634  if (MathUtility::canBeInterpretedAsInteger($this->conf['special.']['depth'])) {
635  $depth = MathUtility::forceIntegerInRange($this->conf['special.']['depth'], 0, 20);
636  } else {
637  $depth = 20;
638  }
639  // Max number of items
640  $limit = MathUtility::forceIntegerInRange($this->conf['special.']['limit'], 0, 100);
641  $extraWhere = ' AND pages.uid<>' . $value . ($this->conf['includeNotInMenu'] ? '' : ' AND pages.nav_hide=0') . $this->getDoktypeExcludeWhere();
642  if ($this->conf['special.']['excludeNoSearchPages']) {
643  $extraWhere .= ' AND pages.no_search=0';
644  }
645  // Start point
646  $eLevel = $this->parent_cObj->getKey(isset($this->conf['special.']['entryLevel.']) ? $this->parent_cObj->stdWrap($this->conf['special.']['entryLevel'], $this->conf['special.']['entryLevel.']) : $this->conf['special.']['entryLevel'], $this->tmpl->rootLine);
647  $startUid = (int)$this->tmpl->rootLine[$eLevel]['uid'];
648  // Which field is for keywords
649  $kfield = 'keywords';
650  if ($this->conf['special.']['keywordsField']) {
651  list($kfield) = explode(' ', trim($this->conf['special.']['keywordsField']));
652  }
653  // If there are keywords and the startuid is present.
654  if ($kw && $startUid) {
655  $bA = MathUtility::forceIntegerInRange($this->conf['special.']['beginAtLevel'], 0, 100);
656  $id_list = $this->parent_cObj->getTreeList(-1 * $startUid, $depth - 1 + $bA, $bA - 1);
657  $kwArr = explode(',', $kw);
658  foreach ($kwArr as $word) {
659  $word = trim($word);
660  if ($word) {
661  $keyWordsWhereArr[] = $kfield . ' LIKE \'%' . $GLOBALS['TYPO3_DB']->quoteStr($word, 'pages') . '%\'';
662  }
663  }
664  $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));
665  while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
666  $GLOBALS['TSFE']->sys_page->versionOL('pages', $row, TRUE);
667  if (is_array($row)) {
668  $temp[$row['uid']] = $this->sys_page->getPageOverlay($row);
669  }
670  }
671  }
672  break;
673  case 'categories':
675  $categoryMenuUtility = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\Menu\\CategoryMenuUtility');
676  $temp = $categoryMenuUtility->collectPages($value, $this->conf['special.'], $this);
677  break;
678  case 'rootline':
679  $range = isset($this->conf['special.']['range.']) ? $this->parent_cObj->stdWrap($this->conf['special.']['range'], $this->conf['special.']['range.']) : $this->conf['special.']['range'];
680  $begin_end = explode('|', $range);
681  $begin_end[0] = (int)$begin_end[0];
682  if (!MathUtility::canBeInterpretedAsInteger($begin_end[1])) {
683  $begin_end[1] = -1;
684  }
685  $beginKey = $this->parent_cObj->getKey($begin_end[0], $this->tmpl->rootLine);
686  $endKey = $this->parent_cObj->getKey($begin_end[1], $this->tmpl->rootLine);
687  if ($endKey < $beginKey) {
688  $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 there are no specific target for the page, put the level specific target on.
702  if (!$temp[$temp_key]['target']) {
703  $temp[$temp_key]['target'] = $this->conf['special.']['targets.'][$k_rl];
704  $temp[$temp_key]['_MP_PARAM'] = implode(',', $rl_MParray);
705  }
706  } else {
707  unset($temp[$temp_key]);
708  }
709  }
710  // For normal mount points, set the variable for next level.
711  if ($v_rl['_MP_PARAM'] && !$v_rl['_MOUNT_OL']) {
712  $rl_MParray[] = $v_rl['_MP_PARAM'];
713  }
714  }
715  // Reverse order of elements (e.g. "1,2,3,4" gets "4,3,2,1"):
716  if (isset($this->conf['special.']['reverseOrder']) && $this->conf['special.']['reverseOrder']) {
717  $temp = array_reverse($temp);
718  $rl_MParray = array_reverse($rl_MParray);
719  }
720  break;
721  case 'browse':
722  list($value) = GeneralUtility::intExplode(',', $value);
723  if (!$value) {
724  $value = $GLOBALS['TSFE']->page['uid'];
725  }
726  // Will not work out of rootline
727  if ($value != $this->tmpl->rootLine[0]['uid']) {
728  $recArr = array();
729  // The page record of the 'value'.
730  $value_rec = $this->sys_page->getPage($value);
731  // 'up' page cannot be outside rootline
732  if ($value_rec['pid']) {
733  // The page record of 'up'.
734  $recArr['up'] = $this->sys_page->getPage($value_rec['pid']);
735  }
736  // If the 'up' item was NOT level 0 in rootline...
737  if ($recArr['up']['pid'] && $value_rec['pid'] != $this->tmpl->rootLine[0]['uid']) {
738  // The page record of "index".
739  $recArr['index'] = $this->sys_page->getPage($recArr['up']['pid']);
740  }
741  // prev / next is found
742  $prevnext_menu = $this->removeInaccessiblePages($this->sys_page->getMenu($value_rec['pid'], '*', $altSortField));
743  $lastKey = 0;
744  $nextActive = 0;
745  foreach ($prevnext_menu as $k_b => $v_b) {
746  if ($nextActive) {
747  $recArr['next'] = $v_b;
748  $nextActive = 0;
749  }
750  if ($v_b['uid'] == $value) {
751  if ($lastKey) {
752  $recArr['prev'] = $prevnext_menu[$lastKey];
753  }
754  $nextActive = 1;
755  }
756  $lastKey = $k_b;
757  }
758  reset($prevnext_menu);
759  $recArr['first'] = pos($prevnext_menu);
760  end($prevnext_menu);
761  $recArr['last'] = pos($prevnext_menu);
762  // prevsection / nextsection is found
763  // You can only do this, if there is a valid page two levels up!
764  if (is_array($recArr['index'])) {
765  $prevnextsection_menu = $this->removeInaccessiblePages($this->sys_page->getMenu($recArr['index']['uid'], '*', $altSortField));
766  $lastKey = 0;
767  $nextActive = 0;
768  foreach ($prevnextsection_menu as $k_b => $v_b) {
769  if ($nextActive) {
770  $sectionRec_temp = $this->removeInaccessiblePages($this->sys_page->getMenu($v_b['uid'], '*', $altSortField));
771  if (count($sectionRec_temp)) {
772  reset($sectionRec_temp);
773  $recArr['nextsection'] = pos($sectionRec_temp);
774  end($sectionRec_temp);
775  $recArr['nextsection_last'] = pos($sectionRec_temp);
776  $nextActive = 0;
777  }
778  }
779  if ($v_b['uid'] == $value_rec['pid']) {
780  if ($lastKey) {
781  $sectionRec_temp = $this->removeInaccessiblePages($this->sys_page->getMenu($prevnextsection_menu[$lastKey]['uid'], '*', $altSortField));
782  if (count($sectionRec_temp)) {
783  reset($sectionRec_temp);
784  $recArr['prevsection'] = pos($sectionRec_temp);
785  end($sectionRec_temp);
786  $recArr['prevsection_last'] = pos($sectionRec_temp);
787  }
788  }
789  $nextActive = 1;
790  }
791  $lastKey = $k_b;
792  }
793  }
794  if ($this->conf['special.']['items.']['prevnextToSection']) {
795  if (!is_array($recArr['prev']) && is_array($recArr['prevsection_last'])) {
796  $recArr['prev'] = $recArr['prevsection_last'];
797  }
798  if (!is_array($recArr['next']) && is_array($recArr['nextsection'])) {
799  $recArr['next'] = $recArr['nextsection'];
800  }
801  }
802  $items = explode('|', $this->conf['special.']['items']);
803  $c = 0;
804  foreach ($items as $k_b => $v_b) {
805  $v_b = strtolower(trim($v_b));
806  if ((int)$this->conf['special.'][$v_b . '.']['uid']) {
807  $recArr[$v_b] = $this->sys_page->getPage((int)$this->conf['special.'][$v_b . '.']['uid']);
808  }
809  if (is_array($recArr[$v_b])) {
810  $temp[$c] = $recArr[$v_b];
811  if ($this->conf['special.'][$v_b . '.']['target']) {
812  $temp[$c]['target'] = $this->conf['special.'][$v_b . '.']['target'];
813  }
814  $tmpSpecialFields = $this->conf['special.'][$v_b . '.']['fields.'];
815  if (is_array($tmpSpecialFields)) {
816  foreach ($tmpSpecialFields as $fk => $val) {
817  $temp[$c][$fk] = $val;
818  }
819  }
820  $c++;
821  }
822  }
823  }
824  break;
825  }
826  if ($this->mconf['sectionIndex']) {
827  $sectionIndexes = array();
828  foreach ($temp as $page) {
829  $sectionIndexes = $sectionIndexes + $this->sectionIndex($altSortField, $page['uid']);
830  }
831  $temp = $sectionIndexes;
832  }
833  } elseif (is_array($this->alternativeMenuTempArray)) {
834  // Setting $temp array if not level 1.
836  } elseif ($this->mconf['sectionIndex']) {
837  $temp = $this->sectionIndex($altSortField);
838  } else {
839  // Default:
840  // gets the menu
841  $temp = $this->sys_page->getMenu($this->id, '*', $altSortField);
842  }
843  $c = 0;
844  $c_b = 0;
845  $minItems = (int)($this->mconf['minItems'] ?: $this->conf['minItems']);
846  $maxItems = (int)($this->mconf['maxItems'] ?: $this->conf['maxItems']);
847  $begin = $this->parent_cObj->calc($this->mconf['begin'] ? $this->mconf['begin'] : $this->conf['begin']);
848  $minItemsConf = isset($this->mconf['minItems.']) ? $this->mconf['minItems.'] : (isset($this->conf['minItems.']) ? $this->conf['minItems.'] : NULL);
849  $minItems = is_array($minItemsConf) ? $this->parent_cObj->stdWrap($minItems, $minItemsConf) : $minItems;
850  $maxItemsConf = isset($this->mconf['maxItems.']) ? $this->mconf['maxItems.'] : (isset($this->conf['maxItems.']) ? $this->conf['maxItems.'] : NULL);
851  $maxItems = is_array($maxItemsConf) ? $this->parent_cObj->stdWrap($maxItems, $maxItemsConf) : $maxItems;
852  $beginConf = isset($this->mconf['begin.']) ? $this->mconf['begin.'] : (isset($this->conf['begin.']) ? $this->conf['begin.'] : NULL);
853  $begin = is_array($beginConf) ? $this->parent_cObj->stdWrap($begin, $beginConf) : $begin;
854  $banUidArray = $this->getBannedUids();
855  // Fill in the menuArr with elements that should go into the menu:
856  $this->menuArr = array();
857  foreach ($temp as $data) {
858  $spacer = GeneralUtility::inList($this->spacerIDList, $data['doktype']) || $data['ITEM_STATE'] === 'SPC' ? 1 : 0;
859  // if item is a spacer, $spacer is set
860  if ($this->filterMenuPages($data, $banUidArray, $spacer)) {
861  $c_b++;
862  // If the beginning item has been reached.
863  if ($begin <= $c_b) {
864  $this->menuArr[$c] = $data;
865  $this->menuArr[$c]['isSpacer'] = $spacer;
866  $c++;
867  if ($maxItems && $c >= $maxItems) {
868  break;
869  }
870  }
871  }
872  }
873  // Fill in fake items, if min-items is set.
874  if ($minItems) {
875  while ($c < $minItems) {
876  $this->menuArr[$c] = array(
877  'title' => '...',
878  'uid' => $GLOBALS['TSFE']->id
879  );
880  $c++;
881  }
882  }
883  // Passing the menuArr through a user defined function:
884  if ($this->mconf['itemArrayProcFunc']) {
885  if (!is_array($this->parentMenuArr)) {
886  $this->parentMenuArr = array();
887  }
888  $this->menuArr = $this->userProcess('itemArrayProcFunc', $this->menuArr);
889  }
890  // Setting number of menu items
891  $GLOBALS['TSFE']->register['count_menuItems'] = count($this->menuArr);
892  $this->hash = md5(serialize($this->menuArr) . serialize($this->mconf) . serialize($this->tmpl->rootLine) . serialize($this->MP_array));
893  // Get the cache timeout:
894  if ($this->conf['cache_period']) {
895  $cacheTimeout = $this->conf['cache_period'];
896  } else {
897  $cacheTimeout = $GLOBALS['TSFE']->get_cache_timeout();
898  }
899  $cache = $this->getCache();
900  $cachedData = $cache->get($this->hash);
901  if (!is_array($cachedData)) {
902  $this->generate();
903  $cache->set($this->hash, $this->result, array('ident_MENUDATA'), (int)$cacheTimeout);
904  } else {
905  $this->result = $cachedData;
906  }
907  // End showAccessRestrictedPages
908  if ($this->mconf['showAccessRestrictedPages']) {
909  // RESTORING where_groupAccess
910  $this->sys_page->where_groupAccess = $SAVED_where_groupAccess;
911  }
912  }
913  }
914 
921  protected function removeInaccessiblePages(array $pages) {
922  $banned = $this->getBannedUids();
923  $filteredPages = array();
924  foreach ($pages as $aPage) {
925  if ($this->filterMenuPages($aPage, $banned, $aPage['doktype'] === PageRepository::DOKTYPE_SPACER)) {
926  $filteredPages[$aPage['uid']] = $aPage;
927  }
928  }
929  return $filteredPages;
930  }
931 
938  protected function analyzeCacheHashRequirements($queryString) {
940  if (count($parameters) > 0) {
941  if (!isset($parameters['id'])) {
942  $queryString .= '&id=' . $GLOBALS['TSFE']->id;
943  }
944  $cacheHashCalculator = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\CacheHashCalculator');
946  $cHashParameters = $cacheHashCalculator->getRelevantParameters($queryString);
947  if (count($cHashParameters) > 1) {
948  $this->useCacheHash = (
949  $GLOBALS['TYPO3_CONF_VARS']['FE']['disableNoCacheParameter'] ||
950  !isset($parameters['no_cache']) ||
951  !$parameters['no_cache']
952  );
953  }
954  }
955  }
956 
966  public function filterMenuPages(&$data, $banUidArray, $spacer) {
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 = GeneralUtility::getUserObj($classRef);
971  if (!$hookObject instanceof \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuFilterPagesHookInterface) {
972  throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Frontend\\ContentObject\\Menu\\AbstractMenuFilterPagesHookInterface', 1269877402);
973  }
974  $includePage = $includePage && $hookObject->processFilter($data, $banUidArray, $spacer, $this);
975  }
976  }
977  if (!$includePage) {
978  return FALSE;
979  }
980  if ($data['_SAFE']) {
981  return TRUE;
982  }
983  $uid = $data['uid'];
984  // If the spacer-function is not enabled, spacers will not enter the $menuArr
985  if ($this->mconf['SPC'] || !$spacer) {
986  // Page may not be 'not_in_menu' or 'Backend User Section'
987  if (!GeneralUtility::inList($this->doktypeExcludeList, $data['doktype'])) {
988  // Not hidden in navigation
989  if (!$data['nav_hide'] || $this->conf['includeNotInMenu']) {
990  // not in banned uid's
991  if (!GeneralUtility::inArray($banUidArray, $uid)) {
992  // Checks if the default language version can be shown:
993  // Block page is set, if l18n_cfg allows plus: 1) Either default language or 2) another language but NO overlay record set for page!
994  $blockPage = GeneralUtility::hideIfDefaultLanguage($data['l18n_cfg']) && (!$GLOBALS['TSFE']->sys_language_uid || $GLOBALS['TSFE']->sys_language_uid && !$data['_PAGES_OVERLAY']);
995  if (!$blockPage) {
996  // Checking if a page should be shown in the menu depending on whether a translation exists:
997  $tok = TRUE;
998  // There is an alternative language active AND the current page requires a translation:
999  if ($GLOBALS['TSFE']->sys_language_uid && GeneralUtility::hideIfNotTranslated($data['l18n_cfg'])) {
1000  if (!$data['_PAGES_OVERLAY']) {
1001  $tok = FALSE;
1002  }
1003  }
1004  // Continue if token is TRUE:
1005  if ($tok) {
1006  // Checking if "&L" should be modified so links to non-accessible pages will not happen.
1007  if ($this->conf['protectLvar']) {
1008  $languageUid = (int)$GLOBALS['TSFE']->config['config']['sys_language_uid'];
1009  if ($languageUid && ($this->conf['protectLvar'] == 'all' || GeneralUtility::hideIfNotTranslated($data['l18n_cfg']))) {
1010  $olRec = $GLOBALS['TSFE']->sys_page->getPageOverlay($data['uid'], $languageUid);
1011  if (!count($olRec)) {
1012  // 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"
1013  $data['_ADD_GETVARS'] .= '&L=0';
1014  }
1015  }
1016  }
1017  return TRUE;
1018  }
1019  }
1020  }
1021  }
1022  }
1023  }
1024  }
1025 
1036  public function procesItemStates($splitCount) {
1037  // Prepare normal settings
1038  if (!is_array($this->mconf['NO.']) && $this->mconf['NO']) {
1039  // Setting a blank array if NO=1 and there are no properties.
1040  $this->mconf['NO.'] = array();
1041  }
1042  $NOconf = $this->tmpl->splitConfArray($this->mconf['NO.'], $splitCount);
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  // Prepare IFSUB settings, overriding normal settings
1049  // IFSUB is TRUE if there exist submenu items to the current item
1050  if ($this->mconf['IFSUB']) {
1051  // Flag: If $IFSUB is generated
1052  $IFSUBinit = 0;
1053  foreach ($NOconf as $key => $val) {
1054  if ($this->isItemState('IFSUB', $key)) {
1055  // if this is the first IFSUB element, we must generate IFSUB.
1056  if (!$IFSUBinit) {
1057  $IFSUBconf = $this->tmpl->splitConfArray($this->mconf['IFSUB.'], $splitCount);
1058  if ($this->mconf['IFSUBRO']) {
1059  $IFSUBROconf = $this->tmpl->splitConfArray($this->mconf['IFSUBRO.'], $splitCount);
1060  }
1061  $IFSUBinit = 1;
1062  }
1063  // Substitute normal with ifsub
1064  $NOconf[$key] = $IFSUBconf[$key];
1065  // If rollOver on normal, we must apply a state for rollOver on the active
1066  if ($ROconf) {
1067  // If RollOver on active then apply this
1068  $ROconf[$key] = $IFSUBROconf[$key] ?: $IFSUBconf[$key];
1069  }
1070  }
1071  }
1072  }
1073  // Prepare active settings, overriding normal settings
1074  if ($this->mconf['ACT']) {
1075  // Flag: If $ACT is generated
1076  $ACTinit = 0;
1077  // Find active
1078  foreach ($NOconf as $key => $val) {
1079  if ($this->isItemState('ACT', $key)) {
1080  // If this is the first 'active', we must generate ACT.
1081  if (!$ACTinit) {
1082  $ACTconf = $this->tmpl->splitConfArray($this->mconf['ACT.'], $splitCount);
1083  // Prepare active rollOver settings, overriding normal active settings
1084  if ($this->mconf['ACTRO']) {
1085  $ACTROconf = $this->tmpl->splitConfArray($this->mconf['ACTRO.'], $splitCount);
1086  }
1087  $ACTinit = 1;
1088  }
1089  // Substitute normal with active
1090  $NOconf[$key] = $ACTconf[$key];
1091  // If rollOver on normal, we must apply a state for rollOver on the active
1092  if ($ROconf) {
1093  // If RollOver on active then apply this
1094  $ROconf[$key] = $ACTROconf[$key] ?: $ACTconf[$key];
1095  }
1096  }
1097  }
1098  }
1099  // Prepare ACT (active)/IFSUB settings, overriding normal settings
1100  // ACTIFSUB is TRUE if there exist submenu items to the current item and the current item is active
1101  if ($this->mconf['ACTIFSUB']) {
1102  // Flag: If $ACTIFSUB is generated
1103  $ACTIFSUBinit = 0;
1104  // Find active
1105  foreach ($NOconf as $key => $val) {
1106  if ($this->isItemState('ACTIFSUB', $key)) {
1107  // If this is the first 'active', we must generate ACTIFSUB.
1108  if (!$ACTIFSUBinit) {
1109  $ACTIFSUBconf = $this->tmpl->splitConfArray($this->mconf['ACTIFSUB.'], $splitCount);
1110  // Prepare active rollOver settings, overriding normal active settings
1111  if ($this->mconf['ACTIFSUBRO']) {
1112  $ACTIFSUBROconf = $this->tmpl->splitConfArray($this->mconf['ACTIFSUBRO.'], $splitCount);
1113  }
1114  $ACTIFSUBinit = 1;
1115  }
1116  // Substitute normal with active
1117  $NOconf[$key] = $ACTIFSUBconf[$key];
1118  // If rollOver on normal, we must apply a state for rollOver on the active
1119  if ($ROconf) {
1120  // If RollOver on active then apply this
1121  $ROconf[$key] = $ACTIFSUBROconf[$key] ?: $ACTIFSUBconf[$key];
1122  }
1123  }
1124  }
1125  }
1126  // Prepare CUR (current) settings, overriding normal settings
1127  // CUR is TRUE if the current page equals the item here!
1128  if ($this->mconf['CUR']) {
1129  // Flag: If $CUR is generated
1130  $CURinit = 0;
1131  foreach ($NOconf as $key => $val) {
1132  if ($this->isItemState('CUR', $key)) {
1133  // if this is the first 'current', we must generate CUR. Basically this control is just inherited
1134  // from the other implementations as current would only exist one time and thats it
1135  // (unless you use special-features of HMENU)
1136  if (!$CURinit) {
1137  $CURconf = $this->tmpl->splitConfArray($this->mconf['CUR.'], $splitCount);
1138  if ($this->mconf['CURRO']) {
1139  $CURROconf = $this->tmpl->splitConfArray($this->mconf['CURRO.'], $splitCount);
1140  }
1141  $CURinit = 1;
1142  }
1143  // Substitute normal with current
1144  $NOconf[$key] = $CURconf[$key];
1145  // If rollOver on normal, we must apply a state for rollOver on the active
1146  if ($ROconf) {
1147  // If RollOver on active then apply this
1148  $ROconf[$key] = $CURROconf[$key] ?: $CURconf[$key];
1149  }
1150  }
1151  }
1152  }
1153  // Prepare CUR (current)/IFSUB settings, overriding normal settings
1154  // CURIFSUB is TRUE if there exist submenu items to the current item and the current page equals the item here!
1155  if ($this->mconf['CURIFSUB']) {
1156  // Flag: If $CURIFSUB is generated
1157  $CURIFSUBinit = 0;
1158  foreach ($NOconf as $key => $val) {
1159  if ($this->isItemState('CURIFSUB', $key)) {
1160  // If this is the first 'current', we must generate CURIFSUB.
1161  if (!$CURIFSUBinit) {
1162  $CURIFSUBconf = $this->tmpl->splitConfArray($this->mconf['CURIFSUB.'], $splitCount);
1163  // Prepare current rollOver settings, overriding normal current settings
1164  if ($this->mconf['CURIFSUBRO']) {
1165  $CURIFSUBROconf = $this->tmpl->splitConfArray($this->mconf['CURIFSUBRO.'], $splitCount);
1166  }
1167  $CURIFSUBinit = 1;
1168  }
1169  // Substitute normal with active
1170  $NOconf[$key] = $CURIFSUBconf[$key];
1171  // If rollOver on normal, we must apply a state for rollOver on the current
1172  if ($ROconf) {
1173  // If RollOver on current then apply this
1174  $ROconf[$key] = $CURIFSUBROconf[$key] ?: $CURIFSUBconf[$key];
1175  }
1176  }
1177  }
1178  }
1179  // Prepare active settings, overriding normal settings
1180  if ($this->mconf['USR']) {
1181  // Flag: If $USR is generated
1182  $USRinit = 0;
1183  // Find active
1184  foreach ($NOconf as $key => $val) {
1185  if ($this->isItemState('USR', $key)) {
1186  // if this is the first active, we must generate USR.
1187  if (!$USRinit) {
1188  $USRconf = $this->tmpl->splitConfArray($this->mconf['USR.'], $splitCount);
1189  // Prepare active rollOver settings, overriding normal active settings
1190  if ($this->mconf['USRRO']) {
1191  $USRROconf = $this->tmpl->splitConfArray($this->mconf['USRRO.'], $splitCount);
1192  }
1193  $USRinit = 1;
1194  }
1195  // Substitute normal with active
1196  $NOconf[$key] = $USRconf[$key];
1197  // If rollOver on normal, we must apply a state for rollOver on the active
1198  if ($ROconf) {
1199  // If RollOver on active then apply this
1200  $ROconf[$key] = $USRROconf[$key] ?: $USRconf[$key];
1201  }
1202  }
1203  }
1204  }
1205  // Prepare spacer settings, overriding normal settings
1206  if ($this->mconf['SPC']) {
1207  // Flag: If $SPC is generated
1208  $SPCinit = 0;
1209  // Find spacers
1210  foreach ($NOconf as $key => $val) {
1211  if ($this->isItemState('SPC', $key)) {
1212  // If this is the first spacer, we must generate SPC.
1213  if (!$SPCinit) {
1214  $SPCconf = $this->tmpl->splitConfArray($this->mconf['SPC.'], $splitCount);
1215  $SPCinit = 1;
1216  }
1217  // Substitute normal with spacer
1218  $NOconf[$key] = $SPCconf[$key];
1219  }
1220  }
1221  }
1222  // Prepare Userdefined settings
1223  if ($this->mconf['USERDEF1']) {
1224  // Flag: If $USERDEF1 is generated
1225  $USERDEF1init = 0;
1226  // Find active
1227  foreach ($NOconf as $key => $val) {
1228  if ($this->isItemState('USERDEF1', $key)) {
1229  // If this is the first active, we must generate USERDEF1.
1230  if (!$USERDEF1init) {
1231  $USERDEF1conf = $this->tmpl->splitConfArray($this->mconf['USERDEF1.'], $splitCount);
1232  // Prepare active rollOver settings, overriding normal active settings
1233  if ($this->mconf['USERDEF1RO']) {
1234  $USERDEF1ROconf = $this->tmpl->splitConfArray($this->mconf['USERDEF1RO.'], $splitCount);
1235  }
1236  $USERDEF1init = 1;
1237  }
1238  // Substitute normal with active
1239  $NOconf[$key] = $USERDEF1conf[$key];
1240  // If rollOver on normal, we must apply a state for rollOver on the active
1241  if ($ROconf) {
1242  // If RollOver on active then apply this
1243  $ROconf[$key] = $USERDEF1ROconf[$key] ?: $USERDEF1conf[$key];
1244  }
1245  }
1246  }
1247  }
1248  // Prepare Userdefined settings
1249  if ($this->mconf['USERDEF2']) {
1250  // Flag: If $USERDEF2 is generated
1251  $USERDEF2init = 0;
1252  // Find active
1253  foreach ($NOconf as $key => $val) {
1254  if ($this->isItemState('USERDEF2', $key)) {
1255  // If this is the first active, we must generate USERDEF2.
1256  if (!$USERDEF2init) {
1257  $USERDEF2conf = $this->tmpl->splitConfArray($this->mconf['USERDEF2.'], $splitCount);
1258  // Prepare active rollOver settings, overriding normal active settings
1259  if ($this->mconf['USERDEF2RO']) {
1260  $USERDEF2ROconf = $this->tmpl->splitConfArray($this->mconf['USERDEF2RO.'], $splitCount);
1261  }
1262  $USERDEF2init = 1;
1263  }
1264  // Substitute normal with active
1265  $NOconf[$key] = $USERDEF2conf[$key];
1266  // If rollOver on normal, we must apply a state for rollOver on the active
1267  if ($ROconf) {
1268  // If RollOver on active then apply this
1269  $ROconf[$key] = $USERDEF2ROconf[$key] ?: $USERDEF2conf[$key];
1270  }
1271  }
1272  }
1273  }
1274  return array($NOconf, $ROconf);
1275  }
1276 
1288  public function link($key, $altTarget = '', $typeOverride = '') {
1289  // Mount points:
1290  $MP_var = $this->getMPvar($key);
1291  $MP_params = $MP_var ? '&MP=' . rawurlencode($MP_var) : '';
1292  // Setting override ID
1293  if ($this->mconf['overrideId'] || $this->menuArr[$key]['overrideId']) {
1294  $overrideArray = array();
1295  // If a user script returned the value overrideId in the menu array we use that as page id
1296  $overrideArray['uid'] = $this->mconf['overrideId'] ?: $this->menuArr[$key]['overrideId'];
1297  $overrideArray['alias'] = '';
1298  // Clear MP parameters since ID was changed.
1299  $MP_params = '';
1300  } else {
1301  $overrideArray = '';
1302  }
1303  // Setting main target:
1304  if ($altTarget) {
1305  $mainTarget = $altTarget;
1306  } elseif ($this->mconf['target.']) {
1307  $mainTarget = $this->parent_cObj->stdWrap($this->mconf['target'], $this->mconf['target.']);
1308  } else {
1309  $mainTarget = $this->mconf['target'];
1310  }
1311  // Creating link:
1312  if ($this->mconf['collapse'] && $this->isActive($this->menuArr[$key]['uid'], $this->getMPvar($key))) {
1313  $thePage = $this->sys_page->getPage($this->menuArr[$key]['pid']);
1314  $LD = $this->menuTypoLink($thePage, $mainTarget, '', '', $overrideArray, $this->mconf['addParams'] . $MP_params . $this->menuArr[$key]['_ADD_GETVARS'], $typeOverride);
1315  } else {
1316  $LD = $this->menuTypoLink($this->menuArr[$key], $mainTarget, '', '', $overrideArray, $this->mconf['addParams'] . $MP_params . $this->I['val']['additionalParams'] . $this->menuArr[$key]['_ADD_GETVARS'], $typeOverride);
1317  }
1318  // Override URL if using "External URL" as doktype with a valid e-mail address:
1319  if ($this->menuArr[$key]['doktype'] == \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_LINK && $this->menuArr[$key]['urltype'] == 3 && GeneralUtility::validEmail($this->menuArr[$key]['url'])) {
1320  // Create mailto-link using \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::typolink (concerning spamProtectEmailAddresses):
1321  $LD['totalURL'] = $this->parent_cObj->typoLink_URL(array('parameter' => $this->menuArr[$key]['url']));
1322  $LD['target'] = '';
1323  }
1324 
1325  // Override url if current page is a shortcut
1326  $shortcut = NULL;
1327  if ($this->menuArr[$key]['doktype'] == \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SHORTCUT && $this->menuArr[$key]['shortcut_mode'] != \TYPO3\CMS\Frontend\Page\PageRepository::SHORTCUT_MODE_RANDOM_SUBPAGE) {
1328 
1329  $menuItem = $this->determineOriginalShortcutPage($this->menuArr[$key]);
1330 
1331  try {
1332  $shortcut = $GLOBALS['TSFE']->getPageShortcut(
1333  $menuItem['shortcut'],
1334  $menuItem['shortcut_mode'],
1335  $menuItem['uid'],
1336  20,
1337  array(),
1338  TRUE
1339  );
1340  } catch (\Exception $ex) {
1341 
1342  }
1343  if (!is_array($shortcut)) {
1344  return array();
1345  }
1346  // Only setting url, not target
1347  $LD['totalURL'] = $this->parent_cObj->typoLink_URL(array(
1348  'parameter' => $shortcut['uid'],
1349  'additionalParams' => $this->mconf['addParams'] . $MP_params . $this->I['val']['additionalParams'] . $menuItem['_ADD_GETVARS'],
1350  'linkAccessRestrictedPages' => $this->mconf['showAccessRestrictedPages'] && $this->mconf['showAccessRestrictedPages'] !== 'NONE'
1351  ));
1352  }
1353  if ($shortcut) {
1354  $pageData = $shortcut;
1355  $pageData['_SHORTCUT_PAGE_UID'] = $this->menuArr[$key]['uid'];
1356  } else {
1357  $pageData = $this->menuArr[$key];
1358  }
1359  // Manipulation in case of access restricted pages:
1360  $this->changeLinksForAccessRestrictedPages($LD, $pageData, $mainTarget, $typeOverride);
1361  // Overriding URL / Target if set to do so:
1362  if ($this->menuArr[$key]['_OVERRIDE_HREF']) {
1363  $LD['totalURL'] = $this->menuArr[$key]['_OVERRIDE_HREF'];
1364  if ($this->menuArr[$key]['_OVERRIDE_TARGET']) {
1365  $LD['target'] = $this->menuArr[$key]['_OVERRIDE_TARGET'];
1366  }
1367  }
1368  // OnClick open in windows.
1369  $onClick = '';
1370  if ($this->mconf['JSWindow']) {
1371  $conf = $this->mconf['JSWindow.'];
1372  $url = $LD['totalURL'];
1373  $LD['totalURL'] = '#';
1374  $onClick = 'openPic(\'' . $GLOBALS['TSFE']->baseUrlWrap($url) . '\',\'' . ($conf['newWindow'] ? md5($url) : 'theNewPage') . '\',\'' . $conf['params'] . '\'); return false;';
1375  $GLOBALS['TSFE']->setJS('openPic');
1376  }
1377  // look for type and popup
1378  // following settings are valid in field target:
1379  // 230 will add type=230 to the link
1380  // 230 500x600 will add type=230 to the link and open in popup window with 500x600 pixels
1381  // 230 _blank will add type=230 to the link and open with target "_blank"
1382  // 230x450:resizable=0,location=1 will open in popup window with 500x600 pixels with settings "resizable=0,location=1"
1383  $matches = array();
1384  $targetIsType = $LD['target'] && MathUtility::canBeInterpretedAsInteger($LD['target']) ? (int)$LD['target'] : FALSE;
1385  if (preg_match('/([0-9]+[\\s])?(([0-9]+)x([0-9]+))?(:.+)?/s', $LD['target'], $matches) || $targetIsType) {
1386  // has type?
1387  if ((int)$matches[1] || $targetIsType) {
1388  $LD['totalURL'] = $this->parent_cObj->URLqMark($LD['totalURL'], '&type=' . ($targetIsType ?: (int)$matches[1]));
1389  $LD['target'] = $targetIsType ? '' : trim(substr($LD['target'], strlen($matches[1]) + 1));
1390  }
1391  // Open in popup window?
1392  if ($matches[3] && $matches[4]) {
1393  $JSparamWH = 'width=' . $matches[3] . ',height=' . $matches[4] . ($matches[5] ? ',' . substr($matches[5], 1) : '');
1394  $onClick = 'vHWin=window.open('
1395  . GeneralUtility::quoteJSvalue($GLOBALS['TSFE']->baseUrlWrap($LD['totalURL']))
1396  . ',\'FEopenLink\',\'' . $JSparamWH . '\');vHWin.focus();return false;';
1397  $LD['target'] = '';
1398  }
1399  }
1400  // out:
1401  $list = array();
1402  // Added this check: What it does is to enter the baseUrl (if set, which it should for "realurl" based sites)
1403  // as URL if the calculated value is empty. The problem is that no link is generated with a blank URL
1404  // and blank URLs might appear when the realurl encoding is used and a link to the frontpage is generated.
1405  $list['HREF'] = strlen($LD['totalURL']) ? $LD['totalURL'] : $GLOBALS['TSFE']->baseUrl;
1406  $list['TARGET'] = $LD['target'];
1407  $list['onClick'] = $onClick;
1408  return $list;
1409  }
1410 
1423  protected function determineOriginalShortcutPage(array $page) {
1424  // Check if modification is required
1425  if (
1426  $GLOBALS['TSFE']->sys_language_uid > 0
1427  && empty($page['shortcut'])
1428  && !empty($page['uid'])
1429  && !empty($page['_PAGES_OVERLAY'])
1430  && !empty($page['_PAGES_OVERLAY_UID'])
1431  ) {
1432  // Using raw record since the record was overlaid and is correct already:
1433  $originalPage = $this->sys_page->getRawRecord('pages', $page['uid']);
1434 
1435  if ($originalPage['shortcut_mode'] === $page['shortcut_mode'] && !empty($originalPage['shortcut'])) {
1436  $page['shortcut'] = $originalPage['shortcut'];
1437  }
1438  }
1439 
1440  return $page;
1441  }
1442 
1453  public function changeLinksForAccessRestrictedPages(&$LD, $page, $mainTarget, $typeOverride) {
1454  // If access restricted pages should be shown in menus, change the link of such pages to link to a redirection page:
1455  if ($this->mconf['showAccessRestrictedPages'] && $this->mconf['showAccessRestrictedPages'] !== 'NONE' && !$GLOBALS['TSFE']->checkPageGroupAccess($page)) {
1456  $thePage = $this->sys_page->getPage($this->mconf['showAccessRestrictedPages']);
1457  $addParams = str_replace(
1458  array(
1459  '###RETURN_URL###',
1460  '###PAGE_ID###'
1461  ),
1462  array(
1463  rawurlencode($LD['totalURL']),
1464  isset($page['_SHORTCUT_PAGE_UID']) ? $page['_SHORTCUT_PAGE_UID'] : $page['uid']
1465  ),
1466  $this->mconf['showAccessRestrictedPages.']['addParams']
1467  );
1468  $LD = $this->menuTypoLink($thePage, $mainTarget, '', '', '', $addParams, $typeOverride);
1469  }
1470  }
1471 
1481  public function subMenu($uid, $objSuffix = '') {
1482  // Setting alternative menu item array if _SUB_MENU has been defined in the current ->menuArr
1483  $altArray = '';
1484  if (is_array($this->menuArr[$this->I['key']]['_SUB_MENU']) && count($this->menuArr[$this->I['key']]['_SUB_MENU'])) {
1485  $altArray = $this->menuArr[$this->I['key']]['_SUB_MENU'];
1486  }
1487  // Make submenu if the page is the next active
1488  $menuType = $this->conf[($this->menuNumber + 1) . $objSuffix];
1489  // stdWrap for expAll
1490  if (isset($this->mconf['expAll.'])) {
1491  $this->mconf['expAll'] = $this->parent_cObj->stdWrap($this->mconf['expAll'], $this->mconf['expAll.']);
1492  }
1493  if (($this->mconf['expAll'] || $this->isNext($uid, $this->getMPvar($this->I['key'])) || is_array($altArray)) && !$this->mconf['sectionIndex']) {
1494  try {
1495  $menuObjectFactory = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\Menu\\MenuContentObjectFactory');
1496  $submenu = $menuObjectFactory->getMenuObjectByType($menuType);
1497  $submenu->entryLevel = $this->entryLevel + 1;
1498  $submenu->rL_uidRegister = $this->rL_uidRegister;
1499  $submenu->MP_array = $this->MP_array;
1500  if ($this->menuArr[$this->I['key']]['_MP_PARAM']) {
1501  $submenu->MP_array[] = $this->menuArr[$this->I['key']]['_MP_PARAM'];
1502  }
1503  // Especially scripts that build the submenu needs the parent data
1504  $submenu->parent_cObj = $this->parent_cObj;
1505  $submenu->parentMenuArr = $this->menuArr;
1506  // Setting alternativeMenuTempArray (will be effective only if an array)
1507  if (is_array($altArray)) {
1508  $submenu->alternativeMenuTempArray = $altArray;
1509  }
1510  if ($submenu->start($this->tmpl, $this->sys_page, $uid, $this->conf, $this->menuNumber + 1, $objSuffix)) {
1511  $submenu->makeMenu();
1512  // Memorize the current menu item count
1513  $tempCountMenuObj = $GLOBALS['TSFE']->register['count_MENUOBJ'];
1514  // Reset the menu item count for the submenu
1515  $GLOBALS['TSFE']->register['count_MENUOBJ'] = 0;
1516  $content = $submenu->writeMenu();
1517  // Restore the item count now that the submenu has been handled
1518  $GLOBALS['TSFE']->register['count_MENUOBJ'] = $tempCountMenuObj;
1519  $GLOBALS['TSFE']->register['count_menuItems'] = count($this->menuArr);
1520  return $content;
1521  }
1522  } catch (\TYPO3\CMS\Frontend\ContentObject\Menu\Exception\NoSuchMenuTypeException $e) {
1523  }
1524  }
1525  }
1526 
1537  public function isNext($uid, $MPvar = '') {
1538  // Check for always active PIDs:
1539  if (count($this->alwaysActivePIDlist) && in_array($uid, $this->alwaysActivePIDlist)) {
1540  return TRUE;
1541  }
1542  $testUid = $uid . ($MPvar ? ':' . $MPvar : '');
1543  if ($uid && $testUid == $this->nextActive) {
1544  return TRUE;
1545  }
1546  }
1547 
1557  public function isActive($uid, $MPvar = '') {
1558  // Check for always active PIDs:
1559  if (count($this->alwaysActivePIDlist) && in_array($uid, $this->alwaysActivePIDlist)) {
1560  return TRUE;
1561  }
1562  $testUid = $uid . ($MPvar ? ':' . $MPvar : '');
1563  if ($uid && in_array('ITEM:' . $testUid, $this->rL_uidRegister)) {
1564  return TRUE;
1565  }
1566  }
1567 
1577  public function isCurrent($uid, $MPvar = '') {
1578  $testUid = $uid . ($MPvar ? ':' . $MPvar : '');
1579  if ($uid && end($this->rL_uidRegister) === 'ITEM:' . $testUid) {
1580  return TRUE;
1581  }
1582  }
1583 
1593  public function isSubMenu($uid) {
1594  // Looking for a mount-pid for this UID since if that
1595  // exists we should look for a subpages THERE and not in the input $uid;
1596  $mount_info = $this->sys_page->getMountPointInfo($uid);
1597  if (is_array($mount_info)) {
1598  $uid = $mount_info['mount_pid'];
1599  }
1600  $recs = $this->sys_page->getMenu($uid, 'uid,pid,doktype,mount_pid,mount_pid_ol,nav_hide,shortcut,shortcut_mode,l18n_cfg');
1601  $hasSubPages = FALSE;
1602  $bannedUids = $this->getBannedUids();
1603  foreach ($recs as $theRec) {
1604  // no valid subpage if the document type is excluded from the menu
1605  if (GeneralUtility::inList($this->doktypeExcludeList, $theRec['doktype'])) {
1606  continue;
1607  }
1608  // No valid subpage if the page is hidden inside menus and
1609  // it wasn't forced to show such entries
1610  if ($theRec['nav_hide'] && !$this->conf['includeNotInMenu']) {
1611  continue;
1612  }
1613  // No valid subpage if the default language should be shown and the page settings
1614  // are excluding the visibility of the default language
1615  if (!$GLOBALS['TSFE']->sys_language_uid && GeneralUtility::hideIfDefaultLanguage($theRec['l18n_cfg'])) {
1616  continue;
1617  }
1618  // No valid subpage if the alternative language should be shown and the page settings
1619  // are requiring a valid overlay but it doesn't exists
1620  $hideIfNotTranslated = GeneralUtility::hideIfNotTranslated($theRec['l18n_cfg']);
1621  if ($GLOBALS['TSFE']->sys_language_uid && $hideIfNotTranslated && !$theRec['_PAGES_OVERLAY']) {
1622  continue;
1623  }
1624  // No valid subpage if the subpage is banned by excludeUidList
1625  if (in_array($theRec['uid'], $bannedUids)) {
1626  continue;
1627  }
1628  $hasSubPages = TRUE;
1629  break;
1630  }
1631  return $hasSubPages;
1632  }
1633 
1644  public function isItemState($kind, $key) {
1645  $natVal = 0;
1646  // If any value is set for ITEM_STATE the normal evaluation is discarded
1647  if ($this->menuArr[$key]['ITEM_STATE']) {
1648  if ((string)$this->menuArr[$key]['ITEM_STATE'] === (string)$kind) {
1649  $natVal = 1;
1650  }
1651  } else {
1652  switch ($kind) {
1653  case 'SPC':
1654  $natVal = $this->menuArr[$key]['isSpacer'];
1655  break;
1656  case 'IFSUB':
1657  $natVal = $this->isSubMenu($this->menuArr[$key]['uid']);
1658  break;
1659  case 'ACT':
1660  $natVal = $this->isActive($this->menuArr[$key]['uid'], $this->getMPvar($key));
1661  break;
1662  case 'ACTIFSUB':
1663  $natVal = $this->isActive($this->menuArr[$key]['uid'], $this->getMPvar($key)) && $this->isSubMenu($this->menuArr[$key]['uid']);
1664  break;
1665  case 'CUR':
1666  $natVal = $this->isCurrent($this->menuArr[$key]['uid'], $this->getMPvar($key));
1667  break;
1668  case 'CURIFSUB':
1669  $natVal = $this->isCurrent($this->menuArr[$key]['uid'], $this->getMPvar($key)) && $this->isSubMenu($this->menuArr[$key]['uid']);
1670  break;
1671  case 'USR':
1672  $natVal = $this->menuArr[$key]['fe_group'];
1673  break;
1674  }
1675  }
1676  return $natVal;
1677  }
1678 
1687  public function accessKey($title) {
1688  // The global array ACCESSKEY is used to globally control if letters are already used!!
1689  $result = array();
1690  $title = trim(strip_tags($title));
1691  $titleLen = strlen($title);
1692  for ($a = 0; $a < $titleLen; $a++) {
1693  $key = strtoupper(substr($title, $a, 1));
1694  if (preg_match('/[A-Z]/', $key) && !isset($GLOBALS['TSFE']->accessKey[$key])) {
1695  $GLOBALS['TSFE']->accessKey[$key] = 1;
1696  $result['code'] = ' accesskey="' . $key . '"';
1697  $result['alt'] = ' (ALT+' . $key . ')';
1698  $result['key'] = $key;
1699  break;
1700  }
1701  }
1702  return $result;
1703  }
1704 
1715  public function userProcess($mConfKey, $passVar) {
1716  if ($this->mconf[$mConfKey]) {
1717  $funcConf = $this->mconf[$mConfKey . '.'];
1718  $funcConf['parentObj'] = $this;
1719  $passVar = $this->parent_cObj->callUserFunction($this->mconf[$mConfKey], $funcConf, $passVar);
1720  }
1721  return $passVar;
1722  }
1723 
1731  public function setATagParts() {
1732  $params = trim($this->I['val']['ATagParams']) . $this->I['accessKey']['code'];
1733  $params = $params !== '' ? ' ' . $params : '';
1734  $this->I['A1'] = '<a ' . GeneralUtility::implodeAttributes($this->I['linkHREF'], 1) . $params . '>';
1735  $this->I['A2'] = '</a>';
1736  }
1737 
1747  public function getPageTitle($title, $nav_title) {
1748  return trim($nav_title) !== '' ? $nav_title : $title;
1749  }
1750 
1759  public function getMPvar($key) {
1760  if ($GLOBALS['TYPO3_CONF_VARS']['FE']['enable_mount_pids']) {
1761  $localMP_array = $this->MP_array;
1762  // NOTICE: "_MP_PARAM" is allowed to be a commalist of PID pairs!
1763  if ($this->menuArr[$key]['_MP_PARAM']) {
1764  $localMP_array[] = $this->menuArr[$key]['_MP_PARAM'];
1765  }
1766  $MP_params = count($localMP_array) ? implode(',', $localMP_array) : '';
1767  return $MP_params;
1768  }
1769  }
1770 
1778  public function getDoktypeExcludeWhere() {
1779  return $this->doktypeExcludeList ? ' AND pages.doktype NOT IN (' . $this->doktypeExcludeList . ')' : '';
1780  }
1781 
1789  public function getBannedUids() {
1790  $excludeUidList = isset($this->conf['excludeUidList.'])
1791  ? $this->parent_cObj->stdWrap($this->conf['excludeUidList'], $this->conf['excludeUidList.'])
1792  : $this->conf['excludeUidList'];
1793 
1794  if (!trim($excludeUidList)) {
1795  return array();
1796  }
1797 
1798  $banUidList = str_replace('current', $GLOBALS['TSFE']->page['uid'], $excludeUidList);
1799  return GeneralUtility::intExplode(',', $banUidList);
1800  }
1801 
1815  public function menuTypoLink($page, $oTarget, $no_cache, $script, $overrideArray = '', $addParams = '', $typeOverride = '') {
1816  $conf = array(
1817  'parameter' => is_array($overrideArray) && $overrideArray['uid'] ? $overrideArray['uid'] : $page['uid']
1818  );
1819  if (MathUtility::canBeInterpretedAsInteger($typeOverride)) {
1820  $conf['parameter'] .= ',' . (int)$typeOverride;
1821  }
1822  if ($addParams) {
1823  $conf['additionalParams'] = $addParams;
1824  }
1825  if ($no_cache) {
1826  $conf['no_cache'] = TRUE;
1827  } elseif ($this->useCacheHash) {
1828  $conf['useCacheHash'] = TRUE;
1829  }
1830  if ($oTarget) {
1831  $conf['target'] = $oTarget;
1832  }
1833  if ($page['sectionIndex_uid']) {
1834  $conf['section'] = $page['sectionIndex_uid'];
1835  }
1836  $conf['linkAccessRestrictedPages'] = $this->mconf['showAccessRestrictedPages'] && $this->mconf['showAccessRestrictedPages'] !== 'NONE';
1837  $this->parent_cObj->typoLink('|', $conf);
1838  $LD = $this->parent_cObj->lastTypoLinkLD;
1839  $LD['totalURL'] = $this->parent_cObj->lastTypoLinkUrl;
1840  return $LD;
1841  }
1842 
1854  protected function sectionIndex($altSortField, $pid = NULL) {
1855  $pid = (int)($pid ?: $this->id);
1856  $basePageRow = $this->sys_page->getPage($pid);
1857  if (!is_array($basePageRow)) {
1858  return array();
1859  }
1860  $configuration = $this->mconf['sectionIndex.'];
1861  $useColPos = 0;
1862  if (trim($configuration['useColPos']) !== '' || is_array($configuration['useColPos.'])) {
1863  $useColPos = $GLOBALS['TSFE']->cObj->stdWrap($configuration['useColPos'], $configuration['useColPos.']);
1864  $useColPos = (int)$useColPos;
1865  }
1866  $selectSetup = array(
1867  'pidInList' => $pid,
1868  'orderBy' => $altSortField,
1869  'languageField' => 'sys_language_uid',
1870  'where' => $useColPos >= 0 ? 'colPos=' . $useColPos : ''
1871  );
1872  if ($basePageRow['content_from_pid']) {
1873  // If the page is configured to show content from a referenced page the sectionIndex contains only contents of
1874  // the referenced page
1875  $selectSetup['pidInList'] = $basePageRow['content_from_pid'];
1876  }
1877  $resource = $this->parent_cObj->exec_getQuery('tt_content', $selectSetup);
1878  if (!$resource) {
1879  $message = 'SectionIndex: Query to fetch the content elements failed!';
1880  throw new \UnexpectedValueException($message, 1337334849);
1881  }
1882  $result = array();
1883  while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resource)) {
1884  $this->sys_page->versionOL('tt_content', $row);
1885  if ($GLOBALS['TSFE']->sys_language_contentOL && $basePageRow['_PAGES_OVERLAY_LANGUAGE']) {
1886  $row = $this->sys_page->getRecordOverlay('tt_content', $row, $basePageRow['_PAGES_OVERLAY_LANGUAGE'], $GLOBALS['TSFE']->sys_language_contentOL);
1887  }
1888  if ($this->mconf['sectionIndex.']['type'] !== 'all') {
1889  $doIncludeInSectionIndex = $row['sectionIndex'] >= 1;
1890  $doHeaderCheck = $this->mconf['sectionIndex.']['type'] === 'header';
1891  $isValidHeader = ((int)$row['header_layout'] !== 100 || !empty($this->mconf['sectionIndex.']['includeHiddenHeaders'])) && trim($row['header']) !== '';
1892  if (!$doIncludeInSectionIndex || $doHeaderCheck && !$isValidHeader) {
1893  continue;
1894  }
1895  }
1896  if (is_array($row)) {
1897  $uid = $row['uid'];
1898  $result[$uid] = $basePageRow;
1899  $result[$uid]['title'] = $row['header'];
1900  $result[$uid]['nav_title'] = $row['header'];
1901  $result[$uid]['subtitle'] = $row['subheader'];
1902  $result[$uid]['starttime'] = $row['starttime'];
1903  $result[$uid]['endtime'] = $row['endtime'];
1904  $result[$uid]['fe_group'] = $row['fe_group'];
1905  $result[$uid]['media'] = $row['media'];
1906  $result[$uid]['header_layout'] = $row['header_layout'];
1907  $result[$uid]['bodytext'] = $row['bodytext'];
1908  $result[$uid]['image'] = $row['image'];
1909  $result[$uid]['sectionIndex_uid'] = $uid;
1910  }
1911  }
1912  $GLOBALS['TYPO3_DB']->sql_free_result($resource);
1913  return $result;
1914  }
1915 
1921  public function getSysPage() {
1922  return $this->sys_page;
1923  }
1924 
1930  public function getParentContentObject() {
1931  return $this->parent_cObj;
1932  }
1933 
1937  protected function getCache() {
1938  return GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('cache_hash');
1939  }
1940 
1941 }
static implodeAttributes(array $arr, $xhtmlSafe=FALSE, $dontOmitBlankAttribs=FALSE)
static explodeUrl2Array($string, $multidim=FALSE)
$parameters
Definition: FileDumpEID.php:15
$languageItems
Definition: be_users.php:7
static forceIntegerInRange($theInt, $min, $max=2000000000, $defaultValue=0)
Definition: MathUtility.php:32
static intExplode($delimiter, $string, $removeEmptyValues=FALSE, $limit=0)
$uid
Definition: server.php:36
static getUserObj($classRef, $checkPrefix='', $silent=FALSE)
static hideIfDefaultLanguage($localizationConfiguration)
static hideIfNotTranslated($l18n_cfg_fieldValue)
menuTypoLink($page, $oTarget, $no_cache, $script, $overrideArray='', $addParams='', $typeOverride='')
static inArray(array $in_array, $item)
start(&$tmpl, &$sys_page, $id, $conf, $menuNumber, $objSuffix='')
debug($variable='', $name=' *variable *', $line=' *line *', $file=' *file *', $recursiveDepth=3, $debugLevel=E_DEBUG)
if(isset($ajaxID)) if(in_array( $ajaxID, $noUserAjaxIDs))
Re-apply pairs of single-quotes to the text.
Definition: ajax.php:40
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]