2 namespace TYPO3\CMS\Backend\Form\FormDataProvider;
46 protected function resolveItemProcessorFunction(array $result, $fieldName, array $items)
48 $table = $result[
'tableName'];
49 $config = $result[
'processedTca'][
'columns'][$fieldName][
'config'];
51 $pageTsProcessorParameters = null;
52 if (!empty($result[
'pageTsConfig'][
'TCEFORM.'][$table .
'.'][$fieldName .
'.'][
'itemsProcFunc.'])) {
53 $pageTsProcessorParameters = $result[
'pageTsConfig'][
'TCEFORM.'][$table .
'.'][$fieldName .
'.'][
'itemsProcFunc.'];
55 $processorParameters = [
59 'TSconfig' => $pageTsProcessorParameters,
61 'row' => $result[
'databaseRow'],
62 'field' => $fieldName,
64 if (!empty($result[
'flexParentDatabaseRow'])) {
65 $processorParameters[
'flexParentDatabaseRow'] = $result[
'flexParentDatabaseRow'];
73 $fieldLabel = $fieldName;
74 if (!empty($result[
'processedTca'][
'columns'][$fieldName][
'label'])) {
75 $fieldLabel = $languageService->sL($result[
'processedTca'][
'columns'][$fieldName][
'label']);
78 $languageService->sL(
'LLL:EXT:lang/locallang_core.xlf:error.items_proc_func_error'),
80 $exception->getMessage()
92 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
93 $defaultFlashMessageQueue->enqueue($flashMessage);
114 $table = $result[
'tableName'];
115 if (!empty($result[
'pageTsConfig'][
'TCEFORM.'][$table .
'.'][$fieldName .
'.'][
'addItems.'])
116 && is_array($result[
'pageTsConfig'][
'TCEFORM.'][$table .
'.'][$fieldName .
'.'][
'addItems.'])
118 $addItemsArray = $result[
'pageTsConfig'][
'TCEFORM.'][$table .
'.'][$fieldName .
'.'][
'addItems.'];
119 foreach ($addItemsArray as $value => $label) {
121 if (substr($value, -1) ===
'.') {
126 if (isset($addItemsArray[$value .
'.'])
127 && is_array($addItemsArray[$value .
'.'])
128 && !empty($addItemsArray[$value .
'.'][
'icon'])
130 $icon = $addItemsArray[$value .
'.'][
'icon'];
132 $items[] = array($label, $value, $icon);
152 if (empty($result[
'processedTca'][
'columns'][$fieldName][
'config'][
'special'])
153 || !is_string($result[
'processedTca'][
'columns'][$fieldName][
'config'][
'special'])
161 $special = $result[
'processedTca'][
'columns'][$fieldName][
'config'][
'special'];
163 case ($special ===
'tables'):
164 foreach (
$GLOBALS[
'TCA'] as $currentTable => $_) {
165 if (!empty(
$GLOBALS[
'TCA'][$currentTable][
'ctrl'][
'adminOnly'])) {
169 $label = !empty(
$GLOBALS[
'TCA'][$currentTable][
'ctrl'][
'title']) ?
$GLOBALS[
'TCA'][$currentTable][
'ctrl'][
'title'] :
'';
170 $icon = $iconFactory->mapRecordTypeToIconIdentifier($currentTable, []);
172 $languageService->loadSingleTableDescription($currentTable);
174 $helpTextArray =
$GLOBALS[
'TCA_DESCR'][$currentTable][
'columns'][
''];
175 if (!empty($helpTextArray[
'description'])) {
176 $helpText[
'description'] = $helpTextArray[
'description'];
178 $items[] = [$label, $currentTable, $icon, $helpText];
181 case ($special ===
'pagetypes'):
182 if (isset(
$GLOBALS[
'TCA'][
'pages'][
'columns'][
'doktype'][
'config'][
'items'])
183 && is_array(
$GLOBALS[
'TCA'][
'pages'][
'columns'][
'doktype'][
'config'][
'items'])
185 $specialItems =
$GLOBALS[
'TCA'][
'pages'][
'columns'][
'doktype'][
'config'][
'items'];
186 foreach ($specialItems as $specialItem) {
187 if (!is_array($specialItem) || $specialItem[1] ===
'--div--') {
191 $label = $specialItem[0];
192 $value = $specialItem[1];
193 $icon = $iconFactory->mapRecordTypeToIconIdentifier(
'pages', [
'doktype' => $specialItem[1]]);
194 $items[] = [$label, $value, $icon];
198 case ($special ===
'exclude'):
200 foreach ($excludeArrays as $excludeArray) {
202 if ($excludeArray[
'origin'] ===
'flexForm') {
205 if (!isset($items[$excludeArray[
'sectionHeader']])) {
207 $icon = $iconFactory->mapRecordTypeToIconIdentifier($excludeArray[
'table'], array());
208 $items[$excludeArray[
'sectionHeader']] = [
209 $excludeArray[
'sectionHeader'],
216 if (!isset($items[$excludeArray[
'table']])) {
217 $icon = $iconFactory->mapRecordTypeToIconIdentifier($excludeArray[
'table'], array());
218 $items[$excludeArray[
'table']] = [
219 $GLOBALS[
'TCA'][$excludeArray[
'table']][
'ctrl'][
'title'],
227 $languageService->loadSingleTableDescription($excludeArray[
'table']);
228 $helpTextArray =
$GLOBALS[
'TCA_DESCR'][$excludeArray[
'table']][
'columns'][$excludeArray[
'table']];
229 if (!empty($helpTextArray[
'description'])) {
230 $helpText[
'description'] = $helpTextArray[
'description'];
234 rtrim($excludeArray[
'origin'] ===
'flexForm' ? $excludeArray[
'fieldLabel'] : $languageService->sL(
$GLOBALS[
'TCA'][$excludeArray[
'table']][
'columns'][$excludeArray[
'fieldName']][
'label']),
':') .
' (' . $excludeArray[
'fieldName'] .
')',
235 $excludeArray[
'table'] .
':' . $excludeArray[
'fullField'] ,
241 case ($special ===
'explicitValues'):
244 'ALLOW' =>
'status-status-permission-granted',
245 'DENY' =>
'status-status-permission-denied'
248 foreach ($theTypes as $tableFieldKey => $theTypeArrays) {
249 if (is_array($theTypeArrays[
'items'])) {
252 $theTypeArrays[
'tableFieldLabel'],
256 foreach ($theTypeArrays[
'items'] as $itemValue => $itemContent) {
259 '[' . $itemContent[2] .
'] ' . $itemContent[1],
260 $tableFieldKey .
':' . preg_replace(
'/[:|,]/',
'', $itemValue) .
':' . $itemContent[0],
261 $icons[$itemContent[0]]
267 case ($special ===
'languages'):
268 foreach ($result[
'systemLanguageRows'] as $language) {
269 if ($language[
'uid'] !== -1) {
271 0 => $language[
'title'] .
' [' . $language[
'uid'] .
']',
272 1 => $language[
'uid'],
273 2 => $language[
'flagIconIdentifier']
278 case ($special ===
'custom'):
279 $customOptions =
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'customPermOptions'];
280 if (is_array($customOptions)) {
281 foreach ($customOptions as $coKey => $coValue) {
282 if (is_array($coValue[
'items'])) {
285 $languageService->sL($coValue[
'header']),
289 foreach ($coValue[
'items'] as $itemKey => $itemCfg) {
290 $icon =
'empty-empty';
292 if (!empty($itemCfg[2])) {
293 $helpText[
'description'] = $languageService->sL($itemCfg[2]);
296 $languageService->sL($itemCfg[0]),
297 $coKey .
':' . preg_replace(
'/[:|,]/',
'', $itemKey),
306 case ($special ===
'modListGroup' || $special ===
'modListUser'):
308 $loadModules->load(
$GLOBALS[
'TBE_MODULES']);
309 $modList = $special ===
'modListUser' ? $loadModules->modListUser : $loadModules->modListGroup;
310 if (is_array($modList)) {
311 foreach ($modList as $theMod) {
313 $icon = $languageService->moduleLabels[
'tabs_images'][$theMod .
'_tab'];
319 'title' => $languageService->moduleLabels[
'labels'][$theMod .
'_tablabel'],
320 'description' => $languageService->moduleLabels[
'labels'][$theMod .
'_tabdescr']
325 $pp = explode(
'_', $theMod);
326 if (count($pp) > 1) {
327 $label .= $languageService->moduleLabels[
'tabs'][($pp[0] .
'_tab')] .
'>';
330 $label .= $languageService->moduleLabels[
'tabs'][$theMod .
'_tab'];
333 $items[] = [$label, $theMod, $icon, $helpText];
338 throw new \UnexpectedValueException(
339 'Unknown special value ' . $special .
' for field ' . $fieldName .
' of table ' . $result[
'tableName'],
358 if (empty($result[
'processedTca'][
'columns'][$fieldName][
'config'][
'fileFolder'])
359 || !is_string($result[
'processedTca'][
'columns'][$fieldName][
'config'][
'fileFolder'])
364 $fileFolder = $result[
'processedTca'][
'columns'][$fieldName][
'config'][
'fileFolder'];
366 $fileFolder = rtrim($fileFolder,
'/') .
'/';
368 if (@is_dir($fileFolder)) {
369 $fileExtensionList =
'';
370 if (!empty($result[
'processedTca'][
'columns'][$fieldName][
'config'][
'fileFolder_extList'])
371 && is_string($result[
'processedTca'][
'columns'][$fieldName][
'config'][
'fileFolder_extList'])
373 $fileExtensionList = $result[
'processedTca'][
'columns'][$fieldName][
'config'][
'fileFolder_extList'];
375 $recursionLevels = isset($fieldValue[
'config'][
'fileFolder_recursions'])
380 foreach ($fileArray as $fileReference) {
381 $fileInformation = pathinfo($fileReference);
406 protected function addItemsFromForeignTable(array $result, $fieldName, array $items)
409 if (empty($result[
'processedTca'][
'columns'][$fieldName][
'config'][
'foreign_table'])
410 || !is_string($result[
'processedTca'][
'columns'][$fieldName][
'config'][
'foreign_table'])
418 $foreignTable = $result[
'processedTca'][
'columns'][$fieldName][
'config'][
'foreign_table'];
420 $queryResource = $database->exec_SELECT_queryArray($foreignTableQueryArray);
423 $databaseError = $database->sql_error();
424 if (!empty($databaseError)) {
425 $msg = htmlspecialchars($databaseError) .
'<br />' . LF;
426 $msg .= $languageService->sL(
'LLL:EXT:lang/locallang_core.xlf:error.database_schema_mismatch');
427 $msgTitle = $languageService->sL(
'LLL:EXT:lang/locallang_core.xlf:error.database_schema_mismatch_title');
433 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
434 $defaultFlashMessageQueue->enqueue($flashMessage);
435 $database->sql_free_result($queryResource);
440 if (!empty($result[
'processedTca'][
'columns'][$fieldName][
'config'][
'foreign_table_prefix'])) {
441 $labelPrefix = $result[
'processedTca'][
'columns'][$fieldName][
'config'][
'foreign_table_prefix'];
442 $labelPrefix = $languageService->sL($labelPrefix);
445 if (!empty($result[
'processedTca'][
'ctrl'][
'selicon_field'])) {
446 $iconFieldName = $result[
'processedTca'][
'ctrl'][
'selicon_field'];
449 if (!empty($result[
'processedTca'][
'ctrl'][
'selicon_field_path'])) {
450 $iconPath = $result[
'processedTca'][
'ctrl'][
'selicon_field_path'];
455 while ($foreignRow = $database->sql_fetch_assoc($queryResource)) {
457 if (is_array($foreignRow)) {
459 if ($iconFieldName && $iconPath && $foreignRow[$iconFieldName]) {
461 $icon =
'../' . $iconPath .
'/' . trim($iParts[0]);
463 $icon = $iconFactory->mapRecordTypeToIconIdentifier($foreignTable, $foreignRow);
474 $database->sql_free_result($queryResource);
491 $table = $result[
'tableName'];
492 if (!isset($result[
'pageTsConfig'][
'TCEFORM.'][$table .
'.'][$fieldName .
'.'][
'keepItems'])
493 || !is_string($result[
'pageTsConfig'][
'TCEFORM.'][$table .
'.'][$fieldName .
'.'][
'keepItems'])
499 if (empty($result[
'pageTsConfig'][
'TCEFORM.'][$table .
'.'][$fieldName .
'.'][
'keepItems'])
500 && $result[
'pageTsConfig'][
'TCEFORM.'][$table .
'.'][$fieldName .
'.'][
'keepItems'] !==
'0') {
506 $result[
'pageTsConfig'][
'TCEFORM.'][$table .
'.'][$fieldName .
'.'][
'keepItems'],
525 $table = $result[
'tableName'];
526 if (empty($result[
'pageTsConfig'][
'TCEFORM.'][$table .
'.'][$fieldName .
'.'][
'removeItems'])
527 || !is_string($result[
'pageTsConfig'][
'TCEFORM.'][$table .
'.'][$fieldName .
'.'][
'removeItems'])
534 $result[
'pageTsConfig'][
'TCEFORM.'][$table .
'.'][$fieldName .
'.'][
'removeItems'],
537 foreach ($items as $key => $itemValues) {
538 if (in_array($itemValues[1], $removeItems)) {
559 if (empty($result[
'processedTca'][
'ctrl'][
'languageField'])
560 || $result[
'processedTca'][
'ctrl'][
'languageField'] !== $fieldName
566 foreach ($items as $key => $itemValues) {
567 if (!$backendUser->checkLanguageAccess($itemValues[1])) {
588 if (!isset($result[
'processedTca'][
'columns'][$fieldName][
'config'][
'authMode'])
589 || !is_string($result[
'processedTca'][
'columns'][$fieldName][
'config'][
'authMode'])
595 $authMode = $result[
'processedTca'][
'columns'][$fieldName][
'config'][
'authMode'];
596 foreach ($items as $key => $itemValues) {
598 if (!$backendUser->checkAuthMode($result[
'tableName'], $fieldName, $itemValues[1], $authMode)) {
618 $table = $result[
'tableName'];
621 if ($table !==
'pages' && $table !==
'pages_language_overlay'
622 || $fieldName !==
'doktype' || $backendUser->isAdmin()
627 $allowedPageTypes = $backendUser->groupData[
'pagetypes_select'];
628 foreach ($items as $key => $itemValues) {
647 $finalExcludeArray = [];
650 $tableToTranslation = [];
652 foreach (
$GLOBALS[
'TCA'] as $table => $conf) {
653 $tableToTranslation[$table] = $languageService->sL($conf[
'ctrl'][
'title']);
656 asort($tableToTranslation);
657 foreach ($tableToTranslation as $table => $translatedTable) {
658 $excludeArrayTable = [];
661 if (is_array(
$GLOBALS[
'TCA'][$table][
'columns'])
662 && empty(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'adminOnly'])
663 && (empty(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'rootLevel']) || !empty(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'security'][
'ignoreRootLevelRestriction']))
665 foreach (
$GLOBALS[
'TCA'][$table][
'columns'] as $field => $_) {
666 if (
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'exclude']) {
668 $translatedField = $languageService->sL(
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'label']);
670 $excludeArrayTable[] = [
671 'labels' => $translatedTable .
':' . $translatedField,
672 'sectionHeader' => $translatedTable,
674 'tableField' => $field,
675 'fieldName' => $field,
676 'fullField' => $field,
677 'fieldLabel' => $translatedField,
685 foreach ($flexFormArray as $tableField => $flexForms) {
688 if (!empty(
$GLOBALS[
'TCA'][$table][
'columns'][$tableField][
'label'])) {
689 $labelPrefix = $languageService->sL(
$GLOBALS[
'TCA'][$table][
'columns'][$tableField][
'label']);
692 foreach ($flexForms as $extIdent =>
$extConf) {
693 $extTitle = $languageService->sl(trim(
$extConf[
'title']));
695 foreach (
$extConf[
'ds'][
'sheets'] as $sheetName => $sheet) {
696 if (empty($sheet[
'ROOT'][
'el']) || !is_array($sheet[
'ROOT'][
'el'])) {
699 foreach ($sheet[
'ROOT'][
'el'] as $pluginFieldName => $field) {
701 if (empty($field[
'TCEforms'][
'exclude'])) {
704 $fieldLabel = !empty($field[
'TCEforms'][
'label'])
705 ? $languageService->sL($field[
'TCEforms'][
'label'])
707 $excludeArrayTable[] = [
708 'labels' => trim($translatedTable .
' ' . $labelPrefix .
' ' . $extIdent,
': ') .
':' . $fieldLabel,
709 'sectionHeader' => trim(($translatedTable .
' ' . $labelPrefix .
' ' . $extIdent),
':'),
711 'tableField' => $tableField,
712 'extIdent' => $extIdent,
713 'fieldName' => $pluginFieldName,
714 'fullField' => $tableField .
';' . $extIdent .
';' . $sheetName .
';' . $pluginFieldName,
715 'fieldLabel' => $fieldLabel,
716 'origin' =>
'flexForm',
723 if (!empty($excludeArrayTable)) {
724 usort($excludeArrayTable,
function (array $array1, array $array2) {
725 $array1 = reset($array1);
726 $array2 = reset($array2);
727 if (is_string($array1) && is_string($array2)) {
728 return strcasecmp($array1, $array2);
732 $finalExcludeArray = array_merge($finalExcludeArray, $excludeArrayTable);
736 return $finalExcludeArray;
747 if (empty($table) || empty(
$GLOBALS[
'TCA'][$table][
'columns'])) {
751 foreach (
$GLOBALS[
'TCA'][$table][
'columns'] as $tableField => $fieldConf) {
752 if (!empty($fieldConf[
'config'][
'type']) && !empty($fieldConf[
'config'][
'ds']) && $fieldConf[
'config'][
'type'] ==
'flex') {
753 $flexForms[$tableField] = [];
755 $pointerFields = !empty($fieldConf[
'config'][
'ds_pointerField']) ? $fieldConf[
'config'][
'ds_pointerField'] :
'list_type,CType,default';
758 foreach ($fieldConf[
'config'][
'ds'] as $flexFormKey => $dataStructure) {
761 $extIdent = $identFields[0];
762 if (!empty($identFields[1]) && $identFields[1] !==
'list' && $identFields[1] !==
'*') {
763 $extIdent = $identFields[1];
766 if (!is_array($dataStructure)) {
768 if ($file && @is_file($file)) {
772 if (!is_array($dataStructure)) {
778 if (empty($dataStructure[
'sheets']) || !is_array($dataStructure[
'sheets'])) {
785 foreach ($pointerFields as $pointerKey => $pointerName) {
786 if (empty($keyFields[$pointerKey])
787 || $keyFields[$pointerKey] ===
'*'
788 || $keyFields[$pointerKey] ===
'list'
789 || $keyFields[$pointerKey] ===
'default'
793 if (!empty(
$GLOBALS[
'TCA'][$table][
'columns'][$pointerName][
'config'][
'items'])) {
794 $items =
$GLOBALS[
'TCA'][$table][
'columns'][$pointerName][
'config'][
'items'];
795 if (!is_array($items)) {
798 foreach ($items as $itemConf) {
799 if (!empty($itemConf[0]) && !empty($itemConf[1]) && $itemConf[1] == $keyFields[$pointerKey]) {
800 $title = $itemConf[0];
806 $flexForms[$tableField][$extIdent] = [
808 'ds' => $dataStructure
824 $languageService = static::getLanguageService();
826 'ALLOW' => $languageService->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.allow'),
827 'DENY' => $languageService->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.deny')
829 $allowDenyOptions = [];
830 foreach (
$GLOBALS[
'TCA'] as $table => $_) {
832 if (is_array(
$GLOBALS[
'TCA'][$table][
'columns'])) {
833 foreach (
$GLOBALS[
'TCA'][$table][
'columns'] as $field => $__) {
834 $fieldConfig =
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
835 if ($fieldConfig[
'type'] ===
'select' && $fieldConfig[
'authMode']) {
837 if (is_array($fieldConfig[
'items'])) {
839 $allowDenyOptions[$table .
':' . $field][
'tableFieldLabel'] =
840 $languageService->sL(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'title']) .
': '
841 . $languageService->sL(
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'label']);
842 foreach ($fieldConfig[
'items'] as $iVal) {
844 if ((
string)$iVal[1] !==
'') {
847 switch ((
string)$fieldConfig[
'authMode']) {
848 case 'explicitAllow':
855 if ($iVal[4] ===
'EXPL_ALLOW') {
857 }
elseif ($iVal[4] ===
'EXPL_DENY') {
864 $allowDenyOptions[$table .
':' . $field][
'items'][$iVal[1]] = [
866 $languageService->sL($iVal[0]),
877 return $allowDenyOptions;
892 $foreignTableName = $result[
'processedTca'][
'columns'][$localFieldName][
'config'][
'foreign_table'];
894 if (!is_array(
$GLOBALS[
'TCA'][$foreignTableName])) {
895 throw new \UnexpectedValueException(
896 'Field ' . $localFieldName .
' of table ' . $result[
'tableName'] .
' reference to foreign table '
897 . $foreignTableName .
', but this table is not defined in TCA',
911 if (isset(
$GLOBALS[
'TCA'][$foreignTableName][
'ctrl'][
'rootLevel'])) {
912 $rootLevel =
$GLOBALS[
'TCA'][$foreignTableName][
'ctrl'][
'rootLevel'];
915 if ($rootLevel == 1 || $rootLevel == -1) {
916 $pidWhere = $foreignTableName .
'.pid' . (($rootLevel == -1) ?
'<>-1' :
'=0');
917 $queryArray[
'FROM'] = $foreignTableName;
918 $queryArray[
'WHERE'] = $pidWhere . $deleteClause . $foreignTableClauseArray[
'WHERE'];
920 $pageClause = $backendUser->getPagePermsClause(1);
921 if ($foreignTableName ===
'pages') {
922 $queryArray[
'FROM'] =
'pages';
923 $queryArray[
'WHERE'] =
'1=1' . $deleteClause .
' AND' . $pageClause . $foreignTableClauseArray[
'WHERE'];
925 $queryArray[
'FROM'] = $foreignTableName .
', pages';
926 $queryArray[
'WHERE'] =
'pages.uid=' . $foreignTableName .
'.pid AND pages.deleted=0'
927 . $deleteClause .
' AND' . $pageClause . $foreignTableClauseArray[
'WHERE'];
931 $queryArray[
'GROUPBY'] = $foreignTableClauseArray[
'GROUPBY'];
932 $queryArray[
'ORDERBY'] = $foreignTableClauseArray[
'ORDERBY'];
933 $queryArray[
'LIMIT'] = $foreignTableClauseArray[
'LIMIT'];
957 $localTable = $result[
'tableName'];
959 $foreignTableClause =
'';
960 if (!empty($result[
'processedTca'][
'columns'][$localFieldName][
'config'][
'foreign_table_where'])
961 && is_string($result[
'processedTca'][
'columns'][$localFieldName][
'config'][
'foreign_table_where'])
963 $foreignTableClause = $result[
'processedTca'][
'columns'][$localFieldName][
'config'][
'foreign_table_where'];
965 if (strstr($foreignTableClause,
'###REC_FIELD_')) {
967 $whereClauseParts = explode(
'###REC_FIELD_', $foreignTableClause);
968 foreach ($whereClauseParts as $key => $value) {
971 $whereClauseSubParts = explode(
'###', $value, 2);
973 $rowFieldValue = $result[
'databaseRow'][$whereClauseSubParts[0]];
974 if (is_array($rowFieldValue)) {
977 $rowFieldValue = $rowFieldValue[0];
979 if (substr($whereClauseParts[0], -1) ===
'\'' && $whereClauseSubParts[1][0] ===
'\'') {
980 $whereClauseParts[$key] = $database->quoteStr($rowFieldValue, $foreignTableName) . $whereClauseSubParts[1];
982 $whereClauseParts[$key] = $database->fullQuoteStr($rowFieldValue, $foreignTableName) . $whereClauseSubParts[1];
986 $foreignTableClause = implode(
'', $whereClauseParts);
990 foreach ($result[
'rootline'] as $rootlinePage) {
991 if (!empty($rootlinePage[
'is_siteroot'])) {
992 $siteRootUid = (int)$rootlinePage[
'uid'];
997 if ($result[
'pageTsConfig'][
'TCEFORM.'][$localTable .
'.'][$localFieldName .
'.'][
'PAGE_TSCONFIG_ID']) {
998 $pageTsConfigId = (int)$result[
'pageTsConfig'][
'TCEFORM.'][$localTable .
'.'][$localFieldName .
'.'][
'PAGE_TSCONFIG_ID'];
1000 $pageTsConfigIdList = 0;
1001 if ($result[
'pageTsConfig'][
'TCEFORM.'][$localTable .
'.'][$localFieldName .
'.'][
'PAGE_TSCONFIG_IDLIST']) {
1002 $pageTsConfigIdList = $result[
'pageTsConfig'][
'TCEFORM.'][$localTable .
'.'][$localFieldName .
'.'][
'PAGE_TSCONFIG_IDLIST'];
1004 $pageTsConfigIdList = [];
1005 foreach ($pageTsConfigIdListArray as $pageTsConfigIdListElement) {
1007 $pageTsConfigIdList[] = (int)$pageTsConfigIdListElement;
1010 $pageTsConfigIdList = implode(
',', $pageTsConfigIdList);
1012 $pageTsConfigString =
'';
1013 if ($result[
'pageTsConfig'][
'TCEFORM.'][$localTable .
'.'][$localFieldName .
'.'][
'PAGE_TSCONFIG_STR']) {
1014 $pageTsConfigString = $result[
'pageTsConfig'][
'TCEFORM.'][$localTable .
'.'][$localFieldName .
'.'][
'PAGE_TSCONFIG_STR'];
1015 $pageTsConfigString = $database->quoteStr($pageTsConfigString, $foreignTableName);
1018 $foreignTableClause = str_replace(
1020 '###CURRENT_PID###',
1023 '###PAGE_TSCONFIG_ID###',
1024 '###PAGE_TSCONFIG_IDLIST###',
1025 '###PAGE_TSCONFIG_STR###'
1028 (
int)$result[
'effectivePid'],
1029 (
int)$result[
'databaseRow'][
'uid'],
1032 $pageTsConfigIdList,
1041 $foreignTableClause =
' ' . $foreignTableClause;
1042 $foreignTableClauseArray = [
1050 if (preg_match(
'/^(.*)[[:space:]]+LIMIT[[:space:]]+([[:alnum:][:space:],._]+)$/i', $foreignTableClause, $reg)) {
1051 $foreignTableClauseArray[
'LIMIT'] = trim($reg[2]);
1052 $foreignTableClause = $reg[1];
1056 if (preg_match(
'/^(.*)[[:space:]]+ORDER[[:space:]]+BY[[:space:]]+([[:alnum:][:space:],._]+)$/i', $foreignTableClause, $reg)) {
1057 $foreignTableClauseArray[
'ORDERBY'] = trim($reg[2]);
1058 $foreignTableClause = $reg[1];
1062 if (preg_match(
'/^(.*)[[:space:]]+GROUP[[:space:]]+BY[[:space:]]+([[:alnum:][:space:],._]+)$/i', $foreignTableClause, $reg)) {
1063 $foreignTableClauseArray[
'GROUPBY'] = trim($reg[2]);
1064 $foreignTableClause = $reg[1];
1067 $foreignTableClauseArray[
'WHERE'] = $foreignTableClause;
1069 return $foreignTableClauseArray;
1081 $currentDatabaseValues = array_key_exists($fieldName, $row)
1098 protected function processSelectFieldValue(array $result, $fieldName, array $staticValues)
1100 $fieldConfig = $result[
'processedTca'][
'columns'][$fieldName];
1102 $currentDatabaseValueArray = array_key_exists($fieldName, $result[
'databaseRow']) ? $result[
'databaseRow'][$fieldName] : [];
1103 $newDatabaseValueArray = [];
1107 foreach ($currentDatabaseValueArray as $value) {
1108 if (isset($staticValues[$value])) {
1109 $newDatabaseValueArray[] = $value;
1113 if (isset($fieldConfig[
'config'][
'foreign_table']) && !empty($fieldConfig[
'config'][
'foreign_table'])) {
1116 $relationHandler->registerNonTableValues = !empty($fieldConfig[
'config'][
'allowNonIdValues']);
1117 if (!empty($fieldConfig[
'config'][
'MM']) && $result[
'command'] !==
'new') {
1119 $relationHandler->start(
1120 implode(
',', $currentDatabaseValueArray),
1121 $fieldConfig[
'config'][
'foreign_table'],
1122 $fieldConfig[
'config'][
'MM'],
1123 $result[
'databaseRow'][
'uid'],
1124 $result[
'tableName'],
1125 $fieldConfig[
'config']
1130 $relationHandler->start(
1131 implode(
',', $currentDatabaseValueArray),
1132 $fieldConfig[
'config'][
'foreign_table'],
1135 $result[
'tableName'],
1136 $fieldConfig[
'config']
1139 $newDatabaseValueArray = array_merge($newDatabaseValueArray, $relationHandler->getValueArray());
1142 return array_unique($newDatabaseValueArray);
1160 foreach ($itemArray as $key => $item) {
1161 if (!isset($dynamicItems[$key])) {
1162 $staticValues[$item[1]] = $item;
1164 if (isset($result[
'pageTsConfig'][
'TCEFORM.'][$table .
'.'][$fieldName .
'.'][
'altLabels.'][$item[1]])
1165 && !empty($result[
'pageTsConfig'][
'TCEFORM.'][$table .
'.'][$fieldName .
'.'][
'altLabels.'][$item[1]])
1167 $label = $languageService->sL($result[
'pageTsConfig'][
'TCEFORM.'][$table .
'.'][$fieldName .
'.'][
'altLabels.'][$item[1]]);
1169 $label = $languageService->sL(trim($item[0]));
1171 $value = strlen((
string)$item[1]) > 0 ? $item[1] :
'';
1172 $icon = $item[2] ?: null;
1173 $helpText = $item[3] ?: null;
1174 $itemArray[$key] = [
1198 if (!is_array($itemArray)) {
1201 foreach ($itemArray as $item) {
1202 if (!is_array($item)) {
1203 throw new \UnexpectedValueException(
1204 'An item in field ' . $fieldName .
' of table ' . $tableName .
' is not an array as expected',
1223 if (!empty($maxItems)
1224 && (
int)$maxItems > 1
1226 $maxItems = (int)$maxItems;
1244 $table = $result[
'tableName'];
1245 $row = $result[
'databaseRow'];
1247 if (!empty($result[
'processedTca'][
'ctrl'][
'versioningWS'])
1248 && $result[
'pid'] === -1
1250 if (empty($row[
't3ver_oid'])) {
1251 throw new \UnexpectedValueException(
1252 'No t3ver_oid found for record ' . $row[
'uid'] .
' on table ' . $table,
1256 $uid = $row[
't3ver_oid'];
1273 foreach ($itemArray as $key => $item) {
1274 if (!isset($dynamicItemArray[$key])) {
1275 $staticValues[$item[1]] = $item;
1278 return $staticValues;