mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-24 02:13:15 +00:00
Add SearchEngineInterface::isStemmingEnabled
This commit is contained in:
@@ -63,6 +63,7 @@ class ConfigurationPanel extends AbstractConfigurationPanel
|
||||
}
|
||||
|
||||
$configuration['default_sort'] = $request->request->get('default_sort');
|
||||
$configuration['stemming_enabled'] = (int) (Boolean) $request->request->get('stemming_enabled');
|
||||
|
||||
$this->saveConfiguration($configuration);
|
||||
|
||||
@@ -88,6 +89,10 @@ class ConfigurationPanel extends AbstractConfigurationPanel
|
||||
$configuration['default_sort'] = null;
|
||||
}
|
||||
|
||||
if (!isset($configuration['stemming_enabled'])) {
|
||||
$configuration['stemming_enabled'] = false;
|
||||
}
|
||||
|
||||
return $configuration;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,6 +117,16 @@ class PhraseaEngine implements SearchEngineInterface
|
||||
return $sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isStemmingEnabled()
|
||||
{
|
||||
$configuration = $this->getConfiguration();
|
||||
|
||||
return (Boolean) $configuration['stemming_enabled'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -440,7 +450,7 @@ class PhraseaEngine implements SearchEngineInterface
|
||||
private function getSuggestions($query)
|
||||
{
|
||||
$suggestions = array();
|
||||
|
||||
|
||||
if ($this->qp && isset($this->qp['main'])) {
|
||||
$suggestions = array_map(function ($value) use ($query) {
|
||||
return new SearchEngineSuggestion($query, $value['value'], $value['hits']);
|
||||
|
||||
@@ -58,6 +58,11 @@ interface SearchEngineInterface
|
||||
*/
|
||||
public function getDefaultSort();
|
||||
|
||||
/**
|
||||
* @return string The default sort
|
||||
*/
|
||||
public function isStemmingEnabled();
|
||||
|
||||
/**
|
||||
* @return array an array containing sort order values as key and sort order names as value
|
||||
*/
|
||||
|
||||
@@ -109,6 +109,14 @@ class SphinxSearchEngine implements SearchEngineInterface
|
||||
return 'relevance';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isStemmingEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
</div>
|
||||
|
||||
<form method="post" action="{{ path('admin_searchengine_post') }}">
|
||||
<fieldset>
|
||||
<legend>{% trans 'Stemming' %}</legend>
|
||||
{% trans 'Enable stemming' %} <input type="checkbox" name="stemming_enabled" value="1" {% if configuration['stemming_enabled'] %}checked="checked"{% endif %} />
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>{% trans 'Default sort' %}</legend>
|
||||
<select name="default_sort">
|
||||
|
||||
@@ -346,7 +346,7 @@
|
||||
{% if app['phraseanet.SE'].hasStemming() %}
|
||||
<div>
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" checked="checked" name="stemme" /> {% trans 'rechercher par stemme' %}
|
||||
<input type="checkbox" {% if app['phraseanet.SE'].isStemmingEnabled() %} checked="checked" {% endif %} name="stemme" /> {% trans 'rechercher par stemme' %}
|
||||
</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user