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,75 @@
<?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\ViewHelpers\Link;
use TYPO3\CMS\Core\Information\Typo3Information;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
/**
* Use this ViewHelper to provide a link to the official documentation. The ViewHelper will
* use the permalink identifier to generate a permalink to the documentation which is
* a redirect to the actual URI.
*
* The identifier must be given as a string. Be aware that very specific short links into
* the documentation may change over time.
*
* The link will always lead to the documentation of the corresponding TYPO3 version. This
* means in a v12 installation, using `foo-bar` as identifier will link to 'foo-bar@12.4',
* while in v13 the link will be 'foo-bar@13.4'.
*
* Example
* =======
*
* Link to the documentation::
*
* <be:link.documentation identifier="foo-bar">See documentation</be:link.documentation>
*
* Output::
*
* <a href="https://docs.typo3.org/permalink/foo-bar@13.4" target="_blank" rel="noreferrer">
* See documentation
* </a>
*
* @see https://docs.typo3.org/permalink/t3viewhelper:typo3-backend-link-documentation
* @internal not part of TYPO3 Core API.
*/
final class DocumentationViewHelper extends AbstractTagBasedViewHelper
{
protected $tagName = 'a';
public function initializeArguments(): void
{
parent::initializeArguments();
$this->registerArgument('identifier', 'string', 'the documentation permalink identifier as displayed in the modal link popup of any rendered documentation manual', true);
}
/**
* @throws \InvalidArgumentException
*/
public function render(): string
{
// Note: This ViewHelper cannot use DI, because it is used in the Install-Tool context where constructor-based DI does not work.
// Typo3Information is a simple DO so we do not need to utilize makeInstance() here.
$this->tag->addAttribute('href', Typo3Information::getDocsLink($this->arguments['identifier']));
$this->tag->addAttribute('target', '_blank');
$this->tag->addAttribute('rel', 'noreferrer');
$this->tag->setContent($this->renderChildren());
$this->tag->forceClosingTag(true);
return $this->tag->render();
}
}
@@ -0,0 +1,121 @@
<?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\ViewHelpers\Link;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\InvalidArgumentValueException;
/**
* Use this ViewHelper to provide edit links to records. The ViewHelper will
* pass the uid and table to FormEngine.
*
* The uid must be given as a positive integer.
* For new records, use the :ref:`<be:link.newRecordViewHelper> <typo3-backend-link-newrecord>`.
*
* Examples
* ========
*
* Link to the record-edit action passed to FormEngine::
*
* <be:link.editRecord uid="42" table="a_table" returnUrl="foo/bar" />
*
* Output::
*
* <a href="/typo3/record/edit?edit[a_table][42]=edit&returnUrl=foo/bar">
* Edit record
* </a>
*
* Link to edit page uid=3 and then return back to the BE module "web_MyextensionList"::
*
* <be:link.editRecord uid="3" table="pages" returnUrl="{f:be.uri(route: 'web_MyextensionList')}">
*
* Link to edit only the fields title and subtitle of page uid=42 and return to foo/bar::
*
* <be:link.editRecord uid="42" table="pages" fields="title,subtitle" returnUrl="foo/bar">
* Edit record
* </be:link.editRecord>
*
* Output::
*
* <a href="/typo3/record/edit?edit[pages][42]=edit&returnUrl=foo/bar&columnsOnly[pages]=title,subtitle">
* Edit record
* </a>
*
* @see https://docs.typo3.org/permalink/t3viewhelper:typo3-backend-link-editrecord
*/
final class EditRecordViewHelper extends AbstractTagBasedViewHelper
{
/**
* @var string
*/
protected $tagName = 'a';
public function __construct(
private readonly UriBuilder $uriBuilder
) {
parent::__construct();
}
public function initializeArguments(): void
{
parent::initializeArguments();
$this->registerArgument('uid', 'int', 'uid of record to be edited', true);
$this->registerArgument('table', 'string', 'target database table', true);
$this->registerArgument('fields', 'string', 'Edit only these fields (comma separated list)');
$this->registerArgument('module', 'string', 'Set module identifier for context - marking as active when editing the record', false, '');
$this->registerArgument('returnUrl', 'string', 'return to this URL after closing the edit dialog', false, '');
}
/**
* @throws \InvalidArgumentException
* @throws RouteNotFoundException
*/
public function render(): string
{
if ($this->arguments['uid'] < 1) {
throw new InvalidArgumentValueException('Uid must be a positive integer, ' . $this->arguments['uid'] . ' given.', 1526127158);
}
$request = $this->renderingContext->hasAttribute(ServerRequestInterface::class)
? $this->renderingContext->getAttribute(ServerRequestInterface::class) : null;
if (empty($this->arguments['returnUrl']) && $request !== null) {
// @todo: We may want to deprecate fetching returnUrl from request
$this->arguments['returnUrl'] = $request->getAttribute('normalizedParams')->getRequestUri();
}
$params = [
'edit' => [$this->arguments['table'] => [$this->arguments['uid'] => 'edit']],
'module' => ($this->arguments['module'] ?? '') ?: ($request?->getAttribute('module')?->getIdentifier() ?? ''),
'returnUrl' => $this->arguments['returnUrl'],
];
if ($this->arguments['fields'] ?? false) {
$params['columnsOnly'] = [
$this->arguments['table'] => GeneralUtility::trimExplode(',', $this->arguments['fields'], true),
];
}
$uri = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $params);
$this->tag->addAttribute('href', $uri);
$this->tag->setContent((string)$this->renderChildren());
$this->tag->forceClosingTag(true);
return $this->tag->render();
}
}
@@ -0,0 +1,161 @@
<?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\ViewHelpers\Link;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\InvalidArgumentException;
use TYPO3Fluid\Fluid\Core\ViewHelper\InvalidArgumentValueException;
/**
* Use this ViewHelper to provide 'create new record' links.
* The ViewHelper will pass the command to FormEngine.
*
* The table argument is mandatory, it decides what record is to be created.
*
* The pid argument will put the new record on this page, if ``0`` given it will
* be placed to the root page.
*
* The uid argument accepts only negative values. If this is given, the new
* record will be placed (by sorting field) behind the record with the uid.
* It will end up on the same pid as this given record, so the pid must not
* be given explicitly by pid argument.
*
* An exception will be thrown, if both uid and pid are given.
* An exception will be thrown, if the uid argument is not a negative integer.
*
* To edit records, use the :ref:`<be:link.editRecordViewHelper> <typo3-backend-link-editrecord>`.
*
* Examples
* ========
*
* Link to create a new record of a_table after record 17 on the same pid::
*
* <be:link.newRecord table="a_table" returnUrl="foo/bar" uid="-17"/>
*
* Output::
*
* <a href="/typo3/record/edit?edit[a_table][-17]=new&returnUrl=foo/bar">
* New record
* </a>
*
* Link to create a new record of a_table on root page::
*
* <be:link.newRecord table="a_table" returnUrl="foo/bar""/>
*
* Output::
*
* <a href="/typo3/record/edit?edit[a_table][]=new&returnUrl=foo/bar">
* New record
* </a>
*
* Link to create a new record of a_table on page 17::
*
* <be:link.newRecord table="a_table" returnUrl="foo/bar" pid="17"/>
*
* Output::
*
* <a href="/typo3/record/edit?edit[a_table][17]=new&returnUrl=foo/bar">
* New record
* </a>
*
* Link to create a new record then return back to the BE module "web_MyextensionList"::
*
* <be:link.newRecord table="a_table" returnUrl="{f:be.uri(route: 'web_MyextensionList')}" pid="17">
*
* Output::
*
* <a href="/typo3/record/edit?edit[a_table][17]=new&returnUrl=/typo3/module/web/MyextensionList">
* New record
* </a>
*
* Link to create a new record of a_table on page 17 with a default value::
*
* <be:link.newRecord table="a_table" returnUrl="foo/bar" pid="17" defaultValues="{a_table: {a_field: 'value'}}">
*
* Output::
*
* <a href="/typo3/record/edit?edit[a_table][17]=new&returnUrl=foo/bar&defVals[a_table][a_field]=value">
* New record
* </a>
*
* @see https://docs.typo3.org/permalink/t3viewhelper:typo3-backend-link-newrecord
*/
final class NewRecordViewHelper extends AbstractTagBasedViewHelper
{
/**
* @var string
*/
protected $tagName = 'a';
public function __construct(
private readonly UriBuilder $uriBuilder
) {
parent::__construct();
}
public function initializeArguments(): void
{
parent::initializeArguments();
$this->registerArgument('uid', 'int', 'uid < 0 will insert the record after the given uid');
$this->registerArgument('pid', 'int', 'the page id where the record will be created');
$this->registerArgument('table', 'string', 'target database table', true);
$this->registerArgument('module', 'string', 'Set module identifier for context - marking as acitve when editing the record', false, '');
$this->registerArgument('returnUrl', 'string', 'return to this URL after closing the new record dialog', false, '');
$this->registerArgument('defaultValues', 'array', 'default values for fields of the new record', false, []);
}
/**
* @throws InvalidArgumentException
* @throws RouteNotFoundException
*/
public function render(): string
{
if ($this->arguments['uid'] && $this->arguments['pid']) {
throw new InvalidArgumentException('Can\'t handle both uid and pid for new records', 1526129969);
}
if (isset($this->arguments['uid']) && $this->arguments['uid'] >= 0) {
throw new InvalidArgumentValueException('Uid must be negative integer, ' . $this->arguments['uid'] . ' given', 1526134901);
}
$request = $this->renderingContext->hasAttribute(ServerRequestInterface::class)
? $this->renderingContext->getAttribute(ServerRequestInterface::class) : null;
if (empty($this->arguments['returnUrl']) && $request !== null) {
$this->arguments['returnUrl'] = $request->getAttribute('normalizedParams')->getRequestUri();
}
$params = [
'edit' => [$this->arguments['table'] => [$this->arguments['uid'] ?? $this->arguments['pid'] ?? 0 => 'new']],
// @todo add module argument to this view helper
'module' => ($this->arguments['module'] ?? '') ?: ($request?->getAttribute('module')?->getIdentifier() ?? ''),
'returnUrl' => $this->arguments['returnUrl'],
];
if ($this->arguments['defaultValues']) {
$params['defVals'] = $this->arguments['defaultValues'];
}
$uri = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $params);
$this->tag->addAttribute('href', $uri);
$this->tag->setContent((string)$this->renderChildren());
$this->tag->forceClosingTag(true);
return $this->tag->render();
}
}