From 0212a64015772b4636512377bd645093e33894f7 Mon Sep 17 00:00:00 2001 From: Frederik Vosberg Date: Tue, 12 Feb 2013 07:28:16 +0100 Subject: [PATCH] [BUGFIX] excludeUidList not checked for ifsub state For menu item states IFSUB(RO), ACTIFSUB(RO) and CURIFSUB(RO) the excludeUidList was not checked. If all submenu items are excluded the menu item doesn't get the "ifsub" state anymore. Change-Id: Ia113bb187b778718a501e0f2f6c0956c99cb1d8a Fixes: #45254 Releases: 6.1, 6.0, 4.7, 4.5 Reviewed-on: https://review.typo3.org/18214 Reviewed-by: Wouter Wolters Tested-by: Wouter Wolters Reviewed-by: Georg Ringer Reviewed-by: Stefan Neufeind Reviewed-by: Jigal van Hemert Tested-by: Jigal van Hemert --- .../Menu/AbstractMenuContentObject.php | 5 ++ .../Menu/AbstractMenuContentObjectTest.php | 63 ++++++++++++++++++- 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php b/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php index 93bbfa48e4e6..f2873e38533f 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php +++ b/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php @@ -1488,6 +1488,7 @@ class AbstractMenuContentObject { } $recs = $this->sys_page->getMenu($uid, 'uid,pid,doktype,mount_pid,mount_pid_ol,nav_hide,shortcut,shortcut_mode,l18n_cfg'); $hasSubPages = FALSE; + $bannedUids = $this->getBannedUids(); foreach ($recs as $theRec) { // no valid subpage if the document type is excluded from the menu if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->doktypeExcludeList, $theRec['doktype'])) { @@ -1509,6 +1510,10 @@ class AbstractMenuContentObject { if ($GLOBALS['TSFE']->sys_language_uid && $hideIfNotTranslated && !$theRec['_PAGES_OVERLAY']) { continue; } + // No valid subpage if the subpage is banned by excludeUidList + if (in_array($theRec['uid'], $bannedUids)) { + continue; + } $hasSubPages = TRUE; break; } diff --git a/typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/AbstractMenuContentObjectTest.php b/typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/AbstractMenuContentObjectTest.php index 13cf7cd761d6..bbcc378c0a68 100644 --- a/typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/AbstractMenuContentObjectTest.php +++ b/typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/AbstractMenuContentObjectTest.php @@ -225,7 +225,68 @@ class AbstractMenuContentObjectTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTe $this->fixture->_call('sectionIndex', 'field', 12); } + //////////////////////////////////// + // Tests concerning menu item states + //////////////////////////////////// + /** + * @return array + */ + public function ifsubHasToCheckExcludeUidListDataProvider() { + return array( + 'none excluded' => array ( + array(12, 34, 56), + '1, 23, 456', + TRUE + ), + 'one excluded' => array ( + array(1, 234, 567), + '1, 23, 456', + TRUE + ), + 'three excluded' => array ( + array(1, 23, 456), + '1, 23, 456', + FALSE + ), + 'empty excludeList' => array ( + array(1, 123, 45), + '', + TRUE + ), + 'empty menu' => array ( + array(), + '1, 23, 456', + FALSE + ), + ); + + } + + /** + * @test + * @dataProvider ifsubHasToCheckExcludeUidListDataProvider + * @param array $menuItems + * @param string $excludeUidList + * @param boolean $expectedResult + */ + public function ifsubHasToCheckExcludeUidList($menuItems, $excludeUidList, $expectedResult) { + $menu = array(); + foreach ($menuItems as $page) { + $menu[] = array('uid' => $page); + } + + $this->prepareSectionIndexTest(); + $this->fixture->parent_cObj = $this->getMock('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer', array()); + + $this->fixture->sys_page->expects($this->once())->method('getMenu')->will($this->returnValue($menu)); + $this->fixture->menuArr = array( + 0 => array('uid' => 1) + ); + $this->fixture->conf['excludeUidList'] = $excludeUidList; + + $this->assertEquals($expectedResult, $this->fixture->isItemState('IFSUB', 0)); + } } -?> \ No newline at end of file +?> -- 2.20.1