mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
#PHRAS-610 #time 10h
This commit is contained in:
@@ -31,26 +31,43 @@ class Prod extends Helper
|
||||
|
||||
$searchSet = json_decode($this->app['settings']->getUserSetting($this->app->getAuthenticatedUser(), 'search'), true);
|
||||
$saveSettings = $this->app['settings']->getUserSetting($this->app->getAuthenticatedUser(), 'advanced_search_reload');
|
||||
|
||||
foreach ($this->app->getAclForUser($this->app->getAuthenticatedUser())->get_granted_sbas() as $databox) {
|
||||
$acl = $this->app->getAclForUser($this->app->getAuthenticatedUser());
|
||||
foreach ($acl->get_granted_sbas() as $databox) {
|
||||
$sbasId = $databox->get_sbas_id();
|
||||
|
||||
$bases[$sbasId] = array('thesaurus' => (trim($databox->get_thesaurus()) !== ""), 'cterms' => false, 'collections' => array(), 'sbas_id' => $sbasId);
|
||||
$bases[$sbasId] = array(
|
||||
'thesaurus' => (trim($databox->get_thesaurus()) !== ""),
|
||||
'cterms' => false,
|
||||
'collections' => array(),
|
||||
'sbas_id' => $sbasId
|
||||
);
|
||||
|
||||
foreach ($this->app->getAclForUser($this->app->getAuthenticatedUser())->get_granted_base([], [$databox->get_sbas_id()]) as $coll) {
|
||||
$selected = $saveSettings ? ((isset($searchSet['bases']) && isset($searchSet['bases'][$sbasId])) ? (in_array($coll->get_base_id(), $searchSet['bases'][$sbasId])) : true) : true;
|
||||
$bases[$sbasId]['collections'][] = array('selected' => $selected, 'base_id' => $coll->get_base_id());
|
||||
$bases[$sbasId]['collections'][] = array(
|
||||
'selected' => $selected,
|
||||
'base_id' => $coll->get_base_id()
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($databox->get_meta_structure() as $fieldMeta) {
|
||||
if (!$fieldMeta->is_indexable()) {
|
||||
continue;
|
||||
}
|
||||
if($fieldMeta->isBusiness() && !$acl->can_see_business_fields($databox)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$id = $fieldMeta->get_id();
|
||||
$name = $fieldMeta->get_name();
|
||||
$type = $fieldMeta->get_type();
|
||||
|
||||
$data = array('sbas' => array($sbasId), 'fieldname' => $name, 'type' => $type, 'id' => $id);
|
||||
$data = array(
|
||||
'sbas' => array($sbasId),
|
||||
'fieldname' => $name,
|
||||
'type' => $type,
|
||||
'id' => $id
|
||||
);
|
||||
|
||||
if ($fieldMeta->get_type() === \databox_field::TYPE_DATE) {
|
||||
if (!array_key_exists($name, $dates)) {
|
||||
|
@@ -253,9 +253,7 @@ class ElasticSearchEngine implements SearchEngineInterface
|
||||
$context = $this->createQueryContext($options);
|
||||
/** @var QueryCompiler $query_compiler */
|
||||
$query_compiler = $this->app['query_compiler'];
|
||||
file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d)\n%s\n", __FILE__, __LINE__, var_export($string, true)), FILE_APPEND);
|
||||
$recordQuery = $query_compiler->compile($string, $context);
|
||||
file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d)\n%s\n", __FILE__, __LINE__, var_export($recordQuery, true)), FILE_APPEND);
|
||||
|
||||
$params = $this->createRecordQueryParams($recordQuery, $options, null);
|
||||
|
||||
@@ -274,10 +272,8 @@ file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d)\n%s\n", __FILE__,
|
||||
if ($aggs = $this->getAggregationQueryParams($options)) {
|
||||
$params['body']['aggs'] = $aggs;
|
||||
}
|
||||
file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d)\n%s\n", __FILE__, __LINE__, var_export($params, true)), FILE_APPEND);
|
||||
|
||||
$res = $this->client->search($params);
|
||||
file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d)\n%s\n", __FILE__, __LINE__, var_export($res, true)), FILE_APPEND);
|
||||
|
||||
$results = new ArrayCollection();
|
||||
|
||||
@@ -293,7 +289,6 @@ file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d)\n%s\n", __FILE__,
|
||||
$query['query_main'] = $recordQuery;
|
||||
$query['query'] = $params['body'];
|
||||
$query['query_string'] = json_encode($params['body']);
|
||||
file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d)\n%s\n", __FILE__, __LINE__, var_export($query['query_string'], true)), FILE_APPEND);
|
||||
return new SearchEngineResult(
|
||||
$results, // ArrayCollection of results
|
||||
json_encode($query),
|
||||
|
@@ -261,27 +261,30 @@
|
||||
<div class="searchFormWrapper">
|
||||
<form id="searchForm" method="POST" action="{{ path('prod_query') }}" name="phrasea_query" class="phrasea_query">
|
||||
<input id="SENT_query" name="qry" type="hidden" value="{{app['settings'].getUserSetting(app.getAuthenticatedUser(), 'start_page_query')}}">
|
||||
<div class="input-append">
|
||||
<input id="EDIT_query" name="fake_qry" type="text" autocomplete="off" class="search query danger_indicator" value="{{app['settings'].getUserSetting(app.getAuthenticatedUser(), 'start_page_query')}}">
|
||||
<a id="ADV_query" href="#" class="btn btn-inverse adv_trigger adv_search_button">
|
||||
<img src="/skins/icons/settings.png" title="{{ 'Advanced Search' | trans }}"/>
|
||||
</a>
|
||||
<button type="submit" class="btn btn-inverse" style="font-size:14px">{{ 'boutton::rechercher' | trans }}</button>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
{% if GV_multiAndReport %}
|
||||
<label for="mode_type_doc" class="radio inline">
|
||||
<input type="radio" value="0" class="mode_type_doc" name="search_type" {% if GV_defaultQuery_type == 0 %}checked="checked"{% endif %} id="mode_type_doc"/>
|
||||
{{ 'phraseanet::type:: documents' | trans }}
|
||||
</label>
|
||||
<label for="mode_type_reg" class="radio inline">
|
||||
<input type="radio" value="1" class="mode_type_reg" name="search_type" {% if GV_defaultQuery_type != 0 %}checked="checked"{% endif %} id="mode_type_reg"/>
|
||||
{{ 'phraseanet::type:: reportages' | trans }}
|
||||
</label>
|
||||
{% else %}
|
||||
<input type="hidden" value="0" name="search_type" />
|
||||
{% endif %}
|
||||
<input type="hidden" name="pag" id="formAnswerPage" value="">
|
||||
<input type="hidden" name="sel" value="">
|
||||
|
||||
<div class="controls controls-row">
|
||||
<div class="input-append">
|
||||
<input id="EDIT_query" name="fake_qry" type="text" autocomplete="off" class="search query danger_indicator" value="{{app['settings'].getUserSetting(app.getAuthenticatedUser(), 'start_page_query')}}">
|
||||
<a id="ADV_query" href="#" class="btn btn-inverse adv_trigger adv_search_button">
|
||||
<img src="/skins/icons/settings.png" title="{{ 'Advanced Search' | trans }}"/>
|
||||
</a>
|
||||
<button type="submit" class="btn btn-inverse" style="font-size:14px">{{ 'boutton::rechercher' | trans }}</button>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
{% if GV_multiAndReport %}
|
||||
<label for="mode_type_doc" class="radio inline">
|
||||
<input type="radio" value="0" class="mode_type_doc" name="search_type" {% if GV_defaultQuery_type == 0 %}checked="checked"{% endif %} id="mode_type_doc"/>
|
||||
{{ 'phraseanet::type:: documents' | trans }}
|
||||
</label>
|
||||
<label for="mode_type_reg" class="radio inline">
|
||||
<input type="radio" value="1" class="mode_type_reg" name="search_type" {% if GV_defaultQuery_type != 0 %}checked="checked"{% endif %} id="mode_type_reg"/>
|
||||
{{ 'phraseanet::type:: reportages' | trans }}
|
||||
</label>
|
||||
{% else %}
|
||||
<input type="hidden" value="0" name="search_type" />
|
||||
{% endif %}
|
||||
<select name="record_type" id="recordtype_sel" class="input-small">
|
||||
<option value="">{{ 'Tout type' | trans }}</option>
|
||||
<option value="image">{{ 'Image' | trans }}</option>
|
||||
@@ -292,11 +295,9 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="pag" id="formAnswerPage" value="">
|
||||
<input type="hidden" name="sel" value="">
|
||||
|
||||
|
||||
<div class="adv_options" style="display:none;">
|
||||
<div class="controls controls-row adv_options" style="display:none;">
|
||||
<table style="width:100%; table-layout:fixed;">
|
||||
<tr>
|
||||
<td style="width:50%; vertical-align:top;">
|
||||
@@ -316,7 +317,7 @@
|
||||
<input class="btn btn-inverse" type="button" value="{{ 'Re-initialiser' | trans }}" onclick="reset_adv_search();" />
|
||||
</div>
|
||||
<div id="ADVSRCH_OPTIONS_ZONE">
|
||||
<div class="ADVSRCH_SORT_ZONE">
|
||||
<div id="ADVSRCH_SORT_ZONE">
|
||||
<span>{{ 'Trier par' | trans }}</span>
|
||||
<select name="sort" class="input-medium">
|
||||
<option value="{{ constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_CREATED_ON') }}" {% if app['phraseanet.SE'].getDefaultSort() is empty %}selected="selected default-selection"{% endif %}>{{ "Date Added"|trans }}</option>
|
||||
@@ -343,18 +344,18 @@
|
||||
<option value="phraseanet--all--fields">{{ 'rechercher dans tous les champs' | trans }}</option>
|
||||
{% for field_id, field in search_datas['fields'] %}
|
||||
{% if field['type'] != 'date' %}
|
||||
<option class="field_switch field_{{field['sbas']|join(' field_')}}" value="{{field_id}}">{{field['fieldname']}}</option>
|
||||
<option class="dbx db_{{field['sbas']|join(' db_')}}" value="{{field_id}}">{{field['fieldname']}}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div id="ADVSRCH_SB_ZONE">
|
||||
{% set status_length = search_status|length %}
|
||||
{% if status_length > 0 %}
|
||||
{% if search_status|length > 0 %}
|
||||
<hr />
|
||||
<span>{{ 'Status des documents a rechercher' | trans }}</span>
|
||||
{% for databox_id, databox in search_status %}
|
||||
{% if databox.status|length > 0 %}
|
||||
<table style="width: 100%;" id="ADVSRCH_SB_ZONE_{{databox_id}}" class="field_{{databox_id}}">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -393,44 +394,36 @@
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div id="ADVSRCH_DATE_ZONE">
|
||||
<div id="ADVSRCH_DATE_ZONE" class="danger_indicator">
|
||||
{% if app['phraseanet.SE'].getAvailableDateFields() | length > 0 %}
|
||||
<hr />
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan="2">{{ 'Rechercher dans un champ date' | trans }}</td>
|
||||
<td colspan="2">
|
||||
<select name="date_field" class="input-medium">
|
||||
<option onchange="checkFilters(true);" selected="selected"
|
||||
value="">{{ 'Rechercher dans un champ date' | trans }}</option>
|
||||
{% for fieldname, date in search_datas['dates'] %}
|
||||
<option onchange="checkFilters(true);"
|
||||
class="db_{{date['sbas']|join(' db_')}}" value="{{ fieldname }}">{{ fieldname }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{ 'phraseanet::time:: de' | trans }}</td>
|
||||
<td style="padding-right: 5px;">
|
||||
<div class="input-prepend">
|
||||
<span class="add-on"><i class="icon-calendar"></i></span>
|
||||
<input onchange="checkFilters(true);" class="datepicker input-small" type="text" name="date_min" placeholder="{% trans %}YYYY/MM/DD{% endtrans %}" style="margin: 0;position: relative; z-index: 10001;" />
|
||||
</div>
|
||||
</td>
|
||||
<td>{{ 'phraseanet::time:: a' | trans }}</td>
|
||||
<td>
|
||||
<div class="input-prepend">
|
||||
<span class="add-on"><i class="icon-calendar"></i></span>
|
||||
<input onchange="checkFilters(true);" class="datepicker input-small" type="text" name="date_max" placeholder="{% trans %}YYYY/MM/DD{% endtrans %}" style="margin: 0;position: relative; z-index: 10001;" />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<span>
|
||||
<select name="date_field" class="input-medium" onchange="checkFilters(true);">
|
||||
<option selected="selected"
|
||||
value="">{{ 'Rechercher dans un champ date' | trans }}</option>
|
||||
{% for fieldname, date in search_datas['dates'] %}
|
||||
<option
|
||||
class="dbx db_{{date['sbas']|join(' db_')}}" value="{{ fieldname }}">{{ fieldname }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</span>
|
||||
<span id="ADVSRCH_DATE_SELECTORS">
|
||||
{{ 'phraseanet::time:: de' | trans }}
|
||||
<div class="input-prepend">
|
||||
<span class="add-on"><i class="icon-calendar"></i></span>
|
||||
<input onchange="checkFilters(true);" class="datepicker input-small" type="text" name="date_min" placeholder="{% trans %}YYYY/MM/DD{% endtrans %}" style="margin: 0;position: relative; z-index: 10001;" />
|
||||
</div>
|
||||
{{ 'phraseanet::time:: a' | trans }}
|
||||
<div class="input-prepend">
|
||||
<span class="add-on"><i class="icon-calendar"></i></span>
|
||||
<input onchange="checkFilters(true);" class="datepicker input-small" type="text" name="date_max" placeholder="{% trans %}YYYY/MM/DD{% endtrans %}" style="margin: 0;position: relative; z-index: 10001;" />
|
||||
</div>
|
||||
</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -185,31 +185,15 @@ function checkFilters(save) {
|
||||
var fieldsSelect = $('#ADVSRCH_FIELDS_ZONE select', container);
|
||||
var dateFilterSelect = $('#ADVSRCH_DATE_ZONE select', container);
|
||||
var scroll = fieldsSelect.scrollTop();
|
||||
var switches = $('.field_switch', container);
|
||||
/*
|
||||
switches.filter('.was').removeClass('was');
|
||||
switches.filter('option:selected, input:checked').addClass('was');
|
||||
|
||||
// $('select option.field_switch', container).addClass("hidden");
|
||||
// $('input.field_switch:checked', container).removeAttr('checked');
|
||||
// $('input.field_switch:checkbox', container).parent().hide();
|
||||
|
||||
// filters.removeClass('danger');
|
||||
|
||||
|
||||
// mark the selected options in the "fields" select
|
||||
*/
|
||||
// hide all the fields in the "fields" select, so only the relevant ones will be shown again
|
||||
$("option:gt(0)", fieldsSelect).prop("disabled", true); // option[0] is "all fields"
|
||||
$("option:gt(0)", fieldsSelect).hide(); // option[0] is "all fields"
|
||||
|
||||
// hide all the fields in the "sort by" select, so only the relevant ones will be shown again
|
||||
$("option.dbx", fieldsSort).prop("disabled", true); // dbx is for "field of databases"
|
||||
$("option.dbx", fieldsSort).hide();
|
||||
$("option.dbx", fieldsSort).hide().prop("disabled", true); // dbx is for "field of databases"
|
||||
|
||||
// hide all the fields in the "fields" select, so only the relevant ones will be shown again
|
||||
$("option.dbx", fieldsSelect).hide().prop("disabled", true); // option[0] is "all fields"
|
||||
|
||||
// hide all the fields in the "date field" select, so only the relevant ones will be shown again
|
||||
$("option.dbx", dateFilterSelect).prop("disabled", true); // dbx = all "field" entries in the select = all except the firstt
|
||||
$("option.dbx", dateFilterSelect).hide();
|
||||
$("option.dbx", dateFilterSelect).hide().prop("disabled", true); // dbx = all "field" entries in the select = all except the firstt
|
||||
|
||||
var nbTotalSelectedColls = 0;
|
||||
$.each($('.sbascont', adv_box), function () {
|
||||
@@ -241,7 +225,6 @@ function checkFilters(save) {
|
||||
$("#ADVSRCH_SBAS_LABEL_" + sbas_id).removeClass("danger");
|
||||
}
|
||||
|
||||
|
||||
if(nbSelectedColls == 0) {
|
||||
// no collections checked for this databox
|
||||
// hide the status bits
|
||||
@@ -252,22 +235,18 @@ function checkFilters(save) {
|
||||
else {
|
||||
// at least one coll checked for this databox
|
||||
// show again the relevant fields in "sort by" select
|
||||
$(".db_"+sbas_id, fieldsSort).prop("disabled", false);
|
||||
$(".db_"+sbas_id, fieldsSort).show();
|
||||
$(".db_"+sbas_id, fieldsSort).show().prop("disabled", false);
|
||||
// show again the relevant fields in "from fields" select
|
||||
$(".field_"+sbas_id, fieldsSelect).prop("disabled", false);
|
||||
$(".field_"+sbas_id, fieldsSelect).show();
|
||||
$(".db_"+sbas_id, fieldsSelect).show().prop("disabled", false);
|
||||
// show the sb
|
||||
$("#ADVSRCH_SB_ZONE_"+sbas_id, container).show();
|
||||
// show again the relevant fields in "date field" select
|
||||
$(".db_"+sbas_id, dateFilterSelect).prop("disabled", false);
|
||||
$(".db_"+sbas_id, dateFilterSelect).show();
|
||||
$(".db_"+sbas_id, dateFilterSelect).show().prop("disabled", false);
|
||||
}
|
||||
});
|
||||
|
||||
if (nbTotalSelectedColls == 0) {
|
||||
// no collections checked at all
|
||||
// filters.addClass("danger");
|
||||
// hide irrelevant filters
|
||||
$("#ADVSRCH_OPTIONS_ZONE").hide();
|
||||
}
|
||||
@@ -280,7 +259,7 @@ function checkFilters(save) {
|
||||
// --------- sort --------
|
||||
|
||||
// if no field is selected for sort, select the first option
|
||||
if($("option.dbx:selected:visible:enabled", fieldsSort).length == 0) {
|
||||
if($("option.dbx:selected:enabled", fieldsSort).length == 0) {
|
||||
$("option:eq(0)", fieldsSort).prop("selected", true);
|
||||
}
|
||||
|
||||
@@ -329,42 +308,27 @@ function checkFilters(save) {
|
||||
danger = true;
|
||||
}
|
||||
}
|
||||
/*
|
||||
$('#ADVSRCH_SB_ZONE :checkbox[checked]').each(function () {
|
||||
var n = $(this).attr('n');
|
||||
search.status[n] = $(this).val().split('_');
|
||||
});
|
||||
if(search.status.length == 0) {
|
||||
$('#ADVSRCH_SB_ZONE', container).removeClass('danger');
|
||||
}
|
||||
else {
|
||||
$('#ADVSRCH_SB_ZONE', container).addClass('danger');
|
||||
}
|
||||
*/
|
||||
|
||||
//--------- dates filter ---------
|
||||
|
||||
// if no date field is selected for filter, select the first option
|
||||
if($("option.dbx:selected:visible:enabled", dateFilterSelect).length == 0) {
|
||||
$('#ADVSRCH_DATE_ZONE', adv_box).removeClass('danger');
|
||||
if($("option.dbx:selected:enabled", dateFilterSelect).length == 0) {
|
||||
$("option:eq(0)", dateFilterSelect).prop("selected", true);
|
||||
$("#ADVSRCH_DATE_SELECTORS", container).hide();
|
||||
}
|
||||
else {
|
||||
$("#ADVSRCH_DATE_SELECTORS", container).show();
|
||||
search.dates.minbound = $('#ADVSRCH_DATE_ZONE input[name=date_min]', adv_box).val();
|
||||
search.dates.maxbound = $('#ADVSRCH_DATE_ZONE input[name=date_max]', adv_box).val();
|
||||
search.dates.field = $('#ADVSRCH_DATE_ZONE select[name=date_field]', adv_box).val();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
search.dates.minbound = $('#ADVSRCH_DATE_ZONE input[name=date_min]', adv_box).val();
|
||||
search.dates.maxbound = $('#ADVSRCH_DATE_ZONE input[name=date_max]', adv_box).val();
|
||||
search.dates.field = $('#ADVSRCH_DATE_ZONE select[name=date_field]', adv_box).val();
|
||||
|
||||
if ($.trim(search.dates.minbound) || $.trim(search.dates.maxbound)) {
|
||||
danger = true;
|
||||
$('#ADVSRCH_DATE_ZONE', adv_box).addClass('danger');
|
||||
if ($.trim(search.dates.minbound) || $.trim(search.dates.maxbound)) {
|
||||
danger = true;
|
||||
$('#ADVSRCH_DATE_ZONE', adv_box).addClass('danger');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
fieldsSelect.scrollTop(scroll);
|
||||
|
||||
// if one filter shows danger, show it on the query
|
||||
@@ -995,10 +959,10 @@ $(document).ready(function () {
|
||||
var $this = $(this);
|
||||
var $record_types = $('#recordtype_sel');
|
||||
if ($this.hasClass('mode_type_reg')) {
|
||||
$record_types.hide();
|
||||
$record_types.css("visibility", "hidden"); // better than hide because does not change layout
|
||||
$record_types.prop("selectedIndex", 0);
|
||||
} else {
|
||||
$record_types.show();
|
||||
$record_types.css("visibility", "visible");
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user