[BUGFIX] Show first tab in Element Wizard as fallback 67/42767/5
authorChristian Seifert <christian-f-seifert@gmx.de>
Thu, 20 Aug 2015 22:59:29 +0000 (22:59 +0000)
committerWouter Wolters <typo3@wouterwolters.nl>
Fri, 21 Aug 2015 07:16:36 +0000 (09:16 +0200)
Using the extension gridelements it is possible to restrict the
selectable content elements instead of the full menu configured
by TSconfig. At first, you might have 5 menus available and you
click on the last menu tab (maybe the fifth), so the backend
stores 5 as current tab.
Adding content elements within a gridelement, which restricts the
range of selectable CEs, you can only select the first tab (p.e.).
The original code assumes that the fifth tab is still there and
tries to select it.

This patch checks first against the existence of the selected tab.
If there is no "fifth" tab p.e. the index is set to 1.

Resolves: #59810
Releases: master, 6.2
Change-Id: I829489737de4631dfe3362e4fb11909be9315864
Reviewed-on: http://review.typo3.org/42767
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Classes/Controller/PageLayoutController.php
typo3/sysext/backend/Resources/Public/JavaScript/tabmenu.js

index 584ce1f..f320729 100755 (executable)
@@ -549,12 +549,12 @@ class PageLayoutController {
                                }
                        ');
                        $this->doc->JScode .= $this->doc->wrapScriptTags('
-                               var DTM_array = new Array();
-                               var DTM_origClass = new String();
+                               var DTM_array = [];
+                               var DTM_origClass = [];
 
                                        // if tabs are used in a popup window the array might not exists
                                if(!top.DTM_currentTabs) {
-                                       top.DTM_currentTabs = new Array();
+                                       top.DTM_currentTabs = [];
                                }
 
                                function DTM_activate(idBase,index,doToogle) {  //
index a104ad6..12f71b7 100644 (file)
@@ -23,6 +23,12 @@ if (!top.DTM_currentTabs) {
 }
 
 function DTM_activate(idBase,index,doToogle) {
+               // Check, whether the given index really exists
+       if (!document.getElementById(idBase+'-'+index+'-MENU')) {
+               // force the index to be the first one in case of saved settings are not valid anymore
+               index = 1;
+       }
+
                // Hiding all:
        if (DTM_array[idBase]) {
                for(var cnt = 0; cnt < DTM_array[idBase].length; cnt++) {