/**
  * @return mixed
  */
 public function render()
 {
     $pageUid = $this->arguments['pageUid'];
     if (0 === $pageUid) {
         $pageUid = $GLOBALS['TSFE']->id;
     }
     $rootLineData = $this->pageSelect->getRootLine($pageUid);
     return $this->renderChildrenWithVariableOrReturnInput($rootLineData);
 }
 /**
  * @return mixed
  */
 public function render()
 {
     $pageUid = $this->arguments['pageUid'];
     if (0 === $pageUid) {
         $pageUid = $GLOBALS['TSFE']->id;
     }
     $rootLineData = $this->pageSelect->getRootLine($pageUid);
     $as = $this->arguments['as'];
     if (TRUE === empty($as)) {
         return $rootLineData;
     }
     $variables = array($as => $rootLineData);
     $output = ViewHelperUtility::renderChildrenWithVariables($this, $this->templateVariableContainer, $variables);
     return $output;
 }
 /**
  * Render method
  *
  * @return string
  */
 public function render()
 {
     $pageUid = $this->arguments['pageUid'];
     $rootLineData = $this->pageSelect->getRootLine();
     $entryLevel = (int) $this->arguments['entryLevel'];
     if (0 > $entryLevel) {
         $entryLevel = count($rootLineData) + $entryLevel;
     }
     if (TRUE === empty($pageUid)) {
         if (NULL !== $rootLineData[$entryLevel]['uid']) {
             $pageUid = $rootLineData[$entryLevel]['uid'];
         } else {
             return '';
         }
     }
     $menuData = $this->getMenu($pageUid);
     $menu = $this->parseMenu($menuData, $rootLineData);
     $rootLine = $this->parseMenu($rootLineData, $rootLineData);
     $this->cleanupSubmenuVariables();
     $this->cleanTemplateVariableContainer();
     $this->backupVariables();
     $this->templateVariableContainer->add($this->arguments['as'], $menu);
     $this->templateVariableContainer->add($this->arguments['rootLineAs'], $rootLine);
     $this->initalizeSubmenuVariables();
     $output = $this->renderContent($menu);
     $this->cleanupSubmenuVariables();
     $this->templateVariableContainer->remove($this->arguments['as']);
     $this->templateVariableContainer->remove($this->arguments['rootLineAs']);
     $this->restoreVariables();
     return $output;
 }
 /**
  * Get content records based on column and pid
  *
  * @param integer $limit
  * @param string $order
  * @return array
  */
 protected function getContentRecords($limit = NULL, $order = NULL)
 {
     $pageUid = $this->getPageUid();
     $slide = (int) $this->arguments['slide'];
     $slideCollectReverse = (bool) $this->arguments['slideCollectReverse'];
     $slideCollect = (int) $this->arguments['slideCollect'];
     if (0 < $slideCollect) {
         // $slideCollect overrides $slide to automatically start sliding if
         // collection is enabled.
         $slide = $slideCollect;
     }
     // find out which storage page UIDs to read from, respecting slide depth
     $storagePageUids = array();
     if (0 === $slide) {
         $storagePageUids[] = $pageUid;
     } else {
         $rootLine = $this->pageSelect->getRootLine($pageUid, NULL, $slideCollectReverse);
         if (-1 !== $slide) {
             $rootLine = array_slice($rootLine, 0, $slide);
         }
         foreach ($rootLine as $page) {
             $storagePageUids[] = (int) $page['uid'];
         }
     }
     // select content elements, respecting slide and slideCollect.
     $contentRecords = array();
     do {
         $storagePageUid = array_shift($storagePageUids);
         $contentFromPageUid = $this->getContentRecordsFromPage($storagePageUid, $limit, $order);
         if (0 < count($contentFromPageUid)) {
             $contentRecords = array_merge($contentRecords, $contentFromPageUid);
             if (0 === $slideCollect) {
                 // stop collecting because argument said so and we've gotten at least one record now.
                 break;
             }
         }
     } while (0 < count($storagePageUids));
     if (TRUE === (bool) $this->arguments['render']) {
         $contentRecords = $this->getRenderedRecords($contentRecords);
     } else {
         $contentRecords = $contentRecords;
     }
     return $contentRecords;
 }
 /**
  * Get content records based on column and pid
  *
  * @param integer $limit
  * @param string $order
  * @return array
  */
 protected function getContentRecords($limit = NULL, $order = NULL)
 {
     if (NULL === $limit && FALSE === empty($this->arguments['limit'])) {
         $limit = intval($this->arguments['limit']);
     }
     if (NULL === $order && FALSE === empty($this->arguments['order'])) {
         $order = $this->arguments['order'];
     }
     $loadRegister = FALSE;
     if (FALSE === empty($this->arguments['loadRegister'])) {
         $this->contentObject->cObjGetSingle('LOAD_REGISTER', $this->arguments['loadRegister']);
         $loadRegister = TRUE;
     }
     $pageUid = $GLOBALS['TSFE']->id;
     if (FALSE === empty($this->arguments['pageUid'])) {
         $pageUid = $this->arguments['pageUid'];
     } elseif (FALSE === empty($GLOBALS['TSFE']->page['content_from_pid'])) {
         $pageUid = $GLOBALS['TSFE']->page['content_from_pid'];
     }
     $pageUid = intval($pageUid);
     if (FALSE === empty($order)) {
         $sortDirection = strtoupper(trim($this->arguments['sortDirection']));
         if ('ASC' !== $sortDirection && 'DESC' !== $sortDirection) {
             $sortDirection = 'ASC';
         }
         $order = $order . ' ' . $sortDirection;
     }
     $slide = intval($this->arguments['slide']);
     $slideCollect = intval($this->arguments['slideCollect']);
     $slide = min($slide, $slideCollect);
     $slideCollectReverse = (bool) $this->arguments['slideCollectReverse'];
     $rootLine = NULL;
     if (0 !== $slide) {
         $rootLine = $this->pageSelect->getRootLine($pageUid, NULL, $slideCollectReverse);
     }
     $colPos = intval($this->arguments['column']);
     $contentUids = $this->arguments['contentUids'];
     $content = array();
     $hideUntranslated = (bool) $this->arguments['hideUntranslated'];
     $currentLanguage = $GLOBALS['TSFE']->sys_language_content;
     $languageCondition = '(sys_language_uid IN (-1,' . $currentLanguage . ')';
     if (0 < $currentLanguage) {
         if (TRUE === $hideUntranslated) {
             $languageCondition .= ' AND l18n_parent > 0';
         }
         $nestedQuery = $GLOBALS['TYPO3_DB']->SELECTquery('l18n_parent', 'tt_content', 'sys_language_uid = ' . $currentLanguage . $GLOBALS['TSFE']->cObj->enableFields('tt_content'));
         $languageCondition .= ' AND uid NOT IN (' . $nestedQuery . ')';
     }
     $languageCondition .= ')';
     do {
         if (0 !== $slide) {
             $page = array_shift($rootLine);
             if (TRUE === empty($page)) {
                 break;
             }
             $pageUid = $page['uid'];
         }
         if (TRUE === is_array($contentUids)) {
             $conditions = 'uid IN (' . implode(',', $contentUids) . ')';
         } else {
             $conditions = "pid = '" . $pageUid . "' AND colPos = '" . $colPos . "'" . $GLOBALS['TSFE']->cObj->enableFields('tt_content') . ' AND ' . $languageCondition;
         }
         $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'tt_content', $conditions, 'uid', $order, $limit);
         if (TRUE === (bool) $this->arguments['render'] && FALSE === empty($rows)) {
             $content = $this->getRenderedRecords($rows);
         } else {
             $content = $rows;
         }
         if (0 !== count($content) && 0 === $slideCollect) {
             break;
         }
     } while (--$slide !== -1);
     if (TRUE === $loadRegister) {
         $this->contentObject->cObjGetSingle('RESTORE_REGISTER', '');
     }
     return $content;
 }