From ce1513ef21d0c23bd4db26e8ae4c1048b8dd0906 Mon Sep 17 00:00:00 2001 From: Claus Due Date: Sat, 26 Apr 2014 04:07:02 +0200 Subject: [PATCH] [TASK] Fully deprecate and ignore showHidden on menus Field is a core enableField which should be respected. The PageRepository is being used and can (if we decide so in the future) be prepped to show hidden pages *if a BE user is logged in* or depending on other ENV. --- Classes/Service/PageSelectService.php | 23 ++++--------------- .../If/Page/HasSubpagesViewHelper.php | 2 +- .../Page/Menu/AbstractMenuViewHelper.php | 13 +++-------- 3 files changed, 9 insertions(+), 29 deletions(-) diff --git a/Classes/Service/PageSelectService.php b/Classes/Service/PageSelectService.php index 5b61e524b..8723d0150 100644 --- a/Classes/Service/PageSelectService.php +++ b/Classes/Service/PageSelectService.php @@ -42,11 +42,6 @@ class Tx_Vhs_Service_PageSelectService implements \TYPO3\CMS\Core\SingletonInter */ protected static $pageSelect; - /** - * @var \TYPO3\CMS\Frontend\Page\PageRepository - */ - protected static $pageSelectHidden; - /** * @var array */ @@ -71,15 +66,13 @@ class Tx_Vhs_Service_PageSelectService implements \TYPO3\CMS\Core\SingletonInter * Initialize \TYPO3\CMS\Frontend\Page\PageRepository objects */ public function initializeObject() { - self::$pageSelect = $this->createPageSelectInstance(FALSE); - self::$pageSelectHidden = $this->createPageSelectInstance(TRUE); + self::$pageSelect = $this->createPageSelectInstance(); } /** - * @param boolean $showHidden * @return \TYPO3\CMS\Frontend\Page\PageRepository */ - private function createPageSelectInstance($showHidden = FALSE) { + private function createPageSelectInstance() { if (TRUE === is_array($GLOBALS['TSFE']->fe_user->user)) { $groups = array(-2, 0); $groups = array_merge($groups, (array) array_values($GLOBALS['TSFE']->fe_user->groupData['uid'])); @@ -87,7 +80,6 @@ private function createPageSelectInstance($showHidden = FALSE) { $groups = array(-1, 0); } $pageSelect = new \TYPO3\CMS\Frontend\Page\PageRepository(); - $pageSelect->init((boolean) $showHidden); $clauses = array(); foreach ($groups as $group) { $clause = "fe_group = '" . $group . "' OR fe_group LIKE '" . @@ -135,14 +127,13 @@ public function getPageOverlay($pageInput, $languageUid = -1) { * Caution: different signature * * @param integer $pageUid - * @param boolean $showHidden * @param array $excludePages * @param string $where * @param boolean $showHiddenInMenu * @param boolean $checkShortcuts * @return array */ - public function getMenu($pageUid = NULL, $showHidden = FALSE, $excludePages = array(), $where = '', $showHiddenInMenu = FALSE, $checkShortcuts = FALSE) { + public function getMenu($pageUid = NULL, $excludePages = array(), $where = '', $showHiddenInMenu = FALSE, $checkShortcuts = FALSE) { if (NULL === $pageUid) { $pageUid = $GLOBALS['TSFE']->id; } @@ -156,13 +147,9 @@ public function getMenu($pageUid = NULL, $showHidden = FALSE, $excludePages = ar if ('' !== $where) { $addWhere = $where . ' ' . $addWhere; } - $key = md5(intval($showHidden) . $pageUid . $addWhere . intval($checkShortcuts)); + $key = md5(intval($showHiddenInMenu) . $pageUid . $addWhere . intval($checkShortcuts)); if (FALSE === isset(self::$cachedMenus[$key])) { - if (TRUE === $showHidden) { - self::$cachedMenus[$key] = self::$pageSelectHidden->getMenu($pageUid, '*', 'sorting', $addWhere, $checkShortcuts); - } else { - self::$cachedMenus[$key] = self::$pageSelect->getMenu($pageUid, '*', 'sorting', $addWhere, $checkShortcuts); - } + self::$cachedMenus[$key] = self::$pageSelect->getMenu($pageUid, '*', 'sorting', $addWhere, $checkShortcuts); } return self::$cachedMenus[$key]; } diff --git a/Classes/ViewHelpers/If/Page/HasSubpagesViewHelper.php b/Classes/ViewHelpers/If/Page/HasSubpagesViewHelper.php index 641583930..db450b79c 100644 --- a/Classes/ViewHelpers/If/Page/HasSubpagesViewHelper.php +++ b/Classes/ViewHelpers/If/Page/HasSubpagesViewHelper.php @@ -63,7 +63,7 @@ public function render($pageUid = NULL, $includeHidden = FALSE, $showHiddenInMen if (NULL === $pageUid || TRUE === empty($pageUid) || 0 === intval($pageUid)) { $pageUid = $GLOBALS['TSFE']->id; } - $menu = $this->pageSelect->getMenu($pageUid, (boolean) $includeHidden, array(), '', $showHiddenInMenu); + $menu = $this->pageSelect->getMenu($pageUid, array(), '', $showHiddenInMenu); $pageHasSubPages = (0 < count($menu)); if (TRUE === $pageHasSubPages) { return $this->renderThenChild(); diff --git a/Classes/ViewHelpers/Page/Menu/AbstractMenuViewHelper.php b/Classes/ViewHelpers/Page/Menu/AbstractMenuViewHelper.php index c070dc92d..cc44131b1 100644 --- a/Classes/ViewHelpers/Page/Menu/AbstractMenuViewHelper.php +++ b/Classes/ViewHelpers/Page/Menu/AbstractMenuViewHelper.php @@ -89,7 +89,7 @@ public function initializeArguments() { $this->registerArgument('substElementUid', 'boolean', 'Optional parameter for wrapping the link with the uid of the page', FALSE, ''); $this->registerArgument('includeSpacers', 'boolean', 'Wether or not to include menu spacers in the page select query', FALSE, FALSE); $this->registerArgument('resolveExclude', 'boolean', 'Exclude link if realurl/cooluri flag tx_realurl_exclude is set', FALSE, FALSE); - $this->registerArgument('showHidden', 'boolean', 'Include disabled pages into the menu', FALSE, FALSE); + $this->registerArgument('showHidden', 'boolean', 'DEPRECATED - IGNORED. FIELD IS AN ENABLE-FIELD WHICH MUST BE RESPECTED. Include disabled pages into the menu', FALSE, FALSE); $this->registerArgument('showHiddenInMenu', 'boolean', 'Include pages that are set to be hidden in menus', FALSE, FALSE); $this->registerArgument('showCurrent', 'boolean', 'If FALSE, does not display the current page', FALSE, TRUE); $this->registerArgument('linkCurrent', 'boolean', 'If FALSE, does not wrap the current page in a link', FALSE, TRUE); @@ -459,11 +459,7 @@ protected function parseMenu($menu, $rootLine) { $filtered = array(); $allowedDocumentTypes = $this->allowedDoktypeList(); foreach ($menu as $page) { - if (TRUE === (boolean) $page['hidden']) { - continue; - } elseif (TRUE === (boolean) $page['nav_hide'] && FALSE === (boolean) $this->arguments['showHidden']) { - continue; - } elseif (TRUE === isset($page['tx_realurl_exclude']) && TRUE === (boolean) $page['tx_realurl_exclude'] && TRUE === (boolean) $this->arguments['resolveExclude']) { + if (TRUE === isset($page['tx_realurl_exclude']) && TRUE === (boolean) $page['tx_realurl_exclude'] && TRUE === (boolean) $this->arguments['resolveExclude']) { continue; } elseif (TRUE === isset($page['tx_cooluri_exclude']) && TRUE === (boolean) $page['tx_cooluri_exclude'] && TRUE === (boolean) $this->arguments['resolveExclude']) { continue; @@ -471,9 +467,6 @@ protected function parseMenu($menu, $rootLine) { continue; } elseif (TRUE === in_array($page['doktype'], $allowedDocumentTypes)) { $page = $this->getMenuItemEntry($page, $rootLine); - if (TRUE === (boolean) $page['nav_hide'] && FALSE === (boolean) $this->arguments['showHidden']) { - continue; - } $filtered[$page['uid']] = $page; } } @@ -685,7 +678,7 @@ public function getMenu($pageUid, $where = '') { $excludePages = $this->processPagesArgument($this->arguments['excludePages']); $showHidden = (boolean) $this->arguments['showHidden']; $showHiddenInMenu = (boolean) $this->arguments['showHiddenInMenu']; - $menuData = $this->pageSelect->getMenu($pageUid, $showHidden, $excludePages, $where, $showHiddenInMenu, FALSE); + $menuData = $this->pageSelect->getMenu($pageUid, $excludePages, $where, $showHiddenInMenu, FALSE); return $menuData; }