diff --git a/config/vufind/Summon.ini b/config/vufind/Summon.ini index 2f0820ac626473f084e7bec42769ed85b7bb6e84..26d25143dfb695b6afd4034bcc7d7a024dbd4db7 100644 --- a/config/vufind/Summon.ini +++ b/config/vufind/Summon.ini @@ -338,3 +338,20 @@ next_prev_navigation = false ; regular Syndetics if necessary. [List] view=full + +; This section controls the behavior of the Autocomplete within Summon. +[Autocomplete] +; Disabled by default. +enabled = false + +; Define a default_handler +default_handler = None + +; Auto-submit autocomplete on click or enter +auto_submit = true + +; In this section, set the key equal to a search type from [Basic_Searches] and +; the value equal to an autocomplete handler in order to customize autocompletion +; behavior when that search type is selected. See searches.ini for a list of +; available handlers. +[Autocomplete_Types] diff --git a/config/vufind/searches.ini b/config/vufind/searches.ini index 531cd8bfabc633b0ef55d9a02f2bc988d766db4a..45ac7dda10053800127d937e3c160bf00535aebf 100644 --- a/config/vufind/searches.ini +++ b/config/vufind/searches.ini @@ -476,6 +476,11 @@ sort = "last_indexed desc" ; ; The available autocomplete handlers are: ; +; Eds:[Mode] +; Use the EBSCO Discovery Service autocomplete handler (only intended to be +; used in the context of the EDS backend). [Mode] can be either "holdings" for +; title completion in PubFinder or "rawqueries" for completion of basic textual +; queries. ; None ; Do not provide any suggestions. You should use this handler if you want to ; disable suggestions for one search type while still providing suggestions diff --git a/module/VuFind/src/VuFind/Search/Base/Options.php b/module/VuFind/src/VuFind/Search/Base/Options.php index 882024b6624c991d1a5d89a161d355216ea6742e..f3c8d1cfebf34d647f22d96022a7d34248427194 100644 --- a/module/VuFind/src/VuFind/Search/Base/Options.php +++ b/module/VuFind/src/VuFind/Search/Base/Options.php @@ -28,6 +28,7 @@ namespace VuFind\Search\Base; use VuFind\I18n\Translator\TranslatorAwareInterface; +use Zend\Config\Config; /** * Abstract options search model. @@ -938,4 +939,20 @@ abstract class Options implements TranslatorAwareInterface { return $this->firstlastNavigation; } + + /** + * Configure autocomplete preferences from an .ini file. + * + * @param Config $searchSettings Object representation of .ini file + * + * @return void + */ + protected function configureAutocomplete(Config $searchSettings) + { + // Only change settings from current values if they are defined in .ini: + $this->autocompleteEnabled = $searchSettings->Autocomplete->enabled + ?? $this->autocompleteEnabled; + $this->autocompleteAutoSubmit = $searchSettings->Autocomplete->auto_submit + ?? $this->autocompleteAutoSubmit; + } } diff --git a/module/VuFind/src/VuFind/Search/EDS/Options.php b/module/VuFind/src/VuFind/Search/EDS/Options.php index 5756231ac6be1159e4816f1cc62cdb9cdf5ce908..2fa20504888c258251637b76732b0df8a51bfe24 100644 --- a/module/VuFind/src/VuFind/Search/EDS/Options.php +++ b/module/VuFind/src/VuFind/Search/EDS/Options.php @@ -137,14 +137,6 @@ class Options extends \VuFind\Search\Base\Options $facetConf->Advanced_Facet_Settings->translated_facets->toArray() ); } - // Load autocomplete preferences: - if (isset($searchSettings->Autocomplete->enabled)) { - $this->autocompleteEnabled = $searchSettings->Autocomplete->enabled; - } - if (isset($searchSettings->Autocomplete->auto_submit)) { - $this->autocompleteAutoSubmit - = $searchSettings->Autocomplete->auto_submit; - } } /** @@ -406,6 +398,9 @@ class Options extends \VuFind\Search\Base\Options $this->setCommonSettings( $searchSettings, 'common_expanders', 'expanderOptions', 'commonExpanders' ); + + // Load autocomplete preferences: + $this->configureAutocomplete($searchSettings); } /** diff --git a/module/VuFind/src/VuFind/Search/Solr/Options.php b/module/VuFind/src/VuFind/Search/Solr/Options.php index 1a1bfc43f276c73ea7ff8c4cb9ea202205d88efe..d15add0c4e2719863e7d79e9f46a4d4c08937d10 100644 --- a/module/VuFind/src/VuFind/Search/Solr/Options.php +++ b/module/VuFind/src/VuFind/Search/Solr/Options.php @@ -209,13 +209,7 @@ class Options extends \VuFind\Search\Base\Options } // Load autocomplete preferences: - if (isset($searchSettings->Autocomplete->enabled)) { - $this->autocompleteEnabled = $searchSettings->Autocomplete->enabled; - } - if (isset($searchSettings->Autocomplete->auto_submit)) { - $this->autocompleteAutoSubmit - = $searchSettings->Autocomplete->auto_submit; - } + $this->configureAutocomplete($searchSettings); // Load shard settings if (isset($searchSettings->IndexShards) diff --git a/module/VuFind/src/VuFind/Search/Summon/Options.php b/module/VuFind/src/VuFind/Search/Summon/Options.php index ac5fb409c1c9c2cd8452bc2bd373985aa6c567e9..ce8f8888d0d25acf9e7fe82b632f162f678f726b 100644 --- a/module/VuFind/src/VuFind/Search/Summon/Options.php +++ b/module/VuFind/src/VuFind/Search/Summon/Options.php @@ -147,6 +147,9 @@ class Options extends \VuFind\Search\Base\Options = $searchSettings->General->empty_search_relevance_override; } + // Load autocomplete preferences: + $this->configureAutocomplete($searchSettings); + // Set up views $this->initViewOptions($searchSettings); diff --git a/module/VuFind/src/VuFind/Search/Tags/Options.php b/module/VuFind/src/VuFind/Search/Tags/Options.php index 05dcca6376703a1ff32821660d9de8eb3be60360..8ad292ccdd3598d896859423c4e625fd92d767be 100644 --- a/module/VuFind/src/VuFind/Search/Tags/Options.php +++ b/module/VuFind/src/VuFind/Search/Tags/Options.php @@ -75,10 +75,8 @@ class Options extends \VuFind\Search\Base\Options 'title' => 'sort_title', 'author' => 'sort_author', 'year DESC' => 'sort_year', 'year' => 'sort_year asc' ]; - // Load autocomplete preference: - if (isset($searchSettings->Autocomplete->enabled)) { - $this->autocompleteEnabled = $searchSettings->Autocomplete->enabled; - } + // Load autocomplete preferences: + $this->configureAutocomplete($searchSettings); } /**