diff --git a/config/module.ini b/config/module.ini index 5725d747..03ee8a75 100644 --- a/config/module.ini +++ b/config/module.ini @@ -1,6 +1,6 @@ [info] name = "Search" -description = "Add improved search capabilities to Omeka S" +description = "Add improved search capabilities to Omeka S: filters, facets, etc." tags = "search, advanced search, filter, facet" license = "CECILL-2.1" author = "Daniel Berthereau (based on the module Search of BibLibre)" @@ -8,5 +8,5 @@ author_link = "https://gitlab.com/Daniel-KM" module_link = "https://gitlab.com/Daniel-KM/Omeka-S-module-Search" support_link = "https://gitlab.com/Daniel-KM/Omeka-S-module-Search/-/issues" configurable = false -version = "3.5.20.3" +version = "3.5.21.3" omeka_version_constraint = "^3.0.0" diff --git a/data/scripts/upgrade.php b/data/scripts/upgrade.php index 652aac7b..6de47aa6 100644 --- a/data/scripts/upgrade.php +++ b/data/scripts/upgrade.php @@ -1,6 +1,10 @@ query($sql); $result = $stmt->fetchAll(\PDO::FETCH_KEY_PAIR); if ($result) { - foreach ($result as $id => $params) { - $params = json_decode($params, true) ?: []; - if ($params) { + foreach ($result as $id => $searchPageSettings) { + $searchPageSettings = json_decode($searchPageSettings, true) ?: []; + if ($searchPageSettings) { foreach (['facets', 'sort_fields'] as $type) { - if (!isset($params[$type])) { - $params[$type] = []; + if (!isset($searchPageSettings[$type])) { + $searchPageSettings[$type] = []; } else { // @see \Search\Controller\Admin\SearchPageController::configureAction() // Sort enabled first, then available, else sort by weigth. - uasort($params[$type], function ($a, $b) { + uasort($searchPageSettings[$type], function ($a, $b) { // Sort by availability. if (isset($a['enabled']) && isset($b['enabled'])) { if ($a['enabled'] > $b['enabled']) { @@ -163,11 +167,11 @@ } } } - $params = $connection->quote(json_encode($params, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); + $searchPageSettings = $connection->quote(json_encode($searchPageSettings, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); $sql = <<exec($sql); } @@ -200,9 +204,9 @@ $mainSearchPage = basename($mainSearchPage); // The api for search_pages is not available during upgrade. $sql = <<fetchColumn($sql, ['search_page' => $mainSearchPage], 0); $settings->set('search_main_page', $id ? (string) $id : null); @@ -212,27 +216,27 @@ if (version_compare($oldVersion, '3.5.14', '<')) { // Add new default options to settings of search pages. $sql = <<<'SQL' -SELECT id, settings FROM search_page; +SELECT `id`, `settings` FROM `search_page`; SQL; $stmt = $connection->query($sql); $result = $stmt->fetchAll(\PDO::FETCH_KEY_PAIR); if ($result) { - foreach ($result as $id => $params) { - $params = json_decode($params, true) ?: []; - $params += [ + foreach ($result as $id => $searchPageSettings) { + $searchPageSettings = json_decode($searchPageSettings, true) ?: []; + $searchPageSettings += [ 'default_results' => 'default', 'default_query' => '', 'restrict_query_to_form' => '0', ]; - $params['form']['item_set_filter_type'] = 'multi-checkbox'; - $params['form']['resource_class_filter_type'] = 'select'; - $params['form']['resource_template_filter_type'] = 'select'; - $params['form']['filter_collection_number'] = '1'; - $params = $connection->quote(json_encode($params, 320)); + $searchPageSettings['form']['item_set_filter_type'] = 'multi-checkbox'; + $searchPageSettings['form']['resource_class_filter_type'] = 'select'; + $searchPageSettings['form']['resource_template_filter_type'] = 'select'; + $searchPageSettings['form']['filter_collection_number'] = '1'; + $searchPageSettings = $connection->quote(json_encode($searchPageSettings, 320)); $sql = <<exec($sql); } @@ -355,4 +359,17 @@ WHERE `name` = "Internal"; SQL; $connection->exec($sql); + + $messenger = new Messenger(); + $message = new Message( + 'The default search forms "Basic" and "Advanced" have been removed and replaced by a "Main" form. It is recommended to check it and to rename templates if they are customized in a theme.' // @translate + ); + $messenger->addWarning($message); + $message = new Message( + 'The default input type for main search form field "q" is now "search" instead of "text". Check your css or use $this->formText() in your theme.' // @translate + ); + $messenger->addWarning($message); + $message = new Message( + 'The search page form defines new keys and use sub settings, in particular for facets. Check your theme if it was customized.' // @translate + ); }