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
@@ -0,0 +1,26 @@
<?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\Behavior;
interface OnFieldChangeInterface
{
/**
* @return array{name: string, data: array<string, mixed>}
*/
public function toArray(): array;
}
@@ -0,0 +1,73 @@
<?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\Behavior;
use TYPO3\CMS\Core\Crypto\HashService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
trait OnFieldChangeTrait
{
/**
* @param OnFieldChangeInterface[] $items `fieldChangeFunc` items
* @return array<int, array>
*/
protected function getOnFieldChangeItems(array $items): array
{
if ($items === []) {
return [];
}
return array_map(
static function (OnFieldChangeInterface $item): array {
return $item->toArray();
},
array_values($items)
);
}
/**
* @param string $event target client event, either `change` or `click`
* @param list<OnFieldChangeInterface> $items `fieldChangeFunc` items
* @return array<string, string> HTML attrs, not encoded - consumers MUST encode with `htmlspecialchars`
*/
protected function getOnFieldChangeAttrs(string $event, array $items): array
{
if ($items === []) {
return [];
}
$onFieldChangeItems = $this->getOnFieldChangeItems($items);
return [
'data-formengine-field-change-event' => $event,
'data-formengine-field-change-items' => GeneralUtility::jsonEncodeForHtmlAttribute($onFieldChangeItems, false),
];
}
/**
* Forwards URL query params for `LinkBrowserController`
* @param list<OnFieldChangeInterface> $items `fieldChangeFunc` items
* @return array{fieldChangeFunc: array<int, array>, fieldChangeFuncHash: string} relevant URL query params for `LinkBrowserController`
*/
protected function forwardOnFieldChangeQueryParams(array $items): array
{
$func = $this->getOnFieldChangeItems($items);
$hashService = GeneralUtility::makeInstance(HashService::class);
return [
'fieldChangeFunc' => $func,
'fieldChangeFuncHash' => $hashService->hmac(serialize($func), 'backend-link-browser'),
];
}
}
@@ -0,0 +1,42 @@
<?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\Behavior;
/**
* Provides reload behavior in form view,
* in case a particular field has been changed.
*/
class ReloadOnFieldChange implements OnFieldChangeInterface
{
protected bool $confirmation;
public function __construct(bool $confirmation)
{
$this->confirmation = $confirmation;
}
public function toArray(): array
{
return [
'name' => 'typo3-backend-form-reload',
'data' => [
'confirmation' => $this->confirmation,
],
];
}
}
@@ -0,0 +1,50 @@
<?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\Behavior;
/**
* Updates bitmask values for multi-checkboxes.
*/
class UpdateBitmaskOnFieldChange implements OnFieldChangeInterface
{
protected int $position;
protected int $total;
protected bool $invert;
protected string $elementName;
public function __construct(int $position, int $total, bool $invert, string $elementName)
{
$this->position = $position;
$this->total = $total;
$this->invert = $invert;
$this->elementName = $elementName;
}
public function toArray(): array
{
return [
'name' => 'typo3-backend-form-update-bitmask',
'data' => [
'position' => $this->position,
'total' => $this->total,
'invert' => $this->invert,
'elementName' => $this->elementName,
],
];
}
}
@@ -0,0 +1,61 @@
<?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\Behavior;
/**
* Updates `TBE_EDITOR` value (the default action),
* in case a particular field has been changed.
*/
class UpdateValueOnFieldChange implements OnFieldChangeInterface
{
protected string $tableName;
protected string $identifier;
protected string $fieldName;
protected string $elementName;
public function __construct(string $tableName, string $identifier, string $fieldName, string $elementName)
{
$this->tableName = $tableName;
$this->identifier = $identifier;
$this->fieldName = $fieldName;
$this->elementName = $elementName;
}
public function withElementName(string $elementName): self
{
if ($this->elementName === $elementName) {
return $this;
}
$target = clone $this;
$target->elementName = $elementName;
return $target;
}
public function toArray(): array
{
return [
'name' => 'typo3-backend-form-update-value',
'data' => [
'tableName' => $this->tableName,
'identifier' => $this->identifier,
'fieldName' => $this->fieldName,
'elementName' => $this->elementName,
],
];
}
}