Feature #5690: TCEforms: add inline editing of secondary options (thanks to Martin...
authorThomas Hempel <thomas.hempel@typo3.org>
Tue, 18 Sep 2007 08:09:34 +0000 (08:09 +0000)
committerThomas Hempel <thomas.hempel@typo3.org>
Tue, 18 Sep 2007 08:09:34 +0000 (08:09 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2511 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_tceforms.php
typo3/jsfunc.tbe_editor.js

index ecefb19..91202e0 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-09-18     Thomas Hempel   <thomas@typo3-unleashed.net>
+
+       * Feature #5690: TCEforms: add inline editing of secondary options (thanks to Martin Ficzel)
+
 2007-09-13  Ingo Renner  <ingo@typo3.org>
 
        * Fixed bug 5701: linkHandler Hook Not Initialized Properly, patch supplied by Jeff Segars
index 0e207fb..137bf65 100755 (executable)
@@ -739,10 +739,6 @@ class t3lib_TCEforms       {
 
                                        if (!in_array($theField,$this->excludeElements) && $TCA[$table]['columns'][$theField])  {
                                                $this->palFieldArr[$palette][] = $theField;
-                                               if ($this->isPalettesCollapsed($table,$palette))        {
-                                                       $this->hiddenFieldListArr[] = $theField;
-                                               }
-
                                                $part = $this->getSingleField($table,$theField,$row,$parts[1],1,'',$parts[2]);
                                                if (is_array($part))    {
                                                        $palParts[] = $part;
@@ -751,6 +747,7 @@ class t3lib_TCEforms        {
                                }
                        }
                }
+               
                        // Put palette together if there are fields in it:
                if (count($palParts))   {
                        if ($header)    {
@@ -760,21 +757,13 @@ class t3lib_TCEforms      {
                                                        $this->palFieldTemplateHeader
                                                );
                        }
+                       $collapsed = $this->isPalettesCollapsed($table,$palette);
                        $out.= $this->intoTemplate(array(
-                                                       'PALETTE' => $this->printPalette($palParts)
+                                                       'PALETTE' => $this->wrapPaletteField($this->printPalette($palParts), $table, $row ,$palette, $collapsed)
                                                ),
                                                $this->palFieldTemplate
                                        );
                }
-                       // If a palette is collapsed (not shown in form, but in top frame instead) AND a collapse header string is given, then make that string a link to activate the palette.
-               if ($this->isPalettesCollapsed($table,$palette) && $collapsedHeader)    {
-                       $pC = $this->intoTemplate(array(
-                                                       'PALETTE' => $this->wrapOpenPalette('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/options.gif','width="18" height="16"').' border="0" title="'.htmlspecialchars($this->getLL('l_moreOptions')).'" align="top" alt="" /><strong>'.$collapsedHeader.'</strong>',$table,$row,$palette),
-                                               ),
-                                               $this->palFieldTemplate
-                                       );
-                       $out.= $pC;
-               }
 
                return $out;
        }
@@ -3611,23 +3600,28 @@ class t3lib_TCEforms    {
         *
         * @param       string          The string to wrap in an A-tag
         * @param       string          The table name for which to open the palette.
-        * @param       array           The record array
-        * @param       integer         The palette pointer.
-        * @param       boolean         Determines the output type of the function.
-        * @return      mixed           If $retFunc is set, then returns an array with icon code and palette JavaScript function. Otherwise just the icon code.
+        * @param       array           The palette pointer.
+        * @param       integer         The record array
         */
-       function wrapOpenPalette($header,$table,$row,$palette,$retFunc=0)       {
-               $fieldL=array();
-               if (!is_array($this->palFieldArr[$palette]))    {$this->palFieldArr[$palette]=array();}
-               $palFieldN = is_array($this->palFieldArr[$palette]) ? count($this->palFieldArr[$palette]) : 0;
-               $palJSFunc = 'TBE_EDITOR.palUrl(\''.($table.':'.$row['uid'].':'.$palette).'\',\''.implode(',',$this->palFieldArr[$palette]).'\','.$palFieldN.',\''.$table.'\',\''.$row['uid'].'\',1);';
-
-               $aOnClick = $this->blur().substr($palJSFunc,0,-3).'0);return false;';
+       function wrapOpenPalette ( $header, $table,$row , $palette ,$retFunc){
+               $id  = 'TCEFORMS_'.$table.'_'.$palette.'_'.$row['uid'];
+               $res = '<a href="#" onclick="TBE_EDITOR.toggle_display_states(\''.$id.'\',\'block\',\'none\'); return false;" >'.$header.'</a>';
+               return array($res,'');
+       }
 
-               $iconCode = '<a href="#" onclick="'.htmlspecialchars($aOnClick).'" title="'.htmlspecialchars($table).'">'.
-                                       $header.
-                                       '</a>';
-               return $retFunc ? array($iconCode,$palJSFunc) : $iconCode;
+       /**
+        * add the id and the style property to the field palette
+        * @param       string          Palette Code
+        * @param       string          The table name for which to open the palette.
+        * @param       string          Palette ID
+        * @param       string          The record array
+        * @return      boolean         is collapsed 
+        */
+       function wrapPaletteField ( $code, $table, $row, $palette, $collapsed ){
+               $display = $collapsed ? 'none' : 'block';
+               $id = 'TCEFORMS_'.$table.'_'.$palette.'_'.$row['uid'];
+               $code = '<div id="'.$id.'" style="display:'.$display.';" >'.$code.'</div>'; 
+               return $code;
        }
 
        /**
@@ -4264,12 +4258,12 @@ class t3lib_TCEforms    {
                $this->totalWrap='
                <table border="0" cellspacing="0" cellpadding="0" width="'.($this->docLarge ? 440+150 : 440).'" class="typo3-TCEforms">'.
                        '<tr class="bgColor2">
-                               <td>&nbsp;</td>
+                               <td><!-- --></td>
                                <td>###RECORD_ICON### <span class="typo3-TCEforms-recHeader">###TABLE_TITLE###</span> ###ID_NEW_INDICATOR### - ###RECORD_LABEL###</td>
                        </tr>'.
                        '|'.
                        '<tr>
-                               <td>&nbsp;</td>
+                               <td><!-- --></td>
                                <td><img src="clear.gif" width="'.($this->docLarge ? 440+150 : 440).'" height="1" alt="" /></td>
                        </tr>
                </table>';
@@ -4287,12 +4281,12 @@ class t3lib_TCEforms    {
 
                $this->palFieldTemplate='
                        <tr ###BGCOLOR######CLASSATTR_1###>
-                               <td>&nbsp;</td>
+                               <td></td> 
                                <td nowrap="nowrap" valign="top">###FIELD_PALETTE###</td>
                        </tr>';
                $this->palFieldTemplateHeader='
                        <tr ###BGCOLOR_HEAD######CLASSATTR_2###>
-                               <td>&nbsp;</td>
+                               <td><!-- --></td>
                                <td nowrap="nowrap" valign="top"><strong>###FIELD_HEADER###</strong></td>
                        </tr>';
 
index 0e27ede..5480154 100755 (executable)
@@ -379,7 +379,21 @@ var TBE_EDITOR = {
                }
                output+=''+input.substr(pointer);
                return output;
-       }
+       },
+       toggle_display_states: function(id, state_1, state_2) {
+               var node = document.getElementById(id);
+               if (node) {     
+                       switch (node.style.display) {
+                               case state_1:
+                                       node.style.display = state_2;
+                                       break;
+                               case state_2:
+                                       node.style.display = state_1; 
+                                       break;
+                       }
+               }
+               return false;
+       }       
 };
 
 function typoSetup     () {