Hide empty dynTabs in tceforms
authorBernhard Kraft <kraftb@think-open.at>
Tue, 18 Sep 2007 12:05:44 +0000 (12:05 +0000)
committerBernhard Kraft <kraftb@think-open.at>
Tue, 18 Sep 2007 12:05:44 +0000 (12:05 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2512 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_tceforms.php
typo3/template.php

index 91202e0..6509281 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-09-18     Bernhard Kraft  <kraftb@kraftb.at>
+
+       * Hide empty dynTabs in tceforms
+
 2007-09-18     Thomas Hempel   <thomas@typo3-unleashed.net>
 
        * Feature #5690: TCEforms: add inline editing of secondary options (thanks to Martin Ficzel)
index 137bf65..bd1e31a 100755 (executable)
@@ -640,26 +640,41 @@ class t3lib_TCEforms      {
                                // Create parts array for the tab menu:
                        $parts = array();
                        foreach ($out_array as $idx => $sheetContent)   {
-                               $parts[] = array(
-                                       'label' => $out_array_meta[$idx]['title'],
-                                       'content' => '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.
-                                                       implode('',$sheetContent).
-                                               '</table>'
-                               );
+                               $resstr = implode('', $sheetContent);
+                               if ($resstr) {
+                                       $parts[] = array(
+                                               'label' => $out_array_meta[$idx]['title'],
+                                               'content' => '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.
+                                                               $resstr.
+                                                       '</table>'
+                                       );
+                               }
                        }
 
-                               // Unset the current level of tab menus:
-                       $this->popFromDynNestedStack('tab', $tabIdentStringMD5.'-'.($out_sheet+1));
+                       if (count($parts) > 1) {
+                                       // Unset the current level of tab menus:
+                               $this->popFromDynNestedStack('tab', $tabIdentStringMD5.'-'.($out_sheet+1));
 
-                       return '
+                               $output = $this->getDynTabMenu($parts, $tabIdentString);
+
+                       } else {
+                                       // If there is only one tab/part there is no need to wrap it into the dynTab code
+                               $output = isset($parts[0]) ? trim($parts[0]['content']) : '';
+                       }
+
+                       $output = '
                                <tr>
                                        <td colspan="2">
-                                       '.$this->getDynTabMenu($parts, $tabIdentString).'
+                                       '.$output.'
                                        </td>
                                </tr>';
-               } else {        // Only one, so just implode:
-                       return implode('',$out_array[$out_sheet]);
+
+               } else {
+                               // Only one, so just implode:
+                       $output = implode('',$out_array[$out_sheet]);
                }
+
+               return $output;
        }
 
        /**
index 03dd9c3..68f835e 100755 (executable)
@@ -1704,33 +1704,34 @@ $str.=$this->docBodyTagBegin().
                                        $onclick = 'this.blur(); DTM_activate("'.$id.'","'.$index.'", '.($toggle<0?1:0).'); return false;';
                                }
 
-                               $isActive = strcmp($def['content'],'');
-
-                               $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>';
-                               }
+                               $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>';
+                                       }
 
-                               if ($isActive)  {
                                                // Create DIV layer for content:
                                        $divs[] = '
                                                        <div style="display: none;" id="'.$id.'-'.$index.'-DIV" class="c-tablayer">'.