2 declare(strict_types = 1);
47 foreach ($result[
'processedTca'][
'columns'] as $fieldName => $fieldConfig) {
51 $childTableName = $fieldConfig[
'config'][
'foreign_table'] ??
'';
52 if (!in_array($childTableName, [
'site_errorhandling',
'site_language',
'site_route',
'site_base_variant'],
true)) {
53 throw new \RuntimeException(
'Inline relation to other tables not implemented', 1522494737);
55 $result[
'processedTca'][
'columns'][$fieldName][
'children'] = [];
71 return !empty($fieldConfig[
'config'][
'type']) && $fieldConfig[
'config'][
'type'] ===
'inline';
84 if ($result[
'inlineFirstPid'] ===
null) {
85 $table = $result[
'tableName'];
86 $row = $result[
'databaseRow'];
88 if ($table ===
'pages') {
90 $pid = $liveVersionId ?? $row[
'uid'];
91 } elseif (($row[
'pid'] ?? 0) < 0) {
93 $pid = $prevRec[
'pid'];
95 $pid = $row[
'pid'] ?? 0;
99 if ((
int)$pageRecord[
$GLOBALS[
'TCA'][
'pages'][
'ctrl'][
'transOrigPointerField']] > 0) {
100 $pid = (int)$pageRecord[
$GLOBALS[
'TCA'][
'pages'][
'ctrl'][
'transOrigPointerField']];
102 } elseif (strpos($pid,
'NEW') !== 0) {
103 throw new \RuntimeException(
104 'inlineFirstPid should either be an integer or a "NEW..." string',
108 $result[
'inlineFirstPid'] = $pid;
124 if ($result[
'command'] ===
'edit') {
125 $siteConfigurationForPageUid = (int)$result[
'databaseRow'][
'rootPageId'][0];
126 $siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
128 $site = $siteFinder->getSiteByRootPageId($siteConfigurationForPageUid);
132 $siteConfiguration = $site ? $site->getConfiguration() : [];
133 if (is_array($siteConfiguration[$fieldName])) {
134 $connectedUids = array_keys($siteConfiguration[$fieldName]);
139 $foreignTable = $result[
'processedTca'][
'columns'][$fieldName][
'config'][
'foreign_table'];
140 if ($foreignTable ===
'site_language' && $result[
'command'] ===
'new') {
143 $connectedUids[] = $child[
'databaseRow'][
'uid'];
144 $result[
'processedTca'][
'columns'][$fieldName][
'children'][] = $child;
147 $result[
'databaseRow'][$fieldName] = implode(
',', $connectedUids);
148 if ($result[
'inlineCompileExistingChildren']) {
149 foreach ($connectedUids as $uid) {
150 if (strpos((
string)$uid,
'NEW') !== 0) {
151 $compiledChild = $this->
compileChild($result, $fieldName, $uid);
152 $result[
'processedTca'][
'columns'][$fieldName][
'children'][] = $compiledChild;
158 if ($foreignTable ===
'site_language' && $result[
'command'] ===
'edit') {
160 $defaultSysSiteLanguageChildFound =
false;
161 foreach ($result[
'processedTca'][
'columns'][$fieldName][
'children'] as $child) {
162 if (isset($child[
'databaseRow'][
'languageId']) && (
int)$child[
'databaseRow'][
'languageId'][0] == 0) {
163 $defaultSysSiteLanguageChildFound =
true;
166 if (!$defaultSysSiteLanguageChildFound) {
169 $result[
'databaseRow'][$fieldName] = $child[
'databaseRow'][
'uid'] .
',' . $result[
'databaseRow'][$fieldName];
170 array_unshift($result[
'processedTca'][
'columns'][$fieldName][
'children'], $child);
188 if (!is_array($result[
'processedTca'][
'columns'][$fieldName][
'config'][
'selectorOrUniqueConfiguration'])) {
192 $selectorOrUniqueConfiguration = $result[
'processedTca'][
'columns'][$fieldName][
'config'][
'selectorOrUniqueConfiguration'];
193 $foreignFieldName = $selectorOrUniqueConfiguration[
'fieldName'];
194 $selectorOrUniquePossibleRecords = [];
196 if ($selectorOrUniqueConfiguration[
'config'][
'type'] ===
'select') {
199 'tableName' => $result[
'processedTca'][
'columns'][$fieldName][
'config'][
'foreign_table'],
203 'pageTsConfig' => $result[
'pageTsConfig'],
204 'userTsConfig' => $result[
'userTsConfig'],
205 'databaseRow' => $result[
'databaseRow'],
209 $foreignFieldName => [
210 'config' => $selectorOrUniqueConfiguration[
'config'],
214 'inlineExpandCollapseStateArray' => $result[
'inlineExpandCollapseStateArray'],
216 $formDataGroup = GeneralUtility::makeInstance(OnTheFly::class);
217 $formDataGroup->setProviderList([TcaSelectItems::class]);
218 $formDataCompiler = GeneralUtility::makeInstance(FormDataCompiler::class, $formDataGroup);
219 $compilerResult = $formDataCompiler->compile($selectDataInput);
220 $selectorOrUniquePossibleRecords = $compilerResult[
'processedTca'][
'columns'][$foreignFieldName][
'config'][
'items'];
223 $result[
'processedTca'][
'columns'][$fieldName][
'config'][
'selectorOrUniquePossibleRecords'] = $selectorOrUniquePossibleRecords;
236 protected function compileChild(array $result,
string $parentFieldName,
int $childUid): array
238 $parentConfig = $result[
'processedTca'][
'columns'][$parentFieldName][
'config'];
239 $childTableName = $parentConfig[
'foreign_table'];
241 $inlineStackProcessor = GeneralUtility::makeInstance(InlineStackProcessor::class);
242 $inlineStackProcessor->initializeByGivenStructure($result[
'inlineStructure']);
243 $inlineTopMostParent = $inlineStackProcessor->getStructureLevel(0);
245 $formDataGroup = GeneralUtility::makeInstance(SiteConfigurationDataGroup::class);
246 $formDataCompiler = GeneralUtility::makeInstance(FormDataCompiler::class, $formDataGroup);
247 $formDataCompilerInput = [
249 'tableName' => $childTableName,
250 'vanillaUid' => $childUid,
254 'returnUrl' => $result[
'returnUrl'],
255 'isInlineChild' =>
true,
256 'inlineStructure' => $result[
'inlineStructure'],
257 'inlineExpandCollapseStateArray' => $result[
'inlineExpandCollapseStateArray'],
258 'inlineFirstPid' => $result[
'inlineFirstPid'],
259 'inlineParentConfig' => $parentConfig,
263 'inlineParentUid' => $result[
'databaseRow'][
'uid'],
264 'inlineParentTableName' => $result[
'tableName'],
265 'inlineParentFieldName' => $parentFieldName,
268 'inlineTopMostParentUid' => $result[
'inlineTopMostParentUid'] ?: $inlineTopMostParent[
'uid'],
269 'inlineTopMostParentTableName' => $result[
'inlineTopMostParentTableName'] ?: $inlineTopMostParent[
'table'],
270 'inlineTopMostParentFieldName' => $result[
'inlineTopMostParentFieldName'] ?: $inlineTopMostParent[
'field'],
273 if ($parentConfig[
'foreign_selector'] && ($parentConfig[
'appearance'][
'useCombination'] ??
false)) {
274 throw new \RuntimeException(
'useCombination not implemented in sites module', 1522493097);
276 return $formDataCompiler->compile($formDataCompilerInput);
288 $parentConfig = $result[
'processedTca'][
'columns'][$parentFieldName][
'config'];
289 $inlineStackProcessor = GeneralUtility::makeInstance(InlineStackProcessor::class);
290 $inlineStackProcessor->initializeByGivenStructure($result[
'inlineStructure']);
291 $inlineTopMostParent = $inlineStackProcessor->getStructureLevel(0);
292 $formDataGroup = GeneralUtility::makeInstance(SiteConfigurationDataGroup::class);
293 $formDataCompiler = GeneralUtility::makeInstance(FormDataCompiler::class, $formDataGroup);
294 $formDataCompilerInput = [
296 'tableName' =>
'site_language',
297 'vanillaUid' => $result[
'inlineFirstPid'],
298 'returnUrl' => $result[
'returnUrl'],
299 'isInlineChild' =>
true,
300 'inlineStructure' => [],
301 'inlineExpandCollapseStateArray' => $result[
'inlineExpandCollapseStateArray'],
302 'inlineFirstPid' => $result[
'inlineFirstPid'],
303 'inlineParentConfig' => $parentConfig,
304 'inlineParentUid' => $result[
'databaseRow'][
'uid'],
305 'inlineParentTableName' => $result[
'tableName'],
306 'inlineParentFieldName' => $parentFieldName,
307 'inlineTopMostParentUid' => $result[
'inlineTopMostParentUid'] ?: $inlineTopMostParent[
'uid'],
308 'inlineTopMostParentTableName' => $result[
'inlineTopMostParentTableName'] ?: $inlineTopMostParent[
'table'],
309 'inlineTopMostParentFieldName' => $result[
'inlineTopMostParentFieldName'] ?: $inlineTopMostParent[
'field'],
311 'inlineChildChildUid' => 0,
313 return $formDataCompiler->compile($formDataCompilerInput);