mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-19 16:03:14 +00:00
@@ -21,15 +21,15 @@ class Prod extends Helper
|
||||
|
||||
public function get_search_datas()
|
||||
{
|
||||
$searchData = array('bases' => array(), 'dates' => array(), 'fields' => array(), 'sort' => array(),);
|
||||
$searchData = array('bases' => array(), 'dates' => array(), 'fields' => array(), 'sort' => array(), 'elasticSort' => array());
|
||||
|
||||
$bases = $fields = $dates = $sort = array();
|
||||
$bases = $fields = $dates = $sort = $elasticSort = array();
|
||||
|
||||
if (!$this->app->getAuthenticatedUser()) {
|
||||
return $searchData;
|
||||
}
|
||||
|
||||
$searchSet = json_decode($this->app['settings']->getUserSetting($this->app->getAuthenticatedUser(), 'search'), true);
|
||||
$searchSet = json_decode($this->app['settings']->getUserSetting($this->app->getAuthenticatedUser(), 'search', '{}'), true);
|
||||
$saveSettings = $this->app['settings']->getUserSetting($this->app->getAuthenticatedUser(), 'advanced_search_reload');
|
||||
$acl = $this->app->getAclForUser($this->app->getAuthenticatedUser());
|
||||
foreach ($acl->get_granted_sbas() as $databox) {
|
||||
@@ -102,10 +102,15 @@ class Prod extends Helper
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($searchSet['elasticSort'])) {
|
||||
$elasticSort = $searchSet['elasticSort'];
|
||||
}
|
||||
|
||||
$searchData['fields'] = $fields;
|
||||
$searchData['dates'] = $dates;
|
||||
$searchData['bases'] = $bases;
|
||||
$searchData['sort'] = $sort;
|
||||
$searchData['elasticSort'] = $elasticSort;
|
||||
|
||||
return $searchData;
|
||||
}
|
||||
|
@@ -133,7 +133,7 @@ class ElasticSearchEngine implements SearchEngineInterface
|
||||
*/
|
||||
public function getDefaultSort()
|
||||
{
|
||||
return SearchEngineOptions::SORT_RELEVANCE;
|
||||
return SearchEngineOptions::SORT_CREATED_ON;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -132,7 +132,9 @@ function checkFilters(save) {
|
||||
bases: {},
|
||||
fields: [],
|
||||
dates: {},
|
||||
status: []
|
||||
status: [],
|
||||
elasticSort: {}
|
||||
|
||||
};
|
||||
|
||||
var adv_box = $('form.phrasea_query .adv_options');
|
||||
@@ -221,6 +223,9 @@ function checkFilters(save) {
|
||||
$("option.default-selection", fieldsSortOrd).prop("selected", true);
|
||||
}
|
||||
|
||||
search.elasticSort.by = $("option:selected:enabled", fieldsSort).val();
|
||||
search.elasticSort.order = $("option:selected:enabled", fieldsSortOrd).val();
|
||||
|
||||
//--------- from fields filter ---------
|
||||
|
||||
// unselect the unavailable fields (or all fields if "all" is selected)
|
||||
|
@@ -237,15 +237,29 @@
|
||||
</div>
|
||||
<div id="ADVSRCH_OPTIONS_ZONE">
|
||||
<div id="ADVSRCH_SORT_ZONE">
|
||||
{% set sortByDefault = app['phraseanet.SE'].getDefaultSort()%}
|
||||
{% set sortOrderDefault = app['phraseanet.SE'].getDefaultSortDirection()%}
|
||||
|
||||
{% set sortByPreference = sortByDefault %}
|
||||
{% if search_datas.elasticSort.by is defined %}
|
||||
{% set sortByPreference = search_datas.elasticSort.by %}
|
||||
{% endif %}
|
||||
|
||||
{% set sortOrderPreference = sortOrderDefault %}
|
||||
{% if search_datas.elasticSort.order is defined %}
|
||||
{% set sortOrderPreference = search_datas.elasticSort.order %}
|
||||
{% endif %}
|
||||
<span>{{ 'Trier par' | trans }}</span>
|
||||
<select name="sort" class="input-medium">
|
||||
{% set b = (app['phraseanet.SE'].getDefaultSort() == constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_CREATED_ON')) %}
|
||||
<option value="{{ constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_CREATED_ON') }}" {% if b %}selected="selected" class="default-selection"{% endif %}>{{ "Date Added"|trans }}</option>
|
||||
{% set b = (app['phraseanet.SE'].getDefaultSort() == constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_RELEVANCE')) %}
|
||||
<option value="{{ constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_RELEVANCE') }}" {% if b %}selected="selected" class="default-selection"{% endif %}>{{ "Relevance"|trans }}</option>
|
||||
<select name="sort" class="input-medium" onchange="checkFilters(true);">
|
||||
{% set isSelected = (sortByPreference == 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>
|
||||
{% set isSelected = (sortByPreference == 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>
|
||||
<optgroup label="{{ 'By field'|trans }}">
|
||||
{% for fieldname, sort in search_datas['sort'] %}
|
||||
{% set b = (app['phraseanet.SE'].getDefaultSort() == fieldname) %}
|
||||
{% set b = (sortOrderPreference == fieldname) %}
|
||||
<option value="{{ fieldname }}"
|
||||
{% if b %}selected="selected"{% endif %}
|
||||
class="{% if b %}default-selection {% endif %}dbx db_{{sort['sbas']|join(' db_')}}"
|
||||
@@ -253,10 +267,11 @@
|
||||
{% endfor %}
|
||||
</optgroup>
|
||||
</select>
|
||||
<select name="ord" class="input-medium">
|
||||
<select name="ord" class="input-medium" onchange="checkFilters(true);">
|
||||
{% for ord, ord_name in app['phraseanet.SE'].getAvailableOrder() %}
|
||||
{% set b = (app['phraseanet.SE'].getDefaultSortDirection() == ord) %}
|
||||
<option value="{{ ord }}" {% if b %}selected="selected" class="default-selection"{% endif %}>{{ ord_name }}</option>
|
||||
{% set isSelected = (sortOrderPreference == ord) %}
|
||||
{% set isDefault = (sortOrderDefault == ord) %}
|
||||
<option value="{{ ord }}" {% if isSelected %}selected="selected"{% endif %}{% if isDefault %} class="default-selection"{% endif %}>{{ ord_name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user