TYPO3 v15 dev-main snapshot ()

This commit is contained in:
2026-08-10 22:31:02 +02:00
commit b53992613d
22 changed files with 2485 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\Belog\ViewHelpers;
use TYPO3\CMS\Belog\Domain\Model\LogEntry;
use TYPO3\CMS\Core\Log\LogDataTrait;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* ViewHelper to create detail string from a log entry.
*
* ```
* <belog:formatDetails logEntry="{logItem}" />
* ```
*
* @internal
*/
final class FormatDetailsViewHelper extends AbstractViewHelper
{
use LogDataTrait;
public function initializeArguments(): void
{
$this->registerArgument('logEntry', LogEntry::class, 'Log entry instance to be rendered', true);
}
/**
* Create formatted detail string from log row.
*
* The method handles two properties of the model: details and logData
* Details is a string with possible %s placeholders, and logData an array
* with the substitutions.
* Furthermore, possible files in logData are stripped to their basename if
* the action logged was a file action
*/
public function render(): string
{
/** @var LogEntry $logEntry */
$logEntry = $this->arguments['logEntry'];
$detailString = $logEntry->getDetails();
$substitutes = $logEntry->getLogData();
// Strip paths from file names if the log was a file action
if ($logEntry->getType() === 2) {
$substitutes = self::stripPathFromFilenames($substitutes);
}
return self::formatLogDetailsStatic($detailString, $substitutes);
}
/**
* Strips path from array of file names
*/
private static function stripPathFromFilenames(array $files = []): array
{
foreach ($files as $key => $file) {
$files[$key] = PathUtility::basename((string)$file);
}
return $files;
}
}
@@ -0,0 +1,60 @@
<?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\Belog\ViewHelpers;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* ViewHelper to get a username from a backend user id.
*
* ```
* <belog:username uid="{logItem.backendUserUid}" />
* ```
*
* @internal
*/
final class UsernameViewHelper extends AbstractViewHelper
{
public function __construct(
#[Autowire(service: 'cache.runtime')]
private readonly FrontendInterface $usernameRuntimeCache
) {}
public function initializeArguments(): void
{
$this->registerArgument('uid', 'int', 'Uid of the user', true);
}
/**
* Resolve username from backend user id. Can return empty string if there is no user with that UID.
*/
public function render(): string
{
$uid = $this->arguments['uid'];
$cacheIdentifier = 'belog-viewhelper-username_' . $uid;
if ($this->usernameRuntimeCache->has($cacheIdentifier)) {
return $this->usernameRuntimeCache->get($cacheIdentifier);
}
$username = BackendUtility::getRecord('be_users', $uid)['username'] ?? '';
$this->usernameRuntimeCache->set($cacheIdentifier, $username);
return $username;
}
}
@@ -0,0 +1,77 @@
<?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\Belog\ViewHelpers;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* ViewHelper to get workspace title from a workspace id.
*
* ```
* belog:workspaceTitle uid="{logItem.workspaceUid}" />
* ```
*
* @internal
*/
final class WorkspaceTitleViewHelper extends AbstractViewHelper
{
public function __construct(
#[Autowire(service: 'cache.runtime')]
private readonly FrontendInterface $workspaceTitleRuntimeCache
) {}
public function initializeArguments(): void
{
$this->registerArgument('uid', 'int', 'UID of the workspace', true);
}
/**
* Return resolved workspace title or empty string if it can not be resolved.
*
* @throws \InvalidArgumentException
*/
public function render(): string
{
$uid = $this->arguments['uid'];
$cacheIdentifier = 'belog-viewhelper-workspace-title_' . $uid;
if ($this->workspaceTitleRuntimeCache->has($cacheIdentifier)) {
return $this->workspaceTitleRuntimeCache->get($cacheIdentifier);
}
if ($uid === 0) {
$this->workspaceTitleRuntimeCache->set($cacheIdentifier, htmlspecialchars(self::getLanguageService()->sL(
'LLL:EXT:belog/Resources/Private/Language/locallang.xlf:live'
)));
} elseif (!ExtensionManagementUtility::isLoaded('workspaces')) {
$this->workspaceTitleRuntimeCache->set($cacheIdentifier, '');
} else {
$workspace = BackendUtility::getRecord('sys_workspace', $uid);
$this->workspaceTitleRuntimeCache->set($cacheIdentifier, $workspace['title'] ?? '');
}
return $this->workspaceTitleRuntimeCache->get($cacheIdentifier);
}
private static function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
}