42 foreach ($result[
'processedTca'][
'columns'] as $fieldName => $fieldConfig) {
43 if (empty($fieldConfig[
'config'][
'type'])
44 || $fieldConfig[
'config'][
'type'] !==
'group'
45 || empty($fieldConfig[
'config'][
'internal_type'])
52 $fieldConfig[
'config'][
'maxitems'] ?? 0,
56 if ($result[
'processedTca'][
'columns'][$fieldName][
'config'][
'maxitems'] === 0) {
57 $result[
'processedTca'][
'columns'][$fieldName][
'config'][
'maxitems'] = 99999;
60 $databaseRowFieldContent =
'';
61 if (!empty($result[
'databaseRow'][$fieldName])) {
62 $databaseRowFieldContent = (string)$result[
'databaseRow'][$fieldName];
66 $sanitizedClipboardElements = [];
67 $internalType = $fieldConfig[
'config'][
'internal_type'];
69 if ($internalType ===
'file_reference' || $internalType ===
'file') {
72 if (empty($fieldConfig[
'config'][
'allowed'])) {
73 $result[
'processedTca'][
'columns'][$fieldName][
'config'][
'allowed'] =
'*';
76 if ($internalType ===
'file_reference') {
77 $result[
'processedTca'][
'columns'][$fieldName][
'config'][
'uploadfolder'] =
'';
81 $fileList = GeneralUtility::trimExplode(
',', $databaseRowFieldContent,
true);
83 foreach ($fileList as $uidOrPath) {
85 'uidOrPath' => $uidOrPath,
86 'title' => $uidOrPath,
90 $fileObject = $fileFactory->getFileObject($uidOrPath);
91 $item[
'title'] = $fileObject->getName();
100 $allowed = GeneralUtility::trimExplode(
',', $result[
'processedTca'][
'columns'][$fieldName][
'config'][
'allowed'],
true);
101 $clipboard = GeneralUtility::makeInstance(Clipboard::class);
102 $clipboard->initializeClipboard();
103 $clipboardElements = $clipboard->elFromTable(
'_FILE');
104 if ($allowed[0] !==
'*') {
106 foreach ($clipboardElements as $elementValue) {
107 $pathInfo = pathinfo($elementValue);
108 if (in_array(strtolower($pathInfo[
'extension']), $allowed)) {
109 $sanitizedClipboardElements[] = [
110 'title' => $elementValue,
111 'value' => $elementValue,
118 foreach ($clipboardElements as $elementValue) {
119 $sanitizedClipboardElements[] = [
120 'title' => $elementValue,
121 'value' => $elementValue,
125 } elseif ($internalType ===
'db') {
126 if (empty($fieldConfig[
'config'][
'allowed'])) {
127 throw new \RuntimeException(
128 'Mandatory TCA config setting "allowed" missing in field "' . $fieldName .
'" of table "' . $result[
'tableName'] .
'"',
136 $relationHandler = GeneralUtility::makeInstance(RelationHandler::class);
137 $relationHandler->start(
138 $databaseRowFieldContent,
139 $fieldConfig[
'config'][
'allowed'],
140 $fieldConfig[
'config'][
'MM'],
142 $result[
'tableName'],
143 $fieldConfig[
'config']
145 $relationHandler->getFromDB();
146 $relations = $relationHandler->getResolvedItemArray();
147 foreach ($relations as $relation) {
148 $tableName = $relation[
'table'];
149 $uid = $relation[
'uid'];
153 'table' => $tableName,
154 'uid' => $record[
'uid'] ??
null,
161 $allowed = GeneralUtility::trimExplode(
',', $fieldConfig[
'config'][
'allowed'],
true);
162 $clipboard = GeneralUtility::makeInstance(Clipboard::class);
163 $clipboard->initializeClipboard();
164 if ($allowed[0] !==
'*') {
166 foreach ($allowed as $tablename) {
167 foreach ($clipboard->elFromTable($tablename) as $recordUid) {
169 $sanitizedClipboardElements[] = [
171 'value' => $tablename .
'_' . $recordUid,
177 $clipboardElements = array_keys($clipboard->elFromTable(
''));
178 foreach ($clipboardElements as $elementValue) {
179 list($elementTable, $elementUid) = explode(
'|', $elementValue);
181 $sanitizedClipboardElements[] = [
183 'value' => $elementTable .
'_' . $elementUid,
187 } elseif ($internalType ===
'folder') {
189 $folderList = GeneralUtility::trimExplode(
',', $databaseRowFieldContent,
true);
190 foreach ($folderList as $folder) {
191 if (empty($folder)) {
196 if ($folderObject instanceof
Folder) {
206 throw new \UnexpectedValueException(
207 'TCA internal_type of field "' . $fieldName .
'" in table ' . $result[
'tableName']
208 .
' must be set to either "db", "file" or "file_reference"',
213 $result[
'databaseRow'][$fieldName] = $items;
214 $result[
'processedTca'][
'columns'][$fieldName][
'config'][
'clipboardElements'] = $sanitizedClipboardElements;