Skip to content
Snippets Groups Projects
Commit e9171090 authored by edelm's avatar edelm Committed by Robert Lange
Browse files

Improve Autocomplete configuration (#1374)

- Refactor autocomplete configuration loading to reduce redundancy.
- Improve documentation of autocomplete options in .ini files.
- Add missing configuration support for Summon.
parent 60dabf78
Branches
Tags
No related merge requests found
...@@ -338,3 +338,20 @@ next_prev_navigation = false ...@@ -338,3 +338,20 @@ next_prev_navigation = false
; regular Syndetics if necessary. ; regular Syndetics if necessary.
[List] [List]
view=full 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]
...@@ -476,6 +476,11 @@ sort = "last_indexed desc" ...@@ -476,6 +476,11 @@ sort = "last_indexed desc"
; ;
; The available autocomplete handlers are: ; 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 ; None
; Do not provide any suggestions. You should use this handler if you want to ; Do not provide any suggestions. You should use this handler if you want to
; disable suggestions for one search type while still providing suggestions ; disable suggestions for one search type while still providing suggestions
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
namespace VuFind\Search\Base; namespace VuFind\Search\Base;
use VuFind\I18n\Translator\TranslatorAwareInterface; use VuFind\I18n\Translator\TranslatorAwareInterface;
use Zend\Config\Config;
/** /**
* Abstract options search model. * Abstract options search model.
...@@ -938,4 +939,20 @@ abstract class Options implements TranslatorAwareInterface ...@@ -938,4 +939,20 @@ abstract class Options implements TranslatorAwareInterface
{ {
return $this->firstlastNavigation; 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;
}
} }
...@@ -137,14 +137,6 @@ class Options extends \VuFind\Search\Base\Options ...@@ -137,14 +137,6 @@ class Options extends \VuFind\Search\Base\Options
$facetConf->Advanced_Facet_Settings->translated_facets->toArray() $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 ...@@ -406,6 +398,9 @@ class Options extends \VuFind\Search\Base\Options
$this->setCommonSettings( $this->setCommonSettings(
$searchSettings, 'common_expanders', 'expanderOptions', 'commonExpanders' $searchSettings, 'common_expanders', 'expanderOptions', 'commonExpanders'
); );
// Load autocomplete preferences:
$this->configureAutocomplete($searchSettings);
} }
/** /**
......
...@@ -209,13 +209,7 @@ class Options extends \VuFind\Search\Base\Options ...@@ -209,13 +209,7 @@ class Options extends \VuFind\Search\Base\Options
} }
// Load autocomplete preferences: // Load autocomplete preferences:
if (isset($searchSettings->Autocomplete->enabled)) { $this->configureAutocomplete($searchSettings);
$this->autocompleteEnabled = $searchSettings->Autocomplete->enabled;
}
if (isset($searchSettings->Autocomplete->auto_submit)) {
$this->autocompleteAutoSubmit
= $searchSettings->Autocomplete->auto_submit;
}
// Load shard settings // Load shard settings
if (isset($searchSettings->IndexShards) if (isset($searchSettings->IndexShards)
......
...@@ -147,6 +147,9 @@ class Options extends \VuFind\Search\Base\Options ...@@ -147,6 +147,9 @@ class Options extends \VuFind\Search\Base\Options
= $searchSettings->General->empty_search_relevance_override; = $searchSettings->General->empty_search_relevance_override;
} }
// Load autocomplete preferences:
$this->configureAutocomplete($searchSettings);
// Set up views // Set up views
$this->initViewOptions($searchSettings); $this->initViewOptions($searchSettings);
......
...@@ -75,10 +75,8 @@ class Options extends \VuFind\Search\Base\Options ...@@ -75,10 +75,8 @@ class Options extends \VuFind\Search\Base\Options
'title' => 'sort_title', 'author' => 'sort_author', 'title' => 'sort_title', 'author' => 'sort_author',
'year DESC' => 'sort_year', 'year' => 'sort_year asc' 'year DESC' => 'sort_year', 'year' => 'sort_year asc'
]; ];
// Load autocomplete preference: // Load autocomplete preferences:
if (isset($searchSettings->Autocomplete->enabled)) { $this->configureAutocomplete($searchSettings);
$this->autocompleteEnabled = $searchSettings->Autocomplete->enabled;
}
} }
/** /**
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment