diff --git a/typo3/sysext/fluid_styled_content/Classes/Hooks/TextmediaPreviewRenderer.php b/typo3/sysext/fluid_styled_content/Classes/Hooks/TextmediaPreviewRenderer.php index 8e5bf7e737e0ef24c94ac4a37f5f9c1706664d74..4975587db5f6ad0a03a3c81b57b2f62db823a56f 100644 --- a/typo3/sysext/fluid_styled_content/Classes/Hooks/TextmediaPreviewRenderer.php +++ b/typo3/sysext/fluid_styled_content/Classes/Hooks/TextmediaPreviewRenderer.php @@ -46,10 +46,10 @@ class TextmediaPreviewRenderer implements PageLayoutViewDrawItemHookInterface $itemContent .= $parentObject->linkEditContent($parentObject->renderText($row['bodytext']), $row) . '<br />'; } - if ($row['media']) { - $itemContent .= $parentObject->linkEditContent($parentObject->getThumbCodeUnlinked($row, 'tt_content', 'media'), $row) . '<br />'; + if ($row['assets']) { + $itemContent .= $parentObject->linkEditContent($parentObject->getThumbCodeUnlinked($row, 'tt_content', 'assets'), $row) . '<br />'; - $fileReferences = BackendUtility::resolveFileReferences('tt_content', 'media', $row); + $fileReferences = BackendUtility::resolveFileReferences('tt_content', 'assets', $row); if (!empty($fileReferences)) { $linkedContent = ''; diff --git a/typo3/sysext/fluid_styled_content/Configuration/TCA/Overrides/tt_content.php b/typo3/sysext/fluid_styled_content/Configuration/TCA/Overrides/tt_content.php index 6f1754874ba65f50d859401eda070d29cfa652d8..18789b51a7ef87fc2209a1ada35f6e776cd55830 100644 --- a/typo3/sysext/fluid_styled_content/Configuration/TCA/Overrides/tt_content.php +++ b/typo3/sysext/fluid_styled_content/Configuration/TCA/Overrides/tt_content.php @@ -40,7 +40,7 @@ call_user_func(function () { --palette--;' . $frontendLanguageFilePrefix . 'palette.header;header, bodytext;' . $frontendLanguageFilePrefix . 'bodytext_formlabel;;richtext:rte_transform[mode=ts_css], --div--;' . $frontendLanguageFilePrefix . 'tabs.media, - media, + assets, --palette--;' . $frontendLanguageFilePrefix . 'palette.imagelinks;imagelinks, --div--;' . $frontendLanguageFilePrefix . 'tabs.appearance, layout;' . $frontendLanguageFilePrefix . 'layout_formlabel, @@ -52,19 +52,6 @@ call_user_func(function () { --palette--;' . $frontendLanguageFilePrefix . 'palette.access;access, --div--;' . $frontendLanguageFilePrefix . 'tabs.extended ', - 'columnsOverrides' => [ - 'media' => [ - 'label' => $languageFilePrefix . 'tt_content.media_references', - 'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig('media', [ - 'appearance' => [ - 'createNewRelationLinkTitle' => $languageFilePrefix . 'tt_content.media_references.addFileReference' - ], - // custom configuration for displaying fields in the overlay/reference table - // behaves the same as the image field. - 'foreign_types' => $GLOBALS['TCA']['tt_content']['columns']['image']['config']['foreign_types'] - ], $GLOBALS['TYPO3_CONF_VARS']['SYS']['mediafile_ext']) - ] - ] ]; // Add category tab when categories column exits @@ -117,7 +104,18 @@ call_user_func(function () { ], 'default' => 0 ] - ] + ], + 'assets' => [ + 'label' => $languageFilePrefix . 'tt_content.asset_references', + 'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig('assets', [ + 'appearance' => [ + 'createNewRelationLinkTitle' => $languageFilePrefix . 'tt_content.asset_references.addFileReference' + ], + // custom configuration for displaying fields in the overlay/reference table + // behaves the same as the image field. + 'foreign_types' => $GLOBALS['TCA']['tt_content']['columns']['image']['config']['foreign_types'] + ], $GLOBALS['TYPO3_CONF_VARS']['SYS']['mediafile_ext']) + ], ]; \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tt_content', $additionalColumns); diff --git a/typo3/sysext/fluid_styled_content/Configuration/TypoScript/Static/Setup/lib.fluidContent.ts b/typo3/sysext/fluid_styled_content/Configuration/TypoScript/Static/Setup/lib.fluidContent.ts index 3b6a1f4f3262619baecb2a10f986cb6dc092ee5b..5ba9938a9e9e95b953a22c7ade2e1cd5cb82d34d 100644 --- a/typo3/sysext/fluid_styled_content/Configuration/TypoScript/Static/Setup/lib.fluidContent.ts +++ b/typo3/sysext/fluid_styled_content/Configuration/TypoScript/Static/Setup/lib.fluidContent.ts @@ -34,4 +34,4 @@ lib.fluidContent { } } } -} \ No newline at end of file +} diff --git a/typo3/sysext/fluid_styled_content/Configuration/TypoScript/Static/setup.txt b/typo3/sysext/fluid_styled_content/Configuration/TypoScript/Static/setup.txt index 260d191b9a32b437fb678bbb4240bfbdfb48b325..9e8e0f8d30872f02f7442c533ce4548391a78db3 100644 --- a/typo3/sysext/fluid_styled_content/Configuration/TypoScript/Static/setup.txt +++ b/typo3/sysext/fluid_styled_content/Configuration/TypoScript/Static/setup.txt @@ -174,7 +174,7 @@ tt_content { dataProcessing { 10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor 10 { - references.fieldName = media + references.fieldName = assets } 20 = TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor 20 { @@ -187,7 +187,7 @@ tt_content { } stdWrap { # Setup the edit icon for content element "textmedia" - editIcons = tt_content: header [header_layout], bodytext, media [imageorient|imagewidth|imageheight], [imagecols|imageborder], image_zoom + editIcons = tt_content: header [header_layout], bodytext, assets [imageorient|imagewidth|imageheight], [imagecols|imageborder], image_zoom editIcons { iconTitle.data = LLL:EXT:fluid_styled_content/Resources/Private/Language/FrontendEditing.xlf:editIcon.textmedia } diff --git a/typo3/sysext/fluid_styled_content/Resources/Private/Language/Database.xlf b/typo3/sysext/fluid_styled_content/Resources/Private/Language/Database.xlf index 1b3e6e89d76f8104613fdb3a84ef0b0abbe9c57b..138c578e7cb020be06e53a8228a6bfb0bb591dd9 100644 --- a/typo3/sysext/fluid_styled_content/Resources/Private/Language/Database.xlf +++ b/typo3/sysext/fluid_styled_content/Resources/Private/Language/Database.xlf @@ -48,10 +48,10 @@ <trans-unit id="tt_content.palette.mediaAdjustments"> <source>Media Adjustments</source> </trans-unit> - <trans-unit id="tt_content.media_references"> + <trans-unit id="tt_content.asset_references"> <source>Media elements</source> </trans-unit> - <trans-unit id="tt_content.media_references.addFileReference"> + <trans-unit id="tt_content.asset_references.addFileReference"> <source>Add media file</source> </trans-unit> </body> diff --git a/typo3/sysext/fluid_styled_content/ext_tables.sql b/typo3/sysext/fluid_styled_content/ext_tables.sql index 163cc3f0cb36aefb01813e03bb1d6f76d492f258..a1c5df06076f4e832466f42ba6376ed5f0c466b0 100644 --- a/typo3/sysext/fluid_styled_content/ext_tables.sql +++ b/typo3/sysext/fluid_styled_content/ext_tables.sql @@ -4,5 +4,6 @@ CREATE TABLE tt_content ( bullets_type tinyint(3) unsigned DEFAULT '0' NOT NULL, uploads_description tinyint(1) unsigned DEFAULT '0' NOT NULL, - uploads_type tinyint(3) unsigned DEFAULT '0' NOT NULL + uploads_type tinyint(3) unsigned DEFAULT '0' NOT NULL, + assets int(11) unsigned DEFAULT '0' NOT NULL, ); diff --git a/typo3/sysext/install/Classes/Updates/ContentTypesToTextMediaUpdate.php b/typo3/sysext/install/Classes/Updates/ContentTypesToTextMediaUpdate.php index 3aefbe133a56c8b18be0f8ef940722b5946b5c80..ccb1ee1c01014102f2f094aa423fcb93c5ad6255 100644 --- a/typo3/sysext/install/Classes/Updates/ContentTypesToTextMediaUpdate.php +++ b/typo3/sysext/install/Classes/Updates/ContentTypesToTextMediaUpdate.php @@ -97,9 +97,9 @@ class ContentTypesToTextMediaUpdate extends AbstractUpdate AND sys_file_reference.tablenames =\'tt_content\' AND sys_file_reference.fieldname = \'image\' SET tt_content.CType = \'textmedia\', - tt_content.media = image, - tt_content.image = \'\', - sys_file_reference.fieldname = \'media\' + tt_content.assets = image, + tt_content.image = 0, + sys_file_reference.fieldname = \'assets\' WHERE tt_content.CType = \'textpic\' OR tt_content.CType = \'image\' diff --git a/typo3/sysext/install/Classes/Updates/MigrateMediaToAssetsForTextMediaCe.php b/typo3/sysext/install/Classes/Updates/MigrateMediaToAssetsForTextMediaCe.php new file mode 100644 index 0000000000000000000000000000000000000000..d38927943249b6957243066e2527a153c266ded9 --- /dev/null +++ b/typo3/sysext/install/Classes/Updates/MigrateMediaToAssetsForTextMediaCe.php @@ -0,0 +1,99 @@ +<?php +namespace TYPO3\CMS\Install\Updates; + +/* + * 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! + */ + +/** + * Migrate CTypes 'textmedia' to use 'assets' field instead of 'media' + */ +class MigrateMediaToAssetsForTextMediaCe extends AbstractUpdate +{ + /** + * @var string + */ + protected $title = 'Migrate CTypes textmedia database field "media" to "assets"'; + + /** + * Checks if an update is needed + * + * @param string &$description The description for the update + * @return bool Whether an update is needed (TRUE) or not (FALSE) + */ + public function checkForUpdate(&$description) + { + $updateNeeded = true; + + if ($this->isWizardDone()) { + $updateNeeded = false; + } else { + // No need to join the sys_file_references table here as we can rely on the reference + // counter to check if the wizards has any textmedia content elements to upgrade. + $textmediaCount = $this->getDatabaseConnection()->exec_SELECTcountRows( + 'uid', + 'tt_content', + 'CType = \'textmedia\' AND media > 0' + ); + + if ($textmediaCount === 0) { + $updateNeeded = false; + $this->markWizardAsDone(); + } + } + + $description = 'The extension "fluid_styled_content" is using a new database field for mediafile references. ' . + 'This update wizard migrates these old references to use the new database field.'; + + return $updateNeeded; + } + + /** + * Performs the database update if old mediafile references are available + * + * @param array &$databaseQueries Queries done in this update + * @param mixed &$customMessages Custom messages + * @return bool + */ + public function performUpdate(array &$databaseQueries, &$customMessages) + { + $databaseConnection = $this->getDatabaseConnection(); + + // Update 'textmedia' + $query = ' + UPDATE sys_file_reference + LEFT JOIN tt_content + ON sys_file_reference.uid_foreign = tt_content.uid + AND sys_file_reference.tablenames =\'tt_content\' + AND sys_file_reference.fieldname = \'media\' + SET tt_content.assets = tt_content.media, + tt_content.media = 0, + sys_file_reference.fieldname = \'assets\' + WHERE + tt_content.CType = \'textmedia\' + AND tt_content.media > 0 + '; + $databaseConnection->sql_query($query); + + // Store last executed query + $databaseQueries[] = str_replace(chr(10), ' ', $query); + // Check for errors + if ($databaseConnection->sql_error()) { + $customMessages = 'SQL-ERROR: ' . htmlspecialchars($databaseConnection->sql_error()); + return false; + } + + $this->markWizardAsDone(); + + return true; + } +} diff --git a/typo3/sysext/install/ext_localconf.php b/typo3/sysext/install/ext_localconf.php index a1e3c939ef947b376d6af03593da4877325ca2af..622d23b1e6f727828aa94f9f99a38c52693c1377 100644 --- a/typo3/sysext/install/ext_localconf.php +++ b/typo3/sysext/install/ext_localconf.php @@ -12,6 +12,7 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['tableCType'] $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][\TYPO3\CMS\Install\Updates\FileListIsStartModuleUpdate::class] = \TYPO3\CMS\Install\Updates\FileListIsStartModuleUpdate::class; $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['textmediaCType'] = \TYPO3\CMS\Install\Updates\ContentTypesToTextMediaUpdate::class; $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][\TYPO3\CMS\Install\Updates\WorkspacesNotificationSettingsUpdate::class] = \TYPO3\CMS\Install\Updates\WorkspacesNotificationSettingsUpdate::class; +$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['textmediaAssets'] = \TYPO3\CMS\Install\Updates\MigrateMediaToAssetsForTextMediaCe::class; $signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class); $signalSlotDispatcher->connect(