diff --git a/Classes/Command/ContentElementCommand.php b/Classes/Command/ContentElementCommand.php index 687e76d..488b022 100755 --- a/Classes/Command/ContentElementCommand.php +++ b/Classes/Command/ContentElementCommand.php @@ -36,10 +36,10 @@ class ContentElementCommand extends Command parent::__construct(); } - protected function configure() + protected function configure(): void { $this - ->setAliases(['kc-sitepackage']) + ->setAliases(['ce']) ->addOption( 'pageId', '-p', diff --git a/Classes/Configuration/AdditionalConfiguration.php b/Classes/Configuration/AdditionalConfiguration.php index 298a17a..69530c8 100755 --- a/Classes/Configuration/AdditionalConfiguration.php +++ b/Classes/Configuration/AdditionalConfiguration.php @@ -12,8 +12,6 @@ namespace Evoweb\EwBase\Configuration; * of the License, or any later version. */ -use Mfc\OAuth2\ResourceServer\GitLab; -use Mfc\OAuth2\ResourceServer\Registry; use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -22,24 +20,6 @@ class AdditionalConfiguration { protected string $extensionKey = 'ew_base'; - protected array $oauthOptions = [ - 'enabled' => true, // Enable/Disable the provider - 'arguments' => [ - 'appId' => '', - 'appSecret' => '', - 'projectName' => '', - 'gitlabServer' => 'https://github.com', - // User level at which the user will be given admin permissions - 'gitlabAdminUserLevel' => 30, - // Groups to assign to the User (comma separated list possible) - 'gitlabDefaultGroups' => 1, - // UserConfig db and/or file mount from groups - 'gitlabUserOption' => 3, - // Blocks users with flag external from access the backend - 'blockExternalUser' => false, - ], - ]; - protected array $developConfig = [ 'BE' => [ 'debug' => true, @@ -169,19 +149,6 @@ class AdditionalConfiguration } } - public function addGitlabLogin(array $options = []): void - { - if (!empty($options)) { - $this->oauthOptions['arguments']['gitlabAdminUserLevel'] = GitLab::USER_LEVEL_DEVELOPER; - Registry::addServer( - 'gitlab', - 'Login mit GitLab', - GitLab::class, - $this->arrayMergeRecursive($this->oauthOptions, $options) - ); - } - } - protected function arrayMergeRecursive(array $array1, array $array2): array { $merged = $array1; diff --git a/Classes/EventListener/IsContentUsedOnPageLayout.php b/Classes/EventListener/IsContentUsedOnPageLayout.php index daafc1e..dbf6175 100755 --- a/Classes/EventListener/IsContentUsedOnPageLayout.php +++ b/Classes/EventListener/IsContentUsedOnPageLayout.php @@ -2,7 +2,7 @@ namespace Evoweb\EwBase\EventListener; -use TYPO3\CMS\Backend\ViEvoweb\Event\IsContentUsedOnPageLayoutEvent; +use TYPO3\CMS\Backend\View\Event\IsContentUsedOnPageLayoutEvent; class IsContentUsedOnPageLayout { @@ -15,7 +15,7 @@ class IsContentUsedOnPageLayout { $found = false; foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['ew_base']['ContentUsedStrings'] ?? [] as $search) { - if (strpos($cType, $search) !== false) { + if (str_contains($cType, $search)) { $found = true; break; } diff --git a/Classes/Form/Element/PickColorFromImage.php b/Classes/Form/Element/PickColorFromImage.php index afe6a18..e9e2e4e 100755 --- a/Classes/Form/Element/PickColorFromImage.php +++ b/Classes/Form/Element/PickColorFromImage.php @@ -15,8 +15,12 @@ namespace Evoweb\EwBase\Form\Element; * LICENSE.txt file that was distributed with this source code. */ +use Psr\EventDispatcher\EventDispatcherInterface; use TYPO3\CMS\Backend\Form\Element\AbstractFormElement; -use TYPO3\CMS\Backend\Form\NodeFactory; +use TYPO3\CMS\Backend\Form\Event\ModifyImageManipulationPreviewUrlEvent; +use TYPO3\CMS\Backend\Routing\UriBuilder; +use TYPO3\CMS\Backend\View\BackendViewFactory; +use TYPO3\CMS\Core\Crypto\HashService; use TYPO3\CMS\Core\Imaging\ImageManipulation\Area; use TYPO3\CMS\Core\Imaging\ImageManipulation\CropVariantCollection; use TYPO3\CMS\Core\Imaging\ImageManipulation\InvalidConfigurationException; @@ -27,15 +31,13 @@ use TYPO3\CMS\Core\Resource\ResourceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; use TYPO3\CMS\Core\Utility\StringUtility; -use TYPO3Fluid\Fluid\ViEvoweb\TemplateView; -use TYPO3Fluid\Fluid\ViEvoweb\ViewInterface; class PickColorFromImage extends AbstractFormElement { + private string $wizardRouteName = 'ajax_wizard_image_manipulation'; + /** * Default element configuration - * - * @var array */ protected static array $defaultConfig = [ 'imageField' => 'image', @@ -110,53 +112,31 @@ class PickColorFromImage extends AbstractFormElement ], ]; - protected ViewInterface $templateView; - - public function __construct(NodeFactory $nodeFactory, array $data) - { - parent::__construct($nodeFactory, $data); - // Would be great, if we could inject the view here, but since the constructor is in the interface, we can't - // @todo: It's unfortunate we're using Typo3Fluid TemplateView directly here. We can't - // inject BackendViewFactory here since __construct() is polluted by NodeInterface. - // Remove __construct() from NodeInterface to have DI, then use BackendViewFactory here. - $view = GeneralUtility::makeInstance(TemplateView::class); - $templatePaths = $view->getRenderingContext()->getTemplatePaths(); - $templatePaths - ->setTemplateRootPaths([GeneralUtility::getFileAbsFileName('EXT:ew_base/Resources/Private/Templates')]); - $templatePaths - ->setPartialRootPaths([GeneralUtility::getFileAbsFileName('EXT:ew_base/Resources/Private/Partials')]); - $this->templateView = $view; - } + public function __construct( + private readonly BackendViewFactory $backendViewFactory, + private readonly UriBuilder $uriBuilder, + private readonly EventDispatcherInterface $eventDispatcher, + private readonly ResourceFactory $resourceFactory, + private readonly HashService $hashService, + ) {} + /** + * @throws InvalidConfigurationException + */ public function render(): array { $resultArray = $this->initializeResultArray(); $parameterArray = $this->data['parameterArray']; $config = $this->populateConfiguration($parameterArray['fieldConf']['config']); - $fieldId = StringUtility::getUniqueId('formengine-color-'); - $file = $this->getFileObject($this->data['databaseRow'], $config['imageField']); + $file = $this->getFile($this->data['databaseRow'], $config['imageField']); if (!$file) { - $languageService = $this->getLanguageService(); - $label = $languageService->sL( - 'LLL:EXT:ew_base/Resources/Private/Language/locallang_db.xlf:imageField.empty' - ); - $fieldLabel = $this->data['processedTca']['columns'][$config['imageField']]['label']; - $resultArray['html'] = ' -
-
-
- - ' . sprintf($label, '' . $fieldLabel . '') . ' - -
-
-
- '; // Early return in case we do not find a file return $resultArray; } + $config = $this->processConfiguration($config, $parameterArray['itemFormElValue'], $file); + $fieldInformationResult = $this->renderFieldInformation(); $fieldInformationHtml = $fieldInformationResult['html']; $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldInformationResult, false); @@ -169,14 +149,6 @@ class PickColorFromImage extends AbstractFormElement $fieldWizardHtml = $fieldWizardResult['html']; $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldWizardResult, false); - $width = $this->formMaxWidth( - MathUtility::forceIntegerInRange( - $config['size'] ?? $this->defaultInputWidth, - $this->minimumInputWidth, - $this->maxInputWidth - ) - ); - $arguments = [ 'fieldInformation' => $fieldInformationHtml, 'fieldControl' => $fieldControlHtml, @@ -195,10 +167,15 @@ class PickColorFromImage extends AbstractFormElement 'validation' => '[]', ], 'config' => $config, - 'width' => $width, + 'wizardUri' => $this->getWizardUri(), + 'wizardPayload' => json_encode($this->getWizardPayload($config['cropVariants'], $file)), + 'previewUrl' => $this->eventDispatcher->dispatch( + new ModifyImageManipulationPreviewUrlEvent($this->data['databaseRow'], $config, $file) + )->getPreviewUrl(), ]; if ($arguments['isAllowedFileExtension']) { + $fieldId = StringUtility::getUniqueId('formengine-color-'); $resultArray['stylesheetFiles'][] = 'EXT:ew_base/Resources/Public/JavaScript/form-engine/element/pick-color-from-image.css'; $resultArray['javaScriptModules'][] = JavaScriptModuleInstruction::create( @@ -214,14 +191,14 @@ class PickColorFromImage extends AbstractFormElement $arguments['formEngine']['validation'] = $this->getValidationDataAsJsonString(['required' => true]); } } - - $this->templateView->assignMultiple($arguments); - $resultArray['html'] = $this->templateView->render('Form/ImageManipulationElement'); + $view = $this->backendViewFactory->create($this->data['request']); + $view->assignMultiple($arguments); + $resultArray['html'] = $view->render('Form/ImageManipulationElement'); return $resultArray; } - protected function getFileObject(array $row, string $fieldName): ?File + protected function getFile(array $row, string $fieldName): ?File { $file = null; $fileUid = !empty($row[$fieldName]) ? $row[$fieldName] : null; @@ -230,21 +207,26 @@ class PickColorFromImage extends AbstractFormElement } if (MathUtility::canBeInterpretedAsInteger($fileUid)) { try { - $resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class); - $fileReference = $resourceFactory->getFileReferenceObject($fileUid); - $file = $fileReference->getOriginalFile(); + $file = $this->resourceFactory->getFileObject($fileUid); } catch (FileDoesNotExistException | \InvalidArgumentException) { } } return $file; } + /** + * @throws InvalidConfigurationException + */ protected function populateConfiguration(array $baseConfiguration): array { $defaultConfig = self::$defaultConfig; + + // If ratios are set do not add default options + if (isset($baseConfiguration['cropVariants'])) { + unset($defaultConfig['cropVariants']); + } + $config = array_replace_recursive($defaultConfig, $baseConfiguration); - $imageConfig = $this->data['processedTca']['columns'][$config['imageField']]; - $config['cropVariants'] = $imageConfig['config']['cropVariants'] ?? $defaultConfig['cropVariants']; if (!is_array($config['cropVariants'])) { throw new InvalidConfigurationException('Crop variants configuration must be an array', 1485377267); @@ -282,8 +264,8 @@ class PickColorFromImage extends AbstractFormElement $config['cropVariants'] = $cropVariants; + // 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; } @@ -301,4 +283,22 @@ class PickColorFromImage extends AbstractFormElement ); return $config; } + + protected function getWizardUri(): string + { + return (string)$this->uriBuilder->buildUriFromRoute($this->wizardRouteName); + } + + protected function getWizardPayload(array $cropVariants, File $image): array + { + $uriArguments = []; + $arguments = [ + 'cropVariants' => $cropVariants, + 'image' => $image->getUid(), + ]; + $uriArguments['arguments'] = json_encode($arguments); + $uriArguments['signature'] = $this->hashService->hmac((string)($uriArguments['arguments']), $this->wizardRouteName); + + return $uriArguments; + } } diff --git a/Classes/Form/Element/PickColorFromImagePre13.php b/Classes/Form/Element/PickColorFromImagePre13.php new file mode 100644 index 0000000..ac81de5 --- /dev/null +++ b/Classes/Form/Element/PickColorFromImagePre13.php @@ -0,0 +1,304 @@ + 'image', + 'cropVariants' => [ + 'default' => [ + 'title' => + 'LLL:EXT:core/Resources/Private/Language/locallang_wizards.xlf:imwizard.crop_variant.default', + 'allowedAspectRatios' => [ + '16:9' => [ + 'title' => 'LLL:EXT:core/Resources/Private/Language/locallang_wizards.xlf:imwizard.ratio.16_9', + 'value' => 16 / 9, + ], + '3:2' => [ + 'title' => 'LLL:EXT:core/Resources/Private/Language/locallang_wizards.xlf:imwizard.ratio.3_2', + 'value' => 3 / 2, + ], + '4:3' => [ + 'title' => 'LLL:EXT:core/Resources/Private/Language/locallang_wizards.xlf:imwizard.ratio.4_3', + 'value' => 4 / 3, + ], + '1:1' => [ + 'title' => 'LLL:EXT:core/Resources/Private/Language/locallang_wizards.xlf:imwizard.ratio.1_1', + 'value' => 1.0, + ], + 'NaN' => [ + 'title' => 'LLL:EXT:core/Resources/Private/Language/locallang_wizards.xlf:imwizard.ratio.free', + 'value' => 0.0, + ], + ], + 'selectedRatio' => 'NaN', + 'cropArea' => [ + 'x' => 0.0, + 'y' => 0.0, + 'width' => 1.0, + 'height' => 1.0, + ], + ], + ], + ]; + + /** + * Default field information enabled for this element. + * + * @var array + */ + protected $defaultFieldInformation = [ + 'tcaDescription' => [ + 'renderType' => 'tcaDescription', + ], + ]; + + /** + * Default field wizards enabled for this element. + * + * @var array + */ + protected $defaultFieldWizard = [ + 'localizationStateSelector' => [ + 'renderType' => 'localizationStateSelector', + ], + 'otherLanguageContent' => [ + 'renderType' => 'otherLanguageContent', + 'after' => [ + 'localizationStateSelector', + ], + ], + 'defaultLanguageDifferences' => [ + 'renderType' => 'defaultLanguageDifferences', + 'after' => [ + 'otherLanguageContent', + ], + ], + ]; + + protected ViewInterface $templateView; + + public function __construct(NodeFactory $nodeFactory, array $data) + { + parent::__construct($nodeFactory, $data); + // Would be great, if we could inject the view here, but since the constructor is in the interface, we can't + // @todo: It's unfortunate we're using Typo3Fluid TemplateView directly here. We can't + // inject BackendViewFactory here since __construct() is polluted by NodeInterface. + // Remove __construct() from NodeInterface to have DI, then use BackendViewFactory here. + $view = GeneralUtility::makeInstance(TemplateView::class); + $templatePaths = $view->getRenderingContext()->getTemplatePaths(); + $templatePaths + ->setTemplateRootPaths([GeneralUtility::getFileAbsFileName('EXT:ew_base/Resources/Private/Templates')]); + $templatePaths + ->setPartialRootPaths([GeneralUtility::getFileAbsFileName('EXT:ew_base/Resources/Private/Partials')]); + $this->templateView = $view; + } + + public function render(): array + { + $resultArray = $this->initializeResultArray(); + $parameterArray = $this->data['parameterArray']; + $config = $this->populateConfiguration($parameterArray['fieldConf']['config']); + $fieldId = StringUtility::getUniqueId('formengine-color-'); + + $file = $this->getFileObject($this->data['databaseRow'], $config['imageField']); + if (!$file) { + $languageService = $this->getLanguageService(); + $label = $languageService->sL( + 'LLL:EXT:ew_base/Resources/Private/Language/locallang_db.xlf:imageField.empty' + ); + $fieldLabel = $this->data['processedTca']['columns'][$config['imageField']]['label']; + $resultArray['html'] = ' +
+
+
+ + ' . sprintf($label, '' . $fieldLabel . '') . ' + +
+
+
+ '; + // Early return in case we do not find a file + return $resultArray; + } + + $fieldInformationResult = $this->renderFieldInformation(); + $fieldInformationHtml = $fieldInformationResult['html']; + $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldInformationResult, false); + + $fieldControlResult = $this->renderFieldControl(); + $fieldControlHtml = $fieldControlResult['html']; + $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldControlResult, false); + + $fieldWizardResult = $this->renderFieldWizard(); + $fieldWizardHtml = $fieldWizardResult['html']; + $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldWizardResult, false); + + $width = $this->formMaxWidth( + MathUtility::forceIntegerInRange( + $config['size'] ?? $this->defaultInputWidth, + $this->minimumInputWidth, + $this->maxInputWidth + ) + ); + + $arguments = [ + 'fieldInformation' => $fieldInformationHtml, + 'fieldControl' => $fieldControlHtml, + 'fieldWizard' => $fieldWizardHtml, + 'isAllowedFileExtension' => in_array( + strtolower($file->getExtension()), + GeneralUtility::trimExplode(',', strtolower($config['allowedExtensions'])), + true + ), + 'image' => $file, + 'formEngine' => [ + 'field' => [ + 'value' => $parameterArray['itemFormElValue'], + 'name' => $parameterArray['itemFormElName'], + ], + 'validation' => '[]', + ], + 'config' => $config, + 'width' => $width, + ]; + + if ($arguments['isAllowedFileExtension']) { + $resultArray['stylesheetFiles'][] = + 'EXT:ew_base/Resources/Public/JavaScript/form-engine/element/pick-color-from-image.css'; + $resultArray['javaScriptModules'][] = JavaScriptModuleInstruction::create( + '@evoweb/ew-base/form-engine/element/pick-color-from-image.js', + 'PickColorFromImage' + )->instance( + $fieldId, + $parameterArray['itemFormElValue'], + ($parameterArray['fieldConf']['config']['readOnly'] ?? false) + ); + $arguments['formEngine']['field']['id'] = $fieldId; + if ($config['required'] ?? false) { + $arguments['formEngine']['validation'] = $this->getValidationDataAsJsonString(['required' => true]); + } + } + + $this->templateView->assignMultiple($arguments); + $resultArray['html'] = $this->templateView->render('Form/ImageManipulationElement'); + + return $resultArray; + } + + protected function getFileObject(array $row, string $fieldName): ?File + { + $file = null; + $fileUid = !empty($row[$fieldName]) ? $row[$fieldName] : null; + if (is_array($fileUid) && isset($fileUid[0]['uid'])) { + $fileUid = $fileUid[0]['uid']; + } + if (MathUtility::canBeInterpretedAsInteger($fileUid)) { + try { + $resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class); + $fileReference = $resourceFactory->getFileReferenceObject($fileUid); + $file = $fileReference->getOriginalFile(); + } catch (FileDoesNotExistException | \InvalidArgumentException) { + } + } + return $file; + } + + protected function populateConfiguration(array $baseConfiguration): array + { + $defaultConfig = self::$defaultConfig; + $config = array_replace_recursive($defaultConfig, $baseConfiguration); + $imageConfig = $this->data['processedTca']['columns'][$config['imageField']]; + $config['cropVariants'] = $imageConfig['config']['cropVariants'] ?? $defaultConfig['cropVariants']; + + if (!is_array($config['cropVariants'])) { + throw new InvalidConfigurationException('Crop variants configuration must be an array', 1485377267); + } + + $cropVariants = []; + foreach ($config['cropVariants'] as $id => $cropVariant) { + // Filter allowed aspect ratios + $cropVariant['allowedAspectRatios'] = array_filter( + $cropVariant['allowedAspectRatios'] ?? [], + static function ($aspectRatio) { + return !(bool)($aspectRatio['disabled'] ?? false); + } + ); + + // Ignore disabled crop variants + if (!empty($cropVariant['disabled'])) { + continue; + } + + if (empty($cropVariant['allowedAspectRatios'])) { + throw new InvalidConfigurationException( + 'Crop variants configuration ' . $id . ' contains no allowed aspect ratios', + 1620147893 + ); + } + + // Enforce a crop area (default is full image) + if (empty($cropVariant['cropArea'])) { + $cropVariant['cropArea'] = Area::createEmpty()->asArray(); + } + + $cropVariants[$id] = $cropVariant; + } + + $config['cropVariants'] = $cropVariants; + + $config['allowedExtensions'] ??= $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']; + + return $config; + } + + protected function processConfiguration(array $config, string &$elementValue, File $file): array + { + $cropVariantCollection = CropVariantCollection::create($elementValue, $config['cropVariants']); + if (empty($config['readOnly']) && !empty($file->getProperty('width'))) { + $cropVariantCollection = $cropVariantCollection->applyRatioRestrictionToSelectedCropArea($file); + $elementValue = (string)$cropVariantCollection; + } + $config['cropVariants'] = $cropVariantCollection->asArray(); + $config['allowedExtensions'] = implode( + ', ', + GeneralUtility::trimExplode(',', $config['allowedExtensions'], true) + ); + return $config; + } +} diff --git a/Classes/Form/FormDataProvider/UsercentricsDatabaseEditRow.php b/Classes/Form/FormDataProvider/UsercentricsDatabaseEditRow.php index 1d7e571..2c0b3f2 100755 --- a/Classes/Form/FormDataProvider/UsercentricsDatabaseEditRow.php +++ b/Classes/Form/FormDataProvider/UsercentricsDatabaseEditRow.php @@ -14,8 +14,6 @@ class UsercentricsDatabaseEditRow extends SiteDatabaseEditRow /** * First level of ['customData']['siteData'] to ['databaseRow'] * - * @param array $result - * @return array * @throws \RuntimeException */ public function addData(array $result): array @@ -24,23 +22,19 @@ class UsercentricsDatabaseEditRow extends SiteDatabaseEditRow return $result; } - $tableName = $result['tableName']; $siteFinder = GeneralUtility::makeInstance(SiteFinder::class, $this->siteConfiguration); - if (in_array($tableName, ['site_usercentrics'], true)) { - $rootPageId = (int)($result['inlineTopMostParentUid'] ?? $result['inlineParentUid']); - try { - $rowData = $this->getRawConfigurationForSiteWithRootPageId($siteFinder, $rootPageId); - $parentFieldName = $result['inlineParentFieldName']; - if (!isset($rowData[$parentFieldName])) { - throw new \RuntimeException('Field "' . $parentFieldName . '" not found', 1520886092); - } - $rowData = $rowData[$parentFieldName][$result['vanillaUid']]; - $result['databaseRow']['uid'] = $result['vanillaUid']; - } catch (SiteNotFoundException $e) { - $rowData = []; + + $rootPageId = (int)($result['inlineTopMostParentUid'] ?? $result['inlineParentUid']); + try { + $rowData = $this->getRawConfigurationForSiteWithRootPageId($siteFinder, $rootPageId); + $parentFieldName = $result['inlineParentFieldName']; + if (!isset($rowData[$parentFieldName])) { + throw new \RuntimeException('Field "' . $parentFieldName . '" not found', 1520886092); } - } else { - return $result; + $rowData = $rowData[$parentFieldName][$result['vanillaUid']]; + $result['databaseRow']['uid'] = $result['vanillaUid']; + } catch (SiteNotFoundException) { + $rowData = []; } foreach ($rowData as $fieldName => $value) { diff --git a/Classes/Form/FormDataProvider/UsercentricsTcaInline.php b/Classes/Form/FormDataProvider/UsercentricsTcaInline.php index 1d8e59e..e8685fd 100755 --- a/Classes/Form/FormDataProvider/UsercentricsTcaInline.php +++ b/Classes/Form/FormDataProvider/UsercentricsTcaInline.php @@ -40,7 +40,7 @@ class UsercentricsTcaInline extends SiteTcaInline continue; } $childTableName = $fieldConfig['config']['foreign_table'] ?? ''; - if (!in_array($childTableName, ['site_usercentrics'], true)) { + if ($childTableName !== 'site_usercentrics') { continue; } $result['processedTca']['columns'][$fieldName]['children'] = []; diff --git a/Classes/Updates/ParentChildToContainerMigration.php b/Classes/Updates/ParentChildToContainerMigration.php deleted file mode 100755 index 685daab..0000000 --- a/Classes/Updates/ParentChildToContainerMigration.php +++ /dev/null @@ -1,106 +0,0 @@ -logger = $logManager->getLogger(self::class); - } - - public function getTitle(): string - { - return 'Migrate parent/child to container'; - } - - public function getDescription(): string - { - return 'Migrates content elements that are type parent/child to corresponding container elements'; - } - - public function getPrerequisites(): array - { - return [ - DatabaseUpdatedPrerequisite::class - ]; - } - - public function updateNecessary(): bool - { - return $this->hasRecordsToUpdate(); - } - - public function executeUpdate(): bool - { - $updateSuccessful = true; - try { - $this->service->migrate(); - } catch (\Exception $exception) { - $this->logger->log(LogLevel::ERROR, $exception->getMessage()); - $updateSuccessful = false; - } - - return $updateSuccessful; - } - - protected function hasRecordsToUpdate(): bool - { - $queryBuilder = $this->getPreparedQueryBuilder(); - $tableColumns = $queryBuilder - ->getConnection() - ->createSchemaManager() - ->listTableColumns(self::TABLE_NAME); - return isset($tableColumns['parent']) - && $queryBuilder - ->count('uid') - ->executeQuery() - ->fetchOne() > 0; - } - - protected function getPreparedQueryBuilder(): QueryBuilder - { - $queryBuilder = $this->getConnectionPool()->getQueryBuilderForTable(self::TABLE_NAME); - $queryBuilder->getRestrictions() - ->removeByType(HiddenRestriction::class) - ->removeByType(StartTimeRestriction::class) - ->removeByType(EndTimeRestriction::class); - $queryBuilder - ->from(self::TABLE_NAME) - ->where( - // check if there are still records that have parent instead of tx_container_parent - $queryBuilder->expr()->gt('parent', 0) - ); - return $queryBuilder; - } - - protected function getConnectionPool(): ConnectionPool - { - return GeneralUtility::makeInstance(ConnectionPool::class); - } -} diff --git a/Classes/Updates/ParentChildToContainerService.php b/Classes/Updates/ParentChildToContainerService.php deleted file mode 100755 index 737ed75..0000000 --- a/Classes/Updates/ParentChildToContainerService.php +++ /dev/null @@ -1,168 +0,0 @@ - [ 'CType' => 'container-downloads' ], -]; -*/ - -class ParentChildToContainerService -{ - private const TABLE_NAME = 'tt_content'; - - protected int $colPosOffset = 0; - - protected array $configuration = []; - - public function __construct( - protected ConnectionPool $connectionPool, - protected DataHandler $dataHandler, - protected FlexFormService $flexFormService, - ) { - $config =& $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['ew_base']; - $this->colPosOffset = $config['childParentColPosOffset'] ?? 0; - $this->configuration = $config['childParentMigrationMapping'] ?? []; - } - - public function migrate(): void - { - $this->initializeDataHandler(); - $this->migrateConfiguredContainer(); - } - - protected function initializeDataHandler(): void - { - $backendUser = GeneralUtility::makeInstance(BackendUserAuthentication::class); - $backendUser->user = [ - 'uid' => 0, - 'admin' => 1, - ]; - $this->dataHandler->start([], [], $backendUser); - } - - - protected function migrateConfiguredContainer(): void - { - array_walk($this->configuration, function($config, $key) { - $parents = $this->getParentsByCType((string)$key); - foreach ($parents as $parent) { - $this->processParentMigration($parent, $config); - } - }); - } - - protected function processParentMigration(array $parent, array $config): void - { - $children = $this->getChildren($parent['uid']); - foreach ($children as $child) { - $this->processChildMigration($child, $parent); - } - - $this->updateElement( - $parent['uid'], - [ - 'CType' => $this->getCType($parent, $config), - 'children' => 0, - ] - ); - } - - protected function processChildMigration(array $child, array $parent): void - { - $this->updateElement( - $child['uid'], - [ - 'tx_container_parent' => $parent['uid'], - 'colPos' => $child['colPos'] + $this->colPosOffset, - 'parent' => 0, - ] - ); - } - - protected function getCType(array $container, array $config): string - { - if (is_array($config['CType'])) { - $value = ArrayUtility::getValueByPath($container, $config['CType']['search']); - $result = $config['CType']['matches'][$value] ?? null; - } else { - $result = $config['CType'] ?? null; - } - - if (empty($result)) { - throw new \Exception('CType must always be set'); - } - - return $result; - } - - - protected function updateElement(int $uid, array $changes): void - { - $this->connectionPool - ->getConnectionForTable(self::TABLE_NAME) - ->update(self::TABLE_NAME, $changes, ['uid' => $uid]); - } - - protected function getChildren(int $parentUid): array - { - $queryBuilder = $this->getQueryBuilderForTable(); - - return $queryBuilder - ->select('*') - ->where( - $queryBuilder->expr()->eq( - 'parent', - $queryBuilder->createNamedParameter($parentUid, \PDO::PARAM_INT) - ) - ) - ->orderBy('sorting') - ->executeQuery() - ->fetchAllAssociative(); - } - - protected function getParentsByCType(string $cType): array - { - $queryBuilder = $this->getQueryBuilderForTable(); - $expr = $queryBuilder->expr(); - - return $queryBuilder - ->select('*') - ->where( - $expr->eq('CType', $queryBuilder->createNamedParameter($cType)) - ) - ->orderBy('sorting') - ->executeQuery() - ->fetchAllAssociative(); - } - - protected function getQueryBuilderForTable(string $table = 'tt_content'): QueryBuilder - { - $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) - ->getQueryBuilderForTable($table); - - $queryBuilder->getRestrictions() - ->removeByType(HiddenRestriction::class) - ->removeByType(StartTimeRestriction::class) - ->removeByType(EndTimeRestriction::class); - - $queryBuilder->from($table); - - return $queryBuilder; - } -} diff --git a/Classes/User/AssetPath.php b/Classes/User/AssetPath.php index 9659830..45b94f4 100755 --- a/Classes/User/AssetPath.php +++ b/Classes/User/AssetPath.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace Evoweb\EwBase\User; -use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\PathUtility; /** @@ -18,8 +17,6 @@ class AssetPath { public function getAbsolutePublicPath(string $content, array $conf): string { - return $content - . GeneralUtility::getIndpEnv('TYPO3_SITE_URL') - . ltrim(PathUtility::getPublicResourceWebPath($conf['file']), '/'); + return PathUtility::getAbsoluteWebPath($conf['file']); } } diff --git a/Classes/ViewHelpers/Array/AddViewHelper.php b/Classes/ViewHelpers/Array/AddViewHelper.php index 1d0b5c9..7bdc507 100755 --- a/Classes/ViewHelpers/Array/AddViewHelper.php +++ b/Classes/ViewHelpers/Array/AddViewHelper.php @@ -26,7 +26,7 @@ class AddViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('array', 'array', 'Array to add value to'); @@ -34,18 +34,11 @@ class AddViewHelper extends AbstractViewHelper $this->registerArgument('value', 'mixed', 'Value to add'); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return array - */ public static function renderStatic( array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext - ) { + ): array { $array = $arguments['array'] ?: []; $key = $arguments['key']; $value = !is_null($arguments['value']) ? $arguments['value'] : $renderChildrenClosure(); diff --git a/Classes/ViewHelpers/Iterator/ExplodeViewHelper.php b/Classes/ViewHelpers/Array/ExplodeViewHelper.php similarity index 94% rename from Classes/ViewHelpers/Iterator/ExplodeViewHelper.php rename to Classes/ViewHelpers/Array/ExplodeViewHelper.php index e50139f..364d39e 100755 --- a/Classes/ViewHelpers/Iterator/ExplodeViewHelper.php +++ b/Classes/ViewHelpers/Array/ExplodeViewHelper.php @@ -1,6 +1,6 @@ registerArgument( 'as', @@ -48,16 +48,11 @@ class ExplodeViewHelper extends AbstractViewHelper ); } - /** - * Render method - * - * @return string|array - */ public static function renderStatic( array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext - ) { + ): mixed { $content = $arguments['content'] ?? $renderChildrenClosure(); $glue = static::resolveGlue($arguments); $content = call_user_func_array(static::$method, [$glue, $content]); diff --git a/Classes/ViewHelpers/Be/ThumbnailViewHelper.php b/Classes/ViewHelpers/Be/ThumbnailViewHelper.php index f229195..b2ffa84 100755 --- a/Classes/ViewHelpers/Be/ThumbnailViewHelper.php +++ b/Classes/ViewHelpers/Be/ThumbnailViewHelper.php @@ -30,10 +30,7 @@ class ThumbnailViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; - /** - * Initializes the arguments - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('row', 'array', 'content data', true); @@ -41,20 +38,11 @@ class ThumbnailViewHelper extends AbstractViewHelper $this->registerArgument('fieldName', 'string', 'field name', true); } - /** - * Render a constant - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string Value of constant - */ public static function renderStatic( array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext - ) { + ): string { $row = $arguments['row']; $tableName = $arguments['tableName']; $fieldName = $arguments['fieldName']; diff --git a/Classes/ViewHelpers/Condition/InArrayViewHelper.php b/Classes/ViewHelpers/Condition/InArrayViewHelper.php index bc713f5..d59e8f6 100755 --- a/Classes/ViewHelpers/Condition/InArrayViewHelper.php +++ b/Classes/ViewHelpers/Condition/InArrayViewHelper.php @@ -19,21 +19,14 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractConditionViewHelper; */ class InArrayViewHelper extends AbstractConditionViewHelper { - /** - * Initialize arguments - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('haystack', 'array', 'haystack', true); $this->registerArgument('needle', 'mixed', 'needle', true); } - /** - * @param array $arguments - * @return bool - */ - protected static function evaluateCondition($arguments = null) + protected static function evaluateCondition($arguments = null): bool { $array = $arguments['haystack']->toArray(); return in_array($arguments['needle'], $array); diff --git a/Classes/ViewHelpers/Condition/StringContainsViewHelper.php b/Classes/ViewHelpers/Condition/StringContainsViewHelper.php index efb6b6f..70f01c4 100755 --- a/Classes/ViewHelpers/Condition/StringContainsViewHelper.php +++ b/Classes/ViewHelpers/Condition/StringContainsViewHelper.php @@ -19,22 +19,15 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractConditionViewHelper; */ class StringContainsViewHelper extends AbstractConditionViewHelper { - /** - * Initialize arguments - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('haystack', 'string', 'haystack', true); $this->registerArgument('needle', 'string', 'need', true); } - /** - * @param array $arguments - * @return bool - */ - protected static function evaluateCondition($arguments = null) + protected static function evaluateCondition($arguments = null): bool { - return false !== strpos($arguments['haystack'], $arguments['needle']); + return str_contains($arguments['haystack'], $arguments['needle']); } } diff --git a/Classes/ViewHelpers/Context/DevelopmentViewHelper.php b/Classes/ViewHelpers/Context/DevelopmentViewHelper.php index 0875df1..b9a93fd 100755 --- a/Classes/ViewHelpers/Context/DevelopmentViewHelper.php +++ b/Classes/ViewHelpers/Context/DevelopmentViewHelper.php @@ -14,11 +14,7 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractConditionViewHelper; class DevelopmentViewHelper extends AbstractConditionViewHelper { - /** - * @param array $arguments - * @return bool - */ - protected static function evaluateCondition($arguments = null) + protected static function evaluateCondition($arguments = null): bool { return Environment::getContext()->isDevelopment(); } diff --git a/Classes/ViewHelpers/Context/ProductionViewHelper.php b/Classes/ViewHelpers/Context/ProductionViewHelper.php index f5356bb..9736b03 100755 --- a/Classes/ViewHelpers/Context/ProductionViewHelper.php +++ b/Classes/ViewHelpers/Context/ProductionViewHelper.php @@ -14,11 +14,7 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractConditionViewHelper; class ProductionViewHelper extends AbstractConditionViewHelper { - /** - * @param array $arguments - * @return bool - */ - protected static function evaluateCondition($arguments = null) + protected static function evaluateCondition($arguments = null): bool { return Environment::getContext()->isProduction(); } diff --git a/Classes/ViewHelpers/Context/StagingViewHelper.php b/Classes/ViewHelpers/Context/StagingViewHelper.php index a76003e..c26f387 100755 --- a/Classes/ViewHelpers/Context/StagingViewHelper.php +++ b/Classes/ViewHelpers/Context/StagingViewHelper.php @@ -14,11 +14,7 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractConditionViewHelper; class StagingViewHelper extends AbstractConditionViewHelper { - /** - * @param array $arguments - * @return bool - */ - protected static function evaluateCondition($arguments = null) + protected static function evaluateCondition($arguments = null): bool { return 'Production/Staging' === (string)Environment::getContext(); } diff --git a/Classes/ViewHelpers/FixFlexformForExtbaseViewHelper.php b/Classes/ViewHelpers/FixFlexformForExtbaseViewHelper.php deleted file mode 100755 index de070d9..0000000 --- a/Classes/ViewHelpers/FixFlexformForExtbaseViewHelper.php +++ /dev/null @@ -1,77 +0,0 @@ - - * .... - * - * - * fixed flexform data for extbase controller - * - * - * @api - */ -class FixFlexformForExtbaseViewHelper extends AbstractViewHelper -{ - use CompileWithRenderStatic; - - /** - * @var boolean - */ - protected $escapeOutput = false; - - public function initializeArguments(): void - { - parent::initializeArguments(); - $this->registerArgument('data', 'array', 'The data array of content element', true); - } - - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return array - */ - public static function renderStatic( - array $arguments, - \Closure $renderChildrenClosure, - RenderingContextInterface $renderingContext - ) { - $templateVariableContainer = $renderingContext->getVariableProvider(); - - /** @var FlexFormTools $flexFormTools */ - $flexFormTools = GeneralUtility::makeInstance(FlexFormTools::class); - - $data = $arguments['data']; - if (is_array($data['pi_flexform'])) { - $data['pi_flexform'] = $flexFormTools->flexArray2Xml($data['pi_flexform']); - } - - $templateVariableContainer->add('data', $data); - $output = $renderChildrenClosure(); - $templateVariableContainer->remove('data'); - - return $output; - } -} diff --git a/Classes/ViewHelpers/FlexFormViewHelper.php b/Classes/ViewHelpers/FlexFormViewHelper.php deleted file mode 100755 index cd7fc27..0000000 --- a/Classes/ViewHelpers/FlexFormViewHelper.php +++ /dev/null @@ -1,80 +0,0 @@ - - * .... - * - * - * fixed flexform data for extbase controller - * - * - * @api - */ -class FlexFormViewHelper extends AbstractViewHelper -{ - use CompileWithRenderStatic; - - /** - * @var boolean - */ - protected $escapeOutput = false; - - public function initializeArguments() - { - parent::initializeArguments(); - $this->registerArgument('data', 'array', 'Array to get flex form data from', true); - $this->registerArgument('fieldName', 'string', 'Field name', false, 'pi_flexform'); - $this->registerArgument('as', 'string', 'Name of the variable to assign', false, 'flexFormData'); - } - - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return array - */ - public static function renderStatic( - array $arguments, - \Closure $renderChildrenClosure, - RenderingContextInterface $renderingContext - ) { - $data = []; - - if (is_array($arguments['data'])) { - if (isset($arguments['data'][$arguments['fieldName']])) { - $data = is_array($arguments['data'][$arguments['fieldName']]) ? - $arguments['data'][$arguments['fieldName']] : - GeneralUtility::xml2array($arguments['data'][$arguments['fieldName']]); - $data = $data['data'] ?? $data; - } - } - - $templateVariableContainer = $renderingContext->getVariableProvider(); - $templateVariableContainer->add($arguments['as'], $data); - $content = $renderChildrenClosure(); - $templateVariableContainer->remove($arguments['as']); - - return $content; - } -} diff --git a/Classes/ViewHelpers/HashViewHelper.php b/Classes/ViewHelpers/HashViewHelper.php index 0b61138..6eb11fc 100755 --- a/Classes/ViewHelpers/HashViewHelper.php +++ b/Classes/ViewHelpers/HashViewHelper.php @@ -13,6 +13,9 @@ namespace Evoweb\EwBase\ViewHelpers; * LICENSE.txt file that was distributed with this source code. */ +use TYPO3\CMS\Core\Crypto\HashService; +use TYPO3\CMS\Core\Information\Typo3Version; +use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; @@ -26,33 +29,31 @@ class HashViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('action', 'string', 'Target action'); $this->registerArgument('arguments', 'array', 'Arguments for the controller action, associative array'); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string - */ public static function renderStatic( array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext - ) { + ): string { $result = ''; if ( $arguments['action'] !== null && $arguments['arguments'] !== null && isset($arguments['arguments']['user']) ) { - $result = \TYPO3\CMS\Core\Utility\GeneralUtility::hmac( - $arguments['action'] . '::' . $arguments['arguments']['user'] - ); + if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() < 13) { + $result = GeneralUtility::hmac($arguments['action'] . '::' . $arguments['arguments']['user']); + } else { + /** @var HashService $hashService */ + $hashService = GeneralUtility::makeInstance(HashService::class); + $result = $hashService->hmac($arguments['action'] . '::' . $arguments['arguments']['user'], ''); + } } return $result; diff --git a/Classes/ViewHelpers/Iterator/AddViewHelper.php b/Classes/ViewHelpers/Iterator/AddViewHelper.php deleted file mode 100755 index bb24422..0000000 --- a/Classes/ViewHelpers/Iterator/AddViewHelper.php +++ /dev/null @@ -1,56 +0,0 @@ -registerArgument('array', 'array', 'Array to add value to'); - $this->registerArgument('key', 'string', 'Key to add value by', true); - $this->registerArgument('value', 'mixed', 'Value to add'); - } - - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return array - */ - public static function renderStatic( - array $arguments, - \Closure $renderChildrenClosure, - RenderingContextInterface $renderingContext - ) { - $array = $arguments['array'] ?: []; - $key = $arguments['key']; - $value = $arguments['value'] ?: $renderChildrenClosure(); - - return array_merge($array, [$key => $value]); - } -} diff --git a/Classes/ViewHelpers/PublicPathViewHelper.php b/Classes/ViewHelpers/PublicPathViewHelper.php index 769f001..2971755 100755 --- a/Classes/ViewHelpers/PublicPathViewHelper.php +++ b/Classes/ViewHelpers/PublicPathViewHelper.php @@ -41,27 +41,23 @@ class PublicPathViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - protected static ?array $frontendGroupIds = null; - - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('path', 'string', 'Extension resource path', true); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return bool - */ public static function renderStatic( array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext - ) { + ): string { $path = (string)$arguments['path']; - return PathUtility::getPublicResourceWebPath($path); + try { + $path = PathUtility::getPublicResourceWebPath($path); + } catch (\Exception) { + $path = ''; + } + return $path; } } diff --git a/Classes/ViewHelpers/ReplaceViewHelper.php b/Classes/ViewHelpers/ReplaceViewHelper.php index 77a9837..02d4807 100755 --- a/Classes/ViewHelpers/ReplaceViewHelper.php +++ b/Classes/ViewHelpers/ReplaceViewHelper.php @@ -44,24 +44,18 @@ class ReplaceViewHelper extends AbstractViewHelper { use CompileWithContentArgumentAndRenderStatic; - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('value', 'string', 'String to replace in'); $this->registerArgument('search', 'string', 'Search string'); $this->registerArgument('replace', 'string', 'Replace value'); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return null - */ public static function renderStatic( array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext - ) { + ): string { $content = $arguments['value']; if ($content === null) { $content = $renderChildrenClosure(); diff --git a/Classes/ViewHelpers/SvgViewHelper.php b/Classes/ViewHelpers/SvgViewHelper.php index 2290936..b3e5c76 100755 --- a/Classes/ViewHelpers/SvgViewHelper.php +++ b/Classes/ViewHelpers/SvgViewHelper.php @@ -18,6 +18,7 @@ use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Type\Icon\IconState; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; +use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; /** @@ -61,7 +62,7 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; * * */ -class SvgViewHelper extends \TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper +class SvgViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; @@ -76,24 +77,16 @@ class SvgViewHelper extends \TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper { $this->registerArgument('identifier', 'string', 'Identifier of the icon as registered in the Icon Registry.', true); $this->registerArgument('size', 'string', 'Desired size of the icon. All values of the Icons.sizes enum are allowed, these are: "small", "default", "large" and "overlay".', false, Icon::SIZE_SMALL); - $this->registerArgument('overlay', 'string', 'Identifier of an overlay icon as registered in the Icon Registry.', false); + $this->registerArgument('overlay', 'string', 'Identifier of an overlay icon as registered in the Icon Registry.', false, ''); $this->registerArgument('state', 'string', 'Sets the state of the icon. All values of the Icons.states enum are allowed, these are: "default" and "disabled".', false, IconState::STATE_DEFAULT); - $this->registerArgument('alternativeMarkupIdentifier', 'string', 'Alternative icon identifier. Takes precedence over the identifier if supported by the IconProvider.', false); + $this->registerArgument('alternativeMarkupIdentifier', 'string', 'Alternative icon identifier. Takes precedence over the identifier if supported by the IconProvider.', false, ''); } - /** - * Prints icon html for $identifier key - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string - */ public static function renderStatic( array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext - ) { + ): Icon { $identifier = $arguments['identifier']; $size = $arguments['size']; $overlay = $arguments['overlay']; diff --git a/Classes/ViewHelpers/TrimViewHelper.php b/Classes/ViewHelpers/TrimViewHelper.php index 68683ff..033ee8d 100755 --- a/Classes/ViewHelpers/TrimViewHelper.php +++ b/Classes/ViewHelpers/TrimViewHelper.php @@ -26,27 +26,20 @@ class TrimViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('content', 'string', 'Content to be trimmed'); - $this->registerArgument('characters', 'string', 'Characters to be removed', false); + $this->registerArgument('characters', 'string', 'Characters to be removed'); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string - */ public static function renderStatic( array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext - ) { - $content = $arguments['content'] ? $arguments['content'] : $renderChildrenClosure(); - $characters = $arguments['characters'] ? $arguments['characters'] : null; + ): string { + $content = $arguments['content'] ?: $renderChildrenClosure(); + $characters = $arguments['characters'] ?: null; if ($characters !== null) { $content = trim($content, $characters); diff --git a/Classes/Xclass/SiteDatabaseEditRow.php b/Classes/Xclass/SiteDatabaseEditRow.php index cc4a4c5..93fae38 100755 --- a/Classes/Xclass/SiteDatabaseEditRow.php +++ b/Classes/Xclass/SiteDatabaseEditRow.php @@ -12,8 +12,6 @@ class SiteDatabaseEditRow extends BaseSiteDatabaseEditRow /** * First level of ['customData']['siteData'] to ['databaseRow'] * - * @param array $result - * @return array * @throws \RuntimeException */ public function addData(array $result): array diff --git a/Classes/Xclass/SiteTcaInline.php b/Classes/Xclass/SiteTcaInline.php index 548f6f3..1119f87 100755 --- a/Classes/Xclass/SiteTcaInline.php +++ b/Classes/Xclass/SiteTcaInline.php @@ -8,9 +8,6 @@ class SiteTcaInline extends BaseSiteTcaInline { /** * Resolve inline fields - * - * @param array $result - * @return array */ public function addData(array $result): array { diff --git a/ext_localconf.php b/ext_localconf.php index 1f96207..9b40451 100755 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -3,6 +3,7 @@ defined('TYPO3') or die('access denied'); use Evoweb\EwBase\Form\Element\PickColorFromImage; +use Evoweb\EwBase\Form\Element\PickColorFromImagePre13; use Evoweb\EwBase\Form\FormDataProvider\UsercentricsDatabaseEditRow; use Evoweb\EwBase\Form\FormDataProvider\UsercentricsTcaInline; use Evoweb\EwBase\Hooks\UsercentricsPostRenderHook; @@ -12,6 +13,8 @@ use TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseParentPageRow; use TYPO3\CMS\Backend\Form\FormDataProvider\SiteDatabaseEditRow as BaseSiteDatabaseEditRow; use TYPO3\CMS\Backend\Form\FormDataProvider\SiteTcaInline as BaseSiteTcaInline; use TYPO3\CMS\Backend\Form\FormDataProvider\TcaSiteLanguage; +use TYPO3\CMS\Core\Information\Typo3Version; +use TYPO3\CMS\Core\Utility\GeneralUtility; call_user_func(function () { $GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['namespaces']['ewb'] = [ 'Evoweb\\EwBase\\ViewHelpers' ]; @@ -19,10 +22,11 @@ call_user_func(function () { $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-postProcess'][] = UsercentricsPostRenderHook::class . '->executePostRenderHook'; + $versionPre13 = (GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() < 13; $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1681197508] = [ 'nodeName' => 'pick-color-from-image', 'priority' => '70', - 'class' => PickColorFromImage::class, + 'class' => $versionPre13 ? PickColorFromImagePre13::class : PickColorFromImage::class, ]; $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][BaseSiteDatabaseEditRow::class] = [