diff --git a/config/module.ini b/config/module.ini index 0620fb3..febe18a 100644 --- a/config/module.ini +++ b/config/module.ini @@ -8,6 +8,6 @@ author_link = "https://gitlab.com/Daniel-KM" module_link = "https://gitlab.com/Daniel-KM/Omeka-S-module-BulkImport" support_link = "https://gitlab.com/Daniel-KM/Omeka-S-module-BulkImport/-/issues" configurable = true -version = "3.4.54" +version = "3.4.55" omeka_version_constraint = "^4.0.0" dependencies = "Common, Log" diff --git a/data/scripts/upgrade.php b/data/scripts/upgrade.php index fc5d7d5..d3b0a54 100644 --- a/data/scripts/upgrade.php +++ b/data/scripts/upgrade.php @@ -2,6 +2,7 @@ namespace BulkImport; +use Common\Stdlib\PsrMessage; use Omeka\Module\Exception\ModuleCannotInstallException; use Omeka\Stdlib\Message; @@ -32,7 +33,7 @@ 'To upgrade from version %1$s to version %2$s, you must upgrade to version %3$s first.', // @translate $oldVersion, $newVersion, '3.4.47' ); - throw new ModuleCannotInstallException((string) $message); // @translate + throw new ModuleCannotInstallException((string) $message); } if (!method_exists($this, 'checkModuleActiveVersion') || !$this->checkModuleActiveVersion('Common', '3.4.58')) { @@ -413,4 +414,28 @@ $messenger->addWarning($message); } +if (version_compare($oldVersion, '3.4.55', '<')) { + $message = new PsrMessage( + 'The feature to extract metadata from media that was moved in another module in version 3.4.53 is reintegrated. You should set the option in main settings to use it.' // @translate + ); + $messenger->addSuccess($message); + + /** @see \Common\ManageModuleAndResources::checkStringsInFiles() */ + $manageModuleAndResources = $this->getManageModuleAndResources(); + + $checks = [ + '[mapping]', + ]; + $result = $manageModuleAndResources->checkStringsInFiles($checks, 'data/mapping/json/file.*') ?? []; + if ($result) { + $message = new PsrMessage( + 'To keep the feature to extract metadata from media working, you should replace "[mapping]" by "[maps]" in the customized files "data/mapping/file.xxx". Matching files: {json}', // @translate + ['json' => json_encode($result, 448)] + ); + $messenger->addError($message); + $logger = $services->get('Omeka\Logger'); + $logger->warn($message->getMessage(), $message->getContext()); + } +} + // TODO Remove bulkimport_allow_empty_files and bulkimport_local_path in some version to keep config for EasyAdmin. diff --git a/data/scripts/upgrade_vocabulary.php b/data/scripts/upgrade_vocabulary.php index 85601ac..a474c58 100644 --- a/data/scripts/upgrade_vocabulary.php +++ b/data/scripts/upgrade_vocabulary.php @@ -2,34 +2,39 @@ namespace BulkImport; +use Common\Stdlib\PsrMessage; use Omeka\Module\Exception\ModuleCannotInstallException; -use Omeka\Stdlib\Message; /** * @var Module $this * @var \Laminas\ServiceManager\ServiceLocatorInterface $services + * @var bool $skipMessage */ $services = $this->getServiceLocator(); -if (!method_exists($this, 'getInstallResources')) { - throw new ModuleCannotInstallException((string) new Message( - 'This module requires module %s version %s or greater.', // @translate - 'Generic', - '3.4.43' - )); +if (!method_exists($this, 'getManageModuleAndResources')) { + $plugins = $services->get('ControllerPluginManager'); + $translate = $plugins->get('translate'); + $message = new \Omeka\Stdlib\Message( + $translate('This module requires module %1$s version %2$s or greater.'), // @translate + 'Common', '3.4.58' + ); + throw new ModuleCannotInstallException((string) $message); } -$installResources = $this->getInstallResources(); +$manageModuleAndResources = $this->getManageModuleAndResources(); $module = __NAMESPACE__; $filepath = dirname(__DIR__, 2) . '/data/vocabularies/curation.json'; $data = file_get_contents($filepath); $data = json_decode($data, true); -$installResources->createOrUpdateVocabulary($data, $module); +$manageModuleAndResources->createOrUpdateVocabulary($data, $module); -$messenger = $services->get('ControllerPluginManager')->get('messenger'); -$message = new Message( - 'The vocabulary "%s" was updated successfully.', // @translate - pathinfo($filepath, PATHINFO_FILENAME) -); -$messenger->addSuccess($message); +if (!empty($skipMessage)) { + $messenger = $services->get('ControllerPluginManager')->get('messenger'); + $message = new PsrMessage( + 'The vocabulary "{vocabulary}" was updated successfully.', // @translate + ['vocabulary' => pathinfo($filepath, PATHINFO_FILENAME)] + ); + $messenger->addSuccess($message); +}