Generates comma-delimited string of tag names from tag array(), needed for
initialization of data for text input

@param array $data Tag data array to convert to string.
@return string|array
323346
public function prepareTagsForOutput(array $data) {
		$tags = [];

		foreach ($data as $tag) {
			if ($this->_config['namespace']) {
				$tags[] = $tag['namespace'] . $this->_config['separator'] . $tag['label'];
			} else {
				$tags[] = $tag['label'];
			}
		}

		if ($this->_config['strategy'] === 'array') {
			return $tags;
		}

		return implode($this->_config['delimiter'] . ' ', $tags);
	}
849414
public function deserialize(array $data)
    {
        $original = $data;
        $this->deserializeTos($data);
        $data = $this->getJavascriptsData($data);
        $data = $this->getLogoData($data);
        unset($data['tos']['text']);
        //maybe move this somewhere else
        unset($data['archives']);

        $data = array_merge($this->serialize([Options::SERIALIZE_MINIMAL]), $data);
        ksort($data);
        $data = json_encode($data, JSON_PRETTY_PRINT);

        file_put_contents($this->filePath, $data);

        return $original;
    }
458036
public function generate(array $data): string
    {
        // Parse the flex form
        $flexFormTools = GeneralUtility::makeInstance(FlexFormTools::class);
        $structureIdentifier = $flexFormTools->getDataStructureIdentifier($data['fieldConfig'], $data['tableName'], $data['fieldName'], []);
        $dataStructureArray = $flexFormTools->parseDataStructureByIdentifier($structureIdentifier);

        // Early return if flex couldn't be parsed
        if (!is_array($dataStructureArray)) {
            return '';
        }

        // Loop through this xml mess and call a generator for each found field
        $aFlexFieldData = $data;
        $resultArray = [];
        /** @var FieldGeneratorResolver $resolver */
        $resolver = GeneralUtility::makeInstance(FieldGeneratorResolver::class);
        if (isset($dataStructureArray['sheets']) && is_array($dataStructureArray['sheets'])) {
            foreach ($dataStructureArray['sheets'] as $sheetName => $sheetArray) {
                if (isset($sheetArray['ROOT']['el']) && is_array($sheetArray['ROOT']['el'])) {
                    foreach ($sheetArray['ROOT']['el'] as $sheetElementName => $sheetElementArray) {
                        // Casual field
                        if (isset($sheetElementArray['TCEforms']) && is_array($sheetElementArray['TCEforms'])) {
                            $aFlexFieldData['fieldName'] = $sheetElementName;
                            $aFlexFieldData['fieldConfig'] = $sheetElementArray['TCEforms'];
                            try {
                                $generator = $resolver->resolve($aFlexFieldData);
                                $flexFieldValue = $generator->generate($aFlexFieldData);
                                $resultArray['data'][$sheetName]['lDEF'][$sheetElementName]['vDEF'] = $flexFieldValue;
                            } catch (GeneratorNotFoundException $e) {
                                // No op if no matching generator was found
                            }
                            // Field handled, skip rest
                            continue;
                        }
                        // Container section
                        if (isset($sheetElementArray['type']) && $sheetElementArray['type'] === 'array'
                            && isset($sheetElementArray['section']) && $sheetElementArray['section'] == 1
                            && isset($sheetElementArray['el']) && is_array($sheetElementArray['el'])
                        ) {
                            $containerCounter = 0;
                            foreach ($sheetElementArray['el'] as $containerName => $containerElementArray) {
                                if (!isset($containerElementArray['el']) || !is_array($containerElementArray['el'])) {
                                    continue;
                                }
                                $containerCounter ++;
                                foreach ($containerElementArray['el'] as $containerSingleElementName => $containerSingleElementArray) {
                                    if (!isset($containerSingleElementArray['TCEforms']) || !is_array($containerSingleElementArray['TCEforms'])) {
                                        continue;
                                    }
                                    $aFlexFieldData['fieldName'] = $containerSingleElementName;
                                    $aFlexFieldData['fieldConfig'] = $containerSingleElementArray['TCEforms'];
                                    try {
                                        $generator = $resolver->resolve($aFlexFieldData);
                                        $flexFieldValue = $generator->generate($aFlexFieldData);
                                        $resultArray['data'][$sheetName]['lDEF']
                                            [$sheetElementName]['el']
                                            [$containerCounter][$containerName]['el']
                                            [$containerSingleElementName]['vDEF'] = $flexFieldValue;
                                    } catch (GeneratorNotFoundException $e) {
                                        // No op if no matching generator was found
                                    }
                                    // Field handled, skip rest
                                    continue;
                                }
                            }
                        }
                    }
                }
            }
        } elseif (isset($dataStructureArray['ROOT']['el']) && is_array($dataStructureArray['ROOT']['el'])) {
            foreach ($dataStructureArray['ROOT']['el'] as $elementName => $elementArray) {
                if (isset($elementArray['TCEforms']) && is_array($elementArray['TCEforms'])) {
                    $aFlexFieldData['fieldName'] = $elementName;
                    $aFlexFieldData['fieldConfig'] = $elementArray['TCEforms'];
                    try {
                        $generator = $resolver->resolve($aFlexFieldData);
                        $flexFieldValue = $generator->generate($aFlexFieldData);
                        $resultArray['data']['sDEF']['lDEF'][$elementName]['vDEF'] = $flexFieldValue;
                    } catch (GeneratorNotFoundException $e) {
                        // No op if no matching generator was found
                    }
                }
            }
        }

        // Get string representation of result via FlexFormTools
        $resultString = '';
        if (!empty($resultArray)) {
            $resultString = $flexFormTools->flexArray2Xml($resultArray, true);
        }

        return $resultString;
    }
166208
public function normalizeFormData(array $data)
    {
        if (empty($data)) {
            return $data;
        }

        $renameMap = array_flip($this->renamemap);

        foreach ($renameMap as $customName => $defaultName) {
            if (array_key_exists($customName, $data)) {
                $value = $data[$customName];
                unset($data[$customName]);
                $data[$defaultName] = $value;
            }
        }

        return $data;
    }
19980
public function generate(array $data): string
    {
        /** @var RecordFinder $recordFinder */
        $recordFinder = GeneralUtility::makeInstance(RecordFinder::class);
        $demoImages = $recordFinder->findDemoFileObjects();
        $recordData = [];
        foreach ($demoImages as $demoImage) {
            $newId = StringUtility::getUniqueId('NEW');
            $recordData['sys_file_reference'][$newId] = [
                'table_local' => 'sys_file',
                'uid_local' => $demoImage->getUid(),
                'uid_foreign' => $data['fieldValues']['uid'],
                'tablenames' => $data['tableName'],
                'fieldname' => $data['fieldName'],
                'pid' => $data['fieldValues']['pid'],
            ];
        }
        if (!empty($recordData)) {
            // Populate page tree via recordDataHandler
            /** @var DataHandler $dataHandler */
            $dataHandler = GeneralUtility::makeInstance(DataHandler::class);
            $dataHandler->start($recordData, []);
            $dataHandler->process_datamap();
        }
        return (string)count($demoImages);
    }
535982
public static function fromArray(array $data)
    {
        $result = '';
        foreach ($data as $name => $value) {
            $value = StringHelper::toString($value, "'", Serialize::SERIALIZE_JSON);
            $result .= "$name=$value; ";
        }

        return $result === '' ? null : rtrim($result);
    }
622479
protected function formatTags(array $data = [], $colour = null)
    {
        $info = [];
        foreach ($data as $key => $value) {
            $length = isset($this->maxLengths[$key]) ? '-' . $this->maxLengths[$key] : '';
            if (!is_null($colour)) {
                $valueFormat = sprintf("<options=bold;fg=%s>%{$length}s</>", $colour, $value);
            } else {
                $valueFormat = sprintf("%{$length}s", $value);
            }
            if (is_int($key)) {
                $info[] = $valueFormat;
            } else {
                $info[] = sprintf("<info>%s</info>: %s", $key, $valueFormat);
            }
        }
        return implode(' ', $info);
    }
80889
public static function data_to_xml($data) {
        $xml = '';
        foreach ($data as $key => $val) {
            is_numeric($key) && $key = "item id=\"$key\"";
            $xml    .=  "<$key>";
            $xml    .=  ( is_array($val) || is_object($val)) ? self::data_to_xml($val)  : self::xmlSafeStr($val);
            list($key, ) = explode(' ', $key);
            $xml    .=  "</$key>";
        }
        return $xml;
    }
1342395
protected function dataFormalize($data)
	{
		if(is_array($data))
		{
			$data = json_encode($data);
		}
		else if($data instanceof \DOMDocument)
		{
			$data = $data->saveXML();
		}
		else if($data instanceof \SimpleXMLElement)
		{
			$data = $data->asXML();
		}
		return $data;
	}
1236522
final protected function sanitize($data)
    {
        // Recursively loop through the data array and return the sanitized data
        $sanitized = [];
        if (is_array($data)) {
            foreach ($data as $key => $value) {
                $sanitized[$key] = $this->sanitize($value);
            }
        } else {
            $sanitized = trim(strip_tags($data));
        }
        return $sanitized;
    }
1129230
public function generateForm(array $data)
	{
		/** @var Form $form */
		$form = new $this->formClass;

		if (array_key_exists('attributes', $data))
		{
			$form->setAttributes($data['attributes']);
		}

		if (array_key_exists('content', $data))
		{
			$content = $this->generate($data['content']);
			$form->setContents($content);
		}

		return $form;
	}
406893
protected function parseStringAsTemplate($data)
    {
        $t = $html = $data;

        while (preg_match("/[{]([^{}]+)[}]/", $t, $regs)) {
            $t = str_replace($regs[0], "", $t);

            $input = $this->generateValue($regs[1]);

            if ($input !== null && $input !== false && $input !== $regs[1]) {
                $html = str_replace($regs[0], (string)$input, $html);
            }
        }

        return $html;
    }
62492
private function generateYaml(array $data)
    {
        $fileContent = array();
        $header = array();
        foreach ($data as $path => $scopes) {
            $paths = explode('/', $path);
            if (!isset($header[$paths[0]])) {
                $header[$paths[0]] = true;
                $length = strlen($paths[0]) + 2;
                $fileContent[] = PHP_EOL . $this->getIndentation($length, '#') . PHP_EOL . '# ' . $paths[0] . PHP_EOL . $this->getIndentation($length, '#');
            }

            $fileContent[] = $path . ':';
            foreach ($scopes as $scope => $scopeValues) {
                $fileContent[] = $this->getIndentation(2) . $scope . ':';
                foreach ($scopeValues as $scopeId => $value) {
                    $fileContent[] = $this->getIndentation(4) . $scopeId . ': ' . $this->prepareValue($value);
                }
            }
        }

        return implode(PHP_EOL, $fileContent);
    }
872221
protected function _getData(array $data): array
    {
        // Stringify empty values
        if (!empty($data)) {
            foreach ($data as $fieldName => $value) {
                $data[$fieldName] = $this->_stringifyEmptyValue($value);
            }
        }

        return $data;
    }
1352219
public function encodeArray($data) {
        $d = array();
        foreach ($data as $key => $value) {
            if (is_string($key))
                $key = htmlspecialchars($key);
            if (is_string($value))
                $value = htmlspecialchars($value);
            elseif (is_array($value))
                $value = self::encodeArray($value);
            $d[$key] = $value;
        }
        return $d;
    }
1226439
public function to_xml($data){
        if(!is_array($data) || count($data) <= 0) throw new \Exception('xml data exception!');
        $xml = "<xml>";
        foreach ($data as $key=>$val){
            if (is_numeric($val)){
                $xml.="<".$key.">".$val."</".$key.">";
            }else{
                $xml.="<".$key."><![CDATA[".$val."]]></".$key.">";
            }
        }
        $xml.="</xml>";
        return $xml;
    }
754359
public function generatePlaceholders(array $data)
    {
        $placeholders = array();

        foreach ($data as $d) {
            if (is_float($d)) {
                $placeholders[] = '%f';
            } elseif (is_int($d)) {
                $placeholders[] = '%d';
            } else {
                $placeholders[] = '%s';
            }
        }

        return $placeholders;
    }