Implemented an override of allowed language per workspace. This is an expert feature...
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_flexformtools.php
index 28bd93e..d1953c6 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 2006 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 2006-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -73,6 +73,9 @@ class t3lib_flexformtools {
        var $convertCharset = FALSE;            // If set, the charset of data XML is converted to system charset.
        var $reNumberIndexesOfSectionData = FALSE;      // If set, section indexes are re-numbered before processing
 
+       var $traverseFlexFormXMLData_DS = array();      // Contains data structure when traversing flexform
+       var $traverseFlexFormXMLData_Data = array();    // Contains data array when traversing flexform
+
                // Options for array2xml() for flexform. This will map the weird keys from the internal array to tags that could potentially be checked with a DTD/schema
        var $flexArray2Xml_options = array(
                        'parentTagMap' => array(
@@ -89,7 +92,10 @@ class t3lib_flexformtools {
                );
 
                // Internal:
-       var $callBackObj = NULL;                // Reference to object called
+       /**
+        * Reference to object called
+        */
+       var $callBackObj = NULL;
        var $cleanFlexFormXML = array();                // Used for accumulation of clean XML
 
        /**
@@ -102,13 +108,13 @@ class t3lib_flexformtools {
         * @param       string          Method name of call back function in object for values
         * @return      boolean         If true, error happened (error string returned)
         */
-       function traverseFlexFormXMLData($table,$field,$row,&$callBackObj,$callBackMethod_value)        {
+       function traverseFlexFormXMLData($table, $field, $row, $callBackObj, $callBackMethod_value) {
 
                if (!is_array($GLOBALS['TCA'][$table]) || !is_array($GLOBALS['TCA'][$table]['columns'][$field]))        {
                        return 'TCA table/field was not defined.';
                }
 
-               $this->callBackObj = &$callBackObj;
+               $this->callBackObj = $callBackObj;
 
                        // Get Data Structure:
                $dataStructArray = t3lib_BEfunc::getFlexFormDS($GLOBALS['TCA'][$table]['columns'][$field]['config'],$row,$table);
@@ -182,6 +188,9 @@ class t3lib_flexformtools {
                                                $PA['field'] = $field;
                                                $PA['uid'] = $row['uid'];
 
+                                               $this->traverseFlexFormXMLData_DS = &$dataStruct;
+                                               $this->traverseFlexFormXMLData_Data = &$editData;
+
                                                        // Render flexform:
                                                $this->traverseFlexFormXMLData_recurse(
                                                        $dataStruct['ROOT']['el'],
@@ -226,17 +235,19 @@ class t3lib_flexformtools {
                                                                }
 
                                                                foreach($editData[$key]['el'] as $k3 => $v3)    {
-                                                                       $cc=$k3;
-                                                                       $theType = key($v3);
-                                                                       $theDat = $v3[$theType];
-                                                                       $newSectionEl = $value['el'][$theType];
-                                                                       if (is_array($newSectionEl))    {
-                                                                               $this->traverseFlexFormXMLData_recurse(
-                                                                                       array($theType => $newSectionEl),
-                                                                                       array($theType => $theDat),
-                                                                                       $PA,
-                                                                                       $path.'/'.$key.'/el/'.$cc
-                                                                               );
+                                                                       if (is_array($v3))      {
+                                                                               $cc=$k3;
+                                                                               $theType = key($v3);
+                                                                               $theDat = $v3[$theType];
+                                                                               $newSectionEl = $value['el'][$theType];
+                                                                               if (is_array($newSectionEl))    {
+                                                                                       $this->traverseFlexFormXMLData_recurse(
+                                                                                               array($theType => $newSectionEl),
+                                                                                               array($theType => $theDat),
+                                                                                               $PA,
+                                                                                               $path.'/'.$key.'/el/'.$cc
+                                                                                       );
+                                                                               }
                                                                        }
                                                                }
                                                        }
@@ -349,10 +360,18 @@ class t3lib_flexformtools {
         * @param       object          Object reference to caller
         * @return      void
         */
-       function cleanFlexFormXML_callBackFunction($dsArr, $data, $PA, $path, &$pObj)   {
+       function cleanFlexFormXML_callBackFunction($dsArr, $data, $PA, $path, $pObj) {
                #debug(array($dsArr, $data, $PA),$path);
                        // Just setting value in our own result array, basically replicating the structure:
                $pObj->setArrayValueByPath($path,$this->cleanFlexFormXML,$data);
+
+                       // Looking if an "extension" called ".vDEFbase" is found and if so, accept that too:
+               if ($GLOBALS['TYPO3_CONF_VARS']['BE']['flexFormXMLincludeDiffBase'])    {
+                       $vDEFbase = $pObj->getArrayValueByPath($path.'.vDEFbase',$pObj->traverseFlexFormXMLData_Data);
+                       if (isset($vDEFbase))   {
+                               $pObj->setArrayValueByPath($path.'.vDEFbase',$this->cleanFlexFormXML,$vDEFbase);
+                       }
+               }
        }
 
 
@@ -436,9 +455,13 @@ class t3lib_flexformtools {
         * @return      string          XML content.
         */
        function flexArray2Xml($array, $addPrologue=FALSE)      {
+               if ($GLOBALS['TYPO3_CONF_VARS']['BE']['flexformForceCDATA']) {
+                       $this->flexArray2Xml_options['useCDATA'] = 1;
+               }
 
                $options = $GLOBALS['TYPO3_CONF_VARS']['BE']['niceFlexFormXMLtags'] ? $this->flexArray2Xml_options : array();
-               $output = t3lib_div::array2xml($array,'',0,'T3FlexForms',4, $options);
+               $spaceInd = ($GLOBALS['TYPO3_CONF_VARS']['BE']['compactFlexFormXML'] ? -1 : 4);
+               $output = t3lib_div::array2xml($array,'',0,'T3FlexForms', $spaceInd, $options);
 
                if ($addPrologue)       {
                        $output = '<?xml version="1.0" encoding="'.$GLOBALS['LANG']->charSet.'" standalone="yes" ?>'.chr(10).$output;
@@ -451,4 +474,4 @@ class t3lib_flexformtools {
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_flexformtools.php'])    {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_flexformtools.php']);
 }
-?>
\ No newline at end of file
+?>