[BUGFIX] excludeUidList not checked for ifsub state 14/18214/4
authorFrederik Vosberg <frederik.vosberg@webmeck.de>
Tue, 12 Feb 2013 06:28:16 +0000 (07:28 +0100)
committerJigal van Hemert <jigal@xs4all.nl>
Fri, 19 Apr 2013 11:37:09 +0000 (13:37 +0200)
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
typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php
typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/AbstractMenuContentObjectTest.php

index 93bbfa4..f2873e3 100644 (file)
@@ -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;
                }
index 13cf7cd..bbcc378 100644 (file)
@@ -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
+?>