public function extractDefaultDataFromDataStructure($dataStructure)
    {
        $returnXML = '';
        $sheetArray = [];
        if ($dataStructure) {
            $structureArray = GeneralUtility::xml2array($dataStructure);
            if (!isset($structureArray['sheets']) && isset($structureArray['ROOT'])) {
                $structureArray['sheets']['sDEF']['ROOT'] = $structureArray['ROOT'];
                unset($structureArray['ROOT']);
            }
            if (isset($structureArray['sheets']) && !empty($structureArray['sheets'])) {
                foreach ($structureArray['sheets'] as $sheetName => $sheet) {
                    if (is_array($sheet['ROOT']['el']) && !empty($sheet['ROOT']['el'])) {
                        $elArray = [];
                        foreach ($sheet['ROOT']['el'] as $elName => $elConf) {
                            $config = $elConf['TCEforms']['config'];
                            $elArray[$elName]['vDEF'] = $config['default'];
                            if (!$elArray[$elName]['vDEF'] && $config['type'] === 'select' && !empty($config['items'])) {
                                $elArray[$elName]['vDEF'] = $config['items'][0][1];
                            }
                        }
                        $sheetArray['data'][$sheetName]['lDEF'] = $elArray;
                    }
                }
            }
            if (!empty($sheetArray)) {
                $flexformTools = GeneralUtility::makeInstance(FlexFormTools::class);
                $returnXML = $flexformTools->flexArray2Xml($sheetArray, true);
            }
        }

        return $returnXML;
    }
public function extractDefaultDataFromDataStructure($dataStructure)
    {
        $returnXML = '';
        $sheetArray = [];
        if ($dataStructure) {
            $structureArray = GeneralUtility::xml2array($dataStructure);
            if (!isset($structureArray['sheets']) && isset($structureArray['ROOT'])) {
                $structureArray['sheets']['sDEF']['ROOT'] = $structureArray['ROOT'];
                unset($structureArray['ROOT']);
            }
            if (isset($structureArray['sheets']) && !empty($structureArray['sheets'])) {
                foreach ($structureArray['sheets'] as $sheetName => $sheet) {
                    if (is_array($sheet['ROOT']['el']) && !empty($sheet['ROOT']['el'])) {
                        $elArray = [];
                        foreach ($sheet['ROOT']['el'] as $elName => $elConf) {
                            $config = $elConf['TCEforms']['config'];
                            $elArray[$elName]['vDEF'] = $config['default'];
                            if (!$elArray[$elName]['vDEF'] && $config['type'] === 'select' && !empty($config['items'])) {
                                $elArray[$elName]['vDEF'] = $config['items'][0][1];
                            }
                        }
                        $sheetArray['data'][$sheetName]['lDEF'] = $elArray;
                    }
                }
            }
            if (!empty($sheetArray)) {
                $flexformTools = GeneralUtility::makeInstance(FlexFormTools::class);
                $returnXML = $flexformTools->flexArray2Xml($sheetArray, true);
            }
        }

        return $returnXML;
    }
public function extractDefaultDataFromDataStructure ( $ dataStructure ) { $ returnXML = '' ; $ sheetArray = [ ] ; if ( $ dataStructure ) { $ structureArray = GeneralUtility :: xml2array ( $ dataStructure ) ; if ( ! isset ( $ structureArray [ 'sheets' ] ) && isset ( $ structureArray [ 'ROOT' ] ) ) { $ structureArray [ 'sheets' ] [ 'sDEF' ] [ 'ROOT' ] = $ structureArray [ 'ROOT' ] ; unset ( $ structureArray [ 'ROOT' ] ) ; } if ( isset ( $ structureArray [ 'sheets' ] ) && ! empty ( $ structureArray [ 'sheets' ] ) ) { foreach ( $ structureArray [ 'sheets' ] as $ sheetName => $ sheet ) { if ( is_array ( $ sheet [ 'ROOT' ] [ 'el' ] ) && ! empty ( $ sheet [ 'ROOT' ] [ 'el' ] ) ) { $ elArray = [ ] ; foreach ( $ sheet [ 'ROOT' ] [ 'el' ] as $ elName => $ elConf ) { $ config = $ elConf [ 'TCEforms' ] [ 'config' ] ; $ elArray [ $ elName ] [ 'vDEF' ] = $ config [ 'default' ] ; if ( ! $ elArray [ $ elName ] [ 'vDEF' ] && $ config [ 'type' ] === 'select' && ! empty ( $ config [ 'items' ] ) ) { $ elArray [ $ elName ] [ 'vDEF' ] = $ config [ 'items' ] [ 0 ] [ 1 ] ; } } $ sheetArray [ 'data' ] [ $ sheetName ] [ 'lDEF' ] = $ elArray ; } } } if ( ! empty ( $ sheetArray ) ) { $ flexformTools = GeneralUtility :: makeInstance ( FlexFormTools :: class ) ; $ returnXML = $ flexformTools -> flexArray2Xml ( $ sheetArray , true ) ; } } return $ returnXML ; }
extracts the default data out of a given XML data structure

@param string $dataStructure

@return string $defaultData
extracts the default data out of a given XML data structure