‪TYPO3CMS  ‪main
ActiveTypoScriptController.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\Container\ContainerInterface;
21 use Psr\Http\Message\ResponseInterface;
22 use Psr\Http\Message\ServerRequestInterface;
27 use TYPO3\CMS\Backend\Utility\BackendUtility;
30 use TYPO3\CMS\Core\Imaging\IconSize;
47 use TYPO3\CMS\Core\TypoScript\Tokenizer\LosslessTokenizer;
50 
56 #[AsController]
58 {
59  public function ‪__construct(
60  private readonly ContainerInterface $container,
61  private readonly ‪ModuleTemplateFactory $moduleTemplateFactory,
62  private readonly ‪FlashMessageService $flashMessageService,
63  private readonly ‪SysTemplateRepository $sysTemplateRepository,
64  private readonly ‪SysTemplateTreeBuilder $treeBuilder,
65  ) {}
66 
70  public function ‪indexAction(ServerRequestInterface $request): ResponseInterface
71  {
72  $backendUser = $this->‪getBackendUser();
73  $languageService = $this->‪getLanguageService();
74 
75  $queryParams = $request->getQueryParams();
76  $parsedBody = $request->getParsedBody();
77 
78  $currentModule = $request->getAttribute('module');
79  $currentModuleIdentifier = $currentModule->getIdentifier();
80  $moduleData = $request->getAttribute('moduleData');
81 
82  $pageUid = (int)($queryParams['id'] ?? 0);
83  if ($pageUid === 0) {
84  // Redirect to template record overview if on page 0.
85  return new ‪RedirectResponse($this->uriBuilder->buildUriFromRoute('web_typoscript_recordsoverview'));
86  }
87  $pageRecord = BackendUtility::readPageAccess($pageUid, '1=1') ?: [];
88  if (empty($pageRecord)) {
89  // Redirect to records overview if page could not be determined.
90  // Edge case if page has been removed meanwhile.
91  BackendUtility::setUpdateSignal('updatePageTree');
92  return new ‪RedirectResponse($this->uriBuilder->buildUriFromRoute('web_typoscript_recordsoverview'));
93  }
94 
95  // @todo: Switch to BU::BEgetRootLine($pageUid, '', true) as in PageTsConfig? Similar in other controllers and actions.
96  $rootLine = GeneralUtility::makeInstance(RootlineUtility::class, $pageUid)->get();
97  $site = $request->getAttribute('site');
98  $rootLine = $this->‪getScopedRootline($site, $rootLine);
99 
100  // Template selection handling for this page
101  $allTemplatesOnPage = $this->‪getAllTemplateRecordsOnPage($pageUid);
102  $selectedTemplateFromModuleData = (array)$moduleData->get('selectedTemplatePerPage');
103  $selectedTemplateUid = (int)($parsedBody['selectedTemplate'] ?? $selectedTemplateFromModuleData[$pageUid] ?? 0);
104  if (!in_array($selectedTemplateUid, array_column($allTemplatesOnPage, 'uid'))) {
105  $selectedTemplateUid = (int)($allTemplatesOnPage[0]['uid'] ?? 0);
106  }
107  if (($moduleData->get('selectedTemplatePerPage')[$pageUid] ?? 0) !== $selectedTemplateUid) {
108  $selectedTemplateFromModuleData[$pageUid] = $selectedTemplateUid;
109  $moduleData->set('selectedTemplatePerPage', $selectedTemplateFromModuleData);
110  $backendUser->pushModuleData($currentModuleIdentifier, $moduleData->toArray());
111  }
112  $templateTitle = '';
113  foreach ($allTemplatesOnPage as $templateRow) {
114  if ((int)$templateRow['uid'] === $selectedTemplateUid) {
115  $templateTitle = $templateRow['title'];
116  }
117  }
118 
119  // Force boolean toggles to bool and init further get/post vars
120  if ($moduleData->clean('sortAlphabetically', [true, false])) {
121  $backendUser->pushModuleData($currentModuleIdentifier, $moduleData->toArray());
122  }
123  $sortAlphabetically = $moduleData->get('sortAlphabetically');
124  if ($moduleData->clean('displayConstantSubstitutions', [true, false])) {
125  $backendUser->pushModuleData($currentModuleIdentifier, $moduleData->toArray());
126  }
127  $displayConstantSubstitutions = $moduleData->get('displayConstantSubstitutions');
128  if ($moduleData->clean('displayComments', [true, false])) {
129  $backendUser->pushModuleData($currentModuleIdentifier, $moduleData->toArray());
130  }
131  $displayComments = $moduleData->get('displayComments');
132 
133  $sysTemplateRows = $this->sysTemplateRepository->getSysTemplateRowsByRootlineWithUidOverride($rootLine, $request, $selectedTemplateUid);
134 
135  // Build the constant include tree
136  $constantIncludeTree = $this->treeBuilder->getTreeBySysTemplateRowsAndSite('constants', $sysTemplateRows, new LosslessTokenizer(), $site);
137  // Set enabled conditions in constant include tree
138  $constantConditions = $this->‪handleToggledConstantConditions($constantIncludeTree, $moduleData, $parsedBody);
139  $conditionEnforcerVisitor = new ‪IncludeTreeConditionEnforcerVisitor();
140  $conditionEnforcerVisitor->setEnabledConditions(array_column(array_filter($constantConditions, static fn($condition) => $condition['active']), 'value'));
141  $treeTraverser = new ‪ConditionVerdictAwareIncludeTreeTraverser();
142  $treeTraverserVisitors = [];
143  $treeTraverserVisitors[] = $conditionEnforcerVisitor;
144  $constantAstBuilderVisitor = $this->container->get(IncludeTreeCommentAwareAstBuilderVisitor::class);
145  $treeTraverserVisitors[] = $constantAstBuilderVisitor;
146  $treeTraverser->traverse($constantIncludeTree, $treeTraverserVisitors);
147  $constantAst = $constantAstBuilderVisitor->getAst();
148  $constantAst->setIdentifier('TypoScript constants');
149  if ($sortAlphabetically) {
150  $astTraverser = new ‪AstTraverser();
151  $astTraverser->traverse($constantAst, [new ‪AstSortChildrenVisitor()]);
152  }
153 
154  // Flatten constant AST. Needed for setup condition display and setup AST constant substitution.
155  $flattenedConstants = $constantAst->flatten();
156  // Build the setup include tree
157  $setupIncludeTree = $this->treeBuilder->getTreeBySysTemplateRowsAndSite('setup', $sysTemplateRows, new LosslessTokenizer(), $site);
158  // Set enabled conditions in setup include tree and let it handle constant substitutions in setup conditions.
159  $setupConditions = $this->‪handleToggledSetupConditions($setupIncludeTree, $moduleData, $parsedBody, $flattenedConstants);
160  $conditionEnforcerVisitor = new ‪IncludeTreeConditionEnforcerVisitor();
161  $conditionEnforcerVisitor->setEnabledConditions(array_column(array_filter($setupConditions, static fn($condition) => $condition['active']), 'value'));
162  $treeTraverser = new ‪ConditionVerdictAwareIncludeTreeTraverser();
163  $treeTraverserVisitors = [];
164  $treeTraverserVisitors[] = $conditionEnforcerVisitor;
165  $setupAstBuilderVisitor = $this->container->get(IncludeTreeCommentAwareAstBuilderVisitor::class);
166  $setupAstBuilderVisitor->setFlatConstants($flattenedConstants);
167  $treeTraverserVisitors[] = $setupAstBuilderVisitor;
168  $treeTraverser->traverse($setupIncludeTree, $treeTraverserVisitors);
169  // Build the setup AST
170  $setupAst = $setupAstBuilderVisitor->getAst();
171  $setupAst->setIdentifier('TypoScript setup');
172  if ($sortAlphabetically) {
173  $astTraverser = new ‪AstTraverser();
174  $astTraverser->traverse($setupAst, [new ‪AstSortChildrenVisitor()]);
175  }
176 
177  $view = $this->moduleTemplateFactory->create($request);
178  $view->setTitle($languageService->sL($currentModule->getTitle()), $pageRecord['title']);
179  $view->getDocHeaderComponent()->setMetaInformation($pageRecord);
180  $this->‪addPreviewButtonToDocHeader($view, $pageUid, (int)$pageRecord['doktype']);
181  $this->‪addShortcutButtonToDocHeader($view, $currentModuleIdentifier, $pageRecord, $pageUid);
182  $view->makeDocHeaderModuleMenu(['id' => $pageUid]);
183  $view->assignMultiple([
184  'templateTitle' => $templateTitle,
185  'selectedTemplateUid' => $selectedTemplateUid,
186  'pageUid' => $pageUid,
187  'allTemplatesOnPage' => $allTemplatesOnPage,
188  'sortAlphabetically' => $sortAlphabetically,
189  'displayConstantSubstitutions' => $displayConstantSubstitutions,
190  'displayComments' => $displayComments,
191  'constantConditions' => $constantConditions,
192  'constantConditionsActiveCount' => count(array_filter($constantConditions, static fn($condition) => $condition['active'])),
193  'constantAst' => $constantAst,
194  'setupConditions' => $setupConditions,
195  'setupConditionsActiveCount' => count(array_filter($setupConditions, static fn($condition) => $condition['active'])),
196  'setupAst' => $setupAst,
197  ]);
198 
199  return $view->renderResponse('ActiveMain');
200  }
201 
205  public function ‪editAction(ServerRequestInterface $request): ResponseInterface
206  {
207  $languageService = $this->‪getLanguageService();
208  $queryParams = $request->getQueryParams();
209  $currentModule = $request->getAttribute('module');
210  $moduleData = $request->getAttribute('moduleData');
211  $pageUid = (int)($queryParams['id'] ?? 0);
212  $type = $queryParams['type'] ?? '';
213  $nodeIdentifier = $queryParams['nodeIdentifier'] ?? '';
214 
215  if (empty($pageUid) || !in_array($type, ['constant', 'setup']) || empty($nodeIdentifier)) {
216  throw new \RuntimeException('Required action argument missing or invalid', 1658562276);
217  }
218 
219  $pageRecord = BackendUtility::readPageAccess($pageUid, '1=1') ?: [];
220  if (empty($pageRecord)) {
221  // Redirect to records overview if page could not be determined.
222  // Edge case if page has been removed meanwhile.
223  BackendUtility::setUpdateSignal('updatePageTree');
224  return new ‪RedirectResponse($this->uriBuilder->buildUriFromRoute('web_typoscript_recordsoverview'));
225  }
226 
227  // @todo: Switch to BU::BEgetRootLine($pageUid, '', true) as in PageTsConfig? Similar in other controllers and actions.
228  $rootLine = GeneralUtility::makeInstance(RootlineUtility::class, $pageUid)->get();
229  $site = $request->getAttribute('site');
230  $rootLine = $this->‪getScopedRootline($site, $rootLine);
231 
232  // Template selection handling
233  $allTemplatesOnPage = $this->‪getAllTemplateRecordsOnPage($pageUid);
234  $selectedTemplateFromModuleData = (array)$moduleData->get('selectedTemplatePerPage');
235  $selectedTemplateUid = (int)($selectedTemplateFromModuleData[$pageUid] ?? 0);
236  if (!in_array($selectedTemplateUid, array_column($allTemplatesOnPage, 'uid'))) {
237  $selectedTemplateUid = (int)($allTemplatesOnPage[0]['uid'] ?? 0);
238  }
239 
240  $hasTemplate = false;
241  $templateTitle = '';
242  foreach ($allTemplatesOnPage as $templateRow) {
243  if ((int)$templateRow['uid'] === $selectedTemplateUid) {
244  $hasTemplate = true;
245  $templateTitle = $templateRow['title'];
246  }
247  }
248 
249  $sysTemplateRows = $this->sysTemplateRepository->getSysTemplateRowsByRootlineWithUidOverride($rootLine, $request, $selectedTemplateUid);
250 
251  // Get current value of to-edit object path
252  // Build the constant include tree
253  $constantIncludeTree = $this->treeBuilder->getTreeBySysTemplateRowsAndSite('constants', $sysTemplateRows, new LosslessTokenizer(), $site);
254  // Set enabled conditions in constant include tree
255  $constantConditions = $this->‪handleToggledConstantConditions($constantIncludeTree, $moduleData, null);
256  $conditionEnforcerVisitor = new ‪IncludeTreeConditionEnforcerVisitor();
257  $conditionEnforcerVisitor->setEnabledConditions(array_column(array_filter($constantConditions, static fn($condition) => $condition['active']), 'value'));
258  $treeTraverser = new ‪ConditionVerdictAwareIncludeTreeTraverser();
259  $treeTraverserVisitors = [];
260  $treeTraverserVisitors[] = $conditionEnforcerVisitor;
261  $constantAstBuilderVisitor = $this->container->get(IncludeTreeAstBuilderVisitor::class);
262  $treeTraverserVisitors[] = $constantAstBuilderVisitor;
263  $treeTraverser->traverse($constantIncludeTree, $treeTraverserVisitors);
264 
265  $astNodeFinderVisitor = new ‪AstNodeFinderVisitor();
266  $astNodeFinderVisitor->setNodeIdentifier($nodeIdentifier);
267  if ($type === 'constant') {
268  $constantAst = $constantAstBuilderVisitor->getAst();
269  $constantAst->setIdentifier('TypoScript constants');
270  $astTraverser = new ‪AstTraverser();
271  $astTraverser->traverse($constantAst, [$astNodeFinderVisitor]);
272  } else {
273  // Build the setup include tree
274  $setupIncludeTree = $this->treeBuilder->getTreeBySysTemplateRowsAndSite('setup', $sysTemplateRows, new LosslessTokenizer(), $site);
275  $flattenedConstants = $constantAstBuilderVisitor->getAst()->flatten();
276  // Set enabled conditions in setup include tree
277  $setupConditions = $this->‪handleToggledSetupConditions($setupIncludeTree, $moduleData, null, $flattenedConstants);
278  $conditionEnforcerVisitor = new ‪IncludeTreeConditionEnforcerVisitor();
279  $conditionEnforcerVisitor->setEnabledConditions(array_column(array_filter($setupConditions, static fn($condition) => $condition['active']), 'value'));
280  $treeTraverser = new ‪ConditionVerdictAwareIncludeTreeTraverser();
281  $treeTraverserVisitors = [];
282  $treeTraverserVisitors[] = $conditionEnforcerVisitor;
283  $setupAstBuilderVisitor = $this->container->get(IncludeTreeAstBuilderVisitor::class);
284  $setupAstBuilderVisitor->setFlatConstants($flattenedConstants);
285  $treeTraverserVisitors[] = $setupAstBuilderVisitor;
286  $treeTraverser->traverse($setupIncludeTree, $treeTraverserVisitors);
287  $setupAst = $setupAstBuilderVisitor->getAst();
288  $setupAst->setIdentifier('TypoScript setup');
289  $astTraverser = new ‪AstTraverser();
290  $astTraverser->traverse($setupAst, [$astNodeFinderVisitor]);
291  }
292  $foundNode = $astNodeFinderVisitor->getFoundNode();
293  $foundNodeCurrentObjectPath = $astNodeFinderVisitor->getFoundNodeCurrentObjectPath();
294 
295  if ($foundNode === null || $foundNodeCurrentObjectPath === null) {
296  throw new \RuntimeException('Node with identifier ' . $nodeIdentifier . ' to edit not found', 1675241994);
297  }
298 
299  $view = $this->moduleTemplateFactory->create($request);
300  $view->setTitle($languageService->sL($currentModule->getTitle()), $pageRecord['title']);
301  $view->getDocHeaderComponent()->setMetaInformation($pageRecord);
302  $this->‪addBackButtonToDocHeader($view, $pageUid);
303  $view->makeDocHeaderModuleMenu(['id' => $pageUid]);
304  $view->assignMultiple([
305  'pageUid' => $pageUid,
306  'hasTemplate' => $hasTemplate,
307  'templateTitle' => $templateTitle,
308  'type' => $type,
309  'currentObjectPath' => $foundNodeCurrentObjectPath->getPathAsString(),
310  'currentValue' => $foundNode->getValue(),
311  ]);
312 
313  return $view->renderResponse('ActiveEdit');
314  }
315 
321  public function ‪updateAction(ServerRequestInterface $request): ResponseInterface
322  {
323  $languageService = $this->‪getLanguageService();
324  $moduleData = $request->getAttribute('moduleData');
325  $parsedBody = $request->getParsedBody();
326  $pageUid = (int)($parsedBody['pageUid'] ?? 0);
327  $type = $parsedBody['type'] ?? '';
328  $currentObjectPath = $parsedBody['currentObjectPath'] ?? '';
329 
330  $command = null;
331  if (isset($parsedBody['updateValue'])) {
332  $command = 'updateValue';
333  } elseif (isset($parsedBody['addChild'])) {
334  $command = 'addChild';
335  } elseif (isset($parsedBody['clear'])) {
336  $command = 'clear';
337  }
338 
339  if (empty($pageUid) || !in_array($type, ['constant', 'setup']) || empty($currentObjectPath) || empty($command)) {
340  throw new \RuntimeException('Required action argument missing or invalid', 1658568446);
341  }
342 
343  // Template selection handling
344  $allTemplatesOnPage = $this->‪getAllTemplateRecordsOnPage($pageUid);
345  $selectedTemplateFromModuleData = (array)$moduleData->get('selectedTemplatePerPage');
346  $selectedTemplateUid = (int)($selectedTemplateFromModuleData[$pageUid] ?? 0);
347  $templateRow = null;
348  foreach ($allTemplatesOnPage as $template) {
349  if ($selectedTemplateUid === (int)$template['uid']) {
350  $templateRow = $template;
351  }
352  }
353  if (!in_array($selectedTemplateUid, array_column($allTemplatesOnPage, 'uid'))) {
354  $templateRow = $allTemplatesOnPage[0] ?? [];
355  $selectedTemplateUid = (int)($templateRow['uid'] ?? 0);
356  }
357 
358  if ($selectedTemplateUid < 1) {
359  throw new \RuntimeException('No template on page found', 1658568794);
360  }
361 
362  $newLine = null;
363  $flashMessageQueue = $this->flashMessageService->getMessageQueueByIdentifier();
364  switch ($command) {
365  case 'updateValue':
366  $newLine = $currentObjectPath . ' = ' . trim($parsedBody['value'] ?? '');
367  break;
368  case 'addChild':
369  $childName = str_replace('\\', '', $parsedBody['childName'] ?? '');
370  if (empty($childName) || preg_replace('/[^a-zA-Z0-9_\.]*/', '', $childName) != $childName) {
371  $flashMessage = GeneralUtility::makeInstance(
372  FlashMessage::class,
373  $languageService->sL('LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:updateAction.noSpaces'),
374  $languageService->sL('LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:updateAction.lineNotAdded'),
375  ContextualFeedbackSeverity::WARNING,
376  true
377  );
378  $flashMessageQueue->enqueue($flashMessage);
379  break;
380  }
381  $childName = addcslashes($parsedBody['childName'] ?? '', '.');
382  $childValue = trim($parsedBody['childValue'] ?? '');
383  $newLine = $currentObjectPath . '.' . $childName . ' = ' . $childValue;
384  break;
385  case 'clear':
386  $newLine = $currentObjectPath . ' >';
387  break;
388  }
389 
390  if ($newLine) {
391  $fieldName = $type === 'constant' ? 'constants' : 'config';
392  $recordData = [
393  'sys_template' => [
394  $selectedTemplateUid => [
395  $fieldName => ($templateRow[$fieldName] ?? '') . LF . $newLine,
396  ],
397  ],
398  ];
399  ‪$dataHandler = GeneralUtility::makeInstance(DataHandler::class);
400  ‪$dataHandler->‪start($recordData, []);
402  $flashMessage = GeneralUtility::makeInstance(
403  FlashMessage::class,
404  $newLine,
405  $languageService->sL('LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:updateAction.lineAdded'),
406  ContextualFeedbackSeverity::OK,
407  true
408  );
409  $flashMessageQueue->enqueue($flashMessage);
410  }
411 
412  return new ‪RedirectResponse($this->uriBuilder->buildUriFromRoute('typoscript_active', ['id' => $pageUid]));
413  }
414 
420  private function ‪handleToggledConstantConditions(‪RootInclude $constantTree, ‪ModuleData $moduleData, ?array $parsedBody): array
421  {
422  $conditionAggregatorVisitor = new ‪IncludeTreeConditionAggregatorVisitor();
423  $treeTraverser = new ‪IncludeTreeTraverser();
424  $treeTraverser->traverse($constantTree, [$conditionAggregatorVisitor]);
425  $constantConditions = $conditionAggregatorVisitor->getConditions();
426  $conditionsFromPost = $parsedBody['constantConditions'] ?? [];
427  $conditionsFromModuleData = array_flip((array)$moduleData->‪get('constantConditions'));
428  $typoscriptConditions = [];
429  foreach ($constantConditions as $condition) {
430  $conditionHash = sha1($condition['value']);
431  $conditionActive = array_key_exists($conditionHash, $conditionsFromModuleData);
432  // Note we're not feeding the post values directly to module data, but filter
433  // them through available conditions to prevent polluting module data with
434  // manipulated post values.
435  if (($conditionsFromPost[$conditionHash] ?? null) === '0') {
436  unset($conditionsFromModuleData[$conditionHash]);
437  $conditionActive = false;
438  } elseif (($conditionsFromPost[$conditionHash] ?? null) === '1') {
439  $conditionsFromModuleData[$conditionHash] = true;
440  $conditionActive = true;
441  }
442  $typoscriptConditions[] = [
443  'value' => $condition['value'],
444  'hash' => $conditionHash,
445  'active' => $conditionActive,
446  ];
447  }
448  if ($conditionsFromPost) {
449  $moduleData->‪set('constantConditions', array_keys($conditionsFromModuleData));
450  $this->‪getBackendUser()->pushModuleData($moduleData->‪getModuleIdentifier(), $moduleData->‪toArray());
451  }
452  return $typoscriptConditions;
453  }
454 
460  private function ‪handleToggledSetupConditions(‪RootInclude $setupTree, ‪ModuleData $moduleData, ?array $parsedBody, array $flattenedConstants): array
461  {
462  $setupConditionConstantSubstitutionVisitor = new ‪IncludeTreeSetupConditionConstantSubstitutionVisitor();
463  $setupConditionConstantSubstitutionVisitor->setFlattenedConstants($flattenedConstants);
464  $treeTraverser = new ‪IncludeTreeTraverser();
465  $treeTraverserVisitors = [];
466  $treeTraverserVisitors[] = $setupConditionConstantSubstitutionVisitor;
467  $conditionAggregatorVisitor = new ‪IncludeTreeConditionAggregatorVisitor();
468  $treeTraverserVisitors[] = $conditionAggregatorVisitor;
469  $treeTraverser->traverse($setupTree, $treeTraverserVisitors);
470  $setupConditions = $conditionAggregatorVisitor->getConditions();
471  $conditionsFromPost = $parsedBody['setupConditions'] ?? [];
472  $conditionsFromModuleData = array_flip((array)$moduleData->‪get('setupConditions'));
473  $typoscriptConditions = [];
474  foreach ($setupConditions as $condition) {
475  $conditionHash = sha1($condition['value']);
476  $conditionActive = array_key_exists($conditionHash, $conditionsFromModuleData);
477  // Note we're not feeding the post values directly to module data, but filter
478  // them through available conditions to prevent polluting module data with
479  // manipulated post values.
480  if (($conditionsFromPost[$conditionHash] ?? null) === '0') {
481  unset($conditionsFromModuleData[$conditionHash]);
482  $conditionActive = false;
483  } elseif (($conditionsFromPost[$conditionHash] ?? null) === '1') {
484  $conditionsFromModuleData[$conditionHash] = true;
485  $conditionActive = true;
486  }
487  $typoscriptConditions[] = [
488  'value' => $condition['value'],
489  'originalValue' => $condition['originalValue'],
490  'hash' => $conditionHash,
491  'active' => $conditionActive,
492  ];
493  }
494  if ($conditionsFromPost) {
495  $moduleData->‪set('setupConditions', array_keys($conditionsFromModuleData));
496  $this->‪getBackendUser()->pushModuleData($moduleData->‪getModuleIdentifier(), $moduleData->‪toArray());
497  }
498  return $typoscriptConditions;
499  }
500 
501  private function ‪addShortcutButtonToDocHeader(‪ModuleTemplate $view, string $moduleIdentifier, array $pageInfo, int $pageUid): void
502  {
503  $languageService = $this->‪getLanguageService();
504  $buttonBar = $view->‪getDocHeaderComponent()->getButtonBar();
505  $shortcutTitle = sprintf(
506  '%s: %s [%d]',
507  $languageService->sL('LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:submodule.title'),
508  BackendUtility::getRecordTitle('pages', $pageInfo),
509  $pageUid
510  );
511  $shortcutButton = $buttonBar->makeShortcutButton()
512  ->setRouteIdentifier($moduleIdentifier)
513  ->setDisplayName($shortcutTitle)
514  ->setArguments(['id' => $pageUid]);
515  $buttonBar->addButton($shortcutButton);
516  }
517 
518  private function ‪addBackButtonToDocHeader(‪ModuleTemplate $view, int $pageUid): void
519  {
520  $languageService = $this->‪getLanguageService();
521  $buttonBar = $view->‪getDocHeaderComponent()->getButtonBar();
522  $backButton = $buttonBar->makeLinkButton()
523  ->setHref((string)$this->uriBuilder->buildUriFromRoute('typoscript_active', ['id' => $pageUid]))
524  ->setTitle($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.goBack'))
525  ->setShowLabelText(true)
526  ->setIcon($this->iconFactory->getIcon('actions-view-go-back', IconSize::SMALL));
527  $buttonBar->addButton($backButton);
528  }
529 }
‪TYPO3\CMS\Core\DataHandling\DataHandler
Definition: DataHandler.php:104
‪TYPO3\CMS\Core\TypoScript\IncludeTree\SysTemplateRepository
Definition: SysTemplateRepository.php:40
‪TYPO3\CMS\Tstemplate\Controller\AbstractTemplateModuleController\$dataHandler
‪DataHandler $dataHandler
Definition: AbstractTemplateModuleController.php:55
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeSetupConditionConstantSubstitutionVisitor
Definition: IncludeTreeSetupConditionConstantSubstitutionVisitor.php:40
‪TYPO3\CMS\Core\TypoScript\AST\Visitor\AstSortChildrenVisitor
Definition: AstSortChildrenVisitor.php:30
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeCommentAwareAstBuilderVisitor
Definition: IncludeTreeCommentAwareAstBuilderVisitor.php:45
‪TYPO3\CMS\Backend\Template\ModuleTemplateFactory
Definition: ModuleTemplateFactory.php:35
‪TYPO3\CMS\Tstemplate\Controller\ActiveTypoScriptController\addShortcutButtonToDocHeader
‪addShortcutButtonToDocHeader(ModuleTemplate $view, string $moduleIdentifier, array $pageInfo, int $pageUid)
Definition: ActiveTypoScriptController.php:501
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Traverser\IncludeTreeTraverser
Definition: IncludeTreeTraverser.php:30
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeConditionEnforcerVisitor
Definition: IncludeTreeConditionEnforcerVisitor.php:32
‪TYPO3\CMS\Backend\Module\ModuleData\toArray
‪toArray()
Definition: ModuleData.php:122
‪TYPO3\CMS\Core\Utility\RootlineUtility
Definition: RootlineUtility.php:39
‪TYPO3\CMS\Backend\Module\ModuleData
Definition: ModuleData.php:30
‪TYPO3\CMS\Tstemplate\Controller
Definition: AbstractTemplateModuleController.php:18
‪TYPO3\CMS\Backend\Module\ModuleData\get
‪get(string $propertyName, mixed $default=null)
Definition: ModuleData.php:56
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeAstBuilderVisitor
Definition: IncludeTreeAstBuilderVisitor.php:43
‪TYPO3\CMS\Tstemplate\Controller\ActiveTypoScriptController\indexAction
‪indexAction(ServerRequestInterface $request)
Definition: ActiveTypoScriptController.php:70
‪TYPO3\CMS\Tstemplate\Controller\AbstractTemplateModuleController\getAllTemplateRecordsOnPage
‪getAllTemplateRecordsOnPage(int $pageId)
Definition: AbstractTemplateModuleController.php:196
‪TYPO3\CMS\Backend\Template\ModuleTemplate
Definition: ModuleTemplate.php:46
‪TYPO3\CMS\Core\Type\ContextualFeedbackSeverity
‪ContextualFeedbackSeverity
Definition: ContextualFeedbackSeverity.php:25
‪TYPO3\CMS\Tstemplate\Controller\AbstractTemplateModuleController
Definition: AbstractTemplateModuleController.php:50
‪TYPO3\CMS\Tstemplate\Controller\AbstractTemplateModuleController\getBackendUser
‪getBackendUser()
Definition: AbstractTemplateModuleController.php:277
‪TYPO3\CMS\Tstemplate\Controller\ActiveTypoScriptController\handleToggledConstantConditions
‪handleToggledConstantConditions(RootInclude $constantTree, ModuleData $moduleData, ?array $parsedBody)
Definition: ActiveTypoScriptController.php:420
‪TYPO3\CMS\Tstemplate\Controller\AbstractTemplateModuleController\getScopedRootline
‪getScopedRootline(SiteInterface $site, array $fullRootLine)
Definition: AbstractTemplateModuleController.php:174
‪TYPO3\CMS\Tstemplate\Controller\ActiveTypoScriptController\handleToggledSetupConditions
‪handleToggledSetupConditions(RootInclude $setupTree, ModuleData $moduleData, ?array $parsedBody, array $flattenedConstants)
Definition: ActiveTypoScriptController.php:460
‪TYPO3\CMS\Backend\Module\ModuleData\set
‪set(string $propertyName, mixed $value)
Definition: ModuleData.php:66
‪TYPO3\CMS\Core\Http\RedirectResponse
Definition: RedirectResponse.php:30
‪TYPO3\CMS\Tstemplate\Controller\ActiveTypoScriptController\__construct
‪__construct(private readonly ContainerInterface $container, private readonly ModuleTemplateFactory $moduleTemplateFactory, private readonly FlashMessageService $flashMessageService, private readonly SysTemplateRepository $sysTemplateRepository, private readonly SysTemplateTreeBuilder $treeBuilder,)
Definition: ActiveTypoScriptController.php:59
‪TYPO3\CMS\Tstemplate\Controller\ActiveTypoScriptController\addBackButtonToDocHeader
‪addBackButtonToDocHeader(ModuleTemplate $view, int $pageUid)
Definition: ActiveTypoScriptController.php:518
‪TYPO3\CMS\Tstemplate\Controller\ActiveTypoScriptController\editAction
‪editAction(ServerRequestInterface $request)
Definition: ActiveTypoScriptController.php:205
‪TYPO3\CMS\Tstemplate\Controller\AbstractTemplateModuleController\getLanguageService
‪getLanguageService()
Definition: AbstractTemplateModuleController.php:272
‪TYPO3\CMS\Backend\Template\ModuleTemplate\getDocHeaderComponent
‪getDocHeaderComponent()
Definition: ModuleTemplate.php:181
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:27
‪TYPO3\CMS\Core\DataHandling\DataHandler\start
‪start(array $dataMap, array $commandMap, ?BackendUserAuthentication $backendUser=null, ?ReferenceIndexUpdater $referenceIndexUpdater=null)
Definition: DataHandler.php:517
‪TYPO3\CMS\Tstemplate\Controller\ActiveTypoScriptController\updateAction
‪updateAction(ServerRequestInterface $request)
Definition: ActiveTypoScriptController.php:321
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Traverser\ConditionVerdictAwareIncludeTreeTraverser
Definition: ConditionVerdictAwareIncludeTreeTraverser.php:38
‪TYPO3\CMS\Backend\Attribute\AsController
Definition: AsController.php:25
‪TYPO3\CMS\Core\TypoScript\IncludeTree\IncludeNode\RootInclude
Definition: RootInclude.php:27
‪TYPO3\CMS\Tstemplate\Controller\ActiveTypoScriptController
Definition: ActiveTypoScriptController.php:58
‪TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeConditionAggregatorVisitor
Definition: IncludeTreeConditionAggregatorVisitor.php:32
‪TYPO3\CMS\Tstemplate\Controller\AbstractTemplateModuleController\addPreviewButtonToDocHeader
‪addPreviewButtonToDocHeader(ModuleTemplate $view, int $pageId, int $dokType)
Definition: AbstractTemplateModuleController.php:127
‪TYPO3\CMS\Core\TypoScript\AST\Traverser\AstTraverser
Definition: AstTraverser.php:31
‪TYPO3\CMS\Core\DataHandling\DataHandler\process_datamap
‪bool void process_datamap()
Definition: DataHandler.php:721
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\TypoScript\IncludeTree\SysTemplateTreeBuilder
Definition: SysTemplateTreeBuilder.php:76
‪TYPO3\CMS\Core\Messaging\FlashMessageService
Definition: FlashMessageService.php:27
‪TYPO3\CMS\Backend\Module\ModuleData\getModuleIdentifier
‪getModuleIdentifier()
Definition: ModuleData.php:51
‪TYPO3\CMS\Core\TypoScript\AST\Visitor\AstNodeFinderVisitor
Definition: AstNodeFinderVisitor.php:30