From c56a10b748de77ab65b124617ccb3bce371b9ae2 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Mon, 19 Jun 2023 10:22:54 +0200 Subject: [PATCH] Improve meta data of imported files (#24) * Set ``alternative`` to the ``description`` if available. * Set ``creator_tool`` to the "destination.one". * Set ``source`` to the URL of the fetched image. --- .../DestinationDataImportService/FilesAssignment.php | 4 +++- Documentation/Changelog/3.4.0.rst | 8 ++++++++ .../Import/DestinationDataTest/AbstractTest.php | 4 ++++ .../ImportDoesntBreakWithLongFileTitle.csv | 2 +- ...tHandlesImagesAddsMultipleImagestoSingleEvent.php | 8 ++++++-- ...portHandlesImagesAddsNewImageToExistingImages.php | 12 +++++++++--- .../Assertions/ImportHandlesImagesAddsNewImages.php | 12 +++++++++--- ...ortHandlesImagesRemovesNoLongerExistingImages.php | 4 ---- .../ImportHandlesImagesUpdatesExistingImage.php | 8 ++++++-- .../ImportHandlesImagesUpdatesSortingOfImages.php | 4 ---- .../Database/ImportHandlesImagesExistingData.php | 4 ++-- composer.json | 5 +++-- 12 files changed, 51 insertions(+), 24 deletions(-) diff --git a/Classes/Service/DestinationDataImportService/FilesAssignment.php b/Classes/Service/DestinationDataImportService/FilesAssignment.php index 11302a9..efe15cd 100644 --- a/Classes/Service/DestinationDataImportService/FilesAssignment.php +++ b/Classes/Service/DestinationDataImportService/FilesAssignment.php @@ -152,7 +152,9 @@ class FilesAssignment $this->metaDataRepository->update($file->getUid(), [ 'title' => $this->getShortenedString($mediaObject['value'], 100), 'description' => $mediaObject['description'] ?? '', - 'alternative' => 'DD Import', + 'alternative' => $mediaObject['description'] ?? '', + 'creator_tool' => 'destination.one', + 'source' => $mediaObject['url'] ?? '', ]); } diff --git a/Documentation/Changelog/3.4.0.rst b/Documentation/Changelog/3.4.0.rst index fdd47a0..16f586f 100644 --- a/Documentation/Changelog/3.4.0.rst +++ b/Documentation/Changelog/3.4.0.rst @@ -41,6 +41,14 @@ Features That ensures that modifications during import or while editing records are flushing corresponding pages. +* Improve handling of file meta data during import from destination.one. + + * Set ``alternative`` to the ``description`` if available. + + * Set ``creator_tool`` to the "destination.one". + + * Set ``source`` to the URL of the fetched image. + Fixes ----- diff --git a/Tests/Functional/Import/DestinationDataTest/AbstractTest.php b/Tests/Functional/Import/DestinationDataTest/AbstractTest.php index 949be73..1648764 100644 --- a/Tests/Functional/Import/DestinationDataTest/AbstractTest.php +++ b/Tests/Functional/Import/DestinationDataTest/AbstractTest.php @@ -8,6 +8,10 @@ abstract class AbstractTest extends AbstractFunctionalTestCase { protected function setUp(): void { + $this->coreExtensionsToLoad = [ + 'filemetadata', + ]; + parent::setUp(); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/Structure.php'); diff --git a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportDoesntBreakWithLongFileTitle.csv b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportDoesntBreakWithLongFileTitle.csv index 415f55f..ea23cb1 100644 --- a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportDoesntBreakWithLongFileTitle.csv +++ b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportDoesntBreakWithLongFileTitle.csv @@ -17,7 +17,7 @@ ,3,1,"tx_events_domain_model_event","categories",,,,,,,,,,,,,,,,, "sys_file_metadata",,,,,,,,,,,,,,,,,,,,, ,"uid","pid","title","description","alternative",,,,,,,,,,,,,,,, -,1,0,"This title is longer then the supported 255 chars as limited by default by TYPO3 database. Also c …","This is a supported description","DD Import",,,,,,,,,,,,,,,, +,1,0,"This title is longer then the supported 255 chars as limited by default by TYPO3 database. Also c …","This is a supported description","This is a supported description",,,,,,,,,,,,,,,, "sys_file_reference",,,,,,,,,,,,,,,,,,,,, ,"uid","uid_local","uid_foreign","tablenames","fieldname","title","description",,,,,,,,,,,,,, ,1,1,1,"tx_events_domain_model_event","images",,,,,,,,,,,,,,,, diff --git a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesAddsMultipleImagestoSingleEvent.php b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesAddsMultipleImagestoSingleEvent.php index a71eac4..ac102f4 100644 --- a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesAddsMultipleImagestoSingleEvent.php +++ b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesAddsMultipleImagestoSingleEvent.php @@ -58,7 +58,9 @@ return [ 'file' => 1, 'title' => 'Theater-Rudolstadt_Johannes-Geißer_photo-by-Lisa-Stern_web_.jpg', 'description' => '', - 'alternative' => 'DD Import', + 'alternative' => '', + 'creator_tool' => 'destination.one', + 'source' => 'https://dam.destination.one/849917/279ac45b3fc701a7197131f627164fffd9f8cc77bc75165e2fc2b864ed606920/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', ], [ 'uid' => 2, @@ -66,7 +68,9 @@ return [ 'file' => 2, 'title' => 'Tueftlerzeit©SFZ-Rudolstadt.jpg', 'description' => 'Description of Tueftlerzeit', - 'alternative' => 'DD Import', + 'alternative' => 'Description of Tueftlerzeit', + 'creator_tool' => 'destination.one', + 'source' => 'https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg', ], ], ]; diff --git a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesAddsNewImageToExistingImages.php b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesAddsNewImageToExistingImages.php index e525cd2..dae5ed0 100644 --- a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesAddsNewImageToExistingImages.php +++ b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesAddsNewImageToExistingImages.php @@ -90,7 +90,9 @@ return [ 'file' => 1, 'title' => 'Theater-Rudolstadt_Johannes-Geißer_photo-by-Lisa-Stern_web_.jpg', 'description' => '', - 'alternative' => 'DD Import', + 'alternative' => '', + 'creator_tool' => 'destination.one', + 'source' => 'https://dam.destination.one/849917/279ac45b3fc701a7197131f627164fffd9f8cc77bc75165e2fc2b864ed606920/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', ], [ 'uid' => 2, @@ -98,7 +100,9 @@ return [ 'file' => 2, 'title' => 'Tueftlerzeit©SFZ-Rudolstadt.jpg', 'description' => 'Description of Tueftlerzeit', - 'alternative' => 'DD Import', + 'alternative' => 'Description of Tueftlerzeit', + 'creator_tool' => 'destination.one', + 'source' => 'https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg', ], [ 'uid' => 3, @@ -106,7 +110,9 @@ return [ 'file' => 3, 'title' => 'Lutherkirche.jpg', 'description' => '', - 'alternative' => 'DD Import', + 'alternative' => '', + 'creator_tool' => 'destination.one', + 'source' => 'https://dam.destination.one/853436/109ac1cf87913e21b5e2b0ef0cc63d223a14374364952a855746a8e7c3fcfc36/lutherkirche-jpg.jpg', ], ], ]; diff --git a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesAddsNewImages.php b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesAddsNewImages.php index df0a77c..6c866ed 100644 --- a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesAddsNewImages.php +++ b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesAddsNewImages.php @@ -81,7 +81,9 @@ return [ 'file' => 1, 'title' => 'Theater-Rudolstadt_Johannes-Geißer_photo-by-Lisa-Stern_web_.jpg', 'description' => '', - 'alternative' => 'DD Import', + 'alternative' => '', + 'creator_tool' => 'destination.one', + 'source' => 'https://dam.destination.one/849917/279ac45b3fc701a7197131f627164fffd9f8cc77bc75165e2fc2b864ed606920/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', ], [ 'uid' => 2, @@ -89,7 +91,9 @@ return [ 'file' => 2, 'title' => 'Tueftlerzeit©SFZ-Rudolstadt.jpg', 'description' => 'Description of Tueftlerzeit', - 'alternative' => 'DD Import', + 'alternative' => 'Description of Tueftlerzeit', + 'creator_tool' => 'destination.one', + 'source' => 'https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg', ], [ 'uid' => 3, @@ -97,7 +101,9 @@ return [ 'file' => 3, 'title' => 'Lutherkirche.jpg', 'description' => '', - 'alternative' => 'DD Import', + 'alternative' => '', + 'creator_tool' => 'destination.one', + 'source' => 'https://dam.destination.one/853436/109ac1cf87913e21b5e2b0ef0cc63d223a14374364952a855746a8e7c3fcfc36/lutherkirche-jpg.jpg', ], ], ]; diff --git a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesRemovesNoLongerExistingImages.php b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesRemovesNoLongerExistingImages.php index aa9980d..a011705 100644 --- a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesRemovesNoLongerExistingImages.php +++ b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesRemovesNoLongerExistingImages.php @@ -57,16 +57,12 @@ return [ 'pid' => 0, 'file' => 1, 'title' => 'Theater-Rudolstadt_Johannes-Geißer_photo-by-Lisa-Stern_web_.jpg', - 'description' => '', - 'alternative' => 'DD Import', ], [ 'uid' => 2, 'pid' => 0, 'file' => 2, 'title' => 'Tueftlerzeit©SFZ-Rudolstadt.jpg', - 'description' => 'Description of Tueftlerzeit', - 'alternative' => 'DD Import', ], ], 'tx_events_domain_model_event' => [ diff --git a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesUpdatesExistingImage.php b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesUpdatesExistingImage.php index a71eac4..ac102f4 100644 --- a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesUpdatesExistingImage.php +++ b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesUpdatesExistingImage.php @@ -58,7 +58,9 @@ return [ 'file' => 1, 'title' => 'Theater-Rudolstadt_Johannes-Geißer_photo-by-Lisa-Stern_web_.jpg', 'description' => '', - 'alternative' => 'DD Import', + 'alternative' => '', + 'creator_tool' => 'destination.one', + 'source' => 'https://dam.destination.one/849917/279ac45b3fc701a7197131f627164fffd9f8cc77bc75165e2fc2b864ed606920/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', ], [ 'uid' => 2, @@ -66,7 +68,9 @@ return [ 'file' => 2, 'title' => 'Tueftlerzeit©SFZ-Rudolstadt.jpg', 'description' => 'Description of Tueftlerzeit', - 'alternative' => 'DD Import', + 'alternative' => 'Description of Tueftlerzeit', + 'creator_tool' => 'destination.one', + 'source' => 'https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg', ], ], ]; diff --git a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesUpdatesSortingOfImages.php b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesUpdatesSortingOfImages.php index 03f6a18..97b3f65 100644 --- a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesUpdatesSortingOfImages.php +++ b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesUpdatesSortingOfImages.php @@ -57,16 +57,12 @@ return [ 'pid' => 0, 'file' => 1, 'title' => 'Theater-Rudolstadt_Johannes-Geißer_photo-by-Lisa-Stern_web_.jpg', - 'description' => '', - 'alternative' => 'DD Import', ], [ 'uid' => 2, 'pid' => 0, 'file' => 2, 'title' => 'Tueftlerzeit©SFZ-Rudolstadt.jpg', - 'description' => 'Description of Tueftlerzeit', - 'alternative' => 'DD Import', ], ], ]; diff --git a/Tests/Functional/Import/DestinationDataTest/Fixtures/Database/ImportHandlesImagesExistingData.php b/Tests/Functional/Import/DestinationDataTest/Fixtures/Database/ImportHandlesImagesExistingData.php index e6e632e..2d6eaa6 100644 --- a/Tests/Functional/Import/DestinationDataTest/Fixtures/Database/ImportHandlesImagesExistingData.php +++ b/Tests/Functional/Import/DestinationDataTest/Fixtures/Database/ImportHandlesImagesExistingData.php @@ -64,7 +64,7 @@ return [ 'file' => 1, 'title' => 'Theater-Rudolstadt_Johannes-Geißer_photo-by-Lisa-Stern_web_.jpg', 'description' => '', - 'alternative' => 'DD Import', + 'alternative' => '', ], [ 'uid' => 2, @@ -72,7 +72,7 @@ return [ 'file' => 2, 'title' => 'Tueftlerzeit©SFZ-Rudolstadt.jpg', 'description' => 'Description of Tueftlerzeit', - 'alternative' => 'DD Import', + 'alternative' => 'Description of Tueftlerzeit', ], ], 'tx_events_domain_model_event' => [ diff --git a/composer.json b/composer.json index 932b0cb..cb161a9 100644 --- a/composer.json +++ b/composer.json @@ -18,9 +18,10 @@ "php": "~7.2.0 || ~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0", "typo3/cms-core": "^10.4 || ^11.5", "typo3/cms-extbase": "^10.4 || ^11.5", + "typo3/cms-filelist": "^10.4 || ^11.5", + "typo3/cms-filemetadata": "^10.4 || ^11.5", "typo3/cms-fluid": "^10.4 || ^11.5", - "typo3/cms-frontend": "^10.4 || ^11.5", - "typo3/cms-filelist": "^10.4 || ^11.5" + "typo3/cms-frontend": "^10.4 || ^11.5" }, "autoload": { "psr-4": {