From 73e08ead2fe6b678f7a835547157987d588e35b5 Mon Sep 17 00:00:00 2001 From: Benjamin Kott Date: Mon, 11 Nov 2024 11:02:26 +0100 Subject: [PATCH] [TASK] v13/v14 compatibility: Use \TYPO3\CMS\Core\Resource\FileType ENUM --- Classes/ViewHelpers/File/IsAudioViewHelper.php | 12 ++++-------- Classes/ViewHelpers/File/IsImageViewHelper.php | 12 ++++-------- Classes/ViewHelpers/File/IsMediaViewHelper.php | 12 ++++-------- Configuration/TCA/Overrides/100_pages.php | 4 ++-- .../TCA/Overrides/225_content_element_texticon.php | 2 +- .../TCA/Overrides/300_content_general_columns.php | 2 +- .../TCA/tx_bootstrappackage_accordion_item.php | 4 ++-- .../TCA/tx_bootstrappackage_card_group_item.php | 4 ++-- .../TCA/tx_bootstrappackage_carousel_item.php | 4 ++-- .../TCA/tx_bootstrappackage_icon_group_item.php | 2 +- Configuration/TCA/tx_bootstrappackage_tab_item.php | 4 ++-- .../TCA/tx_bootstrappackage_timeline_item.php | 4 ++-- 12 files changed, 27 insertions(+), 39 deletions(-) diff --git a/Classes/ViewHelpers/File/IsAudioViewHelper.php b/Classes/ViewHelpers/File/IsAudioViewHelper.php index 66a346cb7..3a07ae5c0 100644 --- a/Classes/ViewHelpers/File/IsAudioViewHelper.php +++ b/Classes/ViewHelpers/File/IsAudioViewHelper.php @@ -11,6 +11,7 @@ use TYPO3\CMS\Core\Resource\File; use TYPO3\CMS\Core\Resource\FileReference; +use TYPO3\CMS\Core\Resource\FileType; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; @@ -25,16 +26,11 @@ public function render() $allowedFileExtensions = $GLOBALS['TYPO3_CONF_VARS']['SYS']['audiofile_ext'] ?? ''; $allowedFileExtensions = GeneralUtility::trimExplode(',', $allowedFileExtensions); - if (is_object($file) + return is_object($file) && ($file instanceof FileReference || $file instanceof File) && ( in_array($file->getExtension(), $allowedFileExtensions, true) - || $file->getType() === File::FILETYPE_AUDIO - ) - ) { - return true; - } - - return false; + || $file->getType() === FileType::AUDIO->value + ); } } diff --git a/Classes/ViewHelpers/File/IsImageViewHelper.php b/Classes/ViewHelpers/File/IsImageViewHelper.php index 969dd3c1f..2884fe2dc 100644 --- a/Classes/ViewHelpers/File/IsImageViewHelper.php +++ b/Classes/ViewHelpers/File/IsImageViewHelper.php @@ -11,6 +11,7 @@ use TYPO3\CMS\Core\Resource\File; use TYPO3\CMS\Core\Resource\FileReference; +use TYPO3\CMS\Core\Resource\FileType; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; @@ -25,16 +26,11 @@ public function render() $allowedFileExtensions = $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] ?? ''; $allowedFileExtensions = GeneralUtility::trimExplode(',', $allowedFileExtensions); - if (is_object($file) + return is_object($file) && ($file instanceof FileReference || $file instanceof File) && ( in_array($file->getExtension(), $allowedFileExtensions, true) - || $file->getType() === File::FILETYPE_IMAGE - ) - ) { - return true; - } - - return false; + || $file->getType() === FileType::IMAGE->value + ); } } diff --git a/Classes/ViewHelpers/File/IsMediaViewHelper.php b/Classes/ViewHelpers/File/IsMediaViewHelper.php index ff400a750..4810bd0e8 100644 --- a/Classes/ViewHelpers/File/IsMediaViewHelper.php +++ b/Classes/ViewHelpers/File/IsMediaViewHelper.php @@ -11,6 +11,7 @@ use TYPO3\CMS\Core\Resource\File; use TYPO3\CMS\Core\Resource\FileReference; +use TYPO3\CMS\Core\Resource\FileType; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; @@ -25,16 +26,11 @@ public function render() $allowedFileExtensions = $GLOBALS['TYPO3_CONF_VARS']['SYS']['mediafile_ext'] ?? ''; $allowedFileExtensions = GeneralUtility::trimExplode(',', $allowedFileExtensions); - if (is_object($file) + return is_object($file) && ($file instanceof FileReference || $file instanceof File) && ( in_array($file->getExtension(), $allowedFileExtensions, true) - || $file->getType() === File::FILETYPE_VIDEO - ) - ) { - return true; - } - - return false; + || $file->getType() === FileType::VIDEO->value + ); } } diff --git a/Configuration/TCA/Overrides/100_pages.php b/Configuration/TCA/Overrides/100_pages.php index 0e74d3e6b..090879446 100644 --- a/Configuration/TCA/Overrides/100_pages.php +++ b/Configuration/TCA/Overrides/100_pages.php @@ -88,7 +88,7 @@ ], 'overrideChildTca' => [ 'types' => [ - \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [ + \TYPO3\CMS\Core\Resource\FileType::IMAGE->value => [ 'showitem' => '--palette--;;filePalette', ], ], @@ -108,7 +108,7 @@ 'maxitems' => 1, 'overrideChildTca' => [ 'types' => [ - \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [ + \TYPO3\CMS\Core\Resource\FileType::IMAGE->value => [ 'showitem' => ' --palette--;;imageoverlayPalette, --palette--;;filePalette diff --git a/Configuration/TCA/Overrides/225_content_element_texticon.php b/Configuration/TCA/Overrides/225_content_element_texticon.php index 510f19550..acf0339fe 100644 --- a/Configuration/TCA/Overrides/225_content_element_texticon.php +++ b/Configuration/TCA/Overrides/225_content_element_texticon.php @@ -126,7 +126,7 @@ ], 'overrideChildTca' => [ 'types' => [ - \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [ + \TYPO3\CMS\Core\Resource\FileType::IMAGE->value => [ 'showitem' => '--palette--;;filePalette', ], ], diff --git a/Configuration/TCA/Overrides/300_content_general_columns.php b/Configuration/TCA/Overrides/300_content_general_columns.php index 0d425cef3..6462ebc95 100644 --- a/Configuration/TCA/Overrides/300_content_general_columns.php +++ b/Configuration/TCA/Overrides/300_content_general_columns.php @@ -182,7 +182,7 @@ ], 'overrideChildTca' => [ 'types' => [ - \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [ + \TYPO3\CMS\Core\Resource\FileType::IMAGE->value => [ 'showitem' => 'crop,--palette--;;filePalette', ], ], diff --git a/Configuration/TCA/tx_bootstrappackage_accordion_item.php b/Configuration/TCA/tx_bootstrappackage_accordion_item.php index 45ed47983..4efff5a7a 100644 --- a/Configuration/TCA/tx_bootstrappackage_accordion_item.php +++ b/Configuration/TCA/tx_bootstrappackage_accordion_item.php @@ -189,12 +189,12 @@ ], 'overrideChildTca' => [ 'types' => [ - \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [ + \TYPO3\CMS\Core\Resource\FileType::IMAGE->value => [ 'showitem' => ' --palette--;;imageoverlayPalette, --palette--;;filePalette', ], - \TYPO3\CMS\Core\Resource\File::FILETYPE_VIDEO => [ + \TYPO3\CMS\Core\Resource\FileType::VIDEO->value => [ 'showitem' => ' --palette--;;videoOverlayPalette, --palette--;;filePalette', diff --git a/Configuration/TCA/tx_bootstrappackage_card_group_item.php b/Configuration/TCA/tx_bootstrappackage_card_group_item.php index a4f04e02b..f861bee53 100644 --- a/Configuration/TCA/tx_bootstrappackage_card_group_item.php +++ b/Configuration/TCA/tx_bootstrappackage_card_group_item.php @@ -197,7 +197,7 @@ 'maxitems' => 1, 'overrideChildTca' => [ 'types' => [ - \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [ + \TYPO3\CMS\Core\Resource\FileType::IMAGE->value => [ 'showitem' => ' --palette--;;imageoverlayPalette, --palette--;;filePalette', @@ -275,7 +275,7 @@ ], 'overrideChildTca' => [ 'types' => [ - \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [ + \TYPO3\CMS\Core\Resource\FileType::IMAGE->value => [ 'showitem' => '--palette--;;filePalette', ], ], diff --git a/Configuration/TCA/tx_bootstrappackage_carousel_item.php b/Configuration/TCA/tx_bootstrappackage_carousel_item.php index 775de99d7..6e39603af 100644 --- a/Configuration/TCA/tx_bootstrappackage_carousel_item.php +++ b/Configuration/TCA/tx_bootstrappackage_carousel_item.php @@ -599,7 +599,7 @@ 'maxitems' => 1, 'overrideChildTca' => [ 'types' => [ - \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [ + \TYPO3\CMS\Core\Resource\FileType::IMAGE->value => [ 'showitem' => ' --palette--;;imageoverlayPalette, --palette--;;filePalette', @@ -641,7 +641,7 @@ ], 'overrideChildTca' => [ 'types' => [ - \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [ + \TYPO3\CMS\Core\Resource\FileType::IMAGE->value => [ 'showitem' => 'crop,--palette--;;filePalette', ], ], diff --git a/Configuration/TCA/tx_bootstrappackage_icon_group_item.php b/Configuration/TCA/tx_bootstrappackage_icon_group_item.php index befa4b07b..de5e074d1 100644 --- a/Configuration/TCA/tx_bootstrappackage_icon_group_item.php +++ b/Configuration/TCA/tx_bootstrappackage_icon_group_item.php @@ -228,7 +228,7 @@ ], 'overrideChildTca' => [ 'types' => [ - \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [ + \TYPO3\CMS\Core\Resource\FileType::IMAGE->value => [ 'showitem' => '--palette--;;filePalette', ], ], diff --git a/Configuration/TCA/tx_bootstrappackage_tab_item.php b/Configuration/TCA/tx_bootstrappackage_tab_item.php index 8d206a5f5..87c27980b 100644 --- a/Configuration/TCA/tx_bootstrappackage_tab_item.php +++ b/Configuration/TCA/tx_bootstrappackage_tab_item.php @@ -189,12 +189,12 @@ ], 'overrideChildTca' => [ 'types' => [ - \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [ + \TYPO3\CMS\Core\Resource\FileType::IMAGE->value => [ 'showitem' => ' --palette--;;imageoverlayPalette, --palette--;;filePalette', ], - \TYPO3\CMS\Core\Resource\File::FILETYPE_VIDEO => [ + \TYPO3\CMS\Core\Resource\FileType::VIDEO->value => [ 'showitem' => ' --palette--;;videoOverlayPalette, --palette--;;filePalette', diff --git a/Configuration/TCA/tx_bootstrappackage_timeline_item.php b/Configuration/TCA/tx_bootstrappackage_timeline_item.php index 827789297..05631567b 100644 --- a/Configuration/TCA/tx_bootstrappackage_timeline_item.php +++ b/Configuration/TCA/tx_bootstrappackage_timeline_item.php @@ -223,7 +223,7 @@ ], 'overrideChildTca' => [ 'types' => [ - \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [ + \TYPO3\CMS\Core\Resource\FileType::IMAGE->value => [ 'showitem' => '--palette--;;filePalette', ], ], @@ -243,7 +243,7 @@ 'maxitems' => 1, 'overrideChildTca' => [ 'types' => [ - \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [ + \TYPO3\CMS\Core\Resource\FileType::IMAGE->value => [ 'showitem' => ' --palette--;;imageoverlayPalette, --palette--;;filePalette',