getLanguageService(); $result = $this->initializeResultArray(); $parameterArray = $this->data['parameterArray']; $config = $parameterArray['fieldConf']['config']; $itemName = $parameterArray['itemFormElName']; if (empty($config['allowed']) || !is_string($config['allowed'])) { // No handling if the field has no, or funny "allowed" settings. return $result; } $allowed = GeneralUtility::trimExplode(',', $config['allowed'], true); $allowedTablesHtml = []; foreach ($allowed as $tableName) { if ($tableName === '*') { $label = $languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.allTables'); $allowedTablesHtml[] = ''; $allowedTablesHtml[] = htmlspecialchars($label); $allowedTablesHtml[] = ''; } else { $tableSchema = $this->data['tcaSchemata']->has($tableName) ? $this->data['tcaSchemata']->get($tableName) : null; $label = $languageService->sL($tableSchema?->getTitle() ?? ''); $icon = $this->iconFactory->getIconForRecord($tableName, [], IconSize::SMALL)->render(); if ((bool)($config['fieldControl']['elementBrowser']['disabled'] ?? false)) { $allowedTablesHtml[] = ''; $allowedTablesHtml[] = $icon; $allowedTablesHtml[] = htmlspecialchars($label); $allowedTablesHtml[] = ''; } else { // Initialize attributes $attributes = [ 'class' => 'btn btn-default t3js-element-browser', 'data-mode' => $tableName === 'sys_file' ? 'file' : 'db', 'data-field-reference' => $itemName, 'data-allowed-types' => $tableName, ]; // Add the entry point - if found $attributes = $this->addEntryPoint($tableName, $config, $attributes); $allowedTablesHtml[] = ''; } } } $html = []; $html[] = '
'; $html[] = implode(LF, $allowedTablesHtml); $html[] = '
'; $result['html'] = implode(LF, $html); return $result; } /** * Try to resolve a configured default entry point - page / folder * to be expanded - and add it to the attributes if found. */ protected function addEntryPoint(string $tableName, array $fieldConfig, array $attributes): array { if (!isset($fieldConfig['elementBrowserEntryPoints']) || !is_array($fieldConfig['elementBrowserEntryPoints'])) { // Early return in case no entry points are defined return $attributes; } // Fetch the configured value (which might be a marker) - falls back to _default $entryPoint = (string)($fieldConfig['elementBrowserEntryPoints'][$tableName] ?? $fieldConfig['elementBrowserEntryPoints']['_default'] ?? ''); if ($entryPoint === '') { // In case no entry point exists for the given table and also no default is defined, return return $attributes; } // Check and resolve possible marker if (str_starts_with($entryPoint, '###') && str_ends_with($entryPoint, '###')) { if ($entryPoint === '###CURRENT_PID###') { // Use the current pid $entryPoint = (string)$this->data['effectivePid']; } elseif ($entryPoint === '###SITEROOT###' && ($this->data['site'] ?? null) instanceof Site) { // Use the root page id from the current site $entryPoint = (string)$this->data['site']->getRootPageId(); } else { // Check for special TSconfig marker $TSconfig = FormEngineUtility::getTCEFORM_TSconfig($this->data['tableName'], ['pid' => $this->data['effectivePid']]); $keyword = substr($entryPoint, 3, -3); if (str_starts_with($keyword, 'PAGE_TSCONFIG_')) { $entryPoint = (string)($TSconfig[$this->data['fieldName']][$keyword] ?? ''); } else { $entryPoint = (string)($TSconfig['_' . $keyword] ?? ''); } } } // Add the entry point to the attribute - if resolved if ($entryPoint !== '') { $attributes['data-entry-point'] = $entryPoint; } return $attributes; } protected function getLanguageService(): LanguageService { return $GLOBALS['LANG']; } }