added @var phpDoc comments to various variables
[Packages/TYPO3.CMS.git] / typo3 / wizard_forms.php
index dd3c8d7..9e39b73 100755 (executable)
@@ -1,22 +1,22 @@
 <?php
 /***************************************************************
 *  Copyright notice
-*  
-*  (c) 1999-2003 Kasper Skaarhoj (kasper@typo3.com)
+*
+*  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
-*  This script is part of the TYPO3 project. The TYPO3 project is 
+*  This script is part of the TYPO3 project. The TYPO3 project is
 *  free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
-* 
+*
 *  The GNU General Public License can be found at
 *  http://www.gnu.org/copyleft/gpl.html.
-*  A copy is found in the textfile GPL.txt and important notices to the license 
+*  A copy is found in the textfile GPL.txt and important notices to the license
 *  from the author is found in LICENSE.txt distributed with these scripts.
 *
-* 
+*
 *  This script is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *
 *  This copyright notice MUST APPEAR in all copies of the script!
 ***************************************************************/
-/** 
- * Wizard to help make forms (fx. for tt_content elements) of type 'form'. 
- * 
+/**
+ * Wizard to help make forms (fx. for tt_content elements) of type 'form'.
+ *
  * $Id$
  * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
  * XHTML compliant
- * 
- * @author     Kasper Skaarhoj <kasper@typo3.com>
+ *
+ * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
  */
 /**
  * [CLASS/FUNCTION INDEX of SCRIPT]
  *
  *
  *
- *  175: class SC_wizard_forms 
- *  202:     function init()   
- *  238:     function main()   
- *  254:     function printContent()   
- *  263:     function formsWizard()    
+ *  175: class SC_wizard_forms
+ *  203:     function init()
+ *  242:     function main()
+ *  257:     function printContent()
+ *  268:     function formsWizard()
  *
  *              SECTION: Helper functions
- *  306:     function getConfigCode(&$row)     
- *  378:     function getFormHTML($formCfgArray,$row)  
- *  631:     function changeFunc()     
- *  690:     function cfgArray2CfgString($cfgArr)      
- *  765:     function cfgString2CfgArray($cfgStr)      
- *  854:     function cleanT($tArr)    
- *  872:     function formatCells($fArr)       
+ *  311:     function getConfigCode(&$row)
+ *  382:     function getFormHTML($formCfgArray,$row)
+ *  662:     function changeFunc()
+ *  721:     function cfgArray2CfgString($cfgArr)
+ *  803:     function cfgString2CfgArray($cfgStr)
+ *  902:     function cleanT($tArr)
+ *  920:     function formatCells($fArr)
  *
  * TOTAL FUNCTIONS: 11
  * (This index is automatically created/updated by the extension "extdeveval")
  *
  */
 
+
 
 $BACK_PATH='';
 require ('init.php');
 require ('template.php');
-include ('sysext/lang/locallang_wizards.php');
+$LANG->includeLLFile('EXT:lang/locallang_wizards.xml');
 
 
 
@@ -78,24 +78,24 @@ include ('sysext/lang/locallang_wizards.php');
 
 /**
  * API comments:
- *  
+ *
  * The form wizard can help you to create forms - it allows you to create almost any kind of HTML form elements and in any order and amount.
- * 
+ *
  * The format for the resulting configuration code can be either a line-based configuration. That can look like this:
- * 
+ *
  * Your name: | *name=input | (input your name here!)
  * Your Email: | *email=input
  * Your address: | address=textarea,40,10
- * Your Haircolor: | hair=radio | 
+ * Your Haircolor: | hair=radio |
  * upload | attachment=file
  *  | quoted_printable=hidden | 0
  *  | formtype_mail=submit | Send form
  *  | html_enabled=hidden
  *  | subject=hidden | This is the subject
- * 
- *  
+ *
+ *
  * Alternatively it can be XML. The same configuration from above looks like this in XML:
- * 
+ *
  * <T3FormWizard>
  *     <n2>
  *             <type>input</type>
@@ -159,25 +159,31 @@ include ('sysext/lang/locallang_wizards.php');
  *             <content></content>
  *     </n20>
  * </T3FormWizard>
- * 
- * 
+ *
+ *
  * The XML/phpArray structure is the internal format of the wizard.
  */
-  
+
 
 /**
  * Script Class for rendering the Form Wizard
- * 
- * @author     Kasper Skaarhoj <kasper@typo3.com>
+ *
+ * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage core
  */
 class SC_wizard_forms {
-       
+
                // Internal, dynamic:
-       var $doc;                                       // Document template object
+       /**
+        * document template object
+        *
+        * @var mediumDoc
+        */
+       var $doc;
        var $content;                           // Content accumulation for the module.
        var $include_once=array();      // List of files to include.
+       var $attachmentCounter = 0;     // Used to numerate attachments automatically.
 
 
                // Internal, static:
@@ -196,16 +202,19 @@ class SC_wizard_forms {
 
        /**
         * Initialization the class
-        * 
-        * @return      void            
+        *
+        * @return      void
         */
        function init() {
-               global $BACK_PATH,$HTTP_POST_VARS;
+               global $BACK_PATH;
 
                        // GPvars:
-               $this->P = t3lib_div::GPvar('P',1);
-               $this->special = t3lib_div::GPvar('special');
-               $this->FORMCFG = t3lib_div::GPvar('FORMCFG',1);
+               $this->P = t3lib_div::_GP('P');
+               $this->special = t3lib_div::_GP('special');
+               $this->FORMCFG = t3lib_div::_GP('FORMCFG');
+
+                       // Setting options:
+               $this->xmlStorage = $this->P['params']['xmlOutput'];
 
                        // Document template object:
                $this->doc = t3lib_div::makeInstance('mediumDoc');
@@ -213,27 +222,27 @@ class SC_wizard_forms {
                $this->doc->backPath = $BACK_PATH;
                $this->doc->JScode=$this->doc->wrapScriptTags('
                        function jumpToUrl(URL,formEl)  {       //
-                               document.location = URL;
+                               window.location.href = URL;
                        }
                ');
-               
+
                        // Setting form tag:
                list($rUri) = explode('#',t3lib_div::getIndpEnv('REQUEST_URI'));
                $this->doc->form ='<form action="'.htmlspecialchars($rUri).'" method="post" name="wizardForm">';
-               
+
                        // Start page:
                $this->content=$this->doc->startPage('Form Wizard');
 
                        // If save command found, include tcemain:
-               if ($HTTP_POST_VARS['savedok_x'] || $HTTP_POST_VARS['saveandclosedok_x'])       {
+               if ($_POST['savedok_x'] || $_POST['saveandclosedok_x']) {
                        $this->include_once[]=PATH_t3lib.'class.t3lib_tcemain.php';
                }
        }
 
        /**
         * Main function for rendering the form wizard HTML
-        * 
-        * @return      void            
+        *
+        * @return      void
         */
        function main() {
                global $LANG;
@@ -243,27 +252,28 @@ class SC_wizard_forms {
                } else {
                        $this->content.=$this->doc->section($LANG->getLL('forms_title'),'<span class="typo3-red">'.$LANG->getLL('table_noData',1).'</span>',0,1);
                }
-               $this->content.=$this->doc->endPage();
        }
 
        /**
         * Outputting the accumulated content to screen
-        * 
-        * @return      void            
+        *
+        * @return      void
         */
        function printContent() {
+               $this->content.= $this->doc->endPage();
+               $this->content = $this->doc->insertStylesAndJS($this->content);
                echo $this->content;
        }
-       
+
        /**
         * Draws the form wizard content
-        * 
+        *
         * @return      string          HTML content for the form.
         */
        function formsWizard()  {
-               
+
                        // First, check the references by selecting the record:
-               $row=t3lib_BEfunc::getRecord($this->P['table'],$this->P['uid']);
+               $row = t3lib_BEfunc::getRecord($this->P['table'],$this->P['uid']);
                if (!is_array($row))    {
                        t3lib_BEfunc::typo3PrintError ('Wizard Error','No reference to record',0);
                        exit;
@@ -272,14 +282,14 @@ class SC_wizard_forms {
                        // This will get the content of the form configuration code field to us - possibly cleaned up, saved to database etc. if the form has been submitted in the meantime.
                $formCfgArray = $this->getConfigCode($row);
 
-                       // Generation of the Form Wizards HTML code:            
+                       // Generation of the Form Wizards HTML code:
                $content = $this->getFormHTML($formCfgArray,$row);
-               
+
                        // Return content:
                return $content;
        }
 
-       
+
 
 
 
@@ -298,24 +308,23 @@ class SC_wizard_forms {
        /**
         * Will get and return the configuration code string
         * Will also save (and possibly redirect/exit) the content if a save button has been pressed
-        * 
+        *
         * @param       array           Current parent record row (passed by value!)
         * @return      array           Configuration Array
         * @access private
         */
        function getConfigCode(&$row)   {
-               global $HTTP_POST_VARS;
-               
-                       // If some data has been submitted, then construct 
+
+                       // If some data has been submitted, then construct
                if (isset($this->FORMCFG['c'])) {
-                       
+
                                // Process incoming:
                        $this->changeFunc();
-                       
+
                                // Convert to string (either line based or XML):
                        if ($this->xmlStorage)  {
                                        // Convert the input array to XML:
-                               $bodyText = t3lib_div::array2xml($this->FORMCFG['c'],'',0,'T3FormWizard');
+                               $bodyText = t3lib_div::array2xml_cs($this->FORMCFG['c'],'T3FormWizard');
 
                                        // Setting cfgArr directly from the input:
                                $cfgArr = $this->FORMCFG['c'];
@@ -326,30 +335,30 @@ class SC_wizard_forms {
                                        // Create cfgArr from the string based configuration - that way it is cleaned up and any incompatibilities will be removed!
                                $cfgArr = $this->cfgString2CfgArray($bodyText);
                        }
-                                       
+
                                // If a save button has been pressed, then save the new field content:
-                       if ($HTTP_POST_VARS['savedok_x'] || $HTTP_POST_VARS['saveandclosedok_x'])       {
-                       
+                       if ($_POST['savedok_x'] || $_POST['saveandclosedok_x']) {
+
                                        // Make TCEmain object:
                                $tce = t3lib_div::makeInstance('t3lib_TCEmain');
                                $tce->stripslashes_values=0;
-                               
+
                                        // Put content into the data array:
                                $data=array();
                                $data[$this->P['table']][$this->P['uid']][$this->P['field']]=$bodyText;
                                if ($this->special=='formtype_mail')    {
                                        $data[$this->P['table']][$this->P['uid']]['subheader']=$this->FORMCFG['recipient'];
                                }
-       
+
                                        // Perform the update:
                                $tce->start($data,array());
                                $tce->process_datamap();
-       
+
                                        // Re-load the record content:
                                $row = t3lib_BEfunc::getRecord($this->P['table'],$this->P['uid']);
-                               
+
                                        // If the save/close button was pressed, then redirect the screen:
-                               if ($HTTP_POST_VARS['saveandclosedok_x'])       {
+                               if ($_POST['saveandclosedok_x'])        {
                                        header('Location: '.t3lib_div::locationHeaderUrl($this->P['returnUrl']));
                                        exit;
                                }
@@ -362,14 +371,14 @@ class SC_wizard_forms {
                        }
                        $cfgArr = is_array($cfgArr) ? $cfgArr : array();
                }
-               
+
                        // Return configuration code:
                return $cfgArr;
        }
-       
+
        /**
         * Creates the HTML for the Form Wizard:
-        * 
+        *
         * @param       string          Form config array
         * @param       array           Current parent record array
         * @return      string          HTML for the form wizard
@@ -377,12 +386,12 @@ class SC_wizard_forms {
         */
        function getFormHTML($formCfgArray,$row)        {
                global $LANG;
-       
+
                        // Initialize variables:
                $specParts=array();
                $hiddenFields=array();
                $tRows=array();
-               
+
                        // Set header row:
                $cells=array($LANG->getLL('forms_preview',1).':',
                                                $LANG->getLL('forms_element',1).':',
@@ -394,33 +403,33 @@ class SC_wizard_forms {
                                <td>'.implode('</td>
                                <td>',$cells).'</td>
                        </tr>';
-       
+
                        // Traverse the number of form elements:
                $k=0;
                foreach($formCfgArray as $confData)     {
-               
+
                                // Initialize:
                        $cells=array();
-       
+
                                // If there is a configuration line which is active, then render it:
                        if (!isset($confData['comment'])) {
-                               
+
                                        // Special parts:
                                if ($this->special=='formtype_mail' && t3lib_div::inList('formtype_mail,subject,html_enabled',$confData['fieldname']))  {
-                                       $specParts[$confData['fieldname']]=$confData['default'];
+                                       $specParts[$confData['fieldname']] = $confData['default'];
                                } else {
 
                                                // Render title/field preview COLUMN
                                        $cells[]=$confData['type']!='hidden' ? '<strong>'.htmlspecialchars($confData['label']).'</strong>' : '';
-                                       
+
 
                                                // Render general type/title COLUMN:
                                        $temp_cells=array();
-                                       
+
                                                // Field type selector:
                                        $opt=array();
                                        $opt[]='<option value=""></option>';
-                                       $types = explode(',','input,textarea,select,check,radio,password,file,hidden,submit');
+                                       $types = explode(',','input,textarea,select,check,radio,password,file,hidden,submit,property,label');
                                        foreach($types as $t)   {
                                                $opt[]='
                                                                <option value="'.$t.'"'.($confData['type']==$t?' selected="selected"':'').'>'.$LANG->getLL('forms_type_'.$t,1).'</option>';
@@ -435,9 +444,9 @@ class SC_wizard_forms {
                                        if (!t3lib_div::inList('hidden,submit',$confData['type']))      {
                                                $temp_cells[$LANG->getLL('forms_label')]='<input type="text"'.$this->doc->formWidth(15).' name="FORMCFG[c]['.(($k+1)*2).'][label]" value="'.htmlspecialchars($confData['label']).'" />';
                                        }
-                                       
+
                                                // Required checkbox:
-                                       if (!t3lib_div::inList(',hidden,submit',$confData['type']))             {
+                                       if (!t3lib_div::inList('check,hidden,submit,label',$confData['type']))          {
                                                $temp_cells[$LANG->getLL('forms_required')]='<input type="checkbox" name="FORMCFG[c]['.(($k+1)*2).'][required]" value="1"'.($confData['required']?' checked="checked"':'').' title="'.$LANG->getLL('forms_required',1).'" />';
                                        }
 
@@ -447,9 +456,14 @@ class SC_wizard_forms {
 
                                                // Render specific field configuration COLUMN:
                                        $temp_cells=array();
-                                       
+
                                                // Fieldname
-                                       $temp_cells[$LANG->getLL('forms_fieldName')]='<input type="text"'.$this->doc->formWidth(10).' name="FORMCFG[c]['.(($k+1)*2).'][fieldname]" value="'.htmlspecialchars($confData['fieldname']).'" title="'.$LANG->getLL('forms_fieldName',1).'" />';
+                                       if ($this->special=='formtype_mail' && $confData['type']=='file')       {
+                                               $confData['fieldname'] = 'attachment'.(++$this->attachmentCounter);
+                                       }
+                                       if (!t3lib_div::inList('label',$confData['type']))      {
+                                               $temp_cells[$LANG->getLL('forms_fieldName')]='<input type="text"'.$this->doc->formWidth(10).' name="FORMCFG[c]['.(($k+1)*2).'][fieldname]" value="'.htmlspecialchars($confData['fieldname']).'" title="'.$LANG->getLL('forms_fieldName',1).'" />';
+                                       }
 
                                                // Field configuration depending on the fields type:
                                        switch((string)$confData['type'])       {
@@ -472,7 +486,18 @@ class SC_wizard_forms {
                                                        $temp_cells[$LANG->getLL('forms_multiple')]='<input type="checkbox" name="FORMCFG[c]['.(($k+1)*2).'][multiple]" value="1"'.($confData['multiple']?' checked="checked"':'').' title="'.$LANG->getLL('forms_multiple',1).'" />';
                                                break;
                                        }
-               
+
+                                               // Field configuration depending on the fields type:
+                                       switch((string)$confData['type'])       {
+                                               case 'textarea':
+                                               case 'input':
+                                               case 'password':
+                                                       if (strlen(trim($confData['specialEval'])))     {
+                                                               $hiddenFields[] = '<input type="hidden" name="FORMCFG[c]['.(($k+1)*2).'][specialEval]" value="'.htmlspecialchars($confData['specialEval']).'" />';
+                                                       }
+                                               break;
+                                       }
+
                                                // Default data
                                        if ($confData['type']=='select' || $confData['type']=='radio')  {
                                                $temp_cells[$LANG->getLL('forms_options')]='<textarea '.$this->doc->formWidthText(15).' rows="4" name="FORMCFG[c]['.(($k+1)*2).'][options]" title="'.$LANG->getLL('forms_options',1).'">'.t3lib_div::formatForTextarea($confData['default']).'</textarea>';
@@ -481,14 +506,14 @@ class SC_wizard_forms {
                                        } elseif ($confData['type'] && $confData['type']!='file') {
                                                $temp_cells[$LANG->getLL('forms_default')]='<input type="text"'.$this->doc->formWidth(15).' name="FORMCFG[c]['.(($k+1)*2).'][default]" value="'.htmlspecialchars($confData['default']).'" title="'.$LANG->getLL('forms_default',1).'" />';
                                        }
-               
+
                                        $cells[]=$confData['type']?$this->formatCells($temp_cells):'';
-               
+
                                                // CTRL panel for an item (move up/down/around):
                                        $ctrl='';
                                        $onClick="document.wizardForm.action+='#ANC_".(($k+1)*2-2)."';";
                                        $onClick=' onclick="'.htmlspecialchars($onClick).'"';
-       
+// FIXME $inputStyle undefined
                                        $brTag=$inputStyle?'':'<br />';
                                        if ($k!=0)      {
                                                $ctrl.='<input type="image" name="FORMCFG[row_up]['.(($k+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/pil2up.gif','').$onClick.' title="'.$LANG->getLL('table_up',1).'" />'.$brTag;
@@ -496,15 +521,16 @@ class SC_wizard_forms {
                                                $ctrl.='<input type="image" name="FORMCFG[row_bottom]['.(($k+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/turn_up.gif','').$onClick.' title="'.$LANG->getLL('table_bottom',1).'" />'.$brTag;
                                        }
                                        $ctrl.='<input type="image" name="FORMCFG[row_remove]['.(($k+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/garbage.gif','').$onClick.' title="'.$LANG->getLL('table_removeRow',1).'" />'.$brTag;
+// FIXME $tLines undefined
                                        if (($k+1)!=count($tLines))     {
                                                $ctrl.='<input type="image" name="FORMCFG[row_down]['.(($k+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/pil2down.gif','').$onClick.' title="'.$LANG->getLL('table_down',1).'" />'.$brTag;
                                        } else {
                                                $ctrl.='<input type="image" name="FORMCFG[row_top]['.(($k+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/turn_down.gif','').$onClick.' title="'.$LANG->getLL('table_top',1).'" />'.$brTag;
                                        }
                                        $ctrl.='<input type="image" name="FORMCFG[row_add]['.(($k+1)*2).']"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/add.gif','').$onClick.' title="'.$LANG->getLL('table_addRow',1).'" />'.$brTag;
-                       
+
                                        $ctrl='<span class="c-wizButtonsV">'.$ctrl.'</span>';
-                       
+
                                                // Finally, put together the full row from the generated content above:
                                        $bgC = $confData['type']?' class="bgColor5"':'';
                                        $tRows[]='
@@ -521,7 +547,7 @@ class SC_wizard_forms {
                                // Increment counter:
                        $k++;
                }
-       
+
                        // If the form is of the special type "formtype_mail" (used for tt_content elements):
                if ($this->special=='formtype_mail')    {
 
@@ -535,7 +561,9 @@ class SC_wizard_forms {
                        $tRows[]='
                                <tr>
                                        <td colspan="2" class="bgColor2">&nbsp;</td>
-                                       <td colspan="2" class="bgColor2"><strong>'.$LANG->getLL('forms_special_eform',1).':</strong></td>
+                                       <td colspan="2" class="bgColor2"><strong>'.$LANG->getLL('forms_special_eform',1).':</strong>'.
+                                               t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'wizard_forms_wiz_formmail_info', $GLOBALS['BACK_PATH'],'').
+                                               '</td>
                                </tr>';
 
                                // "FORM type":
@@ -576,7 +604,7 @@ class SC_wizard_forms {
                                                <input type="text"'.$this->doc->formWidth(15).' name="FORMCFG[c]['.(1002*2).'][default]" value="'.htmlspecialchars($specParts['subject']).'" />
                                        </td>
                                </tr>';
-                               
+
                                // Recipient:
                        $tRows[]='
                                <tr class="bgColor5">
@@ -588,20 +616,25 @@ class SC_wizard_forms {
                                        </td>
                                </tr>';
                }
-               
+
+               $content = '';
+
+                       // Add CSH:
+               $content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'wizard_forms_wiz', $GLOBALS['BACK_PATH'],'');
+
                        // Implode all table rows into a string, wrapped in table tags.
-               $content = '
-               
+               $content.= '
+
                        <!--
                                Form wizard
                        -->
                        <table border="0" cellpadding="1" cellspacing="1" id="typo3-formwizard">
                                '.implode('',$tRows).'
                        </table>';
-               
+
                        // Add saving buttons in the bottom:
                $content.= '
-               
+
                        <!--
                                Save buttons:
                        -->
@@ -611,44 +644,47 @@ class SC_wizard_forms {
                $content.= '<a href="#" onclick="'.htmlspecialchars('jumpToUrl(unescape(\''.rawurlencode($this->P['returnUrl']).'\')); return false;').'">'.
                                        '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/closedok.gif','width="21" height="16"').' class="c-inputButton" title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc',1).'" alt="" />'.
                                        '</a>';
-               $content.= '<input type="image" class="c-inputButton" name="_refresh"'.t3lib_iconWorks::skinImg('','gfx/refresh_n.gif','').' title="'.$LANG->getLL('forms_refresh',1).'" />
+               $content.= '<input type="image" class="c-inputButton" name="_refresh"'.t3lib_iconWorks::skinImg('','gfx/refresh_n.gif','').' title="'.$LANG->getLL('forms_refresh',1).'" />';
+                       // Add CSH:
+               $content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'wizard_forms_wiz_buttons', $GLOBALS['BACK_PATH'],'');
+               $content.= '
                        </div>
                ';
 
                        // Add hidden fields:
                $content.= implode('',$hiddenFields);
-               
+
                        // Return content:
                return $content;
-       }       
-        
+       }
+
        /**
         * Detects if a control button (up/down/around/delete) has been pressed for an item and accordingly it will manipulate the internal FORMCFG array
-        * 
-        * @return      void            
+        *
+        * @return      void
         * @access private
         */
        function changeFunc()   {
-               if ($this->FORMCFG['row_remove'])       {       
+               if ($this->FORMCFG['row_remove'])       {
                        $kk = key($this->FORMCFG['row_remove']);
                        $cmd='row_remove';
-               } elseif ($this->FORMCFG['row_add'])    {       
+               } elseif ($this->FORMCFG['row_add'])    {
                        $kk = key($this->FORMCFG['row_add']);
                        $cmd='row_add';
-               } elseif ($this->FORMCFG['row_top'])    {       
+               } elseif ($this->FORMCFG['row_top'])    {
                        $kk = key($this->FORMCFG['row_top']);
                        $cmd='row_top';
-               } elseif ($this->FORMCFG['row_bottom']) {       
+               } elseif ($this->FORMCFG['row_bottom']) {
                        $kk = key($this->FORMCFG['row_bottom']);
                        $cmd='row_bottom';
-               } elseif ($this->FORMCFG['row_up'])     {       
+               } elseif ($this->FORMCFG['row_up'])     {
                        $kk = key($this->FORMCFG['row_up']);
                        $cmd='row_up';
-               } elseif ($this->FORMCFG['row_down'])   {       
+               } elseif ($this->FORMCFG['row_down'])   {
                        $kk = key($this->FORMCFG['row_down']);
                        $cmd='row_down';
                }
-       
+
                if ($cmd && t3lib_div::testInt($kk)) {
                        if (substr($cmd,0,4)=='row_')   {
                                switch($cmd)    {
@@ -682,16 +718,16 @@ class SC_wizard_forms {
 
        /**
         * Converts the input array to a configuration code string
-        * 
+        *
         * @param       array           Array of form configuration (follows the input structure from the form wizard POST form)
         * @return      string          The array converted into a string with line-based configuration.
         * @see cfgString2CfgArray()
         */
        function cfgArray2CfgString($cfgArr)    {
-       
+
                        // Initialize:
                $inLines=array();
-               
+
                        // Traverse the elements of the form wizard and transform the settings into configuration code.
                foreach($cfgArr as $vv) {
                        if ($vv['comment'])     {       // If "content" is found, then just pass it over.
@@ -707,7 +743,7 @@ class SC_wizard_forms {
                                        // Set Type:
                                if ($vv['type'])        {
                                        $thisLine[1]=($vv['required']?'*':'').str_replace(',','',($vv['fieldname']?$vv['fieldname'].'=':'').$vv['type']);
-                                               
+
                                                // Default:
                                        $tArr=array('','','','','','');
                                        switch((string)$vv['type'])     {
@@ -715,11 +751,19 @@ class SC_wizard_forms {
                                                        if (intval($vv['cols']))        $tArr[0]=intval($vv['cols']);
                                                        if (intval($vv['rows']))        $tArr[1]=intval($vv['rows']);
                                                        if (trim($vv['extra']))         $tArr[2]=trim($vv['extra']);
+                                                       if (strlen($vv['specialEval'])) {
+                                                               $thisLine[2] = '';      // Preset blank default value so position 3 can get a value...
+                                                               $thisLine[3] = $vv['specialEval'];
+                                                       }
                                                break;
                                                case 'input':
                                                case 'password':
                                                        if (intval($vv['size']))        $tArr[0]=intval($vv['size']);
                                                        if (intval($vv['max']))         $tArr[1]=intval($vv['max']);
+                                                       if (strlen($vv['specialEval'])) {
+                                                               $thisLine[2] = '';      // Preset blank default value so position 3 can get a value...
+                                                               $thisLine[3] = $vv['specialEval'];
+                                                       }
                                                break;
                                                case 'file':
                                                        if (intval($vv['size']))        $tArr[0]=intval($vv['size']);
@@ -732,9 +776,9 @@ class SC_wizard_forms {
                                        }
                                        $tArr = $this->cleanT($tArr);
                                        if (count($tArr))       $thisLine[1].=','.implode(',',$tArr);
-                                       
+
                                        $thisLine[1]=str_replace('|','',$thisLine[1]);
-               
+
                                                // Default:
                                        if ($vv['type']=='select' || $vv['type']=='radio')      {
                                                $thisLine[2]=str_replace(chr(10),', ',str_replace(',','',$vv['options']));
@@ -745,42 +789,41 @@ class SC_wizard_forms {
                                        }
                                        if (isset($thisLine[2]))                $thisLine[2]=str_replace('|','',$thisLine[2]);
                                }
-                                       
+
                                        // Compile the final line:
                                $inLines[]=ereg_replace("[\n\r]*",'',implode(' | ',$thisLine));
                        }
                }
-               
                        // Finally, implode the lines into a string, and return it:
-               return implode(chr(10),$inLines);       
+               return implode(chr(10),$inLines);
        }
-       
+
        /**
         * Converts the input configuration code string into an array
-        * 
+        *
         * @param       string          Configuration code
         * @return      array           Configuration array
         * @see cfgArray2CfgString()
         */
        function cfgString2CfgArray($cfgStr)    {
-               
+
                        // Traverse the number of form elements:
                $tLines=explode(chr(10),$cfgStr);
                foreach($tLines as $k => $v)    {
-               
+
                                // Initialize:
                        $confData=array();
                        $val=trim($v);
 
                                // Accept a line as configuration if a) it is blank(! - because blank lines indicates new, unconfigured fields) or b) it is NOT a comment.
                        if (!$val || strcspn($val,'#/')) {
-                       
+
                                        // Split:
                                $parts = t3lib_div::trimExplode('|',$val);
 
                                        // Label:
                                $confData['label'] = trim($parts[0]);
-                               
+
                                        // Field:
                                $fParts = t3lib_div::trimExplode(',',$parts[1]);
                                $fParts[0]=trim($fParts[0]);
@@ -788,14 +831,14 @@ class SC_wizard_forms {
                                        $confData['required'] = 1;
                                        $fParts[0] = substr($fParts[0],1);
                                }
-                               
+
                                $typeParts = t3lib_div::trimExplode('=',$fParts[0]);
                                $confData['type'] = trim(strtolower(end($typeParts)));
-                               
+
                                if ($confData['type'])  {
                                        if (count($typeParts)==1)       {
                                                $confData['fieldname'] = substr(ereg_replace('[^a-zA-Z0-9_]','',str_replace(' ','_',trim($parts[0]))),0,30);
-       
+
                                                        // Attachment names...
                                                if ($confData['type']=='file')  {
                                                        $confData['fieldname']='attachment'.$attachmentCounter;
@@ -804,20 +847,30 @@ class SC_wizard_forms {
                                        } else {
                                                $confData['fieldname'] = str_replace(' ','_',trim($typeParts[0]));
                                        }
-                                       
-                                       $confData['default'] = implode(chr(10),t3lib_div::trimExplode(',',$parts[2]));
-       
+
+                                       switch((string)$confData['type'])       {
+                                               case 'select':
+                                               case 'radio':
+                                                       $confData['default'] = implode(chr(10),t3lib_div::trimExplode(',',$parts[2]));
+                                               break;
+                                               default:
+                                                       $confData['default'] = trim($parts[2]);
+                                               break;
+                                       }
+
                                                // Field configuration depending on the fields type:
                                        switch((string)$confData['type'])       {
                                                case 'textarea':
                                                        $confData['cols'] = $fParts[1];
                                                        $confData['rows'] = $fParts[2];
                                                        $confData['extra'] = strtoupper($fParts[3])=='OFF' ? 'OFF' : '';
+                                                       $confData['specialEval'] = trim($parts[3]);
                                                break;
                                                case 'input':
                                                case 'password':
                                                        $confData['size'] = $fParts[1];
                                                        $confData['max'] = $fParts[2];
+                                                       $confData['specialEval'] = trim($parts[3]);
                                                break;
                                                case 'file':
                                                        $confData['size'] = $fParts[1];
@@ -834,19 +887,19 @@ class SC_wizard_forms {
                                $confData=array(
                                        'comment' => $val
                                );
-                       }                       
-                       
+                       }
+
                                // Adding config array:
                        $cfgArr[]=$confData;
                }
-               
+
                        // Return cfgArr
                return $cfgArr;
        }
-       
+
        /**
         * Removes any "trailing elements" in the array which consists of whitespace (little like trim() does for strings, so this does for arrays)
-        * 
+        *
         * @param       array           Single dim array
         * @return      array           Processed array
         * @access private
@@ -864,7 +917,7 @@ class SC_wizard_forms {
 
        /**
         * Wraps items in $fArr in table cells/rows, displaying them vertically.
-        * 
+        *
         * @param       array           Array of label/HTML pairs.
         * @return      string          HTML table
         * @access private
@@ -888,7 +941,7 @@ class SC_wizard_forms {
                                <td></td>
                        </tr>';
 
-                       // Wrap in table and return:            
+                       // Wrap in table and return:
                return '
                        <table border="0" cellpadding="0" cellspacing="0">
                                '.implode('',$lines).'
@@ -921,4 +974,4 @@ foreach($SOBE->include_once as $INC_FILE)   include_once($INC_FILE);
 
 $SOBE->main();
 $SOBE->printContent();
-?>
\ No newline at end of file
+?>