/** * Automatically render a menu * * @param array $menu * @param integer $level * @return string */ protected function autoRender($menu, $level = 1) { $tagName = $this->arguments['tagNameChildren']; $substElementUid = $this->arguments['substElementUid']; $linkCurrent = (bool) $this->arguments['linkCurrent']; $linkActive = (bool) $this->arguments['linkActive']; $showCurrent = (bool) $this->arguments['showCurrent']; $html = array(); foreach ($menu as $page) { if ($page['current'] && !$showCurrent) { continue; } $class = trim($page['class']) != '' ? ' class="' . $page['class'] . '"' : ''; $elementId = $substElementUid ? ' id="elem_' . $page['uid'] . '"' : ''; $target = $page['target'] != '' ? ' target="' . $page['target'] . '"' : ''; $html[] = '<' . $tagName . $elementId . $class . '>'; if ($page['current'] && $linkCurrent === FALSE) { $html[] = $page['title']; } elseif ($page['active'] && $linkActive === FALSE) { $html[] = $page['title']; } else { $html[] = '<a href="' . $page['link'] . '"' . $class . $target . '>' . $page['title'] . '</a>'; } if (($page['active'] || $this->arguments['expandAll']) && $page['hasSubPages'] && $level < $this->arguments['levels']) { $rootLine = $this->pageSelect->getRootLine($page['uid']); $rootLine = $this->parseMenu($rootLine, $rootLine); $subMenu = $this->pageSelect->getMenu($page['uid']); $subMenu = $this->parseMenu($subMenu, $rootLine); $renderedSubMenu = $this->autoRender($subMenu, $level + 1); $this->tag->setTagName($this->arguments['tagName']); $this->tag->setContent($renderedSubMenu); $this->tag->addAttribute('class', ($this->arguments['class'] ? $this->arguments['class'] . ' lvl-' : 'lvl-') . strval($level)); $html[] = $this->tag->render(); $this->tag->addAttribute('class', $this->arguments['class']); } $html[] = '</' . $tagName . '>'; } return implode(LF, $html); }
/** * Returns true if there is a submenu with items for the page id, $uid * Used by the item states "IFSUB", "ACTIFSUB" and "CURIFSUB" to check if there is a submenu * * @param integer Page uid for which to search for a submenu * @return boolean Returns true if there was a submenu with items found * @access private */ function isSubMenu($uid) { // 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; $mount_info = $this->sys_page->getMountPointInfo($uid); if (is_array($mount_info)) { $uid = $mount_info['mount_pid']; } $recs = $this->sys_page->getMenu($uid, 'uid,pid,doktype,mount_pid,mount_pid_ol,nav_hide,shortcut,shortcut_mode'); foreach ($recs as $theRec) { 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!) return TRUE; } } }
/** * Get page shortcut; Finds the records pointed to by input value $SC (the shortcut value) * * @param integer The value of the "shortcut" field from the pages record * @param integer The shortcut mode: 1 and 2 will select either first subpage or random subpage; the default is the page pointed to by $SC * @param integer The current page UID of the page which is a shortcut * @param integer Safety feature which makes sure that the function is calling itself recursively max 20 times (since this function can find shortcuts to other shortcuts to other shortcuts...) * @param array An array filled with previous page uids tested by the function - new page uids are evaluated against this to avoid going in circles. * @return mixed Returns the page record of the page that the shortcut pointed to. * @access private * @see getPageAndRootline() */ function getPageShortcut($SC, $mode, $thisUid, $itera = 20, $pageLog = array()) { $idArray = t3lib_div::intExplode(',', $SC); // Find $page record depending on shortcut mode: switch ($mode) { case 1: case 2: $pageArray = $this->sys_page->getMenu($idArray[0] ? $idArray[0] : $thisUid, '*', 'sorting', 'AND pages.doktype<199 AND pages.doktype!=6'); $pO = 0; if ($mode == 2 && count($pageArray)) { // random $randval = intval(rand(0, count($pageArray) - 1)); $pO = $randval; } $c = 0; foreach ($pageArray as $pV) { if ($c == $pO) { $page = $pV; break; } $c++; } break; default: $page = $this->sys_page->getPage($idArray[0]); break; } // Check if short cut page was a shortcut itself, if so look up recursively: if ($page['doktype'] == 4) { if (!in_array($page['uid'], $pageLog) && $itera > 0) { $pageLog[] = $page['uid']; $page = $this->getPageShortcut($page['shortcut'], $page['shortcut_mode'], $page['uid'], $itera - 1, $pageLog); } else { $pageLog[] = $page['uid']; $message = 'Page shortcuts were looping in uids ' . implode(',', $pageLog) . '...!'; header('HTTP/1.0 500 Internal Server Error'); t3lib_div::sysLog($message, 'cms', t3lib_div::SYSLOG_SEVERITY_ERROR); $this->printError($message); exit; } } // Return resulting page: return $page; }