* Feature #6896: TCA eval on TEXT field does not work
authorSebastian Kurfürst <sebastian.kurfuerst@typo3.org>
Thu, 3 Apr 2008 23:30:29 +0000 (23:30 +0000)
committerSebastian Kurfürst <sebastian.kurfuerst@typo3.org>
Thu, 3 Apr 2008 23:30:29 +0000 (23:30 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@3529 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_tceforms.php
t3lib/class.t3lib_tcemain.php

index 3d89ac0..de4b183 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-04-03  Thomas Hempel  <thomas@typo3-unleashed.net>
+
+       * Feature #6896: TCA eval on TEXT field does not work
+
 2008-04-03  Ingmar Schlecht  <ingmar@typo3.org>
 
        * Fixed bug #4575: Changes in alternative page language does not clear cache
 
        * Fixed bug #7388: CSS Gremlins
 
-2008-02-12  Thomas Hempek  <thomas@typo3-unleashed.net>
+2008-02-12  Thomas Hempel  <thomas@typo3-unleashed.net>
 
        * Code cleanup and bugfix patch for t3editor / preparation for review (Thanks to Tobias Liebig)
 
index c3bc72e..80fd0a3 100755 (executable)
@@ -1253,7 +1253,28 @@ class t3lib_TCEforms     {
                                if (count($classes))    {
                                        $class = ' class="'.implode(' ',$classes).'"';
                                } else $class='';
-
+                               
+                               $evalList = t3lib_div::trimExplode(',',$config['eval'],1);
+                               foreach ($evalList as $func) {
+                                       switch ($func) {
+                                               case 'required':
+                                                       $this->registerRequiredProperty('field', $table.'_'.$row['uid'].'_'.$field, $PA['itemFormElName']);
+                                                       break;
+                                               default:
+                                                       if (substr($func, 0, 3) == 'tx_')       {
+                                                               // Pair hook to the one in t3lib_TCEmain::checkValue_input_Eval() and t3lib_TCEmain::checkValue_text_Eval()
+                                                               $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func].':&'.$func);
+                                                               if (is_object($evalObj) && method_exists($evalObj, 'deevaluateFieldValue'))     {
+                                                                       $_params = array(
+                                                                               'value' => $PA['itemFormElValue']
+                                                                       );
+                                                                       $PA['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
+                                                               }
+                                                       }
+                                                       break;
+                                       }
+                               }
+                               
                                $iOnChange = implode('',$PA['fieldChangeFunc']);
                                $item.= '
                                                        <textarea name="'.$PA['itemFormElName'].'"'.$formWidthText.$class.' rows="'.$rows.'" wrap="'.$wrap.'" onchange="'.htmlspecialchars($iOnChange).'"'.$PA['onFocus'].'>'.
index f44dd06..142ab35 100755 (executable)
@@ -1296,6 +1296,8 @@ class t3lib_TCEmain       {
 
                switch ($tcaFieldConf['type']) {
                        case 'text':
+                               $res = $this->checkValue_text($res,$value,$tcaFieldConf,$PP,$field);
+                       break;
                        case 'passthrough':
                        case 'user':
                                $res['value'] = $value;
@@ -1328,6 +1330,23 @@ class t3lib_TCEmain      {
 
                return $res;
        }
+       
+       
+       /**
+        * Evaluate "text" type values.
+        *
+        * @param       array           The result array. The processed value (if any!) is set in the "value" key.
+        * @param       string          The value to set.
+        * @param       array           Field configuration from TCA
+        * @param       array           Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
+        * @param       string          Field name
+        * @return      array           Modified $res array
+        */
+       function checkValue_text($res,$value,$tcaFieldConf,$PP,$field='')       {
+               $evalCodesArray = t3lib_div::trimExplode(',',$tcaFieldConf['eval'],1);
+               $res = $this->checkValue_text_Eval($value,$evalCodesArray,$tcaFieldConf['is_in']);
+               return $res;
+       }
 
        /**
         * Evaluate "input" type values.
@@ -1946,6 +1965,33 @@ class t3lib_TCEmain      {
                return $value;
        }
 
+       function checkValue_text_Eval($value,$evalArray,$is_in) {
+               $res = Array();
+               $newValue = $value;
+               $set = true;
+               
+               foreach ($evalArray as $func) {
+                       switch ($func) {
+                               case 'trim':
+                                       $value = trim($value);
+                               break;
+                               case 'required':
+                                       if (!$value)    {$set=0;}
+                               break;
+                               default:
+                                       if (substr($func, 0, 3) == 'tx_')       {
+                                               $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func].':&'.$func);
+                                               if (is_object($evalObj) && method_exists($evalObj, 'evaluateFieldValue'))       {
+                                                       $value = $evalObj->evaluateFieldValue($value, $is_in, $set);
+                                               }
+                                       }
+                               break;
+                       }
+               }
+               if ($set)       {$res['value'] = $value;}
+               return $res;
+       }
+       
        /**
         * Evaluation of 'input'-type values based on 'eval' list
         *