Add SearchEngineInterface::isStemmingEnabled

This commit is contained in:
Romain Neutron
2013-09-17 17:03:41 +02:00
parent 8d264052aa
commit 219156bf8e
6 changed files with 34 additions and 2 deletions

View File

@@ -63,6 +63,7 @@ class ConfigurationPanel extends AbstractConfigurationPanel
} }
$configuration['default_sort'] = $request->request->get('default_sort'); $configuration['default_sort'] = $request->request->get('default_sort');
$configuration['stemming_enabled'] = (int) (Boolean) $request->request->get('stemming_enabled');
$this->saveConfiguration($configuration); $this->saveConfiguration($configuration);
@@ -88,6 +89,10 @@ class ConfigurationPanel extends AbstractConfigurationPanel
$configuration['default_sort'] = null; $configuration['default_sort'] = null;
} }
if (!isset($configuration['stemming_enabled'])) {
$configuration['stemming_enabled'] = false;
}
return $configuration; return $configuration;
} }
} }

View File

@@ -117,6 +117,16 @@ class PhraseaEngine implements SearchEngineInterface
return $sort; return $sort;
} }
/**
* {@inheritdoc}
*/
public function isStemmingEnabled()
{
$configuration = $this->getConfiguration();
return (Boolean) $configuration['stemming_enabled'];
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

View File

@@ -58,6 +58,11 @@ interface SearchEngineInterface
*/ */
public function getDefaultSort(); 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 * @return array an array containing sort order values as key and sort order names as value
*/ */

View File

@@ -109,6 +109,14 @@ class SphinxSearchEngine implements SearchEngineInterface
return 'relevance'; return 'relevance';
} }
/**
* {@inheritdoc}
*/
public function isStemmingEnabled()
{
return true;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

View File

@@ -3,6 +3,10 @@
</div> </div>
<form method="post" action="{{ path('admin_searchengine_post') }}"> <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> <fieldset>
<legend>{% trans 'Default sort' %}</legend> <legend>{% trans 'Default sort' %}</legend>
<select name="default_sort"> <select name="default_sort">

View File

@@ -346,7 +346,7 @@
{% if app['phraseanet.SE'].hasStemming() %} {% if app['phraseanet.SE'].hasStemming() %}
<div> <div>
<label class="checkbox"> <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> </label>
</div> </div>
{% endif %} {% endif %}