TYPO3 v15 dev-main snapshot ()

This commit is contained in:
2026-08-10 22:31:41 +02:00
commit 621587f02d
50 changed files with 4650 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
/vendor/
@@ -0,0 +1,317 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Tstemplate\Controller;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Routing\PreviewUriBuilder;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Template\Components\ButtonBar;
use TYPO3\CMS\Backend\Template\Components\ComponentFactory;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Context\VisibilityAspect;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
use TYPO3\CMS\Core\Http\RedirectResponse;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Schema\Capability\TcaSchemaCapability;
use TYPO3\CMS\Core\Schema\TcaSchemaFactory;
use TYPO3\CMS\Core\Site\Entity\Site;
use TYPO3\CMS\Core\Site\Entity\SiteInterface;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Abstract class with helper methods for single 3rd level Template module controllers.
*
* @internal This is a specific Backend Controller implementation and is not considered part of the Public TYPO3 API.
*/
abstract class AbstractTemplateModuleController
{
protected IconFactory $iconFactory;
protected UriBuilder $uriBuilder;
protected ConnectionPool $connectionPool;
protected SiteFinder $siteFinder;
protected ComponentFactory $componentFactory;
private DataHandler $dataHandler;
private TcaSchemaFactory $tcaSchemaFactory;
public function injectIconFactory(IconFactory $iconFactory): void
{
$this->iconFactory = $iconFactory;
}
public function injectUriBuilder(UriBuilder $uriBuilder)
{
$this->uriBuilder = $uriBuilder;
}
public function injectConnectionPool(ConnectionPool $connectionPool)
{
$this->connectionPool = $connectionPool;
}
public function injectDataHandler(DataHandler $dataHandler)
{
$this->dataHandler = $dataHandler;
}
public function injectSiteFinder(SiteFinder $siteFinder)
{
$this->siteFinder = $siteFinder;
}
public function injectTcaSchemaFactory(TcaSchemaFactory $tcaSchemaFactory)
{
$this->tcaSchemaFactory = $tcaSchemaFactory;
}
public function injectComponentFactory(ComponentFactory $componentFactory): void
{
$this->componentFactory = $componentFactory;
}
/**
* Action shared by info/modify ond constant editor to create a new "extension template"
*/
protected function createExtensionTemplateAction(ServerRequestInterface $request, string $redirectTarget): ResponseInterface
{
$pageUid = (int)($request->getQueryParams()['id'] ?? 0);
if ($pageUid === 0) {
throw new \RuntimeException('No proper page uid given', 1661333864);
}
$recordData['sys_template']['NEW'] = [
'pid' => $pageUid,
'title' => '+ext',
];
$this->dataHandler->start($recordData, []);
$this->dataHandler->process_datamap();
return new RedirectResponse($this->uriBuilder->buildUriFromRoute($redirectTarget, ['id' => $pageUid]));
}
/**
* Action shared by info/modify ond constant editor to create a new "site template"
*/
protected function createNewWebsiteTemplateAction(ServerRequestInterface $request, string $redirectTarget): ResponseInterface
{
$languageService = $this->getLanguageService();
$pageUid = (int)($request->getQueryParams()['id'] ?? 0);
if ($pageUid === 0) {
throw new \RuntimeException('No proper page uid given', 1661333863);
}
$recordData['sys_template']['NEW'] = [
'pid' => $pageUid,
'title' => $languageService->sL('LLL:EXT:tstemplate/Resources/Private/Language/locallang.xlf:noRecordFound.createRootTypoScriptRecord.title.placeholder'),
'sorting' => 0,
'root' => 1,
'clear' => 3,
'config' => "\n"
. "# Default PAGE object:\n"
. "page = PAGE\n"
. "page.10 = TEXT\n"
. "page.10.value = HELLO WORLD!\n",
];
$this->dataHandler->start($recordData, []);
$this->dataHandler->process_datamap();
return new RedirectResponse($this->uriBuilder->buildUriFromRoute($redirectTarget, ['id' => $pageUid]));
}
protected function addPreviewButtonToDocHeader(ModuleTemplate $view, array $pageRecord): void
{
$previewUriBuilder = PreviewUriBuilder::create($pageRecord);
if ($previewUriBuilder->isPreviewable()) {
$view->addButtonToButtonBar($this->componentFactory->createViewButton(
$previewUriBuilder
->withRootLine(BackendUtility::BEgetRootLine($pageRecord['uid']))
->buildDispatcherDataAttributes() ?? []
), ButtonBar::BUTTON_POSITION_LEFT, 99);
}
}
protected function addShortcutButtonToDocHeader(ModuleTemplate $view, string $moduleIdentifier, array $pageInfo, int $pageUid, string $moduleTitle): void
{
$shortcutTitle = sprintf(
'%s: %s [%d]',
$moduleTitle,
BackendUtility::getRecordTitle('pages', $pageInfo),
$pageUid
);
$view->getDocHeaderComponent()->setShortcutContext(
$moduleIdentifier,
$shortcutTitle,
['id' => $pageUid]
);
}
/**
* Get the closest page row that has a template up in rootline
*/
protected function getClosestAncestorPageWithTemplateRecord(int $pageId): array
{
$rootLine = BackendUtility::BEgetRootLine($pageId);
foreach ($rootLine as $rootlineNode) {
if ($this->getFirstTemplateRecordOnPage((int)$rootlineNode['uid'])) {
return $rootlineNode;
}
}
return [];
}
protected function getScopedRootline(SiteInterface $site, array $fullRootLine): array
{
if (!$site instanceof Site) {
return $fullRootLine;
}
if (!$site->isTypoScriptRoot()) {
return $fullRootLine;
}
$rootLineUntilSite = [];
foreach ($fullRootLine as $index => $rootlinePage) {
$rootlinePageId = (int)($rootlinePage['uid'] ?? 0);
$rootLineUntilSite[$index] = $rootlinePage;
if ($rootlinePageId === $site->getRootPageId()) {
break;
}
}
return $rootLineUntilSite;
}
/**
* Get an array of all template records on a page.
*/
protected function getAllTemplateRecordsOnPage(int $pageId): array
{
if (!$pageId) {
return [];
}
$templateRecords = [];
try {
$site = $this->siteFinder->getSiteByRootPageId($pageId);
if ($site->isTypoScriptRoot()) {
$typoScript = $site->getTypoScript();
$templateRecords[] = [
'type' => 'site',
'pid' => $pageId,
'constants' => $typoScript->constants ?? '',
'config' => $typoScript->setup ?? '',
'root' => 1,
'clear' => 1,
'sorting' => -1,
'uid' => -1,
'site' => $site,
'title' => $site->getConfiguration()['websiteTitle'] ?? '',
];
}
} catch (SiteNotFoundException) {
// ignore
}
$result = $this->getTemplateQueryBuilder($pageId)->executeQuery();
while ($row = $result->fetchAssociative()) {
$templateRecords[] = [...$row, 'type' => 'sys_template'];
}
return $templateRecords;
}
/**
* Get a single sys_template record attached to a single page.
* If multiple template records are on this page, the first (order by sorting)
* record will be returned, unless a specific template uid is specified via $templateUid
*
* @param int $pageId The pid to select sys_template records from
* @param int $templateUid Optional template uid
* @return array<string,mixed>|false Returns the template record or false if none was found
*/
protected function getFirstTemplateRecordOnPage(int $pageId, int $templateUid = 0): array|false
{
if (empty($pageId)) {
return false;
}
$queryBuilder = $this->getTemplateQueryBuilder($pageId)->setMaxResults(1);
if ($templateUid) {
$queryBuilder->andWhere(
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($templateUid, Connection::PARAM_INT))
);
}
return $queryBuilder->executeQuery()->fetchAssociative();
}
/**
* Helper method to prepare the query builder for getting sys_template records from a given pid.
*/
protected function getTemplateQueryBuilder(int $pid): QueryBuilder
{
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('sys_template');
$queryBuilder->getRestrictions()
->removeAll()
->add(GeneralUtility::makeInstance(DeletedRestriction::class));
$queryBuilder->select('*')
->from('sys_template')
->where(
$queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($pid, Connection::PARAM_INT))
);
$schema = $this->tcaSchemaFactory->has('sys_template')
? $this->tcaSchemaFactory->get('sys_template')
: null;
if ($schema && $schema->hasCapability(TcaSchemaCapability::SortByField)) {
$queryBuilder
->orderBy($schema->getCapability(TcaSchemaCapability::SortByField)->getFieldName());
}
return $queryBuilder;
}
/**
* Create a VisibilityAspect that simulates frontend-like behavior:
* hidden templates and templates outside their scheduled time window
* are excluded, as they would be in the frontend.
*/
protected function createVisibilityAspect(): VisibilityAspect
{
// For the context of the TypoScript management backend, we want to
// edit TypoScript records that are hidden. But in a backend submodule like
// the ActiveTypoScriptController / TemplateAnalyzerController, only
// non-hidden records with matching time constraints should be evaluated,
// just like in the frontend.
return new VisibilityAspect(
includeHiddenPages: true,
includeHiddenContent: false,
includeDeletedRecords: false,
includeScheduledRecords: false,
);
}
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
protected function getBackendUser(): BackendUserAuthentication
{
return $GLOBALS['BE_USER'];
}
}
@@ -0,0 +1,495 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Tstemplate\Controller;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Attribute\AsController;
use TYPO3\CMS\Backend\Module\ModuleData;
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Http\RedirectResponse;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\TypoScript\AST\Traverser\AstTraverser;
use TYPO3\CMS\Core\TypoScript\AST\Visitor\AstNodeFinderVisitor;
use TYPO3\CMS\Core\TypoScript\AST\Visitor\AstSortChildrenVisitor;
use TYPO3\CMS\Core\TypoScript\IncludeTree\IncludeNode\RootInclude;
use TYPO3\CMS\Core\TypoScript\IncludeTree\SysTemplateRepository;
use TYPO3\CMS\Core\TypoScript\IncludeTree\SysTemplateTreeBuilder;
use TYPO3\CMS\Core\TypoScript\IncludeTree\Traverser\ConditionVerdictAwareIncludeTreeTraverser;
use TYPO3\CMS\Core\TypoScript\IncludeTree\Traverser\IncludeTreeTraverser;
use TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeAstBuilderVisitor;
use TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeCommentAwareAstBuilderVisitor;
use TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeConditionAggregatorVisitor;
use TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeConditionEnforcerVisitor;
use TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeSetupConditionConstantSubstitutionVisitor;
use TYPO3\CMS\Core\TypoScript\Tokenizer\LosslessTokenizer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\RootlineUtility;
/**
* The "TypoScript -> Active TypoScript" Backend module
*
* @internal This is a specific Backend Controller implementation and is not considered part of the Public TYPO3 API.
*/
#[AsController]
final class ActiveTypoScriptController extends AbstractTemplateModuleController
{
public function __construct(
private readonly ContainerInterface $container,
private readonly ModuleTemplateFactory $moduleTemplateFactory,
private readonly FlashMessageService $flashMessageService,
private readonly SysTemplateRepository $sysTemplateRepository,
private readonly SysTemplateTreeBuilder $treeBuilder,
) {}
/**
* Default view renders options, constant and setup conditions, constant and setup tree.
*/
public function indexAction(ServerRequestInterface $request): ResponseInterface
{
$backendUser = $this->getBackendUser();
$languageService = $this->getLanguageService();
$queryParams = $request->getQueryParams();
$parsedBody = $request->getParsedBody();
$currentModule = $request->getAttribute('module');
$currentModuleIdentifier = $currentModule->getIdentifier();
$moduleData = $request->getAttribute('moduleData');
$pageUid = (int)($queryParams['id'] ?? 0);
if ($pageUid === 0) {
// Redirect to template record overview if on page 0.
return new RedirectResponse($this->uriBuilder->buildUriFromRoute('web_typoscript_recordsoverview'));
}
$pageRecord = BackendUtility::readPageAccess($pageUid, '1=1') ?: [];
if (empty($pageRecord)) {
// Redirect to records overview if page could not be determined.
// Edge case if page has been removed meanwhile.
BackendUtility::setUpdateSignal('updatePageTree');
return new RedirectResponse($this->uriBuilder->buildUriFromRoute('web_typoscript_recordsoverview'));
}
// @todo: Switch to BU::BEgetRootLine($pageUid, '', true) as in PageTsConfig? Similar in other controllers and actions.
$rootLine = GeneralUtility::makeInstance(RootlineUtility::class, $pageUid)->get();
$site = $request->getAttribute('site');
$rootLine = $this->getScopedRootline($site, $rootLine);
// Template selection handling for this page
$allTemplatesOnPage = $this->getAllTemplateRecordsOnPage($pageUid);
$selectedTemplateFromModuleData = (array)$moduleData->get('selectedTemplatePerPage');
$selectedTemplateUid = (int)($parsedBody['selectedTemplate'] ?? $selectedTemplateFromModuleData[$pageUid] ?? 0);
if (!in_array($selectedTemplateUid, array_column($allTemplatesOnPage, 'uid'))) {
$selectedTemplateUid = (int)($allTemplatesOnPage[0]['uid'] ?? 0);
}
if (($moduleData->get('selectedTemplatePerPage')[$pageUid] ?? 0) !== $selectedTemplateUid) {
$selectedTemplateFromModuleData[$pageUid] = $selectedTemplateUid;
$moduleData->set('selectedTemplatePerPage', $selectedTemplateFromModuleData);
$backendUser->pushModuleData($currentModuleIdentifier, $moduleData->toArray());
}
$templateTitle = '';
foreach ($allTemplatesOnPage as $templateRow) {
if ((int)$templateRow['uid'] === $selectedTemplateUid) {
$templateTitle = $templateRow['title'];
}
}
// Force boolean toggles to bool and init further get/post vars
if ($moduleData->clean('sortAlphabetically', [true, false])) {
$backendUser->pushModuleData($currentModuleIdentifier, $moduleData->toArray());
}
$sortAlphabetically = $moduleData->get('sortAlphabetically');
if ($moduleData->clean('displayConstantSubstitutions', [true, false])) {
$backendUser->pushModuleData($currentModuleIdentifier, $moduleData->toArray());
}
$displayConstantSubstitutions = $moduleData->get('displayConstantSubstitutions');
if ($moduleData->clean('displayComments', [true, false])) {
$backendUser->pushModuleData($currentModuleIdentifier, $moduleData->toArray());
}
$displayComments = $moduleData->get('displayComments');
$sysTemplateRows = $this->sysTemplateRepository->getSysTemplateRowsByRootlineWithUidOverride($rootLine, $request, $selectedTemplateUid, $this->createVisibilityAspect());
// Build the constant include tree
$constantIncludeTree = $this->treeBuilder->getTreeBySysTemplateRowsAndSite('constants', $sysTemplateRows, new LosslessTokenizer(), $site);
// Set enabled conditions in constant include tree
$constantConditions = $this->handleToggledConstantConditions($constantIncludeTree, $moduleData, $parsedBody);
$conditionEnforcerVisitor = new IncludeTreeConditionEnforcerVisitor();
$conditionEnforcerVisitor->setEnabledConditions(array_column(array_filter($constantConditions, static fn($condition) => $condition['active']), 'value'));
$treeTraverser = new ConditionVerdictAwareIncludeTreeTraverser();
$treeTraverserVisitors = [];
$treeTraverserVisitors[] = $conditionEnforcerVisitor;
$constantAstBuilderVisitor = $this->container->get(IncludeTreeCommentAwareAstBuilderVisitor::class);
$treeTraverserVisitors[] = $constantAstBuilderVisitor;
$treeTraverser->traverse($constantIncludeTree, $treeTraverserVisitors);
$constantAst = $constantAstBuilderVisitor->getAst();
$constantAst->setIdentifier('TypoScript constants');
if ($sortAlphabetically) {
$astTraverser = new AstTraverser();
$astTraverser->traverse($constantAst, [new AstSortChildrenVisitor()]);
}
// Flatten constant AST. Needed for setup condition display and setup AST constant substitution.
$flattenedConstants = $constantAst->flatten();
// Build the setup include tree
$setupIncludeTree = $this->treeBuilder->getTreeBySysTemplateRowsAndSite('setup', $sysTemplateRows, new LosslessTokenizer(), $site);
// Set enabled conditions in setup include tree and let it handle constant substitutions in setup conditions.
$setupConditions = $this->handleToggledSetupConditions($setupIncludeTree, $moduleData, $parsedBody, $flattenedConstants);
$conditionEnforcerVisitor = new IncludeTreeConditionEnforcerVisitor();
$conditionEnforcerVisitor->setEnabledConditions(array_column(array_filter($setupConditions, static fn($condition) => $condition['active']), 'value'));
$treeTraverser = new ConditionVerdictAwareIncludeTreeTraverser();
$treeTraverserVisitors = [];
$treeTraverserVisitors[] = $conditionEnforcerVisitor;
$setupAstBuilderVisitor = $this->container->get(IncludeTreeCommentAwareAstBuilderVisitor::class);
$setupAstBuilderVisitor->setFlatConstants($flattenedConstants);
$treeTraverserVisitors[] = $setupAstBuilderVisitor;
$treeTraverser->traverse($setupIncludeTree, $treeTraverserVisitors);
// Build the setup AST
$setupAst = $setupAstBuilderVisitor->getAst();
$setupAst->setIdentifier('TypoScript setup');
if ($sortAlphabetically) {
$astTraverser = new AstTraverser();
$astTraverser->traverse($setupAst, [new AstSortChildrenVisitor()]);
}
$view = $this->moduleTemplateFactory->create($request);
$view->setTitle($languageService->sL($currentModule->getTitle()), $pageRecord['title']);
$view->getDocHeaderComponent()->setPageBreadcrumb($pageRecord);
$this->addPreviewButtonToDocHeader($view, $pageRecord);
$this->addShortcutButtonToDocHeader($view, $currentModuleIdentifier, $pageRecord, $pageUid, $languageService->sL('LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:submodule.title'));
$view->makeDocHeaderModuleMenu(['id' => $pageUid]);
$view->assignMultiple([
'templateTitle' => $templateTitle,
'selectedTemplateUid' => $selectedTemplateUid,
'pageUid' => $pageUid,
'allTemplatesOnPage' => $allTemplatesOnPage,
'sortAlphabetically' => $sortAlphabetically,
'displayConstantSubstitutions' => $displayConstantSubstitutions,
'displayComments' => $displayComments,
'constantConditions' => $constantConditions,
'constantConditionsActiveCount' => count(array_filter($constantConditions, static fn($condition) => $condition['active'])),
'constantAst' => $constantAst,
'setupConditions' => $setupConditions,
'setupConditionsActiveCount' => count(array_filter($setupConditions, static fn($condition) => $condition['active'])),
'setupAst' => $setupAst,
]);
return $view->renderResponse('ActiveMain');
}
/**
* Edit a single property. Linked from "show" view when clicking a property.
*/
public function editAction(ServerRequestInterface $request): ResponseInterface
{
$languageService = $this->getLanguageService();
$queryParams = $request->getQueryParams();
$currentModule = $request->getAttribute('module');
$moduleData = $request->getAttribute('moduleData');
$pageUid = (int)($queryParams['id'] ?? 0);
$type = $queryParams['type'] ?? '';
$nodeIdentifier = $queryParams['nodeIdentifier'] ?? '';
if (empty($pageUid) || !in_array($type, ['constant', 'setup']) || empty($nodeIdentifier)) {
throw new \RuntimeException('Required action argument missing or invalid', 1658562276);
}
$pageRecord = BackendUtility::readPageAccess($pageUid, '1=1') ?: [];
if (empty($pageRecord)) {
// Redirect to records overview if page could not be determined.
// Edge case if page has been removed meanwhile.
BackendUtility::setUpdateSignal('updatePageTree');
return new RedirectResponse($this->uriBuilder->buildUriFromRoute('web_typoscript_recordsoverview'));
}
// @todo: Switch to BU::BEgetRootLine($pageUid, '', true) as in PageTsConfig? Similar in other controllers and actions.
$rootLine = GeneralUtility::makeInstance(RootlineUtility::class, $pageUid)->get();
$site = $request->getAttribute('site');
$rootLine = $this->getScopedRootline($site, $rootLine);
// Template selection handling
$allTemplatesOnPage = $this->getAllTemplateRecordsOnPage($pageUid);
$selectedTemplateFromModuleData = (array)$moduleData->get('selectedTemplatePerPage');
$selectedTemplateUid = (int)($selectedTemplateFromModuleData[$pageUid] ?? 0);
if (!in_array($selectedTemplateUid, array_column($allTemplatesOnPage, 'uid'))) {
$selectedTemplateUid = (int)($allTemplatesOnPage[0]['uid'] ?? 0);
}
$hasTemplate = false;
$templateTitle = '';
foreach ($allTemplatesOnPage as $templateRow) {
if ((int)$templateRow['uid'] === $selectedTemplateUid) {
$hasTemplate = true;
$templateTitle = $templateRow['title'];
}
}
$sysTemplateRows = $this->sysTemplateRepository->getSysTemplateRowsByRootlineWithUidOverride($rootLine, $request, $selectedTemplateUid, $this->createVisibilityAspect());
// Get current value of to-edit object path
// Build the constant include tree
$constantIncludeTree = $this->treeBuilder->getTreeBySysTemplateRowsAndSite('constants', $sysTemplateRows, new LosslessTokenizer(), $site);
// Set enabled conditions in constant include tree
$constantConditions = $this->handleToggledConstantConditions($constantIncludeTree, $moduleData, null);
$conditionEnforcerVisitor = new IncludeTreeConditionEnforcerVisitor();
$conditionEnforcerVisitor->setEnabledConditions(array_column(array_filter($constantConditions, static fn($condition) => $condition['active']), 'value'));
$treeTraverser = new ConditionVerdictAwareIncludeTreeTraverser();
$treeTraverserVisitors = [];
$treeTraverserVisitors[] = $conditionEnforcerVisitor;
$constantAstBuilderVisitor = $this->container->get(IncludeTreeAstBuilderVisitor::class);
$treeTraverserVisitors[] = $constantAstBuilderVisitor;
$treeTraverser->traverse($constantIncludeTree, $treeTraverserVisitors);
$astNodeFinderVisitor = new AstNodeFinderVisitor();
$astNodeFinderVisitor->setNodeIdentifier($nodeIdentifier);
if ($type === 'constant') {
$constantAst = $constantAstBuilderVisitor->getAst();
$constantAst->setIdentifier('TypoScript constants');
$astTraverser = new AstTraverser();
$astTraverser->traverse($constantAst, [$astNodeFinderVisitor]);
} else {
// Build the setup include tree
$setupIncludeTree = $this->treeBuilder->getTreeBySysTemplateRowsAndSite('setup', $sysTemplateRows, new LosslessTokenizer(), $site);
$flattenedConstants = $constantAstBuilderVisitor->getAst()->flatten();
// Set enabled conditions in setup include tree
$setupConditions = $this->handleToggledSetupConditions($setupIncludeTree, $moduleData, null, $flattenedConstants);
$conditionEnforcerVisitor = new IncludeTreeConditionEnforcerVisitor();
$conditionEnforcerVisitor->setEnabledConditions(array_column(array_filter($setupConditions, static fn($condition) => $condition['active']), 'value'));
$treeTraverser = new ConditionVerdictAwareIncludeTreeTraverser();
$treeTraverserVisitors = [];
$treeTraverserVisitors[] = $conditionEnforcerVisitor;
$setupAstBuilderVisitor = $this->container->get(IncludeTreeAstBuilderVisitor::class);
$setupAstBuilderVisitor->setFlatConstants($flattenedConstants);
$treeTraverserVisitors[] = $setupAstBuilderVisitor;
$treeTraverser->traverse($setupIncludeTree, $treeTraverserVisitors);
$setupAst = $setupAstBuilderVisitor->getAst();
$setupAst->setIdentifier('TypoScript setup');
$astTraverser = new AstTraverser();
$astTraverser->traverse($setupAst, [$astNodeFinderVisitor]);
}
$foundNode = $astNodeFinderVisitor->getFoundNode();
$foundNodeCurrentObjectPath = $astNodeFinderVisitor->getFoundNodeCurrentObjectPath();
if ($foundNode === null || $foundNodeCurrentObjectPath === null) {
throw new \RuntimeException('Node with identifier ' . $nodeIdentifier . ' to edit not found', 1675241994);
}
$view = $this->moduleTemplateFactory->create($request);
$view->setTitle($languageService->sL($currentModule->getTitle()), $pageRecord['title']);
$view->getDocHeaderComponent()->setPageBreadcrumb($pageRecord);
$view->makeDocHeaderModuleMenu(['id' => $pageUid]);
$view->assignMultiple([
'pageUid' => $pageUid,
'hasTemplate' => $hasTemplate,
'templateTitle' => $templateTitle,
'type' => $type,
'currentObjectPath' => $foundNodeCurrentObjectPath->getPathAsString(),
'currentValue' => $foundNode->getValue(),
]);
return $view->renderResponse('ActiveEdit');
}
/**
* Add a line to selected sys_template record of given page after editing or clearing a
* property or adding a child in 'edit' view. Update either 'constants' or 'config' field
* using DataHandler, add a flash message and redirect to default "show" action.
*/
public function updateAction(ServerRequestInterface $request): ResponseInterface
{
$languageService = $this->getLanguageService();
$moduleData = $request->getAttribute('moduleData');
$parsedBody = $request->getParsedBody();
$pageUid = (int)($parsedBody['pageUid'] ?? 0);
$type = $parsedBody['type'] ?? '';
$currentObjectPath = $parsedBody['currentObjectPath'] ?? '';
$command = null;
if (isset($parsedBody['updateValue'])) {
$command = 'updateValue';
} elseif (isset($parsedBody['addChild'])) {
$command = 'addChild';
} elseif (isset($parsedBody['clear'])) {
$command = 'clear';
}
if (empty($pageUid) || !in_array($type, ['constant', 'setup']) || empty($currentObjectPath) || empty($command)) {
throw new \RuntimeException('Required action argument missing or invalid', 1658568446);
}
// Template selection handling
$allTemplatesOnPage = $this->getAllTemplateRecordsOnPage($pageUid);
$selectedTemplateFromModuleData = (array)$moduleData->get('selectedTemplatePerPage');
$selectedTemplateUid = (int)($selectedTemplateFromModuleData[$pageUid] ?? 0);
$templateRow = null;
foreach ($allTemplatesOnPage as $template) {
if ($selectedTemplateUid === (int)$template['uid']) {
$templateRow = $template;
}
}
if (!in_array($selectedTemplateUid, array_column($allTemplatesOnPage, 'uid'))) {
$templateRow = $allTemplatesOnPage[0] ?? [];
$selectedTemplateUid = (int)($templateRow['uid'] ?? 0);
}
if ($selectedTemplateUid < 1) {
throw new \RuntimeException('No template on page found', 1658568794);
}
$newLine = null;
$flashMessageQueue = $this->flashMessageService->getMessageQueueByIdentifier();
switch ($command) {
case 'updateValue':
$newLine = $currentObjectPath . ' = ' . trim($parsedBody['value'] ?? '');
break;
case 'addChild':
$childName = str_replace('\\', '', $parsedBody['childName'] ?? '');
if (empty($childName) || preg_replace('/[^a-zA-Z0-9_\.]*/', '', $childName) != $childName) {
$flashMessage = new FlashMessage(
$languageService->sL('LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:updateAction.noSpaces'),
$languageService->sL('LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:updateAction.lineNotAdded'),
ContextualFeedbackSeverity::WARNING,
true
);
$flashMessageQueue->enqueue($flashMessage);
break;
}
$childName = addcslashes($parsedBody['childName'] ?? '', '.');
$childValue = trim($parsedBody['childValue'] ?? '');
$newLine = $currentObjectPath . '.' . $childName . ' = ' . $childValue;
break;
case 'clear':
$newLine = $currentObjectPath . ' >';
break;
}
if ($newLine) {
$fieldName = $type === 'constant' ? 'constants' : 'config';
$recordData = [
'sys_template' => [
$selectedTemplateUid => [
$fieldName => ($templateRow[$fieldName] ?? '') . LF . $newLine,
],
],
];
$dataHandler = GeneralUtility::makeInstance(DataHandler::class);
$dataHandler->start($recordData, []);
$dataHandler->process_datamap();
$flashMessage = new FlashMessage(
$newLine,
$languageService->sL('LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:updateAction.lineAdded'),
ContextualFeedbackSeverity::OK,
true
);
$flashMessageQueue->enqueue($flashMessage);
}
return new RedirectResponse($this->uriBuilder->buildUriFromRoute('typoscript_active', ['id' => $pageUid]));
}
/**
* Align module data active constant conditions with toggled conditions from POST,
* write updated active conditions to user's module data if needed and
* prepare a list of active conditions for view.
*/
private function handleToggledConstantConditions(RootInclude $constantTree, ModuleData $moduleData, ?array $parsedBody): array
{
$conditionAggregatorVisitor = new IncludeTreeConditionAggregatorVisitor();
$treeTraverser = new IncludeTreeTraverser();
$treeTraverser->traverse($constantTree, [$conditionAggregatorVisitor]);
$constantConditions = $conditionAggregatorVisitor->getConditions();
$conditionsFromPost = $parsedBody['constantConditions'] ?? [];
$conditionsFromModuleData = array_flip((array)$moduleData->get('constantConditions'));
$typoscriptConditions = [];
foreach ($constantConditions as $condition) {
$conditionHash = sha1($condition['value']);
$conditionActive = array_key_exists($conditionHash, $conditionsFromModuleData);
// Note we're not feeding the post values directly to module data, but filter
// them through available conditions to prevent polluting module data with
// manipulated post values.
if (($conditionsFromPost[$conditionHash] ?? null) === '0') {
unset($conditionsFromModuleData[$conditionHash]);
$conditionActive = false;
} elseif (($conditionsFromPost[$conditionHash] ?? null) === '1') {
$conditionsFromModuleData[$conditionHash] = true;
$conditionActive = true;
}
$typoscriptConditions[] = [
'value' => $condition['value'],
'hash' => $conditionHash,
'active' => $conditionActive,
];
}
if ($conditionsFromPost) {
$moduleData->set('constantConditions', array_keys($conditionsFromModuleData));
$this->getBackendUser()->pushModuleData($moduleData->getModuleIdentifier(), $moduleData->toArray());
}
return $typoscriptConditions;
}
/**
* Align module data active setup conditions with toggled conditions from POST,
* write updated active conditions to user's module data if needed and
* prepare a list of active conditions for view.
*/
private function handleToggledSetupConditions(RootInclude $setupTree, ModuleData $moduleData, ?array $parsedBody, array $flattenedConstants): array
{
$setupConditionConstantSubstitutionVisitor = new IncludeTreeSetupConditionConstantSubstitutionVisitor();
$setupConditionConstantSubstitutionVisitor->setFlattenedConstants($flattenedConstants);
$treeTraverser = new IncludeTreeTraverser();
$treeTraverserVisitors = [];
$treeTraverserVisitors[] = $setupConditionConstantSubstitutionVisitor;
$conditionAggregatorVisitor = new IncludeTreeConditionAggregatorVisitor();
$treeTraverserVisitors[] = $conditionAggregatorVisitor;
$treeTraverser->traverse($setupTree, $treeTraverserVisitors);
$setupConditions = $conditionAggregatorVisitor->getConditions();
$conditionsFromPost = $parsedBody['setupConditions'] ?? [];
$conditionsFromModuleData = array_flip((array)$moduleData->get('setupConditions'));
$typoscriptConditions = [];
foreach ($setupConditions as $condition) {
$conditionHash = sha1($condition['value']);
$conditionActive = array_key_exists($conditionHash, $conditionsFromModuleData);
// Note we're not feeding the post values directly to module data, but filter
// them through available conditions to prevent polluting module data with
// manipulated post values.
if (($conditionsFromPost[$conditionHash] ?? null) === '0') {
unset($conditionsFromModuleData[$conditionHash]);
$conditionActive = false;
} elseif (($conditionsFromPost[$conditionHash] ?? null) === '1') {
$conditionsFromModuleData[$conditionHash] = true;
$conditionActive = true;
}
$typoscriptConditions[] = [
'value' => $condition['value'],
'originalValue' => $condition['originalValue'],
'hash' => $conditionHash,
'active' => $conditionActive,
];
}
if ($conditionsFromPost) {
$moduleData->set('setupConditions', array_keys($conditionsFromModuleData));
$this->getBackendUser()->pushModuleData($moduleData->getModuleIdentifier(), $moduleData->toArray());
}
return $typoscriptConditions;
}
}
@@ -0,0 +1,459 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Tstemplate\Controller;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Attribute\AsController;
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Http\RedirectResponse;
use TYPO3\CMS\Core\TypoScript\AST\AstBuilderInterface;
use TYPO3\CMS\Core\TypoScript\AST\Node\RootNode;
use TYPO3\CMS\Core\TypoScript\AST\Traverser\AstTraverser;
use TYPO3\CMS\Core\TypoScript\AST\Visitor\AstConstantCommentVisitor;
use TYPO3\CMS\Core\TypoScript\IncludeTree\SysTemplateRepository;
use TYPO3\CMS\Core\TypoScript\IncludeTree\SysTemplateTreeBuilder;
use TYPO3\CMS\Core\TypoScript\IncludeTree\Traverser\IncludeTreeTraverser;
use TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeCommentAwareAstBuilderVisitor;
use TYPO3\CMS\Core\TypoScript\Tokenizer\LosslessTokenizer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Core\Utility\RootlineUtility;
/**
* TypoScript Constant editor
*
* @internal This is a specific Backend Controller implementation and is not considered part of the Public TYPO3 API.
*/
#[AsController]
class ConstantEditorController extends AbstractTemplateModuleController
{
public function __construct(
protected readonly ModuleTemplateFactory $moduleTemplateFactory,
private readonly SysTemplateRepository $sysTemplateRepository,
private readonly SysTemplateTreeBuilder $treeBuilder,
private readonly IncludeTreeTraverser $treeTraverser,
private readonly AstTraverser $astTraverser,
private readonly AstBuilderInterface $astBuilder,
private readonly LosslessTokenizer $losslessTokenizer,
) {}
public function handleRequest(ServerRequestInterface $request): ResponseInterface
{
$queryParams = $request->getQueryParams();
$parsedBody = $request->getParsedBody();
$pageUid = (int)($queryParams['id'] ?? 0);
if ($pageUid === 0) {
// Redirect to template record overview if on page 0.
return new RedirectResponse($this->uriBuilder->buildUriFromRoute('web_typoscript_recordsoverview'));
}
if (($parsedBody['action'] ?? '') === 'createExtensionTemplate') {
return $this->createExtensionTemplateAction($request, 'web_typoscript_constanteditor');
}
if (($parsedBody['action'] ?? '') === 'createNewWebsiteTemplate') {
return $this->createNewWebsiteTemplateAction($request, 'web_typoscript_constanteditor');
}
if (($parsedBody['_savedok'] ?? false) === '1') {
return $this->saveAction($request);
}
$pageUid = (int)($queryParams['id'] ?? 0);
$allTemplatesOnPage = $this->getAllTemplateRecordsOnPage($pageUid);
if (empty($allTemplatesOnPage)) {
return $this->noTemplateAction($request);
}
return $this->showAction($request);
}
private function showAction(ServerRequestInterface $request): ResponseInterface
{
$queryParams = $request->getQueryParams();
$parsedBody = $request->getParsedBody();
$languageService = $this->getLanguageService();
$backendUser = $this->getBackendUser();
$pageUid = (int)($queryParams['id'] ?? 0);
$currentModule = $request->getAttribute('module');
$currentModuleIdentifier = $currentModule->getIdentifier();
$moduleData = $request->getAttribute('moduleData');
if ($moduleData->cleanUp([])) {
$backendUser->pushModuleData($currentModuleIdentifier, $moduleData->toArray());
}
$pageRecord = BackendUtility::readPageAccess($pageUid, '1=1') ?: [];
if (empty($pageRecord)) {
// Redirect to records overview if page could not be determined.
// Edge case if page has been removed meanwhile.
BackendUtility::setUpdateSignal('updatePageTree');
return new RedirectResponse($this->uriBuilder->buildUriFromRoute('web_typoscript_recordsoverview'));
}
// Template selection handling for this page
$allTemplatesOnPage = $this->getAllTemplateRecordsOnPage($pageUid);
$selectedTemplateFromModuleData = (array)$moduleData->get('selectedTemplatePerPage');
$selectedTemplateUid = (int)($parsedBody['selectedTemplate'] ?? $selectedTemplateFromModuleData[$pageUid] ?? 0);
if (!in_array($selectedTemplateUid, array_column($allTemplatesOnPage, 'uid'))) {
$selectedTemplateUid = (int)($allTemplatesOnPage[0]['uid'] ?? 0);
}
if (($moduleData->get('selectedTemplatePerPage')[$pageUid] ?? 0) !== $selectedTemplateUid) {
$selectedTemplateFromModuleData[$pageUid] = $selectedTemplateUid;
$moduleData->set('selectedTemplatePerPage', $selectedTemplateFromModuleData);
$backendUser->pushModuleData($currentModuleIdentifier, $moduleData->toArray());
}
$templateTitle = '';
$currentTemplateConstants = '';
foreach ($allTemplatesOnPage as $templateRow) {
if ((int)$templateRow['uid'] === $selectedTemplateUid) {
$templateTitle = $templateRow['title'];
$currentTemplateConstants = $templateRow['constants'] ?? '';
}
}
$currentTemplateRecord = [];
foreach ($allTemplatesOnPage as $templateRow) {
if ((int)$templateRow['uid'] === $selectedTemplateUid) {
$currentTemplateRecord = $templateRow;
break;
}
}
// Build the constant include tree
$rootLine = GeneralUtility::makeInstance(RootlineUtility::class, $pageUid)->get();
$site = $request->getAttribute('site');
$rootLine = $this->getScopedRootline($site, $rootLine);
$sysTemplateRows = $this->sysTemplateRepository->getSysTemplateRowsByRootlineWithUidOverride($rootLine, $request, $selectedTemplateUid, $this->createVisibilityAspect());
$constantIncludeTree = $this->treeBuilder->getTreeBySysTemplateRowsAndSite('constants', $sysTemplateRows, $this->losslessTokenizer, $site);
$constantAstBuilderVisitor = GeneralUtility::makeInstance(IncludeTreeCommentAwareAstBuilderVisitor::class);
$this->treeTraverser->traverse($constantIncludeTree, [$constantAstBuilderVisitor]);
$constantAst = $constantAstBuilderVisitor->getAst();
$astConstantCommentVisitor = GeneralUtility::makeInstance(AstConstantCommentVisitor::class);
$currentTemplateFlatConstants = $this->astBuilder->build($this->losslessTokenizer->tokenize($currentTemplateConstants), new RootNode())->flatten();
$astConstantCommentVisitor->setCurrentTemplateFlatConstants($currentTemplateFlatConstants);
$this->astTraverser->traverse($constantAst, [$astConstantCommentVisitor]);
$constants = $astConstantCommentVisitor->getConstants();
$categories = $astConstantCommentVisitor->getCategories();
$relevantCategories = [];
foreach ($categories as $categoryKey => $aCategory) {
if ($aCategory['usageCount'] > 0) {
$relevantCategories[$categoryKey] = $aCategory;
}
}
$selectedCategory = array_key_first($relevantCategories) ?? '';
$selectedCategoryFromModuleData = (string)$moduleData->get('selectedCategory');
if (array_key_exists($selectedCategoryFromModuleData, $relevantCategories)) {
$selectedCategory = $selectedCategoryFromModuleData;
}
if (($parsedBody['selectedCategory'] ?? '') && array_key_exists($parsedBody['selectedCategory'], $relevantCategories)) {
$selectedCategory = (string)$parsedBody['selectedCategory'];
}
if ($selectedCategory && $selectedCategory !== $selectedCategoryFromModuleData) {
$moduleData->set('selectedCategory', $selectedCategory);
$backendUser->pushModuleData($currentModuleIdentifier, $moduleData->toArray());
}
$displayConstants = [];
foreach ($constants as $constant) {
if ($constant['cat'] === $selectedCategory) {
$displayConstants[$constant['subcat_sorting_first']]['label'] = $constant['subcat_label'];
$displayConstants[$constant['subcat_sorting_first']]['items'][$constant['subcat_sorting_second']][] = $constant;
}
}
ksort($displayConstants);
foreach ($displayConstants as &$constant) {
ksort($constant['items']);
}
$view = $this->moduleTemplateFactory->create($request);
$view->setTitle($languageService->sL($currentModule->getTitle()), $pageRecord['title']);
$view->getDocHeaderComponent()->setPageBreadcrumb($pageRecord);
$this->addPreviewButtonToDocHeader($view, $pageRecord);
$this->addShortcutButtonToDocHeader($view, $currentModuleIdentifier, $pageRecord, $pageUid, $languageService->sL('LLL:EXT:tstemplate/Resources/Private/Language/locallang_ceditor.xlf:submodule.title'));
if (!empty($relevantCategories)) {
$view->addButtonToButtonBar($this->componentFactory->createSaveButton('TypoScriptConstantEditorController'));
}
$view->makeDocHeaderModuleMenu(['id' => $pageUid]);
$view->assignMultiple([
'templateTitle' => $templateTitle,
'pageUid' => $pageUid,
'templateRecord' => $currentTemplateRecord,
'allTemplatesOnPage' => $allTemplatesOnPage,
'selectedTemplateUid' => $selectedTemplateUid,
'relevantCategories' => $relevantCategories,
'selectedCategory' => $selectedCategory,
'displayConstants' => $displayConstants,
]);
return $view->renderResponse('ConstantEditorMain');
}
private function saveAction(ServerRequestInterface $request): ResponseInterface
{
$queryParams = $request->getQueryParams();
$moduleData = $request->getAttribute('moduleData');
$pageUid = (int)($queryParams['id'] ?? 0);
if ($pageUid === 0) {
throw new \RuntimeException('No proper page uid given', 1661333862);
}
$allTemplatesOnPage = $this->getAllTemplateRecordsOnPage($pageUid);
$selectedTemplateFromModuleData = (array)$moduleData->get('selectedTemplatePerPage');
$selectedTemplateUid = (int)($selectedTemplateFromModuleData[$pageUid] ?? 0);
$templateRow = null;
foreach ($allTemplatesOnPage as $template) {
if ($selectedTemplateUid === (int)$template['uid']) {
$templateRow = $template;
}
}
if (!in_array($selectedTemplateUid, array_column($allTemplatesOnPage, 'uid'))) {
$templateRow = $allTemplatesOnPage[0] ?? [];
$selectedTemplateUid = (int)($templateRow['uid'] ?? 0);
}
if ($selectedTemplateUid < 1) {
throw new \RuntimeException('No template found on page', 1661350211);
}
$rootLine = GeneralUtility::makeInstance(RootlineUtility::class, $pageUid)->get();
$site = $request->getAttribute('site');
$rootLine = $this->getScopedRootline($site, $rootLine);
$sysTemplateRows = $this->sysTemplateRepository->getSysTemplateRowsByRootlineWithUidOverride($rootLine, $request, $selectedTemplateUid, $this->createVisibilityAspect());
$constantIncludeTree = $this->treeBuilder->getTreeBySysTemplateRowsAndSite('constants', $sysTemplateRows, $this->losslessTokenizer, $site);
$constantAstBuilderVisitor = GeneralUtility::makeInstance(IncludeTreeCommentAwareAstBuilderVisitor::class);
$this->treeTraverser->traverse($constantIncludeTree, [$constantAstBuilderVisitor]);
$constantAst = $constantAstBuilderVisitor->getAst();
$astConstantCommentVisitor = GeneralUtility::makeInstance(AstConstantCommentVisitor::class);
$this->astTraverser->traverse($constantAst, [$astConstantCommentVisitor]);
$constants = $astConstantCommentVisitor->getConstants();
$updatedTemplateConstantsArray = $this->updateTemplateConstants($request, $constants, $templateRow['constants'] ?? '');
if ($updatedTemplateConstantsArray) {
$templateUid = empty($templateRow['_ORIG_uid']) ? $templateRow['uid'] : $templateRow['_ORIG_uid'];
$recordData = [];
$recordData['sys_template'][$templateUid]['constants'] = implode(LF, $updatedTemplateConstantsArray);
$dataHandler = GeneralUtility::makeInstance(DataHandler::class);
$dataHandler->start($recordData, []);
$dataHandler->process_datamap();
}
return new RedirectResponse($this->uriBuilder->buildUriFromRoute('web_typoscript_constanteditor', ['id' => $pageUid]));
}
private function noTemplateAction(ServerRequestInterface $request): ResponseInterface
{
$languageService = $this->getLanguageService();
$currentModule = $request->getAttribute('module');
$currentModuleIdentifier = $currentModule->getIdentifier();
$pageUid = (int)($request->getQueryParams()['id'] ?? 0);
if ($pageUid === 0) {
throw new \RuntimeException('No proper page uid given', 1661365944);
}
$pageRecord = BackendUtility::readPageAccess($pageUid, '1=1') ?: [];
if (empty($pageRecord)) {
// Redirect to records overview if page could not be determined.
// Edge case if page has been removed meanwhile.
BackendUtility::setUpdateSignal('updatePageTree');
return new RedirectResponse($this->uriBuilder->buildUriFromRoute('web_typoscript_recordsoverview'));
}
$view = $this->moduleTemplateFactory->create($request);
$view->setTitle($languageService->sL($currentModule->getTitle()), $pageRecord['title']);
$view->getDocHeaderComponent()->setPageBreadcrumb($pageRecord);
$this->addPreviewButtonToDocHeader($view, $pageRecord);
$this->addShortcutButtonToDocHeader($view, $currentModuleIdentifier, $pageRecord, $pageUid, $languageService->sL('LLL:EXT:tstemplate/Resources/Private/Language/locallang_ceditor.xlf:submodule.title'));
$view->makeDocHeaderModuleMenu(['id' => $pageUid]);
$view->assignMultiple([
'pageUid' => $pageUid,
'moduleIdentifier' => $currentModuleIdentifier,
'previousPage' => $this->getClosestAncestorPageWithTemplateRecord($pageUid),
]);
return $view->renderResponse('ConstantEditorNoTemplate');
}
private function updateTemplateConstants(ServerRequestInterface $request, array $constantDefinitions, string $rawTemplateConstants): ?array
{
$rawTemplateConstantsArray = explode(LF, $rawTemplateConstants);
$constantPositions = $this->calculateConstantPositions($rawTemplateConstantsArray);
$parsedBody = $request->getParsedBody();
$data = $parsedBody['data'] ?? null;
$check = $parsedBody['check'] ?? [];
$valuesHaveChanged = false;
if (is_array($data)) {
foreach ($data as $key => $value) {
if (!isset($constantDefinitions[$key])) {
// Ignore if there is no constant definition for this constant key
continue;
}
if (!isset($check[$key]) || ($check[$key] !== 'checked' && isset($constantPositions[$key]))) {
// Remove value if the checkbox is not set, indicating "value to be dropped from template"
$rawTemplateConstantsArray = $this->removeValueFromConstantsArray($rawTemplateConstantsArray, $constantPositions, $key);
$valuesHaveChanged = true;
continue;
}
if ($check[$key] !== 'checked') {
// Don't process if this value is not set
continue;
}
$constantDefinition = $constantDefinitions[$key];
switch ($constantDefinition['type']) {
case 'int':
$min = $constantDefinition['typeIntMin'] ?? PHP_INT_MIN;
$max = $constantDefinition['typeIntMax'] ?? PHP_INT_MAX;
$value = (string)MathUtility::forceIntegerInRange((int)$value, (int)$min, (int)$max);
break;
case 'int+':
$min = $constantDefinition['typeIntMin'] ?? 0;
$max = $constantDefinition['typeIntMax'] ?? PHP_INT_MAX;
$value = (string)MathUtility::forceIntegerInRange((int)$value, (int)$min, (int)$max);
break;
case 'color':
$col = [];
if ($value) {
$value = preg_replace('/[^A-Fa-f0-9]*/', '', $value) ?? '';
$useFulHex = strlen($value) > 3;
$col[] = (int)hexdec($value[0]);
$col[] = (int)hexdec($value[1]);
$col[] = (int)hexdec($value[2]);
if ($useFulHex) {
$col[] = (int)hexdec($value[3]);
$col[] = (int)hexdec($value[4]);
$col[] = (int)hexdec($value[5]);
}
$value = substr('0' . dechex($col[0]), -1) . substr('0' . dechex($col[1]), -1) . substr('0' . dechex($col[2]), -1);
if ($useFulHex) {
$value .= substr('0' . dechex($col[3]), -1) . substr('0' . dechex($col[4]), -1) . substr('0' . dechex($col[5]), -1);
}
$value = '#' . strtoupper($value);
}
break;
case 'comment':
if ($value) {
$value = '';
} else {
$value = '#';
}
break;
case 'wrap':
if (($data[$key]['left'] ?? false) || $data[$key]['right']) {
$value = $data[$key]['left'] . '|' . $data[$key]['right'];
} else {
$value = '';
}
break;
case 'offset':
$value = rtrim(implode(',', $value), ',');
if (trim($value, ',') === '') {
$value = '';
}
break;
case 'boolean':
if ($value) {
$value = ($constantDefinition['trueValue'] ?? false) ?: '1';
}
break;
}
if ((string)($constantDefinition['value'] ?? '') !== (string)$value) {
// Put value in, if changed.
$rawTemplateConstantsArray = $this->addOrUpdateValueInConstantsArray($rawTemplateConstantsArray, $constantPositions, $key, $value);
$valuesHaveChanged = true;
}
}
}
if ($valuesHaveChanged) {
return $rawTemplateConstantsArray;
}
return null;
}
private function calculateConstantPositions(
array $rawTemplateConstantsArray,
array &$constantPositions = [],
string $prefix = '',
int $braceLevel = 0,
int &$lineCounter = 0
): array {
while (isset($rawTemplateConstantsArray[$lineCounter])) {
$line = ltrim($rawTemplateConstantsArray[$lineCounter]);
$lineCounter++;
if (!$line || $line[0] === '[') {
// Ignore empty lines and conditions
continue;
}
if (strcspn($line, '}#/') !== 0) {
$operatorPosition = strcspn($line, ' {=<');
$key = substr($line, 0, $operatorPosition);
$line = ltrim(substr($line, $operatorPosition));
if ($line[0] === '=') {
$constantPositions[$prefix . $key] = $lineCounter - 1;
} elseif ($line[0] === '{') {
$braceLevel++;
$this->calculateConstantPositions($rawTemplateConstantsArray, $constantPositions, $prefix . $key . '.', $braceLevel, $lineCounter);
}
} elseif ($line[0] === '}') {
$braceLevel--;
if ($braceLevel < 0) {
$braceLevel = 0;
} else {
// Leaving this brace level: Force return to caller recursion
break;
}
}
}
return $constantPositions;
}
/**
* Update a constant value in current template constants if key exists already,
* or add key/value at the end if it does not exist yet.
*/
private function addOrUpdateValueInConstantsArray(array $templateConstantsArray, array $constantPositions, string $constantKey, string $value): array
{
$theValue = ' ' . trim($value);
if (isset($constantPositions[$constantKey])) {
$lineNum = $constantPositions[$constantKey];
$parts = explode('=', $templateConstantsArray[$lineNum], 2);
if (count($parts) === 2) {
$parts[1] = $theValue;
}
$templateConstantsArray[$lineNum] = implode('=', $parts);
} else {
$templateConstantsArray[] = $constantKey . ' =' . $theValue;
}
return $templateConstantsArray;
}
/**
* Remove a key from constant array.
*/
private function removeValueFromConstantsArray(array $templateConstantsArray, array $constantPositions, string $constantKey): array
{
if (isset($constantPositions[$constantKey])) {
$lineNum = $constantPositions[$constantKey];
unset($templateConstantsArray[$lineNum]);
}
return $templateConstantsArray;
}
}
+150
View File
@@ -0,0 +1,150 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Tstemplate\Controller;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Attribute\AsController;
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Http\RedirectResponse;
/**
* This class displays the Info/Modify screen of the Sites > TypoScript module
*
* @internal This is a specific Backend Controller implementation and is not considered part of the Public TYPO3 API.
*/
#[AsController]
class InfoModifyController extends AbstractTemplateModuleController
{
public function __construct(
protected readonly ModuleTemplateFactory $moduleTemplateFactory,
) {}
public function handleRequest(ServerRequestInterface $request): ResponseInterface
{
$queryParams = $request->getQueryParams();
$parsedBody = $request->getParsedBody();
$pageUid = (int)($queryParams['id'] ?? 0);
if ($pageUid === 0) {
// Redirect to template record overview if on page 0.
return new RedirectResponse($this->uriBuilder->buildUriFromRoute('web_typoscript_recordsoverview'));
}
if (($parsedBody['action'] ?? '') === 'createExtensionTemplate') {
return $this->createExtensionTemplateAction($request, 'web_typoscript_infomodify');
}
if (($parsedBody['action'] ?? '') === 'createNewWebsiteTemplate') {
return $this->createNewWebsiteTemplateAction($request, 'web_typoscript_infomodify');
}
$allTemplatesOnPage = $this->getAllTemplateRecordsOnPage($pageUid);
if (empty($allTemplatesOnPage)) {
return $this->noTemplateAction($request);
}
return $this->mainAction($request, $pageUid, $allTemplatesOnPage);
}
private function noTemplateAction(ServerRequestInterface $request): ResponseInterface
{
$languageService = $this->getLanguageService();
$currentModule = $request->getAttribute('module');
$currentModuleIdentifier = $currentModule->getIdentifier();
$pageUid = (int)($request->getQueryParams()['id'] ?? 0);
if ($pageUid === 0) {
throw new \RuntimeException('No proper page uid given', 1661769346);
}
$pageRecord = BackendUtility::readPageAccess($pageUid, '1=1') ?: [];
if (empty($pageRecord)) {
// Redirect to records overview if page could not be determined.
// Edge case if page has been removed meanwhile.
BackendUtility::setUpdateSignal('updatePageTree');
return new RedirectResponse($this->uriBuilder->buildUriFromRoute('web_typoscript_recordsoverview'));
}
$view = $this->moduleTemplateFactory->create($request);
$view->setTitle($languageService->sL($currentModule->getTitle()), $pageRecord['title']);
$view->getDocHeaderComponent()->setPageBreadcrumb($pageRecord);
$this->addPreviewButtonToDocHeader($view, $pageRecord);
$this->addShortcutButtonToDocHeader($view, $currentModuleIdentifier, $pageRecord, $pageUid, $languageService->sL('LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:submodule.title'));
$view->makeDocHeaderModuleMenu(['id' => $pageUid]);
$view->assignMultiple([
'pageUid' => $pageUid,
'moduleIdentifier' => $currentModuleIdentifier,
'previousPage' => $this->getClosestAncestorPageWithTemplateRecord($pageUid),
]);
return $view->renderResponse('InfoModifyNoTemplate');
}
private function mainAction(ServerRequestInterface $request, int $pageUid, array $allTemplatesOnPage): ResponseInterface
{
$queryParams = $request->getQueryParams();
$parsedBody = $request->getParsedBody();
$backendUser = $this->getBackendUser();
$languageService = $this->getLanguageService();
$pageRecord = BackendUtility::readPageAccess($pageUid, '1=1') ?: [];
if (empty($pageRecord)) {
// Redirect to records overview if page could not be determined.
// Edge case if page has been removed meanwhile.
BackendUtility::setUpdateSignal('updatePageTree');
return new RedirectResponse($this->uriBuilder->buildUriFromRoute('web_typoscript_recordsoverview'));
}
$currentModule = $request->getAttribute('module');
$currentModuleIdentifier = $currentModule->getIdentifier();
$moduleData = $request->getAttribute('moduleData');
$selectedTemplateFromModuleData = (array)$moduleData->get('selectedTemplatePerPage');
$selectedTemplateUid = (int)($parsedBody['selectedTemplate'] ?? $queryParams['selectedTemplate'] ?? $selectedTemplateFromModuleData[$pageUid] ?? 0);
if (!in_array($selectedTemplateUid, array_column($allTemplatesOnPage, 'uid'))) {
$selectedTemplateUid = (int)($allTemplatesOnPage[0]['uid'] ?? 0);
}
if (($moduleData->get('selectedTemplatePerPage')[$pageUid] ?? 0) !== $selectedTemplateUid) {
$selectedTemplateFromModuleData[$pageUid] = $selectedTemplateUid;
$moduleData->set('selectedTemplatePerPage', $selectedTemplateFromModuleData);
$backendUser->pushModuleData($currentModuleIdentifier, $moduleData->toArray());
}
$currentTemplateRecord = [];
foreach ($allTemplatesOnPage as $templateRow) {
if ((int)$templateRow['uid'] === $selectedTemplateUid) {
$currentTemplateRecord = $templateRow;
break;
}
}
$view = $this->moduleTemplateFactory->create($request);
$view->setTitle($languageService->sL($currentModule->getTitle()), $pageRecord['title']);
$view->getDocHeaderComponent()->setPageBreadcrumb($pageRecord);
$this->addPreviewButtonToDocHeader($view, $pageRecord);
$this->addShortcutButtonToDocHeader($view, $currentModuleIdentifier, $pageRecord, $pageUid, $languageService->sL('LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:submodule.title'));
$view->makeDocHeaderModuleMenu(['id' => $pageUid]);
$view->assignMultiple([
'pageUid' => $pageUid,
'previousPage' => $this->getClosestAncestorPageWithTemplateRecord($pageUid),
'templateRecord' => $currentTemplateRecord,
'allTemplatesOnPage' => $allTemplatesOnPage,
'numberOfConstantsLines' => trim((string)($currentTemplateRecord['constants'] ?? '')) ? count(explode(LF, (string)$currentTemplateRecord['constants'])) : 0,
'numberOfSetupLines' => trim((string)($currentTemplateRecord['config'] ?? '')) ? count(explode(LF, (string)$currentTemplateRecord['config'])) : 0,
]);
return $view->renderResponse('InfoModifyMain');
}
}
@@ -0,0 +1,210 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Tstemplate\Controller;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\StreamFactoryInterface;
use TYPO3\CMS\Backend\Attribute\AsController;
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Http\RedirectResponse;
use TYPO3\CMS\Core\TypoScript\IncludeTree\SysTemplateRepository;
use TYPO3\CMS\Core\TypoScript\IncludeTree\SysTemplateTreeBuilder;
use TYPO3\CMS\Core\TypoScript\IncludeTree\Traverser\IncludeTreeTraverser;
use TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeNodeFinderVisitor;
use TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeSourceAggregatorVisitor;
use TYPO3\CMS\Core\TypoScript\IncludeTree\Visitor\IncludeTreeSyntaxScannerVisitor;
use TYPO3\CMS\Core\TypoScript\Tokenizer\LosslessTokenizer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\RootlineUtility;
/**
* TypoScript template analyzer.
* Show TypoScript constants and setup include tree of current page.
*
* @internal This is a specific Backend Controller implementation and is not considered part of the Public TYPO3 API.
*/
#[AsController]
final class TemplateAnalyzerController extends AbstractTemplateModuleController
{
public function __construct(
private readonly ModuleTemplateFactory $moduleTemplateFactory,
private readonly SysTemplateRepository $sysTemplateRepository,
private readonly IncludeTreeTraverser $treeTraverser,
private readonly SysTemplateTreeBuilder $treeBuilder,
private readonly LosslessTokenizer $losslessTokenizer,
private readonly ResponseFactoryInterface $responseFactory,
private readonly StreamFactoryInterface $streamFactory,
) {}
public function indexAction(ServerRequestInterface $request): ResponseInterface
{
$backendUser = $this->getBackendUser();
$languageService = $this->getLanguageService();
$queryParams = $request->getQueryParams();
$parsedBody = $request->getParsedBody();
$currentModule = $request->getAttribute('module');
$currentModuleIdentifier = $currentModule->getIdentifier();
$moduleData = $request->getAttribute('moduleData');
$pageUid = (int)($queryParams['id'] ?? 0);
if ($pageUid === 0) {
// Redirect to template record overview if on page 0.
return new RedirectResponse($this->uriBuilder->buildUriFromRoute('web_typoscript_recordsoverview'));
}
$pageRecord = BackendUtility::readPageAccess($pageUid, '1=1') ?: [];
if (empty($pageRecord)) {
// Redirect to records overview if page could not be determined.
// Edge case if page has been removed meanwhile.
BackendUtility::setUpdateSignal('updatePageTree');
return new RedirectResponse($this->uriBuilder->buildUriFromRoute('web_typoscript_recordsoverview'));
}
// Template selection handling for this page
$allTemplatesOnPage = $this->getAllTemplateRecordsOnPage($pageUid);
$selectedTemplateFromModuleData = (array)$moduleData->get('selectedTemplatePerPage');
$selectedTemplateUid = (int)($parsedBody['selectedTemplate'] ?? $selectedTemplateFromModuleData[$pageUid] ?? 0);
if (!in_array($selectedTemplateUid, array_column($allTemplatesOnPage, 'uid'))) {
$selectedTemplateUid = (int)($allTemplatesOnPage[0]['uid'] ?? 0);
}
if (($moduleData->get('selectedTemplatePerPage')[$pageUid] ?? 0) !== $selectedTemplateUid) {
$selectedTemplateFromModuleData[$pageUid] = $selectedTemplateUid;
$moduleData->set('selectedTemplatePerPage', $selectedTemplateFromModuleData);
$backendUser->pushModuleData($currentModuleIdentifier, $moduleData->toArray());
}
$templateTitle = '';
foreach ($allTemplatesOnPage as $templateRow) {
if ((int)$templateRow['uid'] === $selectedTemplateUid) {
$templateTitle = $templateRow['title'];
}
}
$rootLine = GeneralUtility::makeInstance(RootlineUtility::class, $pageUid)->get();
$site = $request->getAttribute('site');
$rootLine = $this->getScopedRootline($site, $rootLine);
$sysTemplateRows = $this->sysTemplateRepository->getSysTemplateRowsByRootlineWithUidOverride($rootLine, $request, $selectedTemplateUid, $this->createVisibilityAspect());
// Build the constant include tree
$constantIncludeTree = $this->treeBuilder->getTreeBySysTemplateRowsAndSite('constants', $sysTemplateRows, $this->losslessTokenizer, $site);
$constantIncludeTree->setIdentifier('constants tstemplate includes');
$treeTraverserVisitors = [];
$constantSyntaxScannerVisitor = new IncludeTreeSyntaxScannerVisitor();
$treeTraverserVisitors[] = $constantSyntaxScannerVisitor;
$this->treeTraverser->traverse($constantIncludeTree, $treeTraverserVisitors);
// Build the setup include tree
$setupIncludeTree = $this->treeBuilder->getTreeBySysTemplateRowsAndSite('setup', $sysTemplateRows, $this->losslessTokenizer, $site);
$setupIncludeTree->setIdentifier('setup tstemplate includes');
$treeTraverserVisitors = [];
$setupSyntaxScannerVisitor = new IncludeTreeSyntaxScannerVisitor();
$treeTraverserVisitors[] = $setupSyntaxScannerVisitor;
$this->treeTraverser->traverse($setupIncludeTree, $treeTraverserVisitors);
$view = $this->moduleTemplateFactory->create($request);
$view->setTitle($languageService->sL($currentModule->getTitle()), $pageRecord['title']);
$view->getDocHeaderComponent()->setPageBreadcrumb($pageRecord);
$this->addPreviewButtonToDocHeader($view, $pageRecord);
$this->addShortcutButtonToDocHeader($view, $currentModuleIdentifier, $pageRecord, $pageUid, $languageService->sL('LLL:EXT:tstemplate/Resources/Private/Language/locallang_analyzer.xlf:submodule.title'));
$view->makeDocHeaderModuleMenu(['id' => $pageUid]);
$view->assignMultiple([
'pageUid' => $pageUid,
'allTemplatesOnPage' => $allTemplatesOnPage,
'selectedTemplateUid' => $selectedTemplateUid,
'templateTitle' => $templateTitle,
'constantIncludeTree' => $constantIncludeTree,
'constantErrors' => $constantSyntaxScannerVisitor->getErrors(),
'constantErrorCount' => count($constantSyntaxScannerVisitor->getErrors()),
'setupIncludeTree' => $setupIncludeTree,
'setupErrors' => $setupSyntaxScannerVisitor->getErrors(),
'setupErrorCount' => count($setupSyntaxScannerVisitor->getErrors()),
]);
return $view->renderResponse('Analyzer');
}
public function sourceAction(ServerRequestInterface $request): ResponseInterface
{
$queryParams = $request->getQueryParams();
$pageUid = (int)($queryParams['id'] ?? 0);
$type = $queryParams['includeType'] ?? null;
$includeIdentifier = $queryParams['identifier'] ?? null;
$moduleData = $request->getAttribute('moduleData');
$allTemplatesOnPage = $this->getAllTemplateRecordsOnPage($pageUid);
$selectedTemplateUid = (int)($moduleData->get('selectedTemplatePerPage')[$pageUid] ?? 0);
if (!in_array($selectedTemplateUid, array_column($allTemplatesOnPage, 'uid'))) {
$selectedTemplateUid = (int)($allTemplatesOnPage[0]['uid'] ?? 0);
}
if ($pageUid === 0 || $includeIdentifier === null || !in_array($type, ['constants', 'setup'], true)) {
return $this->responseFactory->createResponse(400);
}
$rootLine = GeneralUtility::makeInstance(RootlineUtility::class, $pageUid)->get();
$sysTemplateRows = $this->sysTemplateRepository->getSysTemplateRowsByRootlineWithUidOverride($rootLine, $request, $selectedTemplateUid, $this->createVisibilityAspect());
$site = $request->getAttribute('site');
$includeTree = $this->treeBuilder->getTreeBySysTemplateRowsAndSite($type, $sysTemplateRows, $this->losslessTokenizer, $site);
$includeTree->setIdentifier($type . ' tstemplate includes');
$nodeFinderVisitor = GeneralUtility::makeInstance(IncludeTreeNodeFinderVisitor::class);
$nodeFinderVisitor->setNodeIdentifier($includeIdentifier);
$this->treeTraverser->traverse($includeTree, [$nodeFinderVisitor]);
$foundNode = $nodeFinderVisitor->getFoundNode();
if ($foundNode?->getLineStream() === null) {
return $this->responseFactory->createResponse(400);
}
return $this->responseFactory
->createResponse()
->withHeader('Content-Type', 'text/plain')
->withBody($this->streamFactory->createStream((string)$foundNode->getLineStream()));
}
public function sourceWithIncludesAction(ServerRequestInterface $request): ResponseInterface
{
$queryParams = $request->getQueryParams();
$pageUid = (int)($queryParams['id'] ?? 0);
$type = $queryParams['includeType'] ?? null;
$includeIdentifier = $queryParams['identifier'] ?? null;
$moduleData = $request->getAttribute('moduleData');
$allTemplatesOnPage = $this->getAllTemplateRecordsOnPage($pageUid);
$selectedTemplateUid = (int)($moduleData->get('selectedTemplatePerPage')[$pageUid] ?? 0);
if (!in_array($selectedTemplateUid, array_column($allTemplatesOnPage, 'uid'))) {
$selectedTemplateUid = (int)($allTemplatesOnPage[0]['uid'] ?? 0);
}
if ($pageUid === 0 || $includeIdentifier === null || !in_array($type, ['constants', 'setup'], true)) {
return $this->responseFactory->createResponse(400);
}
$rootLine = GeneralUtility::makeInstance(RootlineUtility::class, $pageUid)->get();
$sysTemplateRows = $this->sysTemplateRepository->getSysTemplateRowsByRootlineWithUidOverride($rootLine, $request, $selectedTemplateUid, $this->createVisibilityAspect());
$site = $request->getAttribute('site');
$includeTree = $this->treeBuilder->getTreeBySysTemplateRowsAndSite($type, $sysTemplateRows, $this->losslessTokenizer, $site);
$includeTree->setIdentifier($type . ' tstemplate includes');
$sourceAggregatorVisitor = new IncludeTreeSourceAggregatorVisitor();
$sourceAggregatorVisitor->setStartNodeIdentifier($includeIdentifier);
$this->treeTraverser->traverse($includeTree, [$sourceAggregatorVisitor]);
$source = $sourceAggregatorVisitor->getSource();
return $this->responseFactory
->createResponse()
->withHeader('Content-Type', 'text/plain')
->withBody($this->streamFactory->createStream($source));
}
}
@@ -0,0 +1,145 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Tstemplate\Controller;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Attribute\AsController;
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Http\RedirectResponse;
use TYPO3\CMS\Core\Site\Entity\Site;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Overview of all sys_template records from site root
*
* @internal This is a specific Backend Controller implementation and is not considered part of the Public TYPO3 API.
*/
#[AsController]
class TemplateRecordsOverviewController extends AbstractTemplateModuleController
{
public function __construct(
private readonly ModuleTemplateFactory $moduleTemplateFactory,
) {}
public function handleRequest(ServerRequestInterface $request): ResponseInterface
{
$backendUser = $this->getBackendUser();
$currentModule = $request->getAttribute('module');
$currentModuleIdentifier = $currentModule->getIdentifier();
$pageUid = (int)($request->getQueryParams()['id'] ?? 0);
$pageRecord = BackendUtility::readPageAccess($pageUid, '1=1') ?: [];
if ($pageUid > 0 && empty($pageRecord)) {
// Redirect to records overview of page 0 if page could not be determined.
// Edge case if page has been removed meanwhile.
BackendUtility::setUpdateSignal('updatePageTree');
return new RedirectResponse($this->uriBuilder->buildUriFromRoute('web_typoscript_recordsoverview'));
}
$moduleData = $request->getAttribute('moduleData');
if ($moduleData->cleanUp([])) {
$backendUser->pushModuleData($currentModuleIdentifier, $moduleData->toArray());
}
$pagesWithTemplates = [];
$sites = $this->siteFinder->getAllSites();
foreach ($sites as $site) {
if (!$site->isTypoScriptRoot()) {
continue;
}
$rootPageId = $site->getRootPageId();
$additionalFieldsForRootline = ['sorting', 'shortcut'];
$rootline = array_reverse(BackendUtility::BEgetRootLine($rootPageId, '', true, $additionalFieldsForRootline));
if ($rootline !== []) {
$pagesWithTemplates = $this->setInPageArray($pagesWithTemplates, $rootline, [
'type' => 'site',
'root' => 1,
'clear' => 1,
'pid' => $rootPageId,
'sorting' => -1,
'uid' => -1,
'title' => $site->getConfiguration()['websiteTitle'] ?? '',
'site' => $site,
]);
}
}
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('sys_template');
$queryBuilder->getRestrictions()->removeAll()
->add(GeneralUtility::makeInstance(DeletedRestriction::class));
$result = $queryBuilder
->select('uid', 'pid', 'title', 'root', 'hidden', 'starttime', 'endtime')
->from('sys_template')
// sys_template shouldn't exist pid 0, they'll be ignored in FE anyway. Ignore them.
->where($queryBuilder->expr()->gt('pid', $queryBuilder->createNamedParameter(0, Connection::PARAM_INT)))
->orderBy('sys_template.pid')
->addOrderBy('sys_template.sorting')
->executeQuery();
while ($record = $result->fetchAssociative()) {
$additionalFieldsForRootline = ['sorting', 'shortcut'];
$rootline = array_reverse(BackendUtility::BEgetRootLine($record['pid'], '', true, $additionalFieldsForRootline));
if ($rootline !== []) {
$pagesWithTemplates = $this->setInPageArray($pagesWithTemplates, $rootline, [...$record, 'type' => 'sys_template']);
}
}
$view = $this->moduleTemplateFactory->create($request);
$view->setTitle($this->getLanguageService()->sL($currentModule->getTitle()), '');
$view->getDocHeaderComponent()->setPageBreadcrumb($pageRecord);
$this->addPreviewButtonToDocHeader($view, $pageRecord);
$this->addShortcutButtonToDocHeader($view, $currentModuleIdentifier, $pageRecord, $pageUid, $this->getLanguageService()->sL('LLL:EXT:tstemplate/Resources/Private/Language/locallang_overview.xlf:typoscriptRecords.title'));
if ($pageUid !== 0) {
$view->makeDocHeaderModuleMenu(['id' => $pageUid]);
}
$view->assign('pageTree', $pagesWithTemplates);
return $view->renderResponse('TemplateRecordsOverview');
}
/**
* Recursively add template row in pages tree array by given pages rootline to prepare tree rendering.
* @param non-empty-array $rootline
*/
private function setInPageArray(array $pages, array $rootline, array $row): array
{
if (!$rootline[0]['uid']) {
// Skip 'root'
array_shift($rootline);
}
$currentRootlineElement = current($rootline);
if (empty($pages[$currentRootlineElement['uid']])) {
// Page not in tree yet. Add it.
$pages[$currentRootlineElement['uid']] = $currentRootlineElement;
}
array_shift($rootline);
if (empty($rootline)) {
// Last rootline element: Add template row
$pages[$currentRootlineElement['uid']]['_templates'][] = $row;
} else {
// Recurse into sub array
$pages[$currentRootlineElement['uid']]['_nodes'] ??= [];
$pages[$currentRootlineElement['uid']]['_nodes'] = $this->setInPageArray($pages[$currentRootlineElement['uid']]['_nodes'], $rootline, $row);
}
// Tree node sorting by pages sorting field
uasort($pages, static fn($a, $b) => $a['sorting'] - $b['sorting']);
return $pages;
}
}
@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Tstemplate\Hooks;
use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\DataHandling\DataHandler;
/**
* @internal
*/
#[Autoconfigure(public: true)]
final class DataHandlerClearCachePostProcHook
{
/**
* @var CacheManager
*/
private $cacheManager;
public function __construct(CacheManager $cacheManager)
{
$this->cacheManager = $cacheManager;
}
public function clearPageCacheIfNecessary(array $parameters, DataHandler $dataHandler): void
{
if (($parameters['table'] ?? '') === 'sys_template') {
$this->cacheManager->flushCachesInGroup('pages');
}
}
}
+112
View File
@@ -0,0 +1,112 @@
<?php
use TYPO3\CMS\Tstemplate\Controller\ActiveTypoScriptController;
use TYPO3\CMS\Tstemplate\Controller\ConstantEditorController;
use TYPO3\CMS\Tstemplate\Controller\InfoModifyController;
use TYPO3\CMS\Tstemplate\Controller\TemplateAnalyzerController;
use TYPO3\CMS\Tstemplate\Controller\TemplateRecordsOverviewController;
/**
* Definitions for modules provided by EXT:tstemplate
*/
return [
'web_ts' => [
'parent' => 'site',
'access' => 'admin',
'path' => '/module/web/ts',
'iconIdentifier' => 'module-template',
'labels' => 'tstemplate.modules.ts',
'navigationComponent' => '@typo3/backend/tree/page-tree-element',
],
'web_typoscript_recordsoverview' => [
'parent' => 'web_ts',
'access' => 'admin',
'path' => '/module/web/typoscript/records-overview',
'iconIdentifier' => 'module-template',
'labels' => 'tstemplate.modules.recordsoverview',
'routes' => [
'_default' => [
'target' => TemplateRecordsOverviewController::class . '::handleRequest',
],
],
],
'web_typoscript_constanteditor' => [
'parent' => 'web_ts',
'access' => 'admin',
'path' => '/module/web/typoscript/constant-editor',
'iconIdentifier' => 'module-template',
'labels' => 'tstemplate.modules.constanteditor',
'routes' => [
'_default' => [
'target' => ConstantEditorController::class . '::handleRequest',
],
],
'moduleData' => [
'selectedTemplatePerPage' => [],
'selectedCategory' => '',
],
],
'web_typoscript_infomodify' => [
'parent' => 'web_ts',
'access' => 'admin',
'path' => '/module/web/typoscript/overview',
'iconIdentifier' => 'module-template',
'labels' => 'tstemplate.modules.infomodify',
'routes' => [
'_default' => [
'target' => InfoModifyController::class . '::handleRequest',
],
],
'moduleData' => [
'selectedTemplatePerPage' => [],
],
],
'typoscript_active' => [
'parent' => 'web_ts',
'access' => 'admin',
'path' => '/module/typoscript/active',
'iconIdentifier' => 'module-template',
'labels' => 'tstemplate.modules.active',
'routes' => [
'_default' => [
'target' => ActiveTypoScriptController::class . '::indexAction',
],
'edit' => [
'target' => ActiveTypoScriptController::class . '::editAction',
],
'update' => [
'target' => ActiveTypoScriptController::class . '::updateAction',
'methods' => ['POST'],
],
],
'moduleData' => [
'sortAlphabetically' => true,
'displayConstantSubstitutions' => true,
'displayComments' => true,
'selectedTemplatePerPage' => [],
'constantConditions' => [],
'setupConditions' => [],
],
],
'web_typoscript_analyzer' => [
'parent' => 'web_ts',
'access' => 'admin',
'path' => '/module/web/typoscript/analyzer',
'iconIdentifier' => 'module-template',
'labels' => 'tstemplate.modules.analyzer',
'routes' => [
'_default' => [
'target' => TemplateAnalyzerController::class . '::indexAction',
],
'source' => [
'target' => TemplateAnalyzerController::class . '::sourceAction',
],
'sourceWithIncludes' => [
'target' => TemplateAnalyzerController::class . '::sourceWithIncludesAction',
],
],
'moduleData' => [
'selectedTemplatePerPage' => [],
],
],
];
+14
View File
@@ -0,0 +1,14 @@
<?php
return [
'dependencies' => [
'backend',
'core',
],
'tags' => [
'backend.module',
],
'imports' => [
'@typo3/tstemplate/' => 'EXT:tstemplate/Resources/Public/JavaScript/',
],
];
+8
View File
@@ -0,0 +1,8 @@
services:
_defaults:
autowire: true
autoconfigure: true
public: false
TYPO3\CMS\Tstemplate\:
resource: '../Classes/*'
+339
View File
@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
+11
View File
@@ -0,0 +1,11 @@
==============================
TYPO3 extension ``tstemplate``
==============================
This TYPO3 backend module allows the administration of TypoScript records
that configure the frontend rendering.
:Repository: https://github.com/typo3/typo3
:Issues: https://forge.typo3.org/
:Read online: https://docs.typo3.org/
:Packagist: https://packagist.org/packages/typo3/cms-tstemplate
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="en" datatype="plaintext" original="EXT:tstemplate/Resources/Private/Language/Modules/active.xlf" date="2026-11-10T13:37:37Z" product-name="active">
<header/>
<body>
<trans-unit id="title">
<source>Active TypoScript</source>
</trans-unit>
<!-- intentionally left blank, not utilized (for now) -->
<trans-unit id="short_description">
<source/>
</trans-unit>
<trans-unit id="description">
<source/>
</trans-unit>
</body>
</file>
</xliff>
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="en" datatype="plaintext" original="EXT:tstemplate/Resources/Private/Language/Modules/analyzer.xlf" date="2026-11-10T13:37:37Z" product-name="analyzer">
<header/>
<body>
<trans-unit id="title">
<source>Included TypoScript</source>
</trans-unit>
<!-- intentionally left blank, not utilized (for now) -->
<trans-unit id="short_description">
<source/>
</trans-unit>
<trans-unit id="description">
<source/>
</trans-unit>
</body>
</file>
</xliff>
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="en" datatype="plaintext" original="EXT:tstemplate/Resources/Private/Language/Modules/constanteditor.xlf" date="2026-11-10T13:37:37Z" product-name="constanteditor">
<header/>
<body>
<trans-unit id="title">
<source>Constant Editor</source>
</trans-unit>
<!-- intentionally left blank, not utilized (for now) -->
<trans-unit id="short_description">
<source/>
</trans-unit>
<trans-unit id="description">
<source/>
</trans-unit>
</body>
</file>
</xliff>
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="en" datatype="plaintext" original="EXT:tstemplate/Resources/Private/Language/Modules/infomodify.xlf" date="2026-11-10T13:37:37Z" product-name="infomodify">
<header/>
<body>
<trans-unit id="title">
<source>Edit TypoScript Record</source>
</trans-unit>
<!-- intentionally left blank, not utilized (for now) -->
<trans-unit id="short_description">
<source/>
</trans-unit>
<trans-unit id="description">
<source/>
</trans-unit>
</body>
</file>
</xliff>
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="en" datatype="plaintext" original="EXT:tstemplate/Resources/Private/Language/Modules/recordsoverview.xlf" date="2026-11-10T13:37:37Z" product-name="recordsoverview">
<header/>
<body>
<trans-unit id="title">
<source>TypoScript Overview</source>
</trans-unit>
<!-- intentionally left blank, not utilized (for now) -->
<trans-unit id="short_description">
<source/>
</trans-unit>
<trans-unit id="description">
<source/>
</trans-unit>
</body>
</file>
</xliff>
+17
View File
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="en" datatype="plaintext" original="EXT:tstemplate/Resources/Private/Language/Modules/ts.xlf" date="2026-11-10T13:37:37Z" product-name="ts">
<header/>
<body>
<trans-unit id="short_description">
<source>TypoScript tools</source>
</trans-unit>
<trans-unit id="description">
<source>Here you manage the TypoScript records which are in charge of the look of your website on the frontend. The module provides specialized features like a TypoScript tree, a constant editor and raw editing facilities.</source>
</trans-unit>
<trans-unit id="title">
<source>TypoScript</source>
</trans-unit>
</body>
</file>
</xliff>
+41
View File
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="en" datatype="plaintext" original="EXT:tstemplate/Resources/Private/Language/locallang.xlf" date="2011-10-17T20:22:37Z" product-name="tstemplate">
<header/>
<body>
<trans-unit id="noRecordFound.infobox.title">
<source>No TypoScript record on the current page</source>
</trans-unit>
<trans-unit id="noRecordFound.infobox.message">
<source>You need to create a TypoScript record in order to edit your configuration.</source>
</trans-unit>
<trans-unit id="noRecordFound.goToClosestRecord.description">
<source>The closest TypoScript record is located on page '%s' (uid %s).</source>
</trans-unit>
<trans-unit id="noRecordFound.goToClosestRecord.link.title">
<source>Select this TypoScript record</source>
</trans-unit>
<trans-unit id="noRecordFound.createRootTypoScriptRecord.headline">
<source>Root TypoScript record</source>
</trans-unit>
<trans-unit id="noRecordFound.createRootTypoScriptRecord.description">
<source>Choose this option if you want this page to be the root of a new site.</source>
</trans-unit>
<trans-unit id="noRecordFound.createRootTypoScriptRecord.link.title">
<source>Create a root TypoScript record</source>
</trans-unit>
<trans-unit id="noRecordFound.createRootTypoScriptRecord.title.placeholder">
<source>NEW SITE</source>
</trans-unit>
<trans-unit id="noRecordFound.createAdditionalTypoScriptRecord.headline">
<source>Additional TypoScript record</source>
</trans-unit>
<trans-unit id="noRecordFound.createAdditionalTypoScriptRecord.description">
<source>An additional TypoScript record allows you to enter TypoScript values that will affect only this page and subpages.</source>
</trans-unit>
<trans-unit id="noRecordFound.createAdditionalTypoScriptRecord.link.title">
<source>Create an additional TypoScript record</source>
</trans-unit>
</body>
</file>
</xliff>
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="en" datatype="plaintext" original="EXT:tstemplate/Resources/Private/Language/locallang_active.xlf" date="2011-10-17T20:22:37Z" product-name="tstemplate">
<header/>
<body>
<trans-unit id="submodule.title">
<source>Active TypoScript</source>
</trans-unit>
<trans-unit id="submodule.titleWithRecord">
<source>Active TypoScript for record "%s"</source>
</trans-unit>
<trans-unit id="submodule.description">
<source>Overview of the current TypoScript configuration of the system, divided into constants and setup parts. Optionally, the constant values can be displayed directly in the setup. A targeted search for values and TypoScript names is possible. The list of results can also be filtered according to TypoScript conditions.</source>
</trans-unit>
<trans-unit id="infobox.message.noTypoScriptFound">
<source>No TypoScript found.</source>
</trans-unit>
<trans-unit id="options.displayComments">
<source>Display comments</source>
</trans-unit>
<trans-unit id="options.displayConstantSubstitutions">
<source>Substitute constants in setup</source>
</trans-unit>
<trans-unit id="options.selectedRecord">
<source>Selected record</source>
</trans-unit>
<trans-unit id="options.sortAlphabetically">
<source>Sort keys alphabetically</source>
</trans-unit>
<trans-unit id="sectionHeadline.constants">
<source>Constants</source>
</trans-unit>
<trans-unit id="sectionHeadline.setup">
<source>Setup</source>
</trans-unit>
<trans-unit id="panel.header.conditions">
<source>Conditions</source>
</trans-unit>
<trans-unit id="panel.header.configuration">
<source>Configuration</source>
</trans-unit>
<trans-unit id="panel.info.conditionActiveCount.multiple">
<source>%s active conditions</source>
</trans-unit>
<trans-unit id="panel.info.conditionActiveCount.single">
<source>%s active condition</source>
</trans-unit>
<trans-unit id="panel.info.conditionWithConstant">
<source>Constant usage: [%s]</source>
</trans-unit>
<trans-unit id="tree.valueWithConstant">
<source>Constant usage: %s</source>
</trans-unit>
<!-- Edit action -->
<trans-unit id="editAction.submodule.title">
<source>Edit single property</source>
</trans-unit>
<trans-unit id="editAction.submodule.titleWithTemplate">
<source>Edit single property in TypoScript record "%s"</source>
</trans-unit>
<trans-unit id="editAction.infobox.title.noTypoScriptTemplateOnCurrentPage">
<source>No TypoScript record on the current page</source>
</trans-unit>
<trans-unit id="editAction.infobox.message.noTypoScriptTemplateOnCurrentPage">
<source>You cannot edit properties and values if there is no current TypoScript record in which the configuration can be stored. Please create an extension TypoScript record in "Edit TypoScript Record" first.</source>
</trans-unit>
<trans-unit id="editAction.addProperty.headline">
<source>Add or override child property</source>
</trans-unit>
<trans-unit id="editAction.addProperty.btn">
<source>Add</source>
</trans-unit>
<trans-unit id="editAction.editProperty.headline">
<source>Edit current value</source>
</trans-unit>
<trans-unit id="editAction.editProperty.btn">
<source>Update</source>
</trans-unit>
<trans-unit id="editAction.clearObject.headline">
<source>Clear the object</source>
</trans-unit>
<trans-unit id="editAction.clearObject.infotextWithProperty">
<source>The object will be cleared via the statement:</source>
</trans-unit>
<trans-unit id="editAction.clearObject.btn">
<source>Clear now</source>
</trans-unit>
<!-- Update action -->
<trans-unit id="updateAction.lineAdded">
<source>Line added to current TypoScript record</source>
</trans-unit>
<trans-unit id="updateAction.lineNotAdded">
<source>No line added to current TypoScript record</source>
</trans-unit>
<trans-unit id="updateAction.noSpaces">
<source>You must enter a property with characters "a-z", "A-Z", "0-9", or ".". Dots will be quoted. No spaces or special chars.</source>
</trans-unit>
</body>
</file>
</xliff>
@@ -0,0 +1,119 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="en" datatype="plaintext" original="EXT:tstemplate/Resources/Private/Language/locallang_analyzer.xlf" date="2011-10-17T20:22:37Z" product-name="tstemplate">
<header/>
<body>
<trans-unit id="submodule.title">
<source>Included TypoScript</source>
</trans-unit>
<trans-unit id="submodule.titleWithRecord">
<source>Included TypoScript for record "%s"</source>
</trans-unit>
<trans-unit id="submodule.description">
<source>Overview of the included TypoScript and include order for the current page.</source>
</trans-unit>
<trans-unit id="infobox.message.noTypoScriptFound">
<source>No TypoScript found.</source>
</trans-unit>
<trans-unit id="options.selectedRecord">
<source>Selected record</source>
</trans-unit>
<trans-unit id="sectionHeadline.constants">
<source>Constants</source>
</trans-unit>
<trans-unit id="sectionHeadline.setup">
<source>Setup</source>
</trans-unit>
<trans-unit id="panel.header.syntaxErrors">
<source>Syntax scanner warnings</source>
</trans-unit>
<trans-unit id="panel.header.configuration">
<source>Configuration</source>
</trans-unit>
<trans-unit id="panel.info.syntaxErrorCount.single">
<source>%s syntax warning</source>
</trans-unit>
<trans-unit id="panel.info.syntaxErrorCount.multiple">
<source>%s syntax warnings</source>
</trans-unit>
<trans-unit id="syntaxError.sourceCode">
<source>Show affected code snippet</source>
</trans-unit>
<trans-unit id="syntaxError.type.line.invalid">
<source>Invalid line in "%1$s", line number "%2$s"</source>
</trans-unit>
<trans-unit id="syntaxError.type.brace.excess">
<source>Brace in excess in "%1$s", line number "%2$s"</source>
</trans-unit>
<trans-unit id="syntaxError.type.brace.missing">
<source>Brace missing in "%1$s", line number "%2$s"</source>
</trans-unit>
<trans-unit id="syntaxError.type.import.empty">
<source>Import does not find a file in "%1$s", line number "%2$s"</source>
</trans-unit>
<trans-unit id="tree.child.btn.sourceCode">
<source>Show code</source>
</trans-unit>
<trans-unit id="tree.child.btn.sourceCodeWithResolvedIncludes">
<source>Show code including possible includes/imports</source>
</trans-unit>
<trans-unit id="tree.child.setting.clear">
<source>Clear</source>
</trans-unit>
<trans-unit id="tree.child.setting.root">
<source>Root</source>
</trans-unit>
<trans-unit id="tree.child.sysTemplateRecord">
<source>TypoScript record (page UID %s)</source>
</trans-unit>
<trans-unit id="tree.child.type.AtImport">
<source>Included via "@import"</source>
</trans-unit>
<trans-unit id="tree.child.type.Condition">
<source>Condition (then)</source>
</trans-unit>
<trans-unit id="tree.child.type.ConditionElse">
<source>Condition (else)</source>
</trans-unit>
<trans-unit id="tree.child.type.ConditionStop">
<source>Condition (end)</source>
</trans-unit>
<trans-unit id="tree.child.type.DefaultTypoScript">
<source>Included via "$GLOBALS"</source>
</trans-unit>
<trans-unit id="tree.child.type.DefaultTypoScriptMagicKey">
<source>Included via "$GLOBALS"</source>
</trans-unit>
<trans-unit id="tree.child.type.DefaultTypoScriptMagicKey_formlabel">
<source>Default content rendering</source>
</trans-unit>
<trans-unit id="tree.child.type.ExtensionStatic">
<source>TypoScript set (loaded automatically)</source>
</trans-unit>
<trans-unit id="tree.child.type.File">
<source>Part of a TypoScript set</source>
</trans-unit>
<trans-unit id="tree.child.type.IncludeStaticFileDatabase">
<source>TypoScript set</source>
</trans-unit>
<trans-unit id="tree.child.type.IncludeStaticFileFile">
<source>TypoScript set (included via file)</source>
</trans-unit>
<trans-unit id="tree.child.type.Root">
<source>Root</source>
</trans-unit>
<trans-unit id="tree.child.type.Segment">
<source>Code segment</source>
</trans-unit>
<trans-unit id="tree.child.type.Site">
<source>Site</source>
</trans-unit>
<trans-unit id="tree.child.type.SiteTemplate">
<source>Site configuration</source>
</trans-unit>
<trans-unit id="tree.child.type.SysTemplate">
<source>TypoScript record</source>
</trans-unit>
</body>
</file>
</xliff>
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="en" datatype="plaintext" original="EXT:tstemplate/Resources/Private/Language/locallang_ceditor.xlf" date="2011-10-17T20:22:37Z" product-name="tstemplate">
<header/>
<body>
<trans-unit id="submodule.title">
<source>Constant Editor</source>
</trans-unit>
<trans-unit id="submodule.titleWithRecord">
<source>Constant Editor for TypoScript record "%s"</source>
</trans-unit>
<trans-unit id="submodule.description">
<source>Overwrite constants and save them to the selected TypoScript record on the current page. Only options that have been made available for editing in the constant editor are shown below. In addition, more constants can exist in the system.</source>
</trans-unit>
<trans-unit id="options.selectedCategory">
<source>Selected category</source>
</trans-unit>
<trans-unit id="options.selectedRecord">
<source>Selected record</source>
</trans-unit>
<trans-unit id="infobox.message.noConstants">
<source>There are no editable constants available for the Constant Editor.</source>
</trans-unit>
</body>
</file>
</xliff>
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="en" datatype="plaintext" original="EXT:tstemplate/Resources/Private/Language/locallang_info.xlf" date="2011-10-17T20:22:37Z" product-name="tstemplate">
<header/>
<body>
<trans-unit id="submodule.title">
<source>Edit TypoScript record</source>
</trans-unit>
<trans-unit id="submodule.titleWithRecord">
<source>Edit TypoScript record "%s"</source>
</trans-unit>
<trans-unit id="submodule.description">
<source>Modify the content of the selected TypoScript record of the current page. Modifications can be made either for configurations like TypoScript constants and setup or basics like the title and description of the TypoScript record itself.</source>
</trans-unit>
<trans-unit id="options.selectedRecord">
<source>Selected record</source>
</trans-unit>
<trans-unit id="table.column.constants">
<source>Constants</source>
</trans-unit>
<trans-unit id="table.column.description">
<source>Description</source>
</trans-unit>
<trans-unit id="table.column.lines">
<source>%s lines</source>
</trans-unit>
<trans-unit id="table.column.setup">
<source>Setup</source>
</trans-unit>
<trans-unit id="table.column.title">
<source>Title</source>
</trans-unit>
<trans-unit id="btn.editSiteConfiguration">
<source>Edit site configuration</source>
</trans-unit>
<trans-unit id="btn.editSiteSettings">
<source>Edit site settings</source>
</trans-unit>
<trans-unit id="btn.editTypoScriptRecord">
<source>Edit the whole TypoScript record</source>
</trans-unit>
<trans-unit id="infoTypoScriptRecordFromSite.title">
<source>TypoScript settings have been implicitly generated from site sets includes</source>
</trans-unit>
<trans-unit id="infoTypoScriptRecordFromSite.message">
<source>The site configuration '%s' has one or more dependencies on site sets. The sets can be configured in the 'Sites » Setup' backend module. The TypoScript definitions can be edited on the file system.</source>
</trans-unit>
<trans-unit id="noConstantsButSiteSettings.title">
<source>Site Settings available</source>
</trans-unit>
<trans-unit id="noConstantsButSiteSettings.message">
<source>Edit site settings via the 'Sites » Setup' backend module.</source>
</trans-unit>
</body>
</file>
</xliff>
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="en" datatype="plaintext" original="EXT:tstemplate/Resources/Private/Language/locallang_overview.xlf" date="2023-01-22T19:53:00Z" product-name="tstemplate">
<header/>
<body>
<trans-unit id="typoscriptRecords.title">
<source>TypoScript Overview</source>
</trans-unit>
<trans-unit id="typoscriptRecords.description">
<source>Global overview of all pages with active TypoScript definitions (database records and site sets).</source>
</trans-unit>
<trans-unit id="typoscriptRecords.noRecordsFound">
<source>No TypoScript definitions found.</source>
</trans-unit>
<trans-unit id="typoscriptRecords.table.column.pageTitle">
<source>Page title</source>
</trans-unit>
<trans-unit id="typoscriptRecords.table.column.typoscriptRecords">
<source>TypoScript definitions</source>
</trans-unit>
<trans-unit id="typoscriptRecords.table.column.site">
<source>Site set</source>
</trans-unit>
<trans-unit id="typoscriptRecords.table.column.root">
<source>Marked as root</source>
</trans-unit>
</body>
</file>
</xliff>
@@ -0,0 +1,87 @@
<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:backend="http://typo3.org/ns/TYPO3/CMS/Backend/ViewHelpers"
data-namespace-typo3-fluid="true"
>
<f:if condition="{conditions}">
<div class="panel panel-default">
<h3 class="panel-heading" role="tab" id="typoscript-active-{type}-conditions-heading">
<div class="panel-heading-row">
<button
class="panel-button collapsed"
type="button"
data-bs-toggle="collapse"
data-bs-target="#typoscript-active-{type}-conditions-body"
aria-controls="typoscript-active-{type}-conditions-body"
aria-expanded="false"
>
<div class="panel-title">
<strong><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:panel.header.conditions"/></strong>
</div>
<f:if condition="{conditionActiveCount}">
<div class="panel-badge">
<span class="badge badge-info">
<f:translate
key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:panel.info.conditionActiveCount.{f:if(condition: '{conditionActiveCount} > 1', then:'multiple', else: 'single')}"
arguments="{0: conditionActiveCount}"
/>
</span>
</div>
</f:if>
<span class="caret"></span>
</button>
</div>
</h3>
<div
class="panel-collapse collapse"
id="typoscript-active-{type}-conditions-body"
aria-labelledby="typoscript-active-{type}-conditions-heading"
role="tabpanel"
data-persist-collapse-state="true"
>
<div class="panel-body">
<form action="{f:be.uri(route: 'typoscript_active', parameters: '{id: pageUid}')}" method="post">
<f:for each="{conditions}" as="condition">
<input type="hidden" name="{type}Conditions[{condition.hash}]" value="0" />
<div class="form-check form-switch">
<input
type="checkbox"
class="form-check-input"
name="{type}Conditions[{condition.hash}]"
id="{type}Condition{condition.hash}"
value="1"
{f:if(condition: condition.active, then:'checked="checked"')}
data-global-event="change"
data-action-submit="$form"
data-value-selector="input[name='{type}Conditions[{condition.hash}]']"
/>
<label class="form-check-label" for="{type}Condition{condition.hash}">
<f:if condition="{displayConstantSubstitutions} && {condition.originalValue}">
<f:then>
<span class="font-monospace">[{condition.value}]</span>
<span class="diff-inline">
<f:format.raw>
<f:translate
key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:panel.info.conditionWithConstant"
arguments="{
0: '{backend:typoScript.fineDiff(from: condition.originalValue, to: condition.value)}'
}"
/>
</f:format.raw>
</span>
</f:then>
<f:else>
<span class="font-monospace">[{condition.value}]</span>
</f:else>
</f:if>
</label>
</div>
</f:for>
</form>
</div>
</div>
</div>
</f:if>
</html>
@@ -0,0 +1,122 @@
<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:core="http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers"
data-namespace-typo3-fluid="true"
>
<div class="form-row-md">
<f:if condition="{f:count(subject: allTemplatesOnPage)} > 1">
<div class="form-group">
<form action="{f:be.uri(route: 'typoscript_active', parameters: '{id: pageUid}')}" method="post">
<label class="form-label" for="selectedTemplate">
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:options.selectedRecord" />
</label>
<select
name="selectedTemplate"
id="selectedTemplate"
class="form-select"
data-global-event="change"
data-action-navigate="$data=~s/$value/"
data-action-submit="$form"
>
<f:for each="{allTemplatesOnPage}" as="template">
<option
value="{template.uid}"
{f:if(condition:'{selectedTemplateUid} == {template.uid}', then:'selected="selected"')}
>
{template.title}
</option>
</f:for>
</select>
</form>
</div>
</f:if>
<div class="form-group">
<form action="#">
<label for="searchValue" class="form-label">
<f:translate key="LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.label.searchString" />
</label>
<div class="input-group">
<input
type="search"
autocomplete="off"
class="form-control t3js-collapse-search-term"
name="searchValue"
id="searchValue"
data-persist-collapse-search-key="collapse-search-term-typoscript-active"
value=""
minlength="3"
/>
</div>
</form>
</div>
<div class="form-group">
<div class="form-row-md">
<div class="form-group">
<form action="{f:be.uri(route: 'typoscript_active', parameters: '{id: pageUid}')}" method="post">
<div class="form-check form-switch form-check-size-input">
<input type="hidden" name="displayConstantSubstitutions" value="0" />
<input
type="checkbox"
class="form-check-input"
name="displayConstantSubstitutions"
id="displayConstantSubstitutions"
value="1"
{f:if(condition: displayConstantSubstitutions, then:'checked="checked"')}
data-global-event="change"
data-action-submit="$form"
data-value-selector="input[name='displayConstantSubstitutions']"
/>
<label class="form-check-label" for="displayConstantSubstitutions">
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:options.displayConstantSubstitutions" />
</label>
</div>
</form>
</div>
<div class="form-group">
<form action="{f:be.uri(route: 'typoscript_active', parameters: '{id: pageUid}')}" method="post">
<div class="form-check form-switch form-check-size-input">
<input type="hidden" name="displayComments" value="0" />
<input
type="checkbox"
class="form-check-input"
name="displayComments"
id="displayComments"
value="1"
{f:if(condition: displayComments, then:'checked="checked"')}
data-global-event="change"
data-action-submit="$form"
data-value-selector="input[name='displayComments']"
/>
<label class="form-check-label" for="displayComments">
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:options.displayComments" />
</label>
</div>
</form>
</div>
<div class="form-group">
<form action="{f:be.uri(route: 'typoscript_active', parameters: '{id: pageUid}')}" method="post">
<div class="form-check form-switch form-check-size-input">
<input type="hidden" name="sortAlphabetically" value="0" />
<input
type="checkbox"
class="form-check-input"
name="sortAlphabetically"
id="sortAlphabetically"
value="1"
{f:if(condition: sortAlphabetically, then:'checked="checked"')}
data-global-event="change"
data-action-submit="$form"
data-value-selector="input[name='sortAlphabetically']"
/>
<label class="form-check-label" for="sortAlphabetically">
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:options.sortAlphabetically" />
</label>
</div>
</form>
</div>
</div>
</div>
</div>
</html>
@@ -0,0 +1,83 @@
<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:backend="http://typo3.org/ns/TYPO3/CMS/Backend/ViewHelpers"
data-namespace-typo3-fluid="true"
>
<f:for each="{tree.nextChild}" as="child">
<f:if condition="{displayComments} && {child.comments}">
<li class="loose">
<div class="treelist-comment">
<f:for each="{child.comments}" as="comment" iteration="iterator">
<div><f:format.nl2br>{comment}</f:format.nl2br></div>
</f:for>
</div>
</li>
</f:if>
<f:if condition="{displayConstantSubstitutions} && {child.originalValueTokenStream}">
<li class="loose">
<span class="diff-inline">
<f:format.raw>
<f:variable name="trimmedValueTokenStream"><f:format.trim>{child.originalValueTokenStream}</f:format.trim></f:variable>
<f:translate
key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:tree.valueWithConstant"
arguments="{
0: '{backend:typoScript.fineDiff(from: trimmedValueTokenStream, to: child.value)}'
}"
/>
</f:format.raw>
</span>
</li>
</f:if>
<li>
<f:if condition="{child.children}">
<typo3-backend-tree-node-toggle
class="treelist-control collapsed"
data-bs-toggle="collapse"
data-bs-target="#collapse-list-{child.identifier}"
aria-expanded="false">
</typo3-backend-tree-node-toggle>
</f:if>
<span class="treelist-group treelist-group-monospace">
<span class="treelist-label">
<a href="{editUri}&nodeIdentifier={child.identifier}">{child.name}</a>
</span>
<f:if condition="!{child.valueNull}">
<span class="treelist-operator">=</span>
<span class="treelist-value">{child.value}</span>
</f:if>
<f:if condition="{child.referenceSourceStream}">
<span class="treelist-operator">=<</span>
<span class="treelist-value">{child.referenceSourceStream}</span>
</f:if>
</span>
<f:if condition="{child.children}">
<div
class="treelist-collapse collapse"
data-persist-collapse-state="true"
data-persist-collapse-state-suffix="typoscript-active-{type}"
data-persist-collapse-state-not-if-search="true"
data-persist-collapse-state-if-state="shown"
id="collapse-list-{child.identifier}"
>
<ul class="treelist">
<f:render
partial="ActiveTree"
arguments="{
type: type,
tree: child,
pageUid: pageUid,
displayConstantSubstitutions: displayConstantSubstitutions,
displayComments: displayComments,
editUri: editUri
}"
/>
</ul>
</div>
</f:if>
</li>
</f:for>
</html>
@@ -0,0 +1,68 @@
<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
data-namespace-typo3-fluid="true"
>
<div class="panel panel-default">
<h3 class="panel-heading" role="tab" id="typoscript-active-{type}-ast-heading">
<div class="panel-heading-row">
<button
class="panel-button collapsed"
type="button"
data-bs-toggle="collapse"
data-bs-target="#typoscript-active-{type}-ast-body"
aria-controls="typoscript-active-{type}-ast-body"
aria-expanded="false"
id="panel-tree-heading-{type}"
>
<div class="panel-title">
<strong><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:panel.header.configuration"/></strong>
</div>
<div class="panel-badge">
<span class="badge badge-success hidden t3js-collapse-states-search-numberOfSearchMatches"></span>
</div>
<span class="caret"></span>
</button>
</div>
</h3>
<div
class="panel-collapse collapse"
id="typoscript-active-{type}-ast-body"
aria-labelledby="typoscript-active-{type}-ast-heading"
role="tabpanel"
data-persist-collapse-state="true"
data-persist-collapse-state-if-state="shown"
>
<div class="panel-body t3js-collapse-states-search-tree">
<form action="{f:be.uri(route: 'typoscript_active', parameters: '{id: pageUid}')}" method="post">
<ul class="treelist">
<f:comment>
Variable {editUri} is a performance optimization hack: The ActiveTree template is called
recursive for each node and then creates an "edit" link in each. This is expensive with
many nodes. With client side expand/collapse, we always render the entire tree in fluid,
with a bigger tree we're easily creating the link thousands of times. The hack below
creates the link once, the usage then adds the child parameter.
Ugly but effective in this case. Don't do this at home, kids.
</f:comment>
<f:variable
name="editUri"
value="{f:be.uri(route: 'typoscript_active.edit', parameters: '{id: pageUid, type: type}')}"
/>
<f:render
partial="ActiveTree"
arguments="{
type: type,
tree: tree,
pageUid: pageUid,
displayConstantSubstitutions: displayConstantSubstitutions,
displayComments: displayComments,
editUri: editUri
}"
/>
</ul>
</form>
</div>
</div>
</div>
</html>
@@ -0,0 +1,36 @@
<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:core="http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers"
data-namespace-typo3-fluid="true"
>
<f:if condition="{f:count(subject: allTemplatesOnPage)} > 1">
<div class="form-row">
<div class="form-group">
<form action="{f:be.uri(route: 'web_typoscript_analyzer', parameters: '{id: pageUid}')}" method="post">
<label class="form-label" for="selectedTemplate">
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_analyzer.xlf:options.selectedRecord" />
</label>
<select
name="selectedTemplate"
id="selectedTemplate"
class="form-select"
data-global-event="change"
data-action-navigate="$data=~s/$value/"
data-action-submit="$form"
>
<f:for each="{allTemplatesOnPage}" as="template">
<option
value="{template.uid}"
{f:if(condition:'{selectedTemplateUid} == {template.uid}', then:'selected="selected"')}
>
{template.title}
</option>
</f:for>
</select>
</form>
</div>
</div>
</f:if>
</html>
@@ -0,0 +1,70 @@
<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:core="http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers"
data-namespace-typo3-fluid="true"
>
<f:if condition="{errors}">
<div class="panel panel-default">
<h3 class="panel-heading" role="tab" id="template-analyzer-{type}-errors-heading">
<div class="panel-heading-row">
<button
class="panel-button collapsed"
type="button"
data-bs-toggle="collapse"
data-bs-target="#template-analyzer-{type}-errors-body"
aria-controls="template-analyzer-{type}-errors-body"
aria-expanded="false"
>
<div class="panel-title">
<strong><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_analyzer.xlf:panel.header.syntaxErrors"/></strong>
</div>
<div class="panel-badge">
<span class="badge badge-warning">
<f:translate
key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_analyzer.xlf:panel.info.syntaxErrorCount.{f:if(condition: '{errorCount} > 1', then:'multiple', else: 'single')}"
arguments="{0: errorCount}"
/>
</span>
</div>
<span class="caret"></span>
</button>
</div>
</h3>
<div
class="panel-collapse collapse"
id="template-analyzer-{type}-errors-body"
aria-labelledby="template-analyzer-{type}-errors-heading"
role="tabpanel"
data-persist-collapse-state="true"
>
<div class="panel-body">
<f:for each="{errors}" as="error">
<div class="row justify-content-between">
<div class="col">
<f:translate
key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_analyzer.xlf:syntaxError.type.{error.type}"
arguments="{0: error.include.name, 1: '{error.lineNumber + 1}'}"
/>
</div>
<div class="col col-auto text-end">
<div class="btn-group">
<f:be.link
route="web_typoscript_analyzer.source"
parameters="{id: pageUid, includeType: type, identifier: error.include.identifier}"
additionalAttributes="{'data-modal-title': error.include.name}"
class="btn btn-default btn-sm t3js-typoscript-analyzer-modal"
title="{f:translate(key: 'LLL:EXT:tstemplate/Resources/Private/Language/locallang_analyzer.xlf:syntaxError.sourceCode')}"
>
<core:icon identifier="actions-variable" />
</f:be.link>
</div>
</div>
</div>
</f:for>
</div>
</div>
</div>
</f:if>
</html>
@@ -0,0 +1,126 @@
<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:core="http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers"
xmlns:ts="http://typo3.org/ns/TYPO3/CMS/Tstemplate/ViewHelpers"
data-namespace-typo3-fluid="true"
>
<f:asset.module identifier="@typo3/backend/tree/tree-node-toggle.js"/>
<f:asset.module identifier="@typo3/backend/utility/collapse-state-persister.js"/>
<f:comment><!-- This is a template that calls itself recursive for sub nodes. --></f:comment>
<f:if condition="{tree.children}">
<f:for each="{tree.nextChild}" as="child">
<li>
<f:if condition="{child.children}">
<typo3-backend-tree-node-toggle
class="treelist-control treelist-control-collapsed"
data-bs-toggle="collapse"
data-bs-target="#collapse-list-{child.identifier}"
aria-expanded="false">
</typo3-backend-tree-node-toggle>
</f:if>
<div class="row justify-content-between">
<div class="col">
<div class="row row-cols-auto justify-content-md-between">
<div class="col col-12 col-lg-auto">
<span class="treelist-group treelist-group-monospace">
<span class="treelist-label">
<f:if condition="{child.type} == 'Segment'">
<f:then>
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_analyzer.xlf:tree.child.type.Segment" />
</f:then>
<f:else if="{child.type} == 'DefaultTypoScriptMagicKey'">
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_analyzer.xlf:tree.child.type.DefaultTypoScriptMagicKey_formlabel" />
</f:else>
<f:else if="{child.type} == 'Condition'">
{child.lineStream}
</f:else>
<f:else if="{child.type} == 'ConditionElse'">
{child.lineStream}
</f:else>
<f:else if="{child.type} == 'ConditionStop'">
{child.lineStream}
</f:else>
<f:else>{child.name}</f:else>
</f:if>
</span>
</span>
</div>
<div class="col col-12 col-lg-auto text-md-end">
<f:comment><!-- Hand {child.type} over to f:translate and add locallang.xlf entries when Include classes stabilized. --></f:comment>
<f:if condition="{child.sysTemplateRecord}">
<f:then>
<span class="badge">
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_analyzer.xlf:tree.child.sysTemplateRecord" arguments="{0: '{child.pid}'}" />
</span>
</f:then>
<f:else if="{child.type} != 'Segment'">
<span class="badge">
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_analyzer.xlf:tree.child.type.{child.type}" />
</span>
</f:else>
</f:if>
<f:if condition="{child.root}">
<span class="badge badge-info">
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_analyzer.xlf:tree.child.setting.root" />
</span>
</f:if>
<f:if condition="{child.clear}">
<span class="badge badge-info">
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_analyzer.xlf:tree.child.setting.clear" />
</span>
</f:if>
</div>
</div>
</div>
<div class="col col-auto text-end">
<div class="btn-group tstemplate-tree-btn-group">
<f:be.link
route="web_typoscript_analyzer.source"
parameters="{id: pageUid, includeType: type, identifier: child.identifier}"
additionalAttributes="{'data-modal-title': child.name}"
class="btn btn-default btn-sm t3js-typoscript-analyzer-modal{f:if(condition:'!{child.lineStream}', then:' disabled')}"
title="{f:translate(key: 'LLL:EXT:tstemplate/Resources/Private/Language/locallang_analyzer.xlf:tree.child.btn.sourceCode')}"
>
<core:icon identifier="{f:if(condition:'{child.lineStream}', then:'actions-variable', else: 'empty-empty')}" />
</f:be.link>
<f:be.link
route="web_typoscript_analyzer.sourceWithIncludes"
parameters="{id: pageUid, includeType: type, identifier: child.identifier}"
additionalAttributes="{'data-modal-title': '{child.name} (with resolved includes)'}"
class="btn btn-default btn-sm t3js-typoscript-analyzer-modal{f:if(condition:'!{child.children}', then:' disabled')}"
title="{f:translate(key: 'LLL:EXT:tstemplate/Resources/Private/Language/locallang_analyzer.xlf:tree.child.btn.sourceCodeWithResolvedIncludes')}"
>
<core:icon identifier="{f:if(condition:'{child.children}', then:'actions-variable-select', else: 'empty-empty')}" />
</f:be.link>
</div>
</div>
</div>
<f:if condition="{child.children}">
<div
class="treelist-collapse collapse"
id="collapse-list-{child.identifier}"
data-persist-collapse-state="true"
data-persist-collapse-state-suffix="typoscript-include-{type}"
data-persist-collapse-state-if-state="shown"
>
<ul class="treelist">
<f:render
partial="AnalyzerTree"
arguments="{
type: type,
pageUid: pageUid,
tree: child
}"
/>
</ul>
</div>
</f:if>
</li>
</f:for>
</f:if>
</html>
@@ -0,0 +1,46 @@
<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
data-namespace-typo3-fluid="true"
>
<div class="panel panel-default">
<h3 class="panel-heading" role="tab" id="template-analyzer-{type}-tree-heading">
<div class="panel-heading-row">
<button
class="panel-button collapsed"
type="button"
data-bs-toggle="collapse"
data-bs-target="#template-analyzer-{type}-tree-body"
aria-controls="template-analyzer-{type}-tree-body"
aria-expanded="false"
>
<div class="panel-title">
<strong><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_analyzer.xlf:panel.header.configuration"/></strong>
</div>
<span class="caret"></span>
</button>
</div>
</h3>
<div
class="panel-collapse collapse"
id="template-analyzer-{type}-tree-body"
data-persist-collapse-state="true"
role="tabpanel"
aria-labelledby="template-analyzer-{type}-tree-heading"
>
<div class="panel-body panel-body-overflow">
<ul class="treelist">
<f:render
partial="AnalyzerTree"
arguments="{
type: type,
pageUid: pageUid,
tree: tree
}"
/>
</ul>
</div>
</div>
</div>
</html>
@@ -0,0 +1,193 @@
<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:core="http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers"
data-namespace-typo3-fluid="true"
>
<form action="{f:be.uri(route: 'web_typoscript_constanteditor', parameters: '{id: pageUid}')}" method="post" id="TypoScriptConstantEditorController">
<f:for each="{displayConstants}" as="mainCategory" key="mainCategoryKey">
<h2>{mainCategory.label}</h2>
<f:for each="{mainCategory.items}" as="constantItems">
<f:for each="{constantItems}" as="constantItem">
<fieldset class="form-section">
<div class="form-group">
<label class="form-label t3js-formengine-label">
<span>{constantItem.label}</span>
<code>[{constantItem.name}]</code>
</label>
<f:if condition="{constantItem.description}"><p>{constantItem.description}</p></f:if>
<f:if condition="{constantItem.typeHint}"><span class="text-variant">{constantItem.typeHint}</span></f:if>
<input
type="hidden"
name="check[{constantItem.name}]"
id="check-{constantItem.idName}"
value="checked"
checked
{f:if(condition: '!{constantItem.isInCurrentTemplate}', then: 'disabled')}
>
<div class="input-group userTS" id="userTS-{constantItem.idName}" style="{f:if(condition: constantItem.isInCurrentTemplate, else: 'display:none;')}">
<button
type="button"
class="btn btn-default t3js-toggle"
data-bs-toggle="undo"
rel="{constantItem.idName}"
title="{f:translate(key:'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.deleteTitle')}">
<core:icon identifier="actions-edit-undo" />
</button>
<f:switch expression="{constantItem.type}">
<f:case value="int+">
<input
class="form-control"
id="{constantItem.idName}"
type="number"
name="data[{constantItem.name}]"
value="{constantItem.value}"
{f:if(condition: '{constantItem.typeIntPlusMin} || {constantItem.typeIntPlusMin == 0}', then: 'min="{constantItem.typeIntPlusMin}"')}
{f:if(condition: constantItem.typeIntPlusMax, then: 'max="{constantItem.typeIntPlusMax}"')}
>
</f:case>
<f:case value="int">
<input
class="form-control"
id="{constantItem.idName}"
type="number"
name="data[{constantItem.name}]"
value="{constantItem.value}"
{f:if(condition: '{constantItem.typeIntMin} || {constantItem.typeIntMin == 0}', then: 'min="{constantItem.typeIntMin}"')}
{f:if(condition: '{constantItem.typeIntMax} || {constantItem.typeIntMax == 0}', then: 'max="{constantItem.typeIntMax}"')}
>
</f:case>
<f:case value="string">
<input
class="form-control"
id="{constantItem.idName}"
type="text"
name="data[{constantItem.name}]"
value="{constantItem.value}"
/>
</f:case>
<f:case value="color">
<typo3-backend-color-picker>
<input
class="form-control"
type="text"
id="{constantItem.idName}"
rel="{constantItem.idName}"
name="data[{constantItem.name}]"
value="{constantItem.value}"
/>
</typo3-backend-color-picker>
</f:case>
<f:case value="wrap">
<input
class="form-control form-control-adapt"
type="text"
id="{constantItem.idName}"
name="data[{constantItem.name}][left]"
value="{constantItem.wrapStart}"
/>
<span class="input-group-text input-group-icon">|</span>
<input
class="form-control form-control-adapt"
type="text"
name="data[{constantItem.name}][right]"
value="{constantItem.wrapEnd}"
/>
</f:case>
<f:case value="offset">
<f:for each="{constantItem.labelValueArray}" as="labelAndValue" iteration="iterator">
<span class="input-group-text input-group-icon">{labelAndValue.label}</span>
<input
type="text"
class="form-control form-control-adapt"
name="data[{constantItem.name}][{iterator.index}]"
value="{labelAndValue.value}"
/>
</f:for>
</f:case>
<f:case value="options">
<select
class="form-select"
id="{constantItem.idName}"
name="data[{constantItem.name}]"
>
<f:for each="{constantItem.labelValueArray}" as="labelAndValue">
<option value="{labelAndValue.value}" {f:if(condition: labelAndValue.selected, then: 'selected')}>
{labelAndValue.label}
</option>
</f:for>
</select>
</f:case>
<f:case value="boolean">
<input
type="hidden"
name="data[{constantItem.name}]"
value="0"
/>
<div class="input-group-text">
<div class="form-check form-check-type-toggle">
<input
type="checkbox"
name="data[{constantItem.name}]"
id="{constantItem.idName}"
class="form-check-input"
value="{constantItem.trueValue}"
{f:if(condition: '{constantItem.value} == {constantItem.trueValue}', then: 'checked')}
/>
</div>
</div>
</f:case>
<f:case value="comment">
<input
type="hidden"
name="data[{constantItem.name}]"
value="0"
/>
<div class="input-group-text">
<div class="form-check form-check-type-toggle">
<input
type="checkbox"
name="data[{constantItem.name}]"
id="{constantItem.idName}"
class="form-check-input mt-0"
value="1"
{f:if(condition: '!{constantItem.value}', then: 'checked')}
/>
</div>
</div>
</f:case>
<f:case value="user">
<input
type="hidden"
name="data[{constantItem.name}]"
value="0"
/>
{constantItem.html -> f:format.raw()}
</f:case>
</f:switch>
</div>
<div class="input-group defaultTS" id="defaultTS-{constantItem.idName}" style="{f:if(condition: constantItem.isInCurrentTemplate, then: 'display:none;')}">
<button type="button" class="btn btn-default t3js-toggle" data-bs-toggle="edit" rel="{constantItem.idName}">
<span title="{f:translate(key:'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.editTitle')}">
<core:icon identifier="actions-open" />
</span>
</button>
<f:if condition="{constantItem.type} == 'color'">
<f:then>
<typo3-backend-color-picker color="{constantItem.default_value}">
<input class="form-control" type="number" placeholder="{constantItem.default_value}" disabled readonly>
</typo3-backend-color-picker>
</f:then>
<f:else>
<input class="form-control" type="number" placeholder="{constantItem.default_value}" disabled readonly>
</f:else>
</f:if>
</div>
</div>
</fieldset>
</f:for>
</f:for>
</f:for>
</form>
</html>
@@ -0,0 +1,64 @@
<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:core="http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers"
data-namespace-typo3-fluid="true"
>
<f:if condition="({f:count(subject: allTemplatesOnPage)} > 1) || ({f:count(subject: relevantCategories)} > 1)">
<div class="form-row">
<f:if condition="{f:count(subject: allTemplatesOnPage)} > 1">
<div class="form-group">
<form action="{f:be.uri(route: 'web_typoscript_constanteditor', parameters: '{id: pageUid}')}" method="post">
<label class="form-label" for="selectedTemplate">
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_ceditor.xlf:options.selectedRecord" />
</label>
<select
name="selectedTemplate"
id="selectedTemplate"
class="form-select"
data-global-event="change"
data-action-navigate="$data=~s/$value/"
data-action-submit="$form"
>
<f:for each="{allTemplatesOnPage}" as="template">
<option
value="{template.uid}"
{f:if(condition:'{selectedTemplateUid} == {template.uid}', then:'selected="selected"')}
>
{template.title}
</option>
</f:for>
</select>
</form>
</div>
</f:if>
<f:if condition="{selectedTemplateUid} > 0 && {f:count(subject: relevantCategories)} > 1">
<div class="form-group">
<form action="{f:be.uri(route: 'web_typoscript_constanteditor', parameters: '{id: pageUid}')}" method="post">
<label class="form-label" for="selectedCategory">
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_ceditor.xlf:options.selectedCategory" />
</label>
<select
name="selectedCategory"
id="selectedCategory"
class="form-select"
data-global-event="change"
data-action-navigate="$data=~s/$value/"
data-action-submit="$form"
>
<f:for each="{relevantCategories}" key="relevantCategoryKey" as="relevantCategory">
<option
value="{relevantCategoryKey}"
{f:if(condition:'{selectedCategory} == {relevantCategoryKey}', then:'selected="selected"')}
>
{relevantCategory.label} ({relevantCategory.usageCount})
</option>
</f:for>
</select>
</form>
</div>
</f:if>
</div>
</f:if>
</html>
@@ -0,0 +1,79 @@
<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
data-namespace-typo3-fluid="true"
>
<f:asset.module identifier="@typo3/backend/context-menu.js"/>
<f:asset.module identifier="@typo3/backend/element/immediate-action-element.js"/>
<f:be.infobox title="{f:translate(key: 'LLL:EXT:tstemplate/Resources/Private/Language/locallang.xlf:noRecordFound.infobox.title')}" state="{f:constant(name: 'TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::INFO')}">
<p>
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang.xlf:noRecordFound.infobox.message" />
</p>
<f:if condition="{previousPage}">
<p class="mt-4">
<f:translate
key="LLL:EXT:tstemplate/Resources/Private/Language/locallang.xlf:noRecordFound.goToClosestRecord.description"
arguments="{0: previousPage.title, 1: previousPage.uid}"
/>
</p>
<f:be.link
route="{moduleIdentifier}"
parameters="{id: previousPage.uid}"
class="btn btn-default"
>
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang.xlf:noRecordFound.goToClosestRecord.link.title" />
</f:be.link>
</f:if>
</f:be.infobox>
<div class="card-container">
<div class="card card-size-medium">
<div class="card-body">
<h2 class="card-title">
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang.xlf:noRecordFound.createRootTypoScriptRecord.headline" />
</h2>
<div class="card-text">
<p>
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang.xlf:noRecordFound.createRootTypoScriptRecord.description" />
</p>
</div>
</div>
<div class="card-footer">
<form action="{f:be.uri(route: moduleIdentifier, parameters: '{id: pageUid}')}" method="post">
<input type="hidden" name="action" value="createNewWebsiteTemplate" />
<input
class="btn btn-default"
type="submit"
name="newWebsite"
value="{f:translate(key: 'LLL:EXT:tstemplate/Resources/Private/Language/locallang.xlf:noRecordFound.createRootTypoScriptRecord.link.title')}"
/>
</form>
</div>
</div>
<div class="card card-size-medium">
<div class="card-body">
<h2 class="card-title">
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang.xlf:noRecordFound.createAdditionalTypoScriptRecord.headline" />
</h2>
<div class="card-text">
<p>
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang.xlf:noRecordFound.createAdditionalTypoScriptRecord.description" />
</p>
</div>
</div>
<div class="card-footer">
<form action="{f:be.uri(route: moduleIdentifier, parameters: '{id: pageUid}')}" method="post">
<input type="hidden" name="action" value="createExtensionTemplate" />
<input
class="btn btn-default"
type="submit"
name="createExtension"
value="{f:translate(key: 'LLL:EXT:tstemplate/Resources/Private/Language/locallang.xlf:noRecordFound.createAdditionalTypoScriptRecord.link.title')}"
/>
</form>
</div>
</div>
</div>
</html>
@@ -0,0 +1,107 @@
<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:core="http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers"
data-namespace-typo3-fluid="true"
>
<f:layout name="Module"/>
<f:section name="Content">
<f:asset.module identifier="@typo3/backend/context-menu.js"/>
<f:comment><!-- Heading --></f:comment>
<h1>
<f:if condition="{templateTitle}">
<f:then>
<f:translate
key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:editAction.submodule.titleWithTemplate"
arguments="{
0: '{templateTitle}'
}"
/>
</f:then>
<f:else>
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:editAction.submodule.title" />
</f:else>
</f:if>
</h1>
<f:comment><!-- Show "no template on this page" infobox, or render edit options --></f:comment>
<f:if condition="!{hasTemplate}">
<f:then>
<f:be.infobox
title="{f:translate(key: 'LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:editAction.infobox.title.noTypoScriptTemplateOnCurrentPage')}"
message="{f:translate(key: 'LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:editAction.infobox.message.noTypoScriptTemplateOnCurrentPage')}"
state="{f:constant(name: 'TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::INFO')}"
/>
</f:then>
<f:else>
<f:comment><!-- Edit property --></f:comment>
<form action="{f:be.uri(route: 'typoscript_active.update', parameters: '{id: pageUid}')}" method="post">
<input type="hidden" name="currentObjectPath" value="{currentObjectPath}" />
<input type="hidden" name="pageUid" value="{pageUid}" />
<input type="hidden" name="type" value="{type}" />
<h2><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:editAction.editProperty.headline" /></h2>
<div class="row row-cols-auto align-items-end g-1">
<div class="col mb-4">
<label class="visually-hidden">{currentObjectPath} =</label>
<div class="input-group">
<div class="input-group-text">{currentObjectPath} =</div>
<input class="form-control" type="text" name="value" value="{currentValue}" />
</div>
</div>
<div class="col mb-4">
<input
type="submit"
name="updateValue"
value="{f:translate(key:'LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:editAction.editProperty.btn')}"
class="btn btn-default"
/>
</div>
</div>
<h2><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:editAction.addProperty.headline" /></h2>
<div class="row row-cols-auto align-items-end g-1 mb-8">
<div class="col mb-4">
<label class="visually-hidden">{currentObjectPath}.</label>
<div class="input-group">
<div class="input-group-text">{currentObjectPath}.</div>
<input name="childName" type="text" class="form-control" />
</div>
</div>
<div class="col mb-4">
<div class="input-group">
<div class="input-group-text">=</div>
<input type="text" name="childValue" class="form-control" />
</div>
</div>
<div class="col mb-4">
<input
type="submit"
name="addChild"
value="{f:translate(key:'LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:editAction.addProperty.btn')}"
class="btn btn-default"
/>
</div>
</div>
<h2><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:editAction.clearObject.headline" /></h2>
<p>
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:editAction.clearObject.infotextWithProperty" />
<code>{currentObjectPath} ></code>
</p>
<input
type="submit"
name="clear"
value="{f:translate(key:'LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:editAction.clearObject.btn')}"
class="btn btn-default"
/>
</form>
</f:else>
</f:if>
</f:section>
</html>
@@ -0,0 +1,116 @@
<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
data-namespace-typo3-fluid="true"
>
<f:layout name="Module"/>
<f:section name="Before">
<f:asset.module identifier="@typo3/backend/context-menu.js"/>
<f:asset.module identifier="@typo3/backend/element/immediate-action-element.js"/>
<f:asset.module identifier="@typo3/backend/tree/tree-node-toggle.js"/>
<f:asset.module identifier="@typo3/backend/utility/collapse-state-persister.js"/>
<f:asset.module identifier="@typo3/backend/utility/collapse-state-search.js"/>
<f:variable name="args" value="{0: 'web', 1: pageUid}" />
<typo3-immediate-action
action="TYPO3.Backend.Storage.ModuleStateStorage.update"
args="{args -> f:format.json() -> f:format.htmlspecialchars()}"
></typo3-immediate-action>
</f:section>
<f:section name="Content">
<h1>
<f:if condition="{templateTitle}">
<f:then>
<f:translate
key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:submodule.titleWithRecord"
arguments="{
0: '{templateTitle}'
}"
/>
</f:then>
<f:else>
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:submodule.title" />
</f:else>
</f:if>
</h1>
<p><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:submodule.description" /></p>
<f:comment><!-- General options --></f:comment>
<f:if condition="{constantAst.children} || {setupAst.children}">
<f:render
partial="ActiveOptions"
arguments="{
allTemplatesOnPage: allTemplatesOnPage,
pageUid: pageUid,
selectedTemplateUid: selectedTemplateUid,
displayConstantSubstitutions: displayConstantSubstitutions,
displayComments: displayComments,
sortAlphabetically: sortAlphabetically
}"
/>
</f:if>
<f:comment><!-- Constants: Conditions and tree --></f:comment>
<f:if condition="{constantAst.children}">
<h2><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:sectionHeadline.constants" /></h2>
<div class="panel-group">
<f:render
partial="ActiveConditions"
arguments="{
pageUid: pageUid,
type: 'constant',
conditions: constantConditions,
conditionActiveCount: constantConditionsActiveCount
}"
/>
<f:render
partial="ActiveTreePanel"
arguments="{
type: 'constant',
tree: constantAst,
pageUid: pageUid,
displayComments: displayComments
}"
/>
</div>
</f:if>
<f:comment><!-- Setup: Conditions and tree --></f:comment>
<f:if condition="{setupAst.children}">
<h2><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:sectionHeadline.setup" /></h2>
<div class="panel-group">
<f:render
partial="ActiveConditions"
arguments="{
pageUid: pageUid,
type: 'setup',
conditions: setupConditions,
conditionActiveCount: setupConditionsActiveCount,
displayConstantSubstitutions: displayConstantSubstitutions
}"
/>
<f:render
partial="ActiveTreePanel"
arguments="{
type: 'setup',
tree: setupAst,
pageUid: pageUid,
displayConstantSubstitutions: displayConstantSubstitutions,
displayComments: displayComments
}"
/>
</div>
</f:if>
<f:if condition="!{constantAst.children} && !{setupAst.children}">
<f:be.infobox
message="{f:translate(key: 'LLL:EXT:tstemplate/Resources/Private/Language/locallang_active.xlf:infobox.message.noTypoScriptFound')}"
state="{f:constant(name: 'TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::INFO')}"
/>
</f:if>
</f:section>
</html>
@@ -0,0 +1,104 @@
<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
data-namespace-typo3-fluid="true"
>
<f:layout name="Module"/>
<f:section name="Before">
<f:asset.module identifier="@typo3/backend/context-menu.js"/>
<f:asset.module identifier="@typo3/backend/element/immediate-action-element.js"/>
<f:asset.module identifier="@typo3/tstemplate/template-analyzer.js"/>
<f:variable name="args" value="{0: 'web', 1: pageUid}" />
<typo3-immediate-action
action="TYPO3.Backend.Storage.ModuleStateStorage.update"
args="{args -> f:format.json() -> f:format.htmlspecialchars()}"
></typo3-immediate-action>
</f:section>
<f:section name="Content">
<h1>
<f:if condition="{templateTitle}">
<f:then>
<f:translate
key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_analyzer.xlf:submodule.titleWithRecord"
arguments="{
0: '{templateTitle}'
}"
/>
</f:then>
<f:else>
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_analyzer.xlf:submodule.title" />
</f:else>
</f:if>
</h1>
<p><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_analyzer.xlf:submodule.description" /></p>
<f:comment><!-- General options --></f:comment>
<f:render
partial="AnalyzerOptions"
arguments="{
allTemplatesOnPage: allTemplatesOnPage,
pageUid: pageUid,
selectedTemplateUid: selectedTemplateUid
}"
/>
<f:comment><!-- Constants: Syntax errors, source and tree --></f:comment>
<f:if condition="{constantIncludeTree.children}">
<h2><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_analyzer.xlf:sectionHeadline.constants" /></h2>
<div class="panel-group">
<f:render
partial="AnalyzerSyntaxErrors"
arguments="{
type: 'constants',
pageUid: pageUid,
errors: constantErrors,
errorCount: constantErrorCount
}"
/>
<f:render
partial="AnalyzerTreePanel"
arguments="{
type: 'constants',
tree: constantIncludeTree,
pageUid: pageUid
}"
/>
</div>
</f:if>
<f:comment><!-- Setup: Syntax errors, source and tree --></f:comment>
<f:if condition="{setupIncludeTree.children}">
<h2><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_analyzer.xlf:sectionHeadline.setup" /></h2>
<div class="panel-group">
<f:render
partial="AnalyzerSyntaxErrors"
arguments="{
type: 'setup',
pageUid: pageUid,
errors: setupErrors,
errorCount: setupErrorCount
}"
/>
<f:render
partial="AnalyzerTreePanel"
arguments="{
type: 'setup',
tree: setupIncludeTree,
pageUid: pageUid
}"
/>
</div>
</f:if>
<f:if condition="!{constantIncludeTree.children} && !{setupIncludeTree.children}">
<f:be.infobox
message="{f:translate(key: 'LLL:EXT:tstemplate/Resources/Private/Language/locallang_analyzer.xlf:infobox.message.noTypoScriptFound')}"
state="{f:constant(name: 'TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::INFO')}"
/>
</f:if>
</f:section>
</html>
@@ -0,0 +1,86 @@
<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
data-namespace-typo3-fluid="true"
>
<f:layout name="Module"/>
<f:section name="Before">
<f:asset.module identifier="@typo3/backend/context-menu.js"/>
<f:asset.module identifier="@typo3/backend/element/immediate-action-element.js"/>
<f:asset.module identifier="@typo3/backend/utility/collapse-state-persister.js"/>
<f:asset.module identifier="@typo3/tstemplate/constant-editor.js"/>
<f:variable name="args" value="{0: 'web', 1: pageUid}" />
<typo3-immediate-action
action="TYPO3.Backend.Storage.ModuleStateStorage.update"
args="{args -> f:format.json() -> f:format.htmlspecialchars()}"
></typo3-immediate-action>
</f:section>
<f:section name="Content">
<h1>
<f:if condition="{templateTitle}">
<f:then>
<f:translate
key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_ceditor.xlf:submodule.titleWithRecord"
arguments="{
0: '{templateTitle}'
}"
/>
</f:then>
<f:else>
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_ceditor.xlf:submodule.title" />
</f:else>
</f:if>
</h1>
<f:if condition="{selectedTemplateUid} > 0">
<p><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_ceditor.xlf:submodule.description" /></p>
</f:if>
<f:comment><!-- Options --></f:comment>
<f:render
partial="ConstantEditorOptions"
arguments="{
allTemplatesOnPage: allTemplatesOnPage,
pageUid: pageUid,
selectedTemplateUid: selectedTemplateUid,
relevantCategories: relevantCategories,
selectedCategory: selectedCategory
}"
/>
<f:if condition="{selectedTemplateUid} > 0">
<f:comment><!-- Main form --></f:comment>
<f:if condition="!{relevantCategories}">
<f:then>
<f:be.infobox message="{f:translate(key:'LLL:EXT:tstemplate/Resources/Private/Language/locallang_ceditor.xlf:infobox.message.noConstants')}" state="{f:constant(name: 'TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::INFO')}" />
</f:then>
<f:else>
<f:render partial="ConstantEditorFields" arguments="{_all}" />
</f:else>
</f:if>
</f:if>
<f:if condition="{selectedTemplateUid} == -1">
<f:be.infobox
state="{f:constant(name: 'TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::INFO')}"
title="{f:translate(key: 'LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:noConstantsButSiteSettings.title')}"
>
<p>
<f:translate
key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:noConstantsButSiteSettings.message"
arguments="{
0: '{templateRecord.site.identifier}'
}"
/>
</p>
<f:variable name="returnUrl">{f:be.uri(route: 'web_typoscript_constanteditor', parameters: {id: pageUid})}</f:variable>
<f:be.link route="site_configuration.editSettings" parameters="{site: templateRecord.site.identifier, returnUrl: returnUrl}" class="btn btn-default">
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:btn.editSiteSettings"/>
</f:be.link>
</f:be.infobox>
</f:if>
</f:section>
</html>
@@ -0,0 +1,24 @@
<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
data-namespace-typo3-fluid="true"
>
<f:layout name="Module"/>
<f:section name="Content">
<h1><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_ceditor.xlf:submodule.title" /></h1>
<p><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_ceditor.xlf:submodule.description" /></p>
<f:render
partial="NoRecordFound"
arguments="{
pageUid: pageUid,
previousPage: previousPage,
moduleIdentifier: moduleIdentifier
}"
/>
</f:section>
</html>
@@ -0,0 +1,189 @@
<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:core="http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers"
xmlns:be="http://typo3.org/ns/TYPO3/CMS/Backend/ViewHelpers"
data-namespace-typo3-fluid="true"
>
<f:layout name="Module"/>
<f:section name="Before">
<f:asset.module identifier="@typo3/backend/context-menu.js"/>
<f:asset.module identifier="@typo3/backend/element/immediate-action-element.js"/>
<f:asset.module identifier="@typo3/tstemplate/information-module.js"/>
<f:variable name="args" value="{0: 'web', 1: pageUid}" />
<typo3-immediate-action
action="TYPO3.Backend.Storage.ModuleStateStorage.update"
args="{args -> f:format.json() -> f:format.htmlspecialchars()}"
></typo3-immediate-action>
</f:section>
<f:section name="Content">
<h1>
<f:if condition="{templateRecord.title}">
<f:then>
<f:translate
key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:submodule.titleWithRecord"
arguments="{
0: '{templateRecord.title}'
}"
/>
</f:then>
<f:else>
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:submodule.title" />
</f:else>
</f:if>
</h1>
<p><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:submodule.description" /></p>
<f:if condition="{f:count(subject: allTemplatesOnPage)} > 1">
<div class="form-row">
<div class="form-group">
<form action="{f:be.uri(route: 'web_typoscript_infomodify', parameters: '{id: pageUid}')}" method="post">
<label class="form-label" for="selectedTemplate">
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:options.selectedRecord" />
</label>
<select
name="selectedTemplate"
id="selectedTemplate"
class="form-select"
data-global-event="change"
data-action-navigate="$data=~s/$value/"
data-action-submit="$form"
>
<f:for each="{allTemplatesOnPage}" as="template">
<option
value="{template.uid}"
{f:if(condition:'{templateRecord.uid} == {template.uid}', then:'selected="selected"')}
>
<f:if condition="{template.type} == 'sys_template'">
{template.title}
</f:if>
<f:if condition="{template.type} == 'site'">
{template.site.configuration.websiteTitle}
</f:if>
</option>
</f:for>
</select>
</form>
</div>
</div>
</f:if>
<f:if condition="{templateRecord.type} == 'site'">
<f:be.infobox
state="{f:constant(name: 'TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::INFO')}"
title="{f:translate(key: 'LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:infoTypoScriptRecordFromSite.title')}"
>
<p>
<f:translate
key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:infoTypoScriptRecordFromSite.message"
arguments="{
0: '{templateRecord.site.identifier}'
}"
/>
</p>
<f:variable name="returnUrl">{f:be.uri(route: 'web_typoscript_infomodify', parameters: {id: pageUid})}</f:variable>
<f:be.link route="site_configuration.edit" parameters="{site: templateRecord.site.identifier, returnUrl: returnUrl}" class="btn btn-default">
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:btn.editSiteConfiguration"/>
</f:be.link>
<f:be.link route="site_configuration.editSettings" parameters="{site: templateRecord.site.identifier, returnUrl: returnUrl}" class="btn btn-default">
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:btn.editSiteSettings"/>
</f:be.link>
</f:be.infobox>
</f:if>
<div class="table-fit">
<table class="table table-striped table-hover">
<tbody>
<tr>
<td class="text-nowrap">
<f:if condition="{templateRecord.type} == 'sys_template'">
<be:link.editRecord
table="sys_template"
uid="{templateRecord.uid}"
fields="title"
class="btn d-block text-start btn-default"
>
<core:icon identifier="actions-open" /> <f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:table.column.title" />
</be:link.editRecord>
</f:if>
<f:if condition="{templateRecord.type} == 'site'">
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:table.column.title" />
</f:if>
</td>
<td width="90%">{templateRecord.title}</td>
</tr>
<tr>
<td class="text-nowrap">
<f:if condition="{templateRecord.type} == 'sys_template'">
<be:link.editRecord
table="sys_template"
uid="{templateRecord.uid}"
fields="description"
class="btn d-block text-start btn-default"
>
<core:icon identifier="actions-open" /> <f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:table.column.description" />
</be:link.editRecord>
</f:if>
<f:if condition="{templateRecord.type} == 'site'">
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:table.column.description" />
</f:if>
</td>
<td width="90%">{templateRecord.description}</td>
</tr>
<tr>
<td class="text-nowrap">
<f:if condition="{templateRecord.type} == 'sys_template'">
<be:link.editRecord
table="sys_template"
uid="{templateRecord.uid}"
fields="constants"
class="btn d-block text-start btn-default"
>
<core:icon identifier="actions-open" /> <f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:table.column.constants" />
</be:link.editRecord>
</f:if>
<f:if condition="{templateRecord.type} == 'site'">
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:table.column.constants" />
</f:if>
</td>
<td width="90%"><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:table.column.lines" arguments="{0: numberOfConstantsLines}" /></td>
</tr>
<tr>
<td class="text-nowrap">
<f:if condition="{templateRecord.type} == 'sys_template'">
<be:link.editRecord
table="sys_template"
uid="{templateRecord.uid}"
fields="config"
class="btn d-block text-start btn-default"
>
<core:icon identifier="actions-open" /> <f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:table.column.setup" />
</be:link.editRecord>
</f:if>
<f:if condition="{templateRecord.type} == 'site'">
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:table.column.setup" />
</f:if>
</td>
<td width="90%"><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:table.column.lines" arguments="{0: numberOfSetupLines}" /></td>
</tr>
</tbody>
</table>
</div>
<f:if condition="{templateRecord.type} == 'sys_template'">
<be:link.editRecord
table="sys_template"
uid="{templateRecord.uid}"
class="btn btn-default"
>
<core:icon identifier="actions-document-open" />
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:btn.editTypoScriptRecord"/>
</be:link.editRecord>
</f:if>
</f:section>
</html>
@@ -0,0 +1,24 @@
<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
data-namespace-typo3-fluid="true"
>
<f:layout name="Module"/>
<f:section name="Content">
<h1><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:submodule.title" /></h1>
<p><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:submodule.description" /></p>
<f:render
partial="NoRecordFound"
arguments="{
pageUid: pageUid,
previousPage: previousPage,
moduleIdentifier: moduleIdentifier
}"
/>
</f:section>
</html>
@@ -0,0 +1,137 @@
<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:core="http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers"
data-namespace-typo3-fluid="true"
>
<f:layout name="Module"/>
<f:section name="Content">
<f:asset.module identifier="@typo3/backend/context-menu.js"/>
<f:asset.module identifier="@typo3/backend/element/immediate-action-element.js"/>
<h1>
<f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_overview.xlf:typoscriptRecords.title" />
</h1>
<p><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_overview.xlf:typoscriptRecords.description" /></p>
<f:if condition="{pageTree}">
<f:then>
<div class="table-fit">
<table class="table table-striped table-hover" id="ts-overview">
<thead>
<tr>
<th class="nowrap align-top"><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_overview.xlf:typoscriptRecords.table.column.pageTitle" /></th>
<th class="nowrap align-top"><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_overview.xlf:typoscriptRecords.table.column.typoscriptRecords" /></th>
<th class="nowrap align-top"><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_overview.xlf:typoscriptRecords.table.column.site" /></th>
<th class="nowrap align-top"><f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_overview.xlf:typoscriptRecords.table.column.root" /></th>
</tr>
</thead>
<tbody>
<f:for each="{pageTree}" as="page">
<f:render
section="TableRow"
arguments="{
page: page,
level: 0
}"
/>
</f:for>
</tbody>
</table>
</div>
</f:then>
<f:else>
<f:be.infobox
message="{f:translate(key: 'LLL:EXT:tstemplate/Resources/Private/Language/locallang_overview.xlf:typoscriptRecords.noRecordsFound')}"
state="{f:constant(name: 'TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::INFO')}"
/>
</f:else>
</f:if>
</f:section>
<f:section name="TableRow">
<f:variable name="maxCharacters" value="30" />
<tr class="{f:if(condition: page.hidden, then: 'inactive')}">
<td class="align-top nowrap">
<span title="id={page.uid}" style="margin-left: {level * 20}px">
<core:IconForRecord table="pages" row="{page}" />
{page.title -> f:format.crop(maxCharacters: maxCharacters)}
</span>
</td>
<td class="align-top">
<f:for each="{page._templates}" as="templateFile" iteration="templateIterator">
<div class="{f:if(condition: '{templateIterator.isLast}', then: '', else: 'mb-2')}">
<f:if condition="{templateFile.type} == 'sys_template'">
<core:IconForRecord table="sys_template" row="{templateFile}" />
<a
href="{f:be.uri(route: 'web_typoscript_infomodify', parameters:'{id: templateFile.pid, selectedTemplate: templateFile.uid}')}"
title="ID: {templateFile.uid}"
>
{templateFile.title -> f:format.crop(maxCharacters: maxCharacters)}
</a>
</f:if>
<f:if condition="{templateFile.type} == 'site'">
<span title="{templateFile.title} (site:{templateFile.site.identifier})">
<core:icon identifier="mimetypes-x-content-template" overlay="mimetypes-x-content-domain" size="small"/>
<f:if condition="{templateFile.title}">
<f:then>
{templateFile.title -> f:format.crop(maxCharacters: maxCharacters)}
</f:then>
<f:else>
{templateFile.site.identifier -> f:format.crop(maxCharacters: maxCharacters)}
</f:else>
</f:if>
</span>
</f:if>
</div>
</f:for>
</td>
<td class="align-top">
<f:for each="{page._templates}" as="templateFile" iteration="templateIterator">
<div class="{f:if(condition: '{templateIterator.isLast}', then: '', else: 'mb-2')}">
<f:if condition="{templateFile.type} == 'site'">
<f:then>
<core:icon identifier="status-status-checked"/>
</f:then>
<f:else>
&nbsp;
</f:else>
</f:if>
</div>
</f:for>
</td>
<td class="align-top">
<f:for each="{page._templates}" as="templateFile" iteration="templateIterator">
<div class="{f:if(condition: '{templateIterator.isLast}', then: '', else: 'mb-2')}">
<f:if condition="{templateFile.root}">
<f:then>
<core:icon identifier="status-status-checked"/>
</f:then>
<f:else>
&nbsp;
</f:else>
</f:if>
</div>
</f:for>
</td>
</tr>
<f:comment><!-- Subpages --></f:comment>
<f:if condition="{page._nodes -> f:count()}">
<f:for each="{page._nodes}" as="page">
<f:render
section="TableRow"
arguments="{
page: page,
level: '{level + 1}'
}"
/>
</f:for>
</f:if>
</f:section>
</html>
Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

@@ -0,0 +1,13 @@
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
import i from"@typo3/core/document-service.js";import l from"@typo3/core/event/regular-event.js";import"@typo3/backend/color-picker.js";var t;(function(o){o.editIconSelector=".t3js-toggle"})(t||(t={}));class d{constructor(){i.ready().then(e=>{e.querySelectorAll("typo3-backend-color-picker").length&&import("@typo3/backend/color-picker.js"),this.registerEvents()})}registerEvents(){new l("click",this.changeProperty).delegateTo(document,t.editIconSelector)}changeProperty(){const e=this.getAttribute("rel"),r=document.getElementById("defaultTS-"+e),n=document.getElementById("userTS-"+e),s=document.getElementById("check-"+e),c=this.dataset.bsToggle;c==="edit"?(r.style.display="none",n.style.removeProperty("display"),s.removeAttribute("disabled")):c==="undo"&&(n.style.display="none",r.style.removeProperty("display"),s.setAttribute("disabled","disabled"))}}var a=new d;export{a as default};
@@ -0,0 +1,13 @@
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
import t from"@typo3/core/event/regular-event.js";class r{constructor(){this.registerEventListeners()}registerEventListeners(){new t("typo3:datahandler:process",o=>{const e=o.detail.payload;e.action==="delete"&&!e.hasErrors&&document.location.reload()}).bindTo(document)}}var a=new r;export{a as default};
@@ -0,0 +1,13 @@
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
import l from"@typo3/core/document-service.js";import o from"@typo3/backend/modal.js";import{topLevelModuleImport as d}from"@typo3/backend/utility/top-level-module-import.js";import{html as r}from"lit";import{until as m}from"lit/directives/until.js";import p from"@typo3/core/ajax/ajax-request.js";class y{constructor(){this.registerEventListeners()}async registerEventListeners(){await l.ready(),document.querySelectorAll(".t3js-typoscript-analyzer-modal").forEach(e=>{e.addEventListener("click",a=>{a.preventDefault();const t=o.types.default,s=e.dataset.modalTitle||e.textContent.trim(),n=e.getAttribute("href"),c=o.sizes.large,i=r`${m(this.fetchModalContent(n),r`<div class=modal-loading><typo3-backend-spinner size=large></typo3-backend-spinner></div>`)}`;o.advanced({type:t,title:s,size:c,content:i})})})}async fetchModalContent(e){d("@typo3/backend/code-editor/element/code-mirror-element.js");const t=await(await new p(e).get()).resolve();return r`<typo3-t3editor-codemirror .mode=${{name:"@typo3/backend/code-editor/language/typoscript.js",flags:2,exportName:"typoscript",items:[{type:"invoke",args:[]}]}} nolazyload readonly class="flex-grow-1 mh-100"><textarea readonly disabled class=form-control>${t}</textarea></typo3-t3editor-codemirror>`}}var f=new y;export{f as default};
+56
View File
@@ -0,0 +1,56 @@
{
"name": "typo3/cms-tstemplate",
"type": "typo3-cms-framework",
"description": "TYPO3 CMS TypoScript - TYPO3 backend module for the management of TypoScript records for the CMS frontend.",
"homepage": "https://typo3.community/",
"funding": [
{
"type": "membership",
"url": "https://typo3.org/membership"
}
],
"license": [
"GPL-2.0-or-later"
],
"authors": [
{
"name": "TYPO3 Core Team",
"email": "typo3cms@typo3.org",
"role": "Developer"
}
],
"support": {
"issues": "https://forge.typo3.org/issues/",
"forum": "https://talk.typo3.org/",
"source": "https://github.com/TYPO3/typo3/",
"docs": "https://docs.typo3.org/",
"rss": "https://news.typo3.com/rss/",
"chat": "https://typo3.community/meet/slack/",
"security": "https://typo3.org/security/"
},
"config": {
"sort-packages": true
},
"require": {
"typo3/cms-core": "15.0.*@dev"
},
"conflict": {
"typo3/cms": "*"
},
"extra": {
"branch-alias": {
"dev-main": "15.0.x-dev"
},
"typo3/cms": {
"Package": {
"partOfFactoryDefault": true
},
"extension-key": "tstemplate"
}
},
"autoload": {
"psr-4": {
"TYPO3\\CMS\\Tstemplate\\": "Classes/"
}
}
}
+9
View File
@@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
use TYPO3\CMS\Tstemplate\Hooks\DataHandlerClearCachePostProcHook;
defined('TYPO3') or die();
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc']['tstemplate'] = DataHandlerClearCachePostProcHook::class . '->clearPageCacheIfNecessary';