Fixed bug #633: Menu doesn't expand if ".special" is set
authorBernhard Kraft <kraftb@think-open.at>
Tue, 13 Nov 2007 18:37:15 +0000 (18:37 +0000)
committerBernhard Kraft <kraftb@think-open.at>
Tue, 13 Nov 2007 18:37:15 +0000 (18:37 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2692 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_tstemplate.php
typo3/sysext/cms/tslib/class.tslib_menu.php

index c57ffae..b650e63 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-11-13  Bernhard Kraft  <kraftb@kraftb.at>
+
+       * Fixed bug #633: Menu doesn't expand if ".special" is set
+
 2007-11-13  Benjamin Mack  <mack@xnos.org>
 
        * (minor) Fixed bug #6548: FE "Preview" Label not stylable
index 4cd1af5..4a6f0d4 100755 (executable)
@@ -1295,6 +1295,22 @@ class t3lib_TStemplate   {
        }
 
 
+       /**
+        * Returns the level of the given page in the rootline - Multiple pages can be given by separating the UIDs by comma.
+        *
+        * @param       string          A list of UIDs for which the rootline-level should get returned
+        * @return      integer The level in the rootline. If more than one page was given the lowest level will get returned.
+        */
+       function getRootlineLevel($list)        {
+               $idx = 0;
+               foreach($this->rootLine as $page)       {
+                       if (t3lib_div::inList($list, $page['uid'])) {
+                               return $idx;
+                       }
+                       $idx++;
+               }
+               return false;
+       }
 
 
 
index c67566c..398b5d0 100755 (executable)
@@ -305,15 +305,26 @@ class tslib_menu {
                                }
                        }
 
+                       // Set $directoryLevel so the following evalution of the nextActive will not return
+                       // an invalid value if .special=directory was set
+                       $directoryLevel = 0;
+                       if ($this->conf['special'] == 'directory')      {
+                               $value = $GLOBALS['TSFE']->cObj->stdWrap($this->conf['special.']['value'], $this->conf['special.']['value.']);
+                               if ($value=='') {
+                                       $value=$GLOBALS['TSFE']->page['uid'];
+                               }
+                               $directoryLevel = intval($GLOBALS['TSFE']->tmpl->getRootlineLevel($value));
+                       }
+
                                // Setting "nextActive": This is the page uid + MPvar of the NEXT page in rootline. Used to expand the menu if we are in the right branch of the tree
-                               // Notice: The automatic expansion of a menu is designed to work only when no "special" modes are used.
-                       if (is_array($this->tmpl->rootLine[$this->entryLevel+$this->menuNumber]))       {
+                               // Notice: The automatic expansion of a menu is designed to work only when no "special" modes (except "directory") are used.
+                       $startLevel = $directoryLevel?$directoryLevel:$this->entryLevel;
+                       if (is_array($this->tmpl->rootLine[$startLevel+$this->menuNumber]))     {
                                $nextMParray = $this->MP_array;
-                               if ($this->tmpl->rootLine[$this->entryLevel+$this->menuNumber]['_MOUNT_OL'])    {       // In overlay mode, add next level MPvars as well:
-                                       $nextMParray[] = $this->tmpl->rootLine[$this->entryLevel+$this->menuNumber]['_MP_PARAM'];
+                               if ($this->tmpl->rootLine[$startLevel+$this->menuNumber]['_MOUNT_OL'])  {       // In overlay mode, add next level MPvars as well:
+                                       $nextMParray[] = $this->tmpl->rootLine[$startLevel+$this->menuNumber]['_MP_PARAM'];
                                }
-                               $this->nextActive = $this->tmpl->rootLine[$this->entryLevel+$this->menuNumber]['uid'].
-                                                                               (count($nextMParray)?':'.implode(',',$nextMParray):'');
+                               $this->nextActive = $this->tmpl->rootLine[$startLevel+$this->menuNumber]['uid'].(count($nextMParray)?':'.implode(',',$nextMParray):'');
                        } else {
                                $this->nextActive = '';
                        }
@@ -354,7 +365,7 @@ class tslib_menu {
                        $altSortFieldValue = trim($this->mconf['alternativeSortingField']);
                        $altSortField = $altSortFieldValue ? $altSortFieldValue : 'sorting';
                        if ($this->menuNumber==1 && $this->conf['special'])     {               // ... only for the FIRST level of a HMENU
-                               $value = $this->conf['special.']['value'];
+                               $value = $this->parent_cObj->stdWrap($this->conf['special.']['value'], $this->conf['special.']['value.']);
 
                                switch($this->conf['special'])  {
                                        case 'userdefined':