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