[BUGFIX] *IFSUB ignores l18n_cfg field
authorStefan Galinski <stefan.galinski@gmail.com>
Fri, 23 Sep 2011 18:55:00 +0000 (20:55 +0200)
committerStefan Galinski <stefan.galinski@gmail.com>
Thu, 9 Feb 2012 20:32:20 +0000 (21:32 +0100)
The l18n_cfg field is used to prevent the appearance of the default
language record or any alternative language records that haven't a translation
in the menu. At the first glance it seems to work like expected, because the
expected page records are not visible in a configured frontend menu. If we have a
closer look at this part, we will see that the flag is badly ignored for the
"*IFSUB" record states. This causes that a page record which has no visible
subpages is marked with the hasSubmenu flag.

Change-Id: Ia988dfeb272b6c64c86c45f9d80b8b9299a09bfc
Resolves: #19925
Releases: 4.7, 4.6, 4.5, 4.4
Reviewed-on: http://review.typo3.org/5573
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Tolleiv Nietsch
Tested-by: Tolleiv Nietsch
Reviewed-by: Stefan Galinski
Tested-by: Stefan Galinski
t3lib/class.t3lib_div.php
typo3/sysext/cms/tslib/class.tslib_menu.php

index dc15efc..1a9ca62 100644 (file)
@@ -4145,6 +4145,17 @@ final class t3lib_div {
        }
 
        /**
+        * Returns true if the "l18n_cfg" field value is not set to hide
+        * pages in the default language
+        *
+        * @param int $localizationConfiguration
+        * @return boolean
+        */
+       public static function hideIfDefaultLanguage($localizationConfiguration) {
+               return ($localizationConfiguration & 1);
+       }
+
+       /**
         * Includes a locallang file and returns the $LOCAL_LANG array found inside.
         *
         * @param string $fileRef Input is a file-reference (see t3lib_div::getFileAbsFileName). That file is expected to be a 'locallang.php' file containing a $LOCAL_LANG array (will be included!) or a 'locallang.xml' file conataining a valid XML TYPO3 language structure.
index 0c22ee5..5dbe704 100644 (file)
@@ -1389,24 +1389,54 @@ class tslib_menu {
         * Returns TRUE if there is a submenu with items for the page id, $uid
         * Used by the item states "IFSUB", "ACTIFSUB" and "CURIFSUB" to check if there is a submenu
         *
-        * @param       integer         Page uid for which to search for a submenu
-        * @return      boolean         Returns TRUE if there was a submenu with items found
+        * @param int $uid Page uid for which to search for a submenu
+        * @return boolean Returns TRUE if there was a submenu with items found
         * @access private
         */
-       function isSubMenu($uid)        {
-
-                       // Looking for a mount-pid for this UID since if that exists we should look for a subpages THERE and not in the input $uid;
+       function isSubMenu($uid) {
+                       // Looking for a mount-pid for this UID since if that
+                       // exists we should look for a subpages THERE and not in the input $uid;
                $mount_info = $this->sys_page->getMountPointInfo($uid);
-               if (is_array($mount_info))      {
+               if (is_array($mount_info)) {
                        $uid = $mount_info['mount_pid'];
                }
 
-               $recs = $this->sys_page->getMenu($uid,'uid,pid,doktype,mount_pid,mount_pid_ol,nav_hide,shortcut,shortcut_mode');
-               foreach($recs as $theRec)       {
-                       if (!t3lib_div::inList($this->doktypeExcludeList,$theRec['doktype']) && (!$theRec['nav_hide'] || $this->conf['includeNotInMenu']))      {       // If a menu item seems to be another type than 'Not in menu', then return TRUE (there were items!)
-                               return TRUE;
+               $recs = $this->sys_page->getMenu(
+                       $uid,
+                       'uid,pid,doktype,mount_pid,mount_pid_ol,nav_hide,shortcut,shortcut_mode,l18n_cfg'
+               );
+
+               $hasSubPages = FALSE;
+               foreach ($recs as $theRec) {
+                               // no valid subpage if the document type is excluded from the menu
+                       if (t3lib_div::inList($this->doktypeExcludeList, $theRec['doktype'])) {
+                               continue;
                        }
+
+                               // no valid subpage if the page is hidden inside menus and
+                               // it wasn't forced to show such entries
+                       if ($theRec['nav_hide'] && !$this->conf['includeNotInMenu']) {
+                               continue;
+                       }
+
+                               // no valid subpage if the default language should be shown and the page settings
+                               // are excluding the visibility of the default language
+                       if (!$GLOBALS['TSFE']->sys_language_uid && t3lib_div::hideIfDefaultLanguage($theRec['l18n_cfg'])) {
+                               continue;
+                       }
+
+                               // no valid subpage if the alternative language should be shown and the page settings
+                               // are requiring a valid overlay but it doesn't exists
+                       $hideIfNotTranslated = t3lib_div::hideIfNotTranslated($theRec['l18n_cfg']);
+                       if ($GLOBALS['TSFE']->sys_language_uid && $hideIfNotTranslated && !$theRec['_PAGES_OVERLAY']) {
+                               continue;
+                       }
+
+                       $hasSubPages = TRUE;
+                       break;
                }
+
+               return $hasSubPages;
        }
 
        /**