Fixed bug #6259: Disabling Tabs with no fields
authorDmitry Dulepov <dmitry.dulepov@gmail.com>
Tue, 20 Nov 2007 14:28:35 +0000 (14:28 +0000)
committerDmitry Dulepov <dmitry.dulepov@gmail.com>
Tue, 20 Nov 2007 14:28:35 +0000 (14:28 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2741 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_tceforms.php
typo3/sysext/t3skin/stylesheets/typo3-dyntabmenu.css
typo3/template.php

index 4e978ee..e9dcc5c 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2007-11-20  Dmitry Dulepov  <dmitry@typo3.org>
 
        * Restored typo3/sysext/lang/locallang_mod_doc.xml because it was zero length and broke translations
+       * Fixed bug #6259: Disabling Tabs with no fields
        * Fixed bug #6773: Allow br in flexform labels
 
 2007-11-20  Oliver Hader  <oh@inpublica.de>
index 6c8a2be..0ca4f0d 100755 (executable)
@@ -229,6 +229,7 @@ class t3lib_TCEforms        {
        var $localizationMode='';                       // If true, the forms are rendering only localization relevant fields of the records.
        var $fieldOrder='';                                     // Overrule the field order set in TCA[types][showitem], eg for tt_content this value, 'bodytext,image', would make first the 'bodytext' field, then the 'image' field (if set for display)... and then the rest in the old order.
        var $doPrintPalette=1;                          // If set to false, palettes will NEVER be rendered.
+       var $dividers2tabs=0;                           // Will be set to TCA[ctrl][dividers2tabs]
 
        /**
         * Set to initialized clipboard object; Then the element browser will offer a link to paste in records from clipboard.
@@ -493,6 +494,9 @@ class t3lib_TCEforms        {
                                // Load the full TCA for the table.
                        t3lib_div::loadTCA($table);
 
+                       // Loads the dividers2tabs from the $TCA
+                       $this->dividers2tabs = $TCA[$table]['ctrl']['dividers2tabs'];
+                       
                                // Load the description content for the table.
                        if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table))       {
                                $GLOBALS['LANG']->loadSingleTableDescription($table);
@@ -517,7 +521,7 @@ class t3lib_TCEforms        {
                                                // If TCEforms will render a tab menu in the next step, push the name to the tab stack:
                                        $tabIdentString = '';
                                        $tabIdentStringMD5 = '';
-                                       if (strstr($itemList, '--div--') !== false && $this->enableTabMenu && $TCA[$table]['ctrl']['dividers2tabs']) {
+                                       if (strstr($itemList, '--div--') !== false && $this->enableTabMenu && $this->dividers2tabs) {
                                                $tabIdentString = 'TCEforms:'.$table.':'.$row['uid'];
                                                $tabIdentStringMD5 = $GLOBALS['TBE_TEMPLATE']->getDynTabMenuId($tabIdentString);
                                                        // Remember that were currently working on the general tab:
@@ -565,7 +569,7 @@ class t3lib_TCEforms        {
                                                                if ($cc>0)      {
                                                                        $out_array[$out_sheet][$out_pointer].=$this->getDivider();
 
-                                                                       if ($this->enableTabMenu && $TCA[$table]['ctrl']['dividers2tabs'])      {
+                                                                       if ($this->enableTabMenu && $this->dividers2tabs)       {
                                                                                $this->wrapBorder($out_array[$out_sheet],$out_pointer);
                                                                                        // Remove last tab entry from the dynNestedStack:
                                                                                $out_sheet++;
@@ -644,16 +648,16 @@ class t3lib_TCEforms      {
                                // Create parts array for the tab menu:
                        $parts = array();
                        foreach ($out_array as $idx => $sheetContent)   {
-                               $resstr = implode('', $sheetContent);
-                               if ($resstr) {
-                                       $parts[$idx] = array(
-                                               'label' => $out_array_meta[$idx]['title'],
-                                               'content' => '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.
-                                                               $resstr.
-                                                       '</table>',
-                                               'newline' => $out_array_meta[$idx]['newline'],  // Newline for this tab/sheet
-                                       );
-                               }
+                               $content = implode('', $sheetContent);
+                               if ($content) {
+                                       // Wrap content (row) with table-tag, otherwise tab/sheet will be disabled (see getdynTabMenu() )
+                                       $content = '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.$content.'</table>';
+                               }
+                               $parts[$idx] = array(
+                                       'label' => $out_array_meta[$idx]['title'],
+                                       'content' => $content,
+                                       'newline' => $out_array_meta[$idx]['newline'],  // Newline for this tab/sheet
+                               );
                        }
 
                        if (count($parts) > 1) {
@@ -3943,7 +3947,7 @@ class t3lib_TCEforms      {
         */
        function getDynTabMenu($parts, $idString) {
                if (is_object($GLOBALS['TBE_TEMPLATE']))        {
-                       return $GLOBALS['TBE_TEMPLATE']->getDynTabMenu($parts, $idString);
+                       return $GLOBALS['TBE_TEMPLATE']->getDynTabMenu($parts, $idString, 0, FALSE, 50, 1, FALSE, 1, $this->dividers2tabs);
                } else {
                        $output = '';
                        foreach($parts as $singlePad)   {
index 499ab7c..ab521fb 100644 (file)
@@ -19,7 +19,8 @@ DIV.typo3-dyntabmenu-divs P.c-descr {
 
 table.typo3-dyntabmenu td {
        color: #E6E1B2;
-       border:0;
+       border: solid 1px #A2AAB8;
+       border-bottom: 0;
        padding: 0;
        cursor: pointer;
        }
@@ -33,14 +34,13 @@ table.typo3-dyntabmenu td.tab {
                }
 
        table.typo3-dyntabmenu td.disabled,
-       table.typo3-dyntabmenu td.disabled:hover {
+       table.typo3-dyntabmenu td.disabled_over {
+               padding: 5px 10px 5px 10px;
                color: #A2AAB8;
                background-color: #EFEFF4;
                }
 
 table.typo3-dyntabmenu td a {
-       border: solid 1px #A2AAB8;
-       border-bottom: 0;
        padding: 5px 10px 5px 10px;
        display: block;
        width: auto;
index cdfcc2b..e274c4c 100755 (executable)
@@ -1392,9 +1392,10 @@ $str.=$this->docBodyTagBegin().
         * @param       boolean         If set, tab table cells are not allowed to wrap their content
         * @param       boolean         If set, the tabs will span the full width of their position
         * @param       integer         Default tab to open (for toggle <=0). Value corresponds to integer-array index + 1 (index zero is "1", index "1" is 2 etc.). A value of zero (or something non-existing) will result in no default tab open.
+        * @param       boolean         If set to '1' empty tabs will be remove, If set to '2' empty tabs will be disabled 
         * @return      string          JavaScript section for the HTML header.
         */
-       function getDynTabMenu($menuItems,$identString,$toggle=0,$foldout=FALSE,$newRowCharLimit=50,$noWrap=1,$fullWidth=FALSE,$defaultTabIndex=1     {
+       function getDynTabMenu($menuItems,$identString,$toggle=0,$foldout=FALSE,$newRowCharLimit=50,$noWrap=1,$fullWidth=FALSE,$defaultTabIndex=1,$dividers2tabs=1)     {
                $content = '';
 
                if (is_array($menuItems))       {
@@ -1414,7 +1415,7 @@ $str.=$this->docBodyTagBegin().
                                $index+=1;      // Need to add one so checking for first index in JavaScript is different than if it is not set at all.
 
                                        // Switch to next tab row if needed
-                               if (!$foldout && ($titleLenCount>$newRowCharLimit | ($def['newline'] === true && $titleLenCount > 0))) { // 50 characters is probably a reasonable count of characters before switching to next row of tabs.
+                               if (!$foldout && ($titleLenCount>$newRowCharLimit | ($def['newline'] === true && $titleLenCount > 0))) {
                                        $titleLenCount=0;
                                        $tabRows++;
                                        $options[$tabRows] = array();
@@ -1426,52 +1427,54 @@ $str.=$this->docBodyTagBegin().
                                        $onclick = 'this.blur(); DTM_activate("'.$id.'","'.$index.'", '.($toggle<0?1:0).'); return false;';
                                }
 
-                               $isActive = strcmp(trim($def['content']),'');
-
-                               if ($isActive) {
-
-                                       $mouseOverOut = ' onmouseover="DTM_mouseOver(this);" onmouseout="DTM_mouseOut(this);"';
-
-                                       if (!$foldout)  {
-                                                       // Create TAB cell:
-                                               $options[$tabRows][] = '
-                                                               <td class="'.($isActive ? 'tab' : 'disabled').'" id="'.$id.'-'.$index.'-MENU"'.$noWrap.$mouseOverOut.'>'.
-                                                               ($isActive ? '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ? ' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>' : '').
-                                                               $def['icon'].
-                                                               ($def['label'] ? htmlspecialchars($def['label']) : '&nbsp;').
-                                                               $this->icons($def['stateIcon'],'margin-left: 10px;').
-                                                               ($isActive ? '</a>' :'').
-                                                               '</td>';
-                                               $titleLenCount+= strlen($def['label']);
-                                       } else {
-                                                       // Create DIV layer for content:
-                                               $divs[] = '
-                                                       <div class="'.($isActive ? 'tab' : 'disabled').'" id="'.$id.'-'.$index.'-MENU"'.$mouseOverOut.'>'.
-                                                               ($isActive ? '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ? ' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>' : '').
-                                                               $def['icon'].
-                                                               ($def['label'] ? htmlspecialchars($def['label']) : '&nbsp;').
-                                                               ($isActive ? '</a>' : '').
-                                                               '</div>';
-                                       }
+                               $isNotEmpty = strcmp(trim($def['content']),'');
+
+                               // "Removes" empty tabs
+                               if (!$isNotEmpty && $dividers2tabs == 1) {
+                                       continue;
+                               }
+
+                               $mouseOverOut = ' onmouseover="DTM_mouseOver(this);" onmouseout="DTM_mouseOut(this);"';
 
+                               if (!$foldout)  {
+                                               // Create TAB cell:
+                                       $options[$tabRows][] = '
+                                                       <td class="'.($isNotEmpty ? 'tab' : 'disabled').'" id="'.$id.'-'.$index.'-MENU"'.$noWrap.$mouseOverOut.'>'.
+                                                       ($isNotEmpty ? '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ? ' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>' : '').
+                                                       $def['icon'].
+                                                       ($def['label'] ? htmlspecialchars($def['label']) : '&nbsp;').
+                                                       $this->icons($def['stateIcon'],'margin-left: 10px;').
+                                                       ($isNotEmpty ? '</a>' :'').
+                                                       '</td>';
+                                       $titleLenCount+= strlen($def['label']);
+                               } else {
                                                // Create DIV layer for content:
                                        $divs[] = '
-                                                       <div style="display: none;" id="'.$id.'-'.$index.'-DIV" class="c-tablayer">'.
-                                                               ($def['description'] ? '<p class="c-descr">'.nl2br(htmlspecialchars($def['description'])).'</p>' : '').
-                                                               $def['content'].
-                                                               '</div>';
-                                               // Create initialization string:
+                                               <div class="'.($isNotEmpty ? 'tab' : 'disabled').'" id="'.$id.'-'.$index.'-MENU"'.$mouseOverOut.'>'.
+                                                       ($isNotEmpty ? '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ? ' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>' : '').
+                                                       $def['icon'].
+                                                       ($def['label'] ? htmlspecialchars($def['label']) : '&nbsp;').
+                                                       ($isNotEmpty ? '</a>' : '').
+                                                       '</div>';
+                               }
+
+                                       // Create DIV layer for content:
+                               $divs[] = '
+                                               <div style="display: none;" id="'.$id.'-'.$index.'-DIV" class="c-tablayer">'.
+                                                       ($def['description'] ? '<p class="c-descr">'.nl2br(htmlspecialchars($def['description'])).'</p>' : '').
+                                                       $def['content'].
+                                                       '</div>';
+                                       // Create initialization string:
+                               $JSinit[] = '
+                                               DTM_array["'.$id.'"]['.$c.'] = "'.$id.'-'.$index.'";
+                               ';
+                               if ($toggle==1) {
                                        $JSinit[] = '
-                                                       DTM_array["'.$id.'"]['.$c.'] = "'.$id.'-'.$index.'";
+                                               if (top.DTM_currentTabs["'.$id.'-'.$index.'"]) { DTM_toggle("'.$id.'","'.$index.'",1); }
                                        ';
-                                       if ($toggle==1) {
-                                               $JSinit[] = '
-                                                       if (top.DTM_currentTabs["'.$id.'-'.$index.'"]) { DTM_toggle("'.$id.'","'.$index.'",1); }
-                                               ';
-                                       }
-
-                                       $c++;
                                }
+
+                               $c++;
                        }
 
                                // Render menu:
@@ -1549,7 +1552,10 @@ $str.=$this->docBodyTagBegin().
                                                for(cnt = 0; cnt < DTM_array[idBase].length ; cnt++)    {
                                                        if (DTM_array[idBase][cnt] != idBase+"-"+index) {
                                                                document.getElementById(DTM_array[idBase][cnt]+"-DIV").style.display = "none";
-                                                               document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
+                                                               // Only Overriding when Tab not disabled
+                                                               if (document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").nodeValue != "disabled") {
+                                                                       document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
+                                                               }
                                                        }
                                                }
                                        }