[TASK] Make compatible with v14

This commit is contained in:
Sebastian Fischer 2025-11-27 21:09:43 +01:00
parent 20f79eef93
commit b010c5e0fd
24 changed files with 135 additions and 45 deletions

View File

@ -7,7 +7,7 @@ declare(strict_types=1);
*
* 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.
* 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.
@ -75,7 +75,7 @@ class ContentElementCommand extends Command
->executeQuery()
->fetchAllAssociative();
(new Table($output))
new Table($output)
->setHeaderTitle('Content in tree ' . $pageId)
->setHeaders(array_keys($result[0]))
->setRows($result)
@ -141,7 +141,7 @@ class ContentElementCommand extends Command
* that you want to use as a WHERE fragment is not prefixed.
*
* @param string $constraint The where part fragment with a possible leading AND / OR operator
* @return string The modified where part without leading operator
* @return string The modified where part without a leading operator
*/
public function stripLogicalOperatorPrefix(string $constraint): string
{

View File

@ -7,7 +7,7 @@ declare(strict_types=1);
*
* 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.
* of the License or any later version.
*/
namespace Evoweb\EwBase\Configuration;

View File

@ -7,7 +7,7 @@ declare(strict_types=1);
*
* 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.
* 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.

View File

@ -7,7 +7,7 @@ declare(strict_types=1);
*
* 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.
* 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.

View File

@ -7,7 +7,7 @@ declare(strict_types=1);
*
* 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.
* 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.

View File

@ -7,7 +7,7 @@ declare(strict_types=1);
*
* 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.
* 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.
@ -214,7 +214,7 @@ class PickColorFromImage extends AbstractFormElement
{
$defaultConfig = self::$defaultConfig;
// If ratios are set do not add default options
// If ratios are set, do not add default options
if (isset($baseConfiguration['cropVariants'])) {
unset($defaultConfig['cropVariants']);
}
@ -233,7 +233,7 @@ class PickColorFromImage extends AbstractFormElement
});
// Aspect ratios may not contain a "." character, see Ratio::__construct()
// To match them again properly, same replacement is required here.
// To match them again properly, the same replacement is required here.
$preparedAllowedAspectRatios = [];
foreach ($cropVariant['allowedAspectRatios'] as $aspectRatio => $aspectRatioDefinition) {
$preparedAllowedAspectRatios[Ratio::prepareAspectRatioId($aspectRatio)] = $aspectRatioDefinition;
@ -259,7 +259,7 @@ class PickColorFromImage extends AbstractFormElement
$config['cropVariants'] = $cropVariants;
// By default we allow all image extensions that can be handled by the GFX functionality
// By default, we allow all image extensions that can be handled by the GFX functionality
$config['allowedExtensions'] ??= $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'];
return $config;
}

View File

@ -7,7 +7,7 @@ declare(strict_types=1);
*
* 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.
* 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.
@ -20,7 +20,7 @@ use Doctrine\DBAL\ParameterType;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
/**
* Utility class that parses sql statements with regard to types and parameters.
* Utility class that parses SQL statements with regard to types and parameters.
*/
class QueryBuilderHelper
{
@ -53,7 +53,7 @@ class QueryBuilderHelper
}
/**
* Gets an array of the placeholders in a sql statements as keys and their positions in the query string.
* Gets an array of the placeholders in a SQL statement as keys and their positions in the query string.
*
* For a statement with positional parameters, returns a zero-indexed list of placeholder position.
* For a statement with named parameters, returns a map of placeholder positions to their parameter names.
@ -127,7 +127,7 @@ class QueryBuilderHelper
}
/**
* For a positional query this method can rewrite the sql statement with regard to array parameters.
* For a positional query this method can rewrite the SQL statement with regard to array parameters.
*
* @throws \Exception
*/
@ -160,7 +160,7 @@ class QueryBuilderHelper
$arrayPositions[$name] = false;
}
// parameter are positional and no array parameter given
// parameters are positional and no array parameter given
if ($isPositional && !$arrayPositions) {
return [$query, $params, $types];
}
@ -210,7 +210,7 @@ class QueryBuilderHelper
$expandStr = $count ? implode(', ', array_fill(0, $count, '?')) : 'NULL';
$query = substr($query, 0, $needlePos) . $expandStr . substr($query, $needlePos + 1);
$paramOffset += $count - 1; // Grows larger by number of parameters minus the replaced needle.
$paramOffset += $count - 1; // Grows larger by the number of parameters minus the replaced needle.
$queryOffset += strlen($expandStr) - 1;
}

View File

@ -7,7 +7,7 @@ declare(strict_types=1);
*
* 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.
* 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.

View File

@ -7,7 +7,7 @@ declare(strict_types=1);
*
* 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.
* 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.
@ -15,6 +15,9 @@ declare(strict_types=1);
namespace Evoweb\EwBase\User;
use TYPO3\CMS\Core\SystemResource\Exception\CanNotResolvePublicResourceException;
use TYPO3\CMS\Core\SystemResource\Exception\CanNotResolveSystemResourceException;
use TYPO3\CMS\Core\SystemResource\Publishing\UriGenerationOptions;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
@ -27,10 +30,18 @@ use TYPO3\CMS\Core\Utility\PathUtility;
*/
class AssetPath
{
/**
* @throws CanNotResolvePublicResourceException
* @throws CanNotResolveSystemResourceException
*/
public function getAbsolutePublicPath(string $content, array $conf): string
{
return $content
. GeneralUtility::getIndpEnv('TYPO3_SITE_URL')
. ltrim(PathUtility::getPublicResourceWebPath($conf['file']), '/');
. ltrim((string)PathUtility::getSystemResourceUri(
$conf['file'],
null,
new UriGenerationOptions(cacheBusting: false)
), '/');
}
}

View File

@ -7,7 +7,7 @@ declare(strict_types=1);
*
* 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.
* 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.

View File

@ -7,7 +7,7 @@ declare(strict_types=1);
*
* 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.
* 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.

View File

@ -7,7 +7,7 @@ declare(strict_types=1);
*
* 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.
* 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.
@ -16,13 +16,22 @@ declare(strict_types=1);
namespace Evoweb\EwBase\ViewHelpers\Be;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerInterface;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Database\RelationHandler;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Imaging\IconSize;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Log\LogManager;
use TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException;
use TYPO3\CMS\Core\Resource\FileReference;
use TYPO3\CMS\Core\Resource\ProcessedFile;
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Schema\Field\FileFieldType;
use TYPO3\CMS\Core\Schema\TcaSchema;
use TYPO3\CMS\Core\Schema\TcaSchemaFactory;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
@ -48,7 +57,7 @@ class ThumbnailViewHelper extends AbstractViewHelper
$field = $this->arguments['fieldName'];
$row = $this->arguments['row'];
$fileReferences = BackendUtility::resolveFileReferences($table, $field, $row);
$fileReferences = $this->resolveFileReferences($table, $field, $row);
$fileObject = is_array($fileReferences) ? current($fileReferences)->getOriginalFile() : null;
if ($fileObject && $fileObject->isMissing()) {
@ -74,6 +83,65 @@ class ThumbnailViewHelper extends AbstractViewHelper
return $this->linkEditContent('<img src="' . $previewFile->getPublicUrl() . '"/>', $row );
}
public function resolveFileReferences(
string $tableName,
string $fieldName,
array $element,
?int $workspaceId = null
): ?array {
if (!($schema = self::getTcaSchema($tableName))?->hasField($fieldName)) {
return null;
}
$field = $schema->getField($fieldName);
if ($field instanceof FileFieldType === false) {
return null;
}
$fileReferences = [];
$relationHandler = GeneralUtility::makeInstance(RelationHandler::class);
if ($workspaceId !== null) {
$relationHandler->setWorkspaceId($workspaceId);
}
$relationHandler->initializeForField(
$tableName,
$field->getConfiguration(),
$element,
$element[$fieldName],
);
$relationHandler->processDeletePlaceholder();
$referenceUids = $relationHandler->tableArray[$field->getConfiguration()['foreign_table']] ?? [];
foreach ($referenceUids as $referenceUid) {
try {
$fileReference = GeneralUtility::makeInstance(ResourceFactory::class)->getFileReferenceObject(
$referenceUid,
[],
$workspaceId === 0
);
$fileReferences[$fileReference->getUid()] = $fileReference;
} catch (FileDoesNotExistException $e) {
/**
* We just catch the exception here
* Reasoning: There is nothing an editor or even admin could do
*/
} catch (\InvalidArgumentException $e) {
/**
* The storage does not exist anymore
* Log the exception message for admins as they maybe can restore the storage
*/
// @extensionScannerIgnoreLine
self::getLogger()->error($e->getMessage(), [
'table' => $tableName,
'fieldName' => $fieldName,
'referenceUid' => $referenceUid,
'exception' => $e,
]);
}
}
return $fileReferences;
}
protected function linkEditContent(string $linkText, $row): string
{
if (empty($linkText)) {
@ -84,10 +152,8 @@ class ThumbnailViewHelper extends AbstractViewHelper
if (
$backendUser->check('tables_modify', 'tt_content')
&& $backendUser->recordEditAccessInternals('tt_content', $row)
&& (
new Permission(
$backendUser->calcPerms(BackendUtility::getRecord('pages', $row['pid']) ?? [])
)
&& new Permission(
$backendUser->calcPerms(BackendUtility::getRecord('pages', $row['pid']) ?? [])
)->editContentPermissionIsGranted()
) {
$urlParameters = [
@ -112,6 +178,17 @@ class ThumbnailViewHelper extends AbstractViewHelper
return $linkText;
}
protected static function getLogger(): LoggerInterface
{
return GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
}
protected static function getTcaSchema(string $tableName): ?TcaSchema
{
$schemaFactory = GeneralUtility::makeInstance(TcaSchemaFactory::class);
return $schemaFactory->has($tableName) ? $schemaFactory->get($tableName) : null;
}
protected function getBackendUser(): BackendUserAuthentication
{
return $GLOBALS['BE_USER'];

View File

@ -7,7 +7,7 @@ declare(strict_types=1);
*
* 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.
* 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.

View File

@ -7,7 +7,7 @@ declare(strict_types=1);
*
* 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.
* 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.

View File

@ -7,7 +7,7 @@ declare(strict_types=1);
*
* 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.
* 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.

View File

@ -7,7 +7,7 @@ declare(strict_types=1);
*
* 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.
* 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.

View File

@ -7,7 +7,7 @@ declare(strict_types=1);
*
* 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.
* 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.

View File

@ -7,7 +7,7 @@ declare(strict_types=1);
*
* 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.
* 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.

View File

@ -7,7 +7,7 @@ declare(strict_types=1);
*
* 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.
* 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.

View File

@ -7,7 +7,7 @@ declare(strict_types=1);
*
* 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.
* 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.
@ -16,6 +16,9 @@ declare(strict_types=1);
namespace Evoweb\EwBase\ViewHelpers;
use TYPO3\CMS\Core\Resource\Exception\InvalidFileException;
use TYPO3\CMS\Core\SystemResource\Exception\CanNotResolvePublicResourceException;
use TYPO3\CMS\Core\SystemResource\Exception\CanNotResolveSystemResourceException;
use TYPO3\CMS\Core\SystemResource\Publishing\UriGenerationOptions;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
@ -25,9 +28,6 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
* <code title="Simple Loop">
* <ewb:publicPath path="{data}">....</ewb:publicPath>
* </code>
* <output>
* fixed flexform data for extbase controller
* </output>
*
* @api
*/
@ -45,11 +45,12 @@ class PublicPathViewHelper extends AbstractViewHelper
}
/**
* @throws InvalidFileException
* @throws CanNotResolvePublicResourceException
* @throws CanNotResolveSystemResourceException
*/
public function renderStatic(): string
public function render(): string
{
$path = (string)$this->arguments['path'];
return PathUtility::getPublicResourceWebPath($path);
return (string)PathUtility::getSystemResourceUri($path, null, new UriGenerationOptions(cacheBusting: false));
}
}

View File

@ -7,7 +7,7 @@ declare(strict_types=1);
*
* 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.
* 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.

View File

@ -7,7 +7,7 @@ declare(strict_types=1);
*
* 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.
* 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.

View File

@ -7,7 +7,7 @@ declare(strict_types=1);
*
* 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.
* 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.

View File

@ -1,6 +1,7 @@
{
"name": "evoweb/ew-base",
"type": "typo3-cms-extension",
"description": "Site base",
"autoload": {
"psr-4": {
"Evoweb\\EwBase\\": "Classes/"