2 namespace TYPO3\CMS\FluidStyledContent\ViewHelpers\Menu;
43 use MenuViewHelperTrait;
52 $this->
registerArgument(
'as',
'string',
'Name of template variable which will contain selected pages',
true);
53 $this->
registerArgument(
'entryLevel',
'integer',
'The entry level',
false, 0);
54 $this->
registerArgument(
'pageUids',
'array',
'Page UIDs of pages to fetch the keywords from',
false, array());
55 $this->
registerArgument(
'keywords',
'array',
'Keywords for which to search',
false, array());
56 $this->
registerArgument(
'includeNotInMenu',
'boolean',
'Include pages that are marked "hide in menu"?',
false,
false);
57 $this->
registerArgument(
'includeMenuSeparator',
'boolean',
'Include pages of the type "Menu separator"?',
false,
false);
58 $this->
registerArgument(
'excludeNoSearchPages',
'boolean',
'Exclude pages that are NOT marked "include in search"?',
false,
true);
68 $typoScriptFrontendController = $this->getTypoScriptFrontendController();
69 $as = (string)$this->arguments[
'as'];
70 $entryLevel = (int)$this->arguments[
'entryLevel'];
71 $pageUids = (array)$this->arguments[
'pageUids'];
72 $keywords = (array)$this->arguments[
'keywords'];
73 $includeNotInMenu = (bool)$this->arguments[
'includeNotInMenu'];
74 $includeMenuSeparator = (bool)$this->arguments[
'includeMenuSeparator'];
75 $excludeNoSearchPages = (bool)$this->arguments[
'excludeNoSearchPages'];
78 if (empty($pageUids)) {
79 $pageUids = array($typoScriptFrontendController->page[
'uid']);
83 if (!is_array($keywords)) {
86 $unfilteredKeywords = $keywords;
90 if (empty($keywords)) {
91 foreach ($pageUids as $pageUid) {
92 $page = $typoScriptFrontendController->sys_page->getPage($pageUid);
93 $unfilteredKeywords = array_merge(
99 $filteredKeywords = array_unique($unfilteredKeywords);
101 $constraints = $this->getPageConstraints($includeNotInMenu, $includeMenuSeparator);
102 if ($excludeNoSearchPages) {
103 $constraints .=
' AND no_search = 0';
106 $keywordConstraints = array();
107 if ($filteredKeywords) {
109 foreach ($filteredKeywords as $keyword) {
110 $keyword = $db->fullQuoteStr(
'%' . $db->escapeStrForLike($keyword,
'pages') .
'%',
'pages');
111 $keywordConstraints[] =
'keywords LIKE ' . $keyword;
113 $constraints .=
' AND (' . implode(
' OR ', $keywordConstraints) .
')';
117 if ($entryLevel < 0) {
118 $entryLevel = count($typoScriptFrontendController->tmpl->rootLine) - 1 + $entryLevel;
120 $startUid = $typoScriptFrontendController->tmpl->rootLine[$entryLevel][
'uid'];
121 $treePageUids = explode(
123 $typoScriptFrontendController->cObj->getTreeList($startUid, 20)
126 $pages = $typoScriptFrontendController->sys_page->getMenuForPages(
127 array_merge([$startUid], $treePageUids),
132 return $this->renderChildrenWithVariables(array(
147 $keywordList = preg_split(
'/[,;' . LF .
']/', $keywords);
149 return array_filter(array_map(
'trim', $keywordList));