Exemple #1
0
 /**
  * @return mixed
  */
 public function render()
 {
     // Get page via pageUid argument or current id
     $pageUid = intval($this->arguments['pageUid']);
     if (0 === $pageUid) {
         $pageUid = $GLOBALS['TSFE']->id;
     }
     $page = $this->pageSelect->getPage($pageUid);
     // Add the page overlay
     $languageUid = intval($GLOBALS['TSFE']->sys_language_uid);
     if (0 !== $languageUid) {
         $pageOverlay = $this->pageSelect->getPageOverlay($pageUid, $languageUid);
         if (TRUE === is_array($pageOverlay)) {
             if (TRUE === method_exists('TYPO3\\CMS\\Core\\Utility\\ArrayUtility', 'mergeRecursiveWithOverrule')) {
                 ArrayUtility::mergeRecursiveWithOverrule($page, $pageOverlay, FALSE, FALSE);
             } else {
                 $page = GeneralUtility::array_merge_recursive_overrule($page, $pageOverlay, FALSE, FALSE);
             }
         }
     }
     $content = NULL;
     // Check if field should be returned or assigned
     $field = $this->arguments['field'];
     if (TRUE === empty($field)) {
         $content = $page;
     } elseif (TRUE === isset($page[$field])) {
         $content = $page[$field];
     }
     return $this->renderChildrenWithVariableOrReturnInput($content);
 }
 /**
  * @return mixed
  */
 public function render()
 {
     // Get page via pageUid argument or current id
     $pageUid = intval($this->arguments['pageUid']);
     if (0 === $pageUid) {
         $pageUid = $GLOBALS['TSFE']->id;
     }
     $page = $this->pageSelect->getPage($pageUid);
     // Add the page overlay
     $languageUid = intval($GLOBALS['TSFE']->sys_language_uid);
     if (0 !== $languageUid) {
         $pageOverlay = $this->pageSelect->getPageOverlay($pageUid, $languageUid);
         if (TRUE === is_array($pageOverlay)) {
             $page = GeneralUtility::array_merge_recursive_overrule($page, $pageOverlay, FALSE, FALSE);
         }
     }
     $content = NULL;
     // Check if field should be returned or assigned
     $field = $this->arguments['field'];
     if (TRUE === empty($field)) {
         $content = $page;
     } elseif (TRUE === isset($page[$field])) {
         $content = $page[$field];
     }
     // Return if no assign
     $as = $this->arguments['as'];
     if (TRUE === empty($as)) {
         return $content;
     }
     $variables = array($as => $content);
     $output = ViewHelperUtility::renderChildrenWithVariables($this, $this->templateVariableContainer, $variables);
     return $output;
 }
Exemple #3
0
 /**
  * Get the selected page.
  *
  * @return array
  */
 private function getPage()
 {
     $pageUid = intval($this->arguments['pageUid']);
     if ($pageUid === 0) {
         $pageUid = $GLOBALS['TSFE']->id;
     }
     return $this->pageSelect->getPage($pageUid);
 }
 /**
  * @param array $page
  * @param array $rootLine
  * @param array $parentPage
  * @return array
  */
 protected function getMenuItemEntry($page, $rootLine, array $parentPage = NULL)
 {
     $getLL = $GLOBALS['TSFE']->sys_language_uid;
     $pageUid = $overlayPageUid = $page['originalPageUid'] = $page['uid'];
     $targetPage = NULL;
     $doktype = (int) $page['doktype'];
     if (NULL !== $parentPage && TRUE === isset($parentPage['_MP_PARAM'])) {
         $page['mountPointParameter'] = $parentPage['_MP_PARAM'];
     }
     if (PageRepository::DOKTYPE_MOUNTPOINT === $doktype) {
         $mountInfo = $GLOBALS['TSFE']->sys_page->getMountPointInfo($page['uid'], $page);
         $page['mountedPageUid'] = $mountInfo['mount_pid'];
         $page['mountPointParameter'] = $mountInfo['MPvar'];
     } elseif (PageRepository::DOKTYPE_SHORTCUT === $doktype) {
         switch ($page['shortcut_mode']) {
             case 3:
                 // mode: parent page of current page (using PID of current page)
                 $targetPage = $this->pageSelect->getPage($page['pid']);
                 if ((int) $page['pid'] === (int) $GLOBALS['TSFE']->id) {
                     array_push($rootLine, $page);
                 }
                 break;
             case 2:
                 // mode: random subpage of selected or current page
                 $menu = $this->getMenu($page['shortcut'] > 0 ? $page['shortcut'] : $pageUid);
                 $targetPage = count($menu) > 0 ? $menu[array_rand($menu)] : $page;
                 break;
             case 1:
                 // mode: first subpage of selected or current page
                 $menu = $this->getMenu($page['shortcut'] > 0 ? $page['shortcut'] : $pageUid);
                 $targetPage = count($menu) > 0 ? reset($menu) : $page;
                 break;
             case 0:
             default:
                 $targetPage = $this->pageSelect->getPage($page['shortcut']);
         }
         if (TRUE === (bool) $this->shouldUseShortcutTarget()) {
             // overwrite current page data with shortcut page data
             $page = $targetPage;
             $overlayPageUid = $targetPage['uid'];
         }
         if (TRUE === (bool) $this->shouldUseShortcutUid()) {
             // overwrite current page UID
             $page['uid'] = $targetPage['uid'];
         }
     }
     if (0 < $getLL) {
         $pageOverlay = $this->pageSelect->getPageOverlay($overlayPageUid, $getLL);
         foreach ($pageOverlay as $name => $value) {
             if (FALSE === empty($value)) {
                 $page[$name] = $value;
             }
         }
     }
     $page['hasSubPages'] = 0 < count($this->getSubmenu($page['originalPageUid']));
     $page['active'] = $this->isActive($page['uid'], $rootLine, $page['originalPageUid']);
     $page['current'] = $this->isCurrent($page['uid']);
     $page['link'] = $this->getItemLink($page);
     $page['linktext'] = $this->getItemTitle($page);
     $page['class'] = implode(' ', $this->getItemClass($page));
     $page['doktype'] = $doktype;
     if (PageRepository::DOKTYPE_LINK === $doktype) {
         $urlTypes = array('1' => 'http://', '4' => 'https://', '2' => 'ftp://', '3' => 'mailto:');
         $page['link'] = $urlTypes[$page['urltype']] . $page['url'];
     }
     return $page;
 }
 /**
  * Render method
  * @return NULL|string
  */
 public function render()
 {
     // Check if link wizard link
     $pageUid = $this->arguments['pageUid'];
     $additionalParameters = (array) $this->arguments['additionalParams'];
     if (FALSE === is_numeric($pageUid)) {
         $linkConfig = GeneralUtility::unQuoteFilenames($pageUid, TRUE);
         if (TRUE === isset($linkConfig[0])) {
             $pageUid = $linkConfig[0];
         }
         if (TRUE === isset($linkConfig[1]) && '-' !== $linkConfig[1]) {
             $this->tag->addAttribute('target', $linkConfig[1]);
         }
         if (TRUE === isset($linkConfig[2]) && '-' !== $linkConfig[2]) {
             $this->tag->addAttribute('class', $linkConfig[2]);
         }
         if (TRUE === isset($linkConfig[3]) && '-' !== $linkConfig[3]) {
             $this->tag->addAttribute('title', $linkConfig[3]);
         }
         if (TRUE === isset($linkConfig[4]) && '-' !== $linkConfig[4]) {
             $additionalParametersString = trim($linkConfig[4], '&');
             $additionalParametersArray = GeneralUtility::trimExplode('&', $additionalParametersString);
             foreach ($additionalParametersArray as $parameter) {
                 list($key, $value) = GeneralUtility::trimExplode('=', $parameter);
                 $additionalParameters[$key] = $value;
             }
         }
     }
     // Get page via pageUid argument or current id
     $pageUid = intval($pageUid);
     if (0 === $pageUid) {
         $pageUid = $GLOBALS['TSFE']->id;
     }
     $page = $this->pageSelect->getPage($pageUid);
     if (TRUE === empty($page)) {
         return NULL;
     }
     // Do not render the link, if the page should be hidden
     $currentLanguageUid = $GLOBALS['TSFE']->sys_language_uid;
     $hidePage = $this->pageSelect->hidePageForLanguageUid($pageUid, $currentLanguageUid);
     if (TRUE === $hidePage) {
         return NULL;
     }
     // Get the title from the page or page overlay
     if (0 < $currentLanguageUid) {
         $pageOverlay = $this->pageSelect->getPageOverlay($pageUid, $currentLanguageUid);
         $title = $this->getTitleValue($pageOverlay);
     } else {
         $title = $this->getTitleValue($page);
     }
     // Check if we should assign page title to the template variable container
     $pageTitleAs = $this->arguments['pageTitleAs'];
     if (FALSE === empty($pageTitleAs)) {
         $variables = array($pageTitleAs => $title);
     } else {
         $variables = array();
     }
     // Render childs to see if an alternative title content should be used
     $renderedTitle = ViewHelperUtility::renderChildrenWithVariables($this, $this->templateVariableContainer, $variables);
     if (FALSE === empty($renderedTitle)) {
         $title = $renderedTitle;
     }
     $uriBuilder = $this->controllerContext->getUriBuilder();
     $uri = $uriBuilder->reset()->setTargetPageUid($pageUid)->setTargetPageType($this->arguments['pageType'])->setNoCache($this->arguments['noCache'])->setUseCacheHash(!$this->arguments['noCacheHash'])->setSection($this->arguments['section'])->setLinkAccessRestrictedPages($this->arguments['linkAccessRestrictedPages'])->setArguments($additionalParameters)->setCreateAbsoluteUri($this->arguments['absolute'])->setAddQueryString($this->arguments['addQueryString'])->setArgumentsToBeExcludedFromQueryString((array) $this->arguments['argumentsToBeExcludedFromQueryString'])->build();
     $this->tag->addAttribute('href', $uri);
     $this->tag->setContent($title);
     return $this->tag->render();
 }
 /**
  * @param array $page
  * @param array $rootLine
  * @throws \Exception
  * @return array
  */
 protected function getMenuItemEntry($page, $rootLine)
 {
     $getLL = $GLOBALS['TSFE']->sys_language_uid;
     $pageUid = $page['uid'];
     // keep a backup of the original page UID to determine 'active' state
     $originalPageUid = $page['uid'];
     // first, ensure the complete data array is present
     $page = $this->pageSelect->getPage($pageUid);
     $targetPage = NULL;
     if (PageRepository::DOKTYPE_SHORTCUT === (int) $page['doktype']) {
         switch ($page['shortcut_mode']) {
             case 3:
                 // mode: parent page of current page (using PID of current page)
                 $targetPage = $this->pageSelect->getPage($page['pid']);
                 if ((int) $page['pid'] === (int) $GLOBALS['TSFE']->id) {
                     array_push($rootLine, $page);
                 }
                 break;
             case 2:
                 // mode: random subpage of selected or current page
                 $menu = $this->getMenu($page['shortcut'] > 0 ? $page['shortcut'] : $pageUid);
                 $targetPage = count($menu) > 0 ? $menu[array_rand($menu)] : $page;
                 break;
             case 1:
                 // mode: first subpage of selected or current page
                 $menu = $this->getMenu($page['shortcut'] > 0 ? $page['shortcut'] : $pageUid);
                 $targetPage = count($menu) > 0 ? reset($menu) : $page;
                 break;
             case 0:
             default:
                 $targetPage = $this->pageSelect->getPage($page['shortcut']);
         }
         if (TRUE === (bool) $this->shouldUseShortcutTarget()) {
             // overwrite current page data with shortcut page data
             $page = $targetPage;
         }
         if (TRUE === (bool) $this->shouldUseShortcutUid()) {
             // overwrite current page UID
             $pageUid = $targetPage['uid'];
         }
     }
     if (0 < $getLL) {
         $pageOverlay = $this->pageSelect->getPageOverlay($page['uid'], $getLL);
         foreach ($pageOverlay as $name => $value) {
             if (FALSE === empty($value)) {
                 $page[$name] = $value;
             }
         }
     }
     $doktype = (int) $page['doktype'];
     $shortcut = PageRepository::DOKTYPE_SHORTCUT === $doktype ? $page['shortcut'] : $page['url'];
     $page['active'] = $this->isActive($pageUid, $rootLine, $originalPageUid);
     $page['current'] = $this->isCurrent($pageUid);
     $page['hasSubPages'] = (bool) (0 < count($this->getSubmenu($originalPageUid)) ? TRUE : FALSE);
     $page['link'] = $this->getItemLink($pageUid, $doktype, $shortcut);
     $page['linktext'] = $this->getItemTitle($page);
     $page['class'] = implode(' ', $this->getItemClass($page));
     $page['doktype'] = $doktype;
     if (PageRepository::DOKTYPE_LINK === $doktype) {
         $urlTypes = array('1' => 'http://', '4' => 'https://', '2' => 'ftp://', '3' => 'mailto:');
         $page['link'] = $urlTypes[$page['urltype']] . $page['url'];
     }
     return $page;
 }