TYPO3 v15 dev-main snapshot ()

This commit is contained in:
2026-08-10 22:31:00 +02:00
commit f9941541b7
1178 changed files with 135377 additions and 0 deletions
+145
View File
@@ -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\Backend\Form\NodeExpansion;
use TYPO3\CMS\Backend\Form\AbstractNode;
use TYPO3\CMS\Backend\Form\NodeFactory;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Imaging\IconSize;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Service\DependencyOrderingService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Field controls are additional HTML on a single element level that are typically
* shown right aside the main element HTML.
*
* They are restricted to only allow an icon as output.
*
* The "edit popup" button next to a select field of a renderType "selectMultipleSideBySide"
* is an example of such an additional control.
*
* The element itself must position any field controls at an appropriate place.
* For instance the "group" element shows them in a row vertically, while others
* display single controls next to each other.
*/
class FieldControl extends AbstractNode
{
public function __construct(
private readonly NodeFactory $nodeFactory,
private readonly IconFactory $iconFactory,
private readonly DependencyOrderingService $dependencyOrderingService,
) {}
/**
* Order the list of field wizards to be rendered with the ordering service,
* then call each wizard element through the node factory and merge their
* results.
*
* @return array Result array
*/
public function render(): array
{
$result = $this->initializeResultArray();
if (!isset($this->data['renderData']['fieldControl'])) {
return $result;
}
$languageService = $this->getLanguageService();
$fieldControl = $this->data['renderData']['fieldControl'];
$orderedFieldControl = $this->dependencyOrderingService->orderByDependencies($fieldControl);
foreach ($orderedFieldControl as $anOrderedFieldControl => $orderedFieldControlConfiguration) {
if (isset($orderedFieldControlConfiguration['disabled']) && $orderedFieldControlConfiguration['disabled']
|| !isset($fieldControl[$anOrderedFieldControl]['renderType'])
) {
// Don't consider this control if disabled.
// Also ignore if renderType is not given.
// Missing renderType may happen if an element registers a default field control
// as disabled, and TCA enabled that. If then additionally for instance the
// element renderType is changed to an element that doesn't register the control
// by default anymore, this would then fatal if we don't continue here.
// @todo: the above scenario indicates a small configuration flaw, maybe log an error somewhere?
continue;
}
$options = $this->data;
$options['renderType'] = $fieldControl[$anOrderedFieldControl]['renderType'];
$options['renderData']['fieldControlOptions'] = $orderedFieldControlConfiguration['options'] ?? [];
$controlResult = $this->nodeFactory->create($options)->render();
// If the controlResult is empty (this control rendered nothing), continue to next one
if (empty($controlResult)) {
continue;
}
if (empty($controlResult['iconIdentifier'])) {
throw new \RuntimeException(
'Field controls must return an iconIdentifier',
1483890332
);
}
if (empty($controlResult['title'])) {
throw new \RuntimeException(
'Field controls must return a title',
1483890482
);
}
if (empty($controlResult['linkAttributes'])) {
throw new \RuntimeException(
'Field controls must return link attributes',
1483891272
);
}
$icon = $controlResult['iconIdentifier'];
$title = $languageService->sL($controlResult['title']);
$linkAttributes = $controlResult['linkAttributes'];
if (!isset($linkAttributes['class'])) {
$linkAttributes['class'] = 'btn btn-default';
} else {
$linkAttributes['class'] .= ' btn btn-default';
}
if (!isset($linkAttributes['href'])) {
$linkAttributes['href'] = '#';
}
unset($controlResult['iconIdentifier']);
unset($controlResult['title']);
unset($controlResult['linkAttributes']);
$html = [];
$html[] = '<a ' . GeneralUtility::implodeAttributes($linkAttributes, true) . '>';
$html[] = $this->iconFactory->getIcon($icon, IconSize::SMALL)->setTitle($title)->render();
$html[] = '</a>';
$finalControlResult = $this->initializeResultArray();
$finalControlResult = array_merge($finalControlResult, $controlResult);
$finalControlResult['html'] = implode(LF, $html);
$result = $this->mergeChildReturnIntoExistingResult($result, $finalControlResult);
}
return $result;
}
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
}
@@ -0,0 +1,90 @@
<?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\Backend\Form\NodeExpansion;
use TYPO3\CMS\Backend\Form\AbstractNode;
use TYPO3\CMS\Backend\Form\NodeFactory;
use TYPO3\CMS\Core\Service\DependencyOrderingService;
/**
* Field information are additional HTML on a single node level that are typically
* shown between the label and the main element. They are registered in ['config']['fieldInformation']
* TCA section and each element may merge that with default registered information.
*
* Field information must not add additional functionality to the element. They are only
* allowed to add "informational" stuff like links, div and spans and similar.
*/
class FieldInformation extends AbstractNode
{
public function __construct(
private readonly NodeFactory $nodeFactory,
private readonly DependencyOrderingService $dependencyOrderingService,
) {}
/**
* Order the list of field information to be rendered with the ordering service,
* then call each information element through the node factory and merge their
* results.
*
* @return array Result array
*/
public function render(): array
{
$result = $this->initializeResultArray();
if (!isset($this->data['renderData']['fieldInformation'])) {
return $result;
}
$fieldInformation = $this->data['renderData']['fieldInformation'];
$orderedFieldInformation = $this->dependencyOrderingService->orderByDependencies($fieldInformation);
foreach ($orderedFieldInformation as $anOrderedFieldInformation => $orderedFieldInformationConfiguration) {
if (isset($orderedFieldInformationConfiguration['disabled']) && $orderedFieldInformationConfiguration['disabled']
|| !isset($fieldInformation[$anOrderedFieldInformation]['renderType'])
) {
// Don't consider this control if disabled.
// Also ignore if renderType is not given.
// Missing renderType may happen if an element registers a default field control
// as disabled, and TCA enabled that. If then additionally for instance the
// element renderType is changed to an element that doesn't register the control
// by default anymore, this would then fatal if we don't continue here.
// @todo: the above scenario indicates a small configuration flaw, maybe log an error somewhere?
continue;
}
$options = $this->data;
$options['renderType'] = $fieldInformation[$anOrderedFieldInformation]['renderType'];
$options['renderData']['fieldInformationOptions'] = $orderedFieldInformationConfiguration['options'] ?? [];
$informationResult = $this->nodeFactory->create($options)->render();
$allowedTags = '<a><br><br/><div><em><i><p><strong><span><code>';
if (strip_tags($informationResult['html'], $allowedTags) !== $informationResult['html']) {
throw new \RuntimeException(
'The field information API supports only a limited number of HTML tags within the result'
. ' HTML of children. Allowed tags are: "' . $allowedTags . '" Child'
. ' ' . $options['renderType'] . ' violated this rule. Either remove offending tags or'
. ' switch to a different API like "fieldWizard" or "fieldControl".',
1485084419
);
}
$result = $this->mergeChildReturnIntoExistingResult($result, $informationResult);
}
return $result;
}
}
@@ -0,0 +1,82 @@
<?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\Backend\Form\NodeExpansion;
use TYPO3\CMS\Backend\Form\AbstractNode;
use TYPO3\CMS\Backend\Form\NodeFactory;
use TYPO3\CMS\Core\Service\DependencyOrderingService;
/**
* Field wizards are additional HTML on a single element level that are typically
* shown below the element input. They are registered in ['config']['fieldWizard']
* TCA section and each element may merge that with default wizards.
*
* Field wizards may add additional functionality to the element. They could add
* new ajax controllers for instance or add buttons and are not restricted by the
* framework further.
*
* Examples for field wizards are the display of the "language diff" in input elements
* and the file upload button in group elements.
*/
class FieldWizard extends AbstractNode
{
public function __construct(
private readonly NodeFactory $nodeFactory,
private readonly DependencyOrderingService $dependencyOrderingService,
) {}
/**
* Order the list of field wizards to be rendered with the ordering service,
* then call each wizard element through the node factory and merge their
* results.
*
* @return array Result array
*/
public function render(): array
{
$result = $this->initializeResultArray();
if (!isset($this->data['renderData']['fieldWizard'])) {
return $result;
}
$fieldWizard = $this->data['renderData']['fieldWizard'];
$orderedFieldWizard = $this->dependencyOrderingService->orderByDependencies($fieldWizard);
foreach ($orderedFieldWizard as $anOrderedFieldWizard => $orderedFieldWizardConfiguration) {
if (isset($orderedFieldWizardConfiguration['disabled']) && $orderedFieldWizardConfiguration['disabled']
|| !isset($fieldWizard[$anOrderedFieldWizard]['renderType'])
) {
// Don't consider this control if disabled.
// Also ignore if renderType is not given.
// Missing renderType may happen if an element registers a default field control
// as disabled, and TCA enabled that. If then additionally for instance the
// element renderType is changed to an element that doesn't register the control
// by default anymore, this would then fatal if we don't continue here.
// @todo: the above scenario indicates a small configuration flaw, maybe log an error somewhere?
continue;
}
$options = $this->data;
$options['renderType'] = $fieldWizard[$anOrderedFieldWizard]['renderType'];
$options['renderData']['fieldWizardOptions'] = $orderedFieldWizardConfiguration['options'] ?? [];
$wizardResult = $this->nodeFactory->create($options)->render();
$result = $this->mergeChildReturnIntoExistingResult($result, $wizardResult);
}
return $result;
}
}