Merge pull request #2629 from aynsix/PHRAS-1875-advancedsearch-updated-on

PHRAS-1875 port to 4.1 advanced search sort by updated_on
This commit is contained in:
Nicolas Maillat
2018-06-05 17:21:57 +02:00
committed by GitHub
3 changed files with 8 additions and 0 deletions

View File

@@ -139,6 +139,7 @@ class ElasticSearchEngine implements SearchEngineInterface
return [ return [
SearchEngineOptions::SORT_RELEVANCE => $this->app->trans('pertinence'), SearchEngineOptions::SORT_RELEVANCE => $this->app->trans('pertinence'),
SearchEngineOptions::SORT_CREATED_ON => $this->app->trans('date dajout'), SearchEngineOptions::SORT_CREATED_ON => $this->app->trans('date dajout'),
SearchEngineOptions::SORT_UPDATED_ON => $this->app->trans('date de modification'),
]; ];
} }
@@ -368,6 +369,9 @@ class ElasticSearchEngine implements SearchEngineInterface
elseif ($options->getSortBy() === SearchEngineOptions::SORT_CREATED_ON) { elseif ($options->getSortBy() === SearchEngineOptions::SORT_CREATED_ON) {
$sort['created_on'] = $options->getSortOrder(); $sort['created_on'] = $options->getSortOrder();
} }
elseif ($options->getSortBy() === SearchEngineOptions::SORT_UPDATED_ON) {
$sort['updated_on'] = $options->getSortOrder();
}
elseif ($options->getSortBy() === 'recordid') { elseif ($options->getSortBy() === 'recordid') {
$sort['record_id'] = $options->getSortOrder(); $sort['record_id'] = $options->getSortOrder();
} }

View File

@@ -36,6 +36,7 @@ class SearchEngineOptions
const TYPE_ALL = ''; const TYPE_ALL = '';
const SORT_RELEVANCE = 'relevance'; const SORT_RELEVANCE = 'relevance';
const SORT_CREATED_ON = 'created_on'; const SORT_CREATED_ON = 'created_on';
const SORT_UPDATED_ON = 'updated_on';
const SORT_RANDOM = 'random'; const SORT_RANDOM = 'random';
const SORT_MODE_ASC = 'asc'; const SORT_MODE_ASC = 'asc';
const SORT_MODE_DESC = 'desc'; const SORT_MODE_DESC = 'desc';

View File

@@ -346,6 +346,9 @@
{% set isSelected = (sortByPreference == constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_CREATED_ON')) %} {% set isSelected = (sortByPreference == constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_CREATED_ON')) %}
{% set isDefault = (sortByDefault == constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_CREATED_ON')) %} {% set isDefault = (sortByDefault == constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_CREATED_ON')) %}
<option value="{{ constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_CREATED_ON') }}" {% if isSelected %}selected="selected"{% endif %}{% if isDefault %} class="default-selection"{% endif %}>{{ "Date Added"|trans }}</option> <option value="{{ constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_CREATED_ON') }}" {% if isSelected %}selected="selected"{% endif %}{% if isDefault %} class="default-selection"{% endif %}>{{ "Date Added"|trans }}</option>
{% set isSelected = (sortByPreference == constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_UPDATED_ON')) %}
{% set isDefault = (sortByDefault == constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_UPDATED_ON')) %}
<option value="{{ constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_UPDATED_ON') }}" {% if isSelected %}selected="selected"{% endif %}{% if isDefault %} class="default-selection"{% endif %}>{{ "Date Updated"|trans }}</option>
{% set isSelected = (sortByPreference == constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_RELEVANCE')) %} {% set isSelected = (sortByPreference == constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_RELEVANCE')) %}
{% set isDefault = (sortByDefault == constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_RELEVANCE')) %} {% set isDefault = (sortByDefault == constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_RELEVANCE')) %}
<option value="{{ constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_RELEVANCE') }}" {% if isSelected %}selected="selected"{% endif %}{% if isDefault %} class="default-selection"{% endif %}>{{ "Relevance"|trans }}</option> <option value="{{ constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_RELEVANCE') }}" {% if isSelected %}selected="selected"{% endif %}{% if isDefault %} class="default-selection"{% endif %}>{{ "Relevance"|trans }}</option>