diff --git a/Classes/Backend/CoreSelectorField.php b/Classes/Backend/CoreSelectorField.php index dd2151d449..e43316a3cd 100644 --- a/Classes/Backend/CoreSelectorField.php +++ b/Classes/Backend/CoreSelectorField.php @@ -15,6 +15,7 @@ namespace ApacheSolrForTypo3\Solr\Backend; +use ApacheSolrForTypo3\Solr\ConnectionManager; use ApacheSolrForTypo3\Solr\Domain\Site\Site; use TYPO3\CMS\Backend\Form\Exception as BackendFormException; use TYPO3\CMS\Backend\Form\FormResultCompiler; @@ -130,10 +131,9 @@ public function render(): string protected function getLanguageUidCoreMap(): array { $coreTableMap = []; - $cores = $this->site->getAllSolrConnectionConfigurations(); - foreach ($cores as $languageUid => $core) { - $corePath = $core['write']['path']; - $coreTableMap[$languageUid] = $corePath; + $solrServers = GeneralUtility::makeInstance(ConnectionManager::class)->getConnectionsBySite($this->site); + foreach ($solrServers as $languageUid => $solrConnection) { + $coreTableMap[$languageUid] = $solrConnection->getWriteService()->getCorePath(); } return $coreTableMap; } @@ -149,10 +149,13 @@ protected function buildSelectorItems(array $coresToOptimize): array { $selectorItems = []; - foreach ($coresToOptimize as $corePath) { - $icon = 'module-searchbackend_SolrCoreoptimization'; + foreach ($coresToOptimize as $systemLanguageId => $corePath) { $corePath = rtrim($corePath, '/'); - $selectorItems[] = [$corePath, $corePath, $icon]; + $selectorItems[] = [ + $corePath, + $corePath, + $this->getFlagIdentifierForSystemLanguageId($systemLanguageId), + ]; } return $selectorItems; @@ -173,22 +176,36 @@ protected function renderSelectCheckbox(array $items, array $selectedValues): st 'itemFormElValue' => $selectedValues, 'fieldConf' => ['config' => ['items' => $items]], 'fieldTSConfig' => ['noMatchingValue_label' => ''], + 'itemFormElID' => '', ]; $nodeFactory = GeneralUtility::makeInstance(NodeFactory::class); $options = [ + 'type' => 'select', 'renderType' => 'selectCheckBox', - 'table' => 'tx_solr_classes_backend_coreselector', + 'tableName' => 'tx_solr_classes_backend_coreselector', 'fieldName' => 'additionalFields', - 'databaseRow' => [], + 'databaseRow' => ['uid' => 0], 'parameterArray' => $parameterArray, + 'processedTca' => ['columns' => ['additionalFields' => ['config' => ['type' => 'select']]]], ]; - $selectCheckboxResult = $nodeFactory->create($options)->render(); + $selectCheckboxResult = $nodeFactory + ->create($options) + ->render(); $formResultCompiler = GeneralUtility::makeInstance(FormResultCompiler::class); $formResultCompiler->mergeResult($selectCheckboxResult); $formHtml = $selectCheckboxResult['html'] ?? ''; return $formResultCompiler->addCssFiles() . $formHtml . $formResultCompiler->printNeededJSFunctions(); } + + protected function getFlagIdentifierForSystemLanguageId($systemLanguageId): string + { + $flagIdentifier = $this->site->getTypo3SiteObject()->getLanguageById((int)$systemLanguageId)->getFlagIdentifier(); + if (!empty($flagIdentifier)) { + return $flagIdentifier; + } + return 'flags-multiple'; + } } diff --git a/Classes/Backend/IndexingConfigurationSelectorField.php b/Classes/Backend/IndexingConfigurationSelectorField.php index 57cfa7139c..2369e6b5ba 100644 --- a/Classes/Backend/IndexingConfigurationSelectorField.php +++ b/Classes/Backend/IndexingConfigurationSelectorField.php @@ -199,7 +199,8 @@ protected function renderSelectCheckbox(array $items, ?array $selectedValues = [ $nodeFactory = GeneralUtility::makeInstance(NodeFactory::class); $options = [ - 'type' => 'select', 'renderType' => 'selectCheckBox', + 'type' => 'select', + 'renderType' => 'selectCheckBox', 'table' => 'tx_solr_classes_backend_indexingconfigurationselector', 'tableName' => 'tx_solr_classes_backend_indexingconfigurationselector', 'fieldName' => 'additionalFields',