2 declare(strict_types = 1);
18 use Psr\Http\Message\ResponseInterface;
19 use Psr\Http\Message\ServerRequestInterface;
28 use TYPO3\CMS\Core\Package\PackageManager;
51 'label' =>
'typo3ConfVars',
53 'globalKey' =>
'TYPO3_CONF_VARS',
61 'label' =>
'tcaDescr',
63 'globalKey' =>
'TCA_DESCR',
67 'label' =>
'loadedExt',
69 'globalKey' =>
'TYPO3_LOADED_EXT',
72 'label' =>
't3services',
75 'globalKey' =>
'T3_SERVICES',
78 'label' =>
'tbemodules',
80 'globalKey' =>
'TBE_MODULES',
83 'label' =>
'tbemodulesext',
85 'globalKey' =>
'TBE_MODULES_EXT',
88 'label' =>
'tbeStyles',
90 'globalKey' =>
'TBE_STYLES',
93 'label' =>
'usersettings',
95 'globalKey' =>
'TYPO3_USER_SETTINGS',
98 'label' =>
'pagesTypes',
100 'globalKey' =>
'PAGES_TYPES',
106 'beUserTsConfig' => [
107 'label' =>
'beUserTsConfig',
108 'type' =>
'beUserTsConfig',
114 'httpMiddlewareStacks' => [
115 'label' =>
'httpMiddlewareStacks',
116 'type' =>
'httpMiddlewareStacks',
118 'siteConfiguration' => [
119 'label' =>
'siteConfiguration',
120 'type' =>
'siteConfiguration',
130 'TYPO3_CONF_VARS' => [
132 'database' =>
'******',
134 'password' =>
'******',
136 'socket' =>
'******',
137 'username' =>
'******',
140 'dbname' =>
'******',
142 'password' =>
'******',
145 'unix_socket' =>
'******',
150 'encryptionKey' =>
'******'
164 public function mainAction(ServerRequestInterface $request): ResponseInterface
169 $queryParams = $request->getQueryParams();
170 $postValues = $request->getParsedBody();
172 $moduleState = $backendUser->uc[
'moduleData'][
'system_config'] ?? [];
175 $selectedTreeKey = $this->treeSetup[$queryParams[
'tree']] ? $queryParams[
'tree']
176 : ($this->treeSetup[$moduleState[
'tree']] ? $moduleState[
'tree'] : key($this->treeSetup));
177 $selectedTreeDetails = $this->treeSetup[$selectedTreeKey];
178 $moduleState[
'tree'] = $selectedTreeKey;
181 $searchString = (string)($postValues[
'searchString'] ? trim($postValues[
'searchString']) :
'');
182 $moduleState[
'regexSearch'] = (bool)($postValues[
'regexSearch'] ?? $moduleState[
'regexSearch'] ??
false);
185 $sortKeysByName =
true;
186 if ($selectedTreeDetails[
'type'] ===
'global') {
187 $globalArrayKey = $selectedTreeDetails[
'globalKey'];
188 $renderArray =
$GLOBALS[$globalArrayKey];
193 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][self::class][
'modifyBlindedConfigurationOptions'] ?? [] as $classReference) {
194 $processingObject = GeneralUtility::makeInstance($classReference);
200 foreach (array_keys(
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'Connections']) as $connectionName) {
201 if ($connectionName !==
'Default') {
211 } elseif ($selectedTreeDetails[
'type'] ===
'beUserTsConfig') {
212 $renderArray = $backendUser->getTSConfig();
213 } elseif ($selectedTreeDetails[
'type'] ===
'uc') {
214 $renderArray = $backendUser->uc;
215 } elseif ($selectedTreeDetails[
'type'] ===
'routes') {
216 $router = GeneralUtility::makeInstance(Router::class);
217 $routes = $router->getRoutes();
219 foreach ($routes as $identifier => $route) {
221 $renderArray[$identifier] = [
222 'path' => $route->getPath(),
223 'options' => $route->getOptions()
226 } elseif ($selectedTreeDetails[
'type'] ===
'httpMiddlewareStacks') {
228 $sortKeysByName =
false;
229 $stackResolver = GeneralUtility::makeInstance(
230 MiddlewareStackResolver::class,
231 GeneralUtility::makeInstance(PackageManager::class),
232 GeneralUtility::makeInstance(DependencyOrderingService::class),
233 GeneralUtility::makeInstance(CacheManager::class)->getCache(
'cache_core')
236 foreach ([
'frontend',
'backend'] as $stackName) {
238 $renderArray[$stackName] = array_reverse($stackResolver->resolve($stackName));
240 } elseif ($selectedTreeDetails[
'type'] ===
'siteConfiguration') {
241 $renderArray = GeneralUtility::makeInstance(SiteTcaConfiguration::class)->getTca();
243 throw new \RuntimeException(
'Unknown array type "' . $selectedTreeDetails[
'type'] .
'"', 1507845662);
245 if ($sortKeysByName) {
250 $arrayBrowser = GeneralUtility::makeInstance(ArrayBrowser::class);
251 $arrayBrowser->dontLinkVar =
true;
252 $arrayBrowser->searchKeysToo =
true;
253 $arrayBrowser->regexMode = $moduleState[
'regexSearch'];
254 $node = $queryParams[
'node'];
256 $arrayBrowser->depthKeys = $arrayBrowser->getSearchKeys($renderArray,
'', $searchString, []);
257 } elseif (is_array($node)) {
258 $newExpandCollapse = $arrayBrowser->depthKeys($node, $moduleState[
'node_' . $selectedTreeKey]);
259 $arrayBrowser->depthKeys = $newExpandCollapse;
260 $moduleState[
'node_' . $selectedTreeKey] = $newExpandCollapse;
262 $arrayBrowser->depthKeys = $moduleState[
'node_' . $selectedTreeKey] ?? [];
266 $backendUser->uc[
'moduleData'][
'system_config'] = $moduleState;
267 $backendUser->writeUC();
270 $view = GeneralUtility::makeInstance(StandaloneView::class);
271 $view->getRequest()->setControllerExtensionName(
'lowlevel');
272 $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName(
273 'EXT:lowlevel/Resources/Private/Templates/Backend/Configuration.html'
275 $view->assignMultiple([
276 'treeName' => $selectedTreeDetails[
'label'],
277 'searchString' => $searchString,
278 'regexSearch' => $moduleState[
'regexSearch'],
279 'tree' => $arrayBrowser->tree($renderArray,
''),
283 $moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
284 $moduleTemplate->setContent($view->render());
285 $moduleTemplate->getPageRenderer()->loadRequireJsModule(
'TYPO3/CMS/Lowlevel/ConfigurationView');
288 $shortcutButton = $moduleTemplate->getDocHeaderComponent()->getButtonBar()->makeShortcutButton();
289 $shortcutButton->setModuleName(
'system_config')
290 ->setDisplayName($languageService->sL(
291 'LLL:EXT:lowlevel/Resources/Private/Language/locallang.xlf:' . $selectedTreeDetails[
'label']
293 ->setSetVariables([
'tree']);
294 $moduleTemplate->getDocHeaderComponent()->getButtonBar()->addButton($shortcutButton);
297 $menu = $moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
298 $menu->setIdentifier(
'tree');
299 foreach ($this->treeSetup as $treeKey => $treeDetails) {
300 $menuItem = $menu->makeMenuItem();
302 $uriBuilder = GeneralUtility::makeInstance(\
TYPO3\CMS\Backend\Routing\UriBuilder::class);
303 $menuItem->setHref((
string)$uriBuilder->buildUriFromRoute(
'system_config', [
'tree' => $treeKey]))
304 ->setTitle($languageService->sL(
305 'LLL:EXT:lowlevel/Resources/Private/Language/locallang.xlf:' . $treeDetails[
'label']
307 if ($selectedTreeKey === $treeKey) {
308 $menuItem->setActive(
true);
310 $menu->addMenuItem($menuItem);
312 $moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);