enrichDisabledField($tca); $tca = $this->enrichStarttimeField($tca); $tca = $this->enrichEndtimeField($tca); $tca = $this->enrichFeGroupField($tca); $tca = $this->enrichEditLockField($tca); $tca = $this->enrichDescriptionField($tca); $tca = $this->enrichLanguageField($tca); $tca = $this->setTransOrigPointerFieldInCtrl($tca); $tca = $this->enrichTransOrigPointerField($tca); $tca = $this->enrichTransOrigDiffSourceField($tca); $tca = $this->enrichTranslationSourceField($tca); return $tca; } private function enrichDisabledField(array $tca): array { foreach ($tca as $table => $tableDefinition) { $disabledFieldName = $tableDefinition['ctrl']['enablecolumns']['disabled'] ?? null; if ($disabledFieldName && !is_array($tableDefinition['columns'][$disabledFieldName] ?? null)) { $tca[$table]['columns'][$disabledFieldName] = [ 'label' => 'core.db.general:enabled', 'exclude' => true, 'config' => [ 'type' => 'check', 'renderType' => 'checkboxToggle', 'default' => 0, 'items' => [ [ 'label' => '', 'invertStateDisplay' => true, ], ], ], ]; } } return $tca; } private function enrichStarttimeField(array $tca): array { foreach ($tca as $table => $tableDefinition) { $starttimeFieldName = $tableDefinition['ctrl']['enablecolumns']['starttime'] ?? null; if ($starttimeFieldName && !is_array($tableDefinition['columns'][$starttimeFieldName] ?? null)) { $tca[$table]['columns'][$starttimeFieldName] = [ 'exclude' => true, 'label' => 'core.db.general:starttime', 'config' => [ 'type' => 'datetime', 'default' => 0, ], ]; } } return $tca; } private function enrichEndtimeField(array $tca): array { foreach ($tca as $table => $tableDefinition) { $endtimeFieldName = $tableDefinition['ctrl']['enablecolumns']['endtime'] ?? null; if ($endtimeFieldName && !is_array($tableDefinition['columns'][$endtimeFieldName] ?? null)) { $tca[$table]['columns'][$endtimeFieldName] = [ 'exclude' => true, 'label' => 'core.db.general:endtime', 'config' => [ 'type' => 'datetime', 'default' => 0, 'range' => [ 'upper' => mktime(0, 0, 0, 1, 1, 2106), ], ], ]; } } return $tca; } private function enrichFeGroupField(array $tca): array { foreach ($tca as $table => $tableDefinition) { $feGroupFieldName = $tableDefinition['ctrl']['enablecolumns']['fe_group'] ?? null; if ($feGroupFieldName && !is_array($tableDefinition['columns'][$feGroupFieldName] ?? null)) { $tca[$table]['columns'][$feGroupFieldName] = [ 'exclude' => true, 'label' => 'core.db.general:fe_group', 'config' => [ 'type' => 'select', 'renderType' => 'selectMultipleSideBySide', 'size' => 5, 'maxitems' => 20, 'items' => [ [ 'label' => 'core.db.general:fe_group.hide_at_login', 'value' => -1, ], [ 'label' => 'core.db.general:fe_group.any_login', 'value' => -2, ], [ 'label' => 'core.db.general:fe_group.usergroups', 'value' => '--div--', ], ], 'exclusiveKeys' => '-1,-2', 'foreign_table' => 'fe_groups', ], ]; } } return $tca; } private function enrichEditLockField(array $tca): array { foreach ($tca as $table => $tableDefinition) { $editLockFieldName = $tableDefinition['ctrl']['editlock'] ?? null; if ($editLockFieldName && !is_array($tableDefinition['columns'][$editLockFieldName] ?? null)) { $tca[$table]['columns'][$editLockFieldName] = [ 'displayCond' => 'HIDE_FOR_NON_ADMINS', 'label' => 'core.db.general:editlock', 'config' => [ 'type' => 'check', 'renderType' => 'checkboxToggle', ], ]; } } return $tca; } private function enrichDescriptionField(array $tca): array { foreach ($tca as $table => $tableDefinition) { $descriptionFieldName = $tableDefinition['ctrl']['descriptionColumn'] ?? null; if ($descriptionFieldName && !is_array($tableDefinition['columns'][$descriptionFieldName] ?? null)) { $tca[$table]['columns'][$descriptionFieldName] = [ 'exclude' => true, 'label' => 'core.db.general:description', 'config' => [ 'type' => 'text', 'rows' => 5, 'cols' => 30, 'max' => 2000, ], ]; } } return $tca; } private function enrichLanguageField(array $tca): array { foreach ($tca as $table => $tableDefinition) { $languageFieldName = $tableDefinition['ctrl']['languageField'] ?? null; if ($languageFieldName && !is_array($tableDefinition['columns'][$languageFieldName] ?? null)) { $tca[$table]['columns'][$languageFieldName] = [ 'exclude' => true, 'label' => 'core.db.general:language', 'config' => [ 'type' => 'language', ], ]; } if ($languageFieldName && !is_array($tableDefinition['columns']['language_tag'] ?? null)) { $tca[$table]['columns']['language_tag'] = [ 'exclude' => true, 'label' => 'Language Tag', 'config' => [ 'type' => 'input', 'size' => 10, 'max' => 35, 'eval' => 'trim', 'default' => '', ], ]; } } return $tca; } /** * When 'languageField' is set, 'transOrigPointerField' must be set as well. * We silently add 'transOrigPointerField' if that iss not the case. * * @todo: This obviously needs a consolidation in ctrl. We should have a single, probably * boolean ctrl toggle to make a table 'localization' aware, with core then handling * all internals. This will require streamlining the field names along the way, and * we can think about this as soon as sys_language_uid=-1 is gone. */ private function setTransOrigPointerFieldInCtrl(array $tca): array { foreach ($tca as $table => $tableDefinition) { if (isset($tableDefinition['ctrl']['languageField']) && !isset($tableDefinition['ctrl']['transOrigPointerField'])) { $tca[$table]['ctrl']['transOrigPointerField'] = 'l10n_parent'; } } return $tca; } private function enrichTransOrigPointerField(array $tca): array { foreach ($tca as $table => $tableDefinition) { $transOrigPointerFieldName = $tableDefinition['ctrl']['transOrigPointerField'] ?? null; if ($transOrigPointerFieldName && !is_array($tableDefinition['columns'][$transOrigPointerFieldName] ?? null)) { $languageFieldName = $tableDefinition['ctrl']['languageField']; $tca[$table]['columns'][$transOrigPointerFieldName] = [ 'displayCond' => 'FIELD:' . $languageFieldName . ':>:0', 'label' => 'core.db.general:l18n_parent', 'config' => [ 'type' => 'select', 'renderType' => 'selectSingle', 'items' => [ [ 'label' => '', 'value' => 0, ], ], 'foreign_table' => $table, 'foreign_table_where' => 'AND {#' . $table . '}.{#pid}=###CURRENT_PID### AND {#' . $table . '}.{#' . $languageFieldName . '} IN (-1,0)', 'default' => 0, ], ]; } } return $tca; } private function enrichTransOrigDiffSourceField(array $tca): array { foreach ($tca as $table => $tableDefinition) { $transOrigDiffSourceFieldName = $tableDefinition['ctrl']['transOrigDiffSourceField'] ?? null; if ($transOrigDiffSourceFieldName && !is_array($tableDefinition['columns'][$transOrigDiffSourceFieldName] ?? null)) { $tca[$table]['columns'][$transOrigDiffSourceFieldName] = [ 'config' => [ 'type' => 'passthrough', 'default' => '', ], ]; } } return $tca; } private function enrichTranslationSourceField(array $tca): array { foreach ($tca as $table => $tableDefinition) { $translationSourceFieldName = $tableDefinition['ctrl']['translationSource'] ?? null; if ($translationSourceFieldName && !is_array($tableDefinition['columns'][$translationSourceFieldName] ?? null)) { $tca[$table]['columns'][$translationSourceFieldName] = [ 'config' => [ 'type' => 'passthrough', ], ]; } } return $tca; } }