TYPO3  7.6
ListViewHelper.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\FluidStyledContent\ViewHelpers\Menu;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
17 
37 {
38  use MenuViewHelperTrait;
39 
43  public function initializeArguments()
44  {
45  $this->registerArgument('as', 'string', 'Name of template variable which will contain selected pages', true);
46  $this->registerArgument('levelAs', 'string', 'Name of template variable which will contain current level', false, null);
47  $this->registerArgument('pageUids', 'array', 'Page UIDs of parent pages', false, array());
48  $this->registerArgument('entryLevel', 'integer', 'The entry level', false, null);
49  $this->registerArgument('maximumLevel', 'integer', 'Maximum level for rendering of nested menus', false, 10);
50  $this->registerArgument('includeNotInMenu', 'boolean', 'Include pages that are marked "hide in menu"?', false, false);
51  $this->registerArgument('includeMenuSeparator', 'boolean', 'Include pages of the type "Menu separator"?', false, false);
52  }
53 
60  public function render()
61  {
62  $typoScriptFrontendController = $this->getTypoScriptFrontendController();
63  $as = $this->arguments['as'];
64  $pageUids = (array)$this->arguments['pageUids'];
65  $entryLevel = $this->arguments['entryLevel'];
66  $levelAs = $this->arguments['levelAs'];
67  $maximumLevel = $this->arguments['maximumLevel'];
68  $includeNotInMenu = (bool)$this->arguments['includeNotInMenu'];
69  $includeMenuSeparator = (bool)$this->arguments['includeMenuSeparator'];
70 
71  $pageUids = $this->getPageUids($pageUids, $entryLevel);
72  $pages = $typoScriptFrontendController->sys_page->getMenuForPages(
73  $pageUids,
74  '*',
75  '',
76  $this->getPageConstraints($includeNotInMenu, $includeMenuSeparator)
77  );
78 
79  $output = '';
80 
81  if (!empty($pages)) {
82  if (!$typoScriptFrontendController->register['ceMenuLevel_list']) {
83  $typoScriptFrontendController->register['ceMenuLevel_list'] = 1;
84  $typoScriptFrontendController->register['ceMenuMaximumLevel_list'] = $maximumLevel;
85  } else {
86  $typoScriptFrontendController->register['ceMenuLevel_list']++;
87  }
88 
89  if ($typoScriptFrontendController->register['ceMenuLevel_list'] > $typoScriptFrontendController->register['ceMenuMaximumLevel_list']) {
90  return '';
91  }
92 
93  $variables = array(
94  $as => $pages
95  );
96  if (!empty($levelAs)) {
97  $variables[$levelAs] = $typoScriptFrontendController->register['ceMenuLevel_list'];
98  }
99  $output = $this->renderChildrenWithVariables($variables);
100 
101  $typoScriptFrontendController->register['ceMenuLevel_list']--;
102 
103  if ($typoScriptFrontendController->register['ceMenuLevel_list'] === 0) {
104  unset($typoScriptFrontendController->register['ceMenuLevel_list']);
105  unset($typoScriptFrontendController->register['ceMenuMaximumLevel_list']);
106  }
107  }
108 
109  return $output;
110  }
111 }