mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 11:33:17 +00:00
[SearchEngine] Add SearchRequest object
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
namespace Alchemy\Phrasea\Controller\Prod;
|
namespace Alchemy\Phrasea\Controller\Prod;
|
||||||
|
|
||||||
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
|
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
|
||||||
|
use Alchemy\Phrasea\Controller\SearchEngineRequest;
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
@@ -99,89 +100,9 @@ class Query implements ControllerProviderInterface
|
|||||||
$mod = $app['phraseanet.user']->getPrefs('view');
|
$mod = $app['phraseanet.user']->getPrefs('view');
|
||||||
|
|
||||||
$json = array();
|
$json = array();
|
||||||
|
|
||||||
$options = new SearchEngineOptions();
|
$SearchRequest = SearchEngineRequest::fromRequest($app, $request);
|
||||||
$options->disallowBusinessFields();
|
$options = $SearchRequest->getOptions();
|
||||||
|
|
||||||
$bas = $app['phraseanet.user']->ACL()->get_granted_base();
|
|
||||||
|
|
||||||
if (is_array($request->request->get('bas'))) {
|
|
||||||
$bas = array_map(function($base_id) use ($app) {
|
|
||||||
return \collection::get_from_base_id($app, $base_id);
|
|
||||||
}, $request->request->get('bas'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$databoxes = array();
|
|
||||||
|
|
||||||
foreach ($bas as $collection) {
|
|
||||||
if (!isset($databoxes[$collection->get_sbas_id()])) {
|
|
||||||
$databoxes[$collection->get_sbas_id()] = $collection->get_databox();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($app['phraseanet.user']->ACL()->has_right('modifyrecord')) {
|
|
||||||
$BF = array_filter($bas, function($collection) use ($app) {
|
|
||||||
return $app['phraseanet.user']->ACL()->has_right_on_base($collection->get_base_id(), 'canmodifrecord');
|
|
||||||
});
|
|
||||||
|
|
||||||
$options->allowBusinessFieldsOn($BF);
|
|
||||||
}
|
|
||||||
|
|
||||||
$status = is_array($request->request->get('status')) ? $request->request->get('status') : array();
|
|
||||||
$fields = is_array($request->request->get('fields')) ? $request->request->get('fields') : array();
|
|
||||||
|
|
||||||
$databoxFields = array();
|
|
||||||
|
|
||||||
foreach ($databoxes as $databox) {
|
|
||||||
foreach ($fields as $field) {
|
|
||||||
try {
|
|
||||||
$databoxField = $databox->get_meta_structure()->get_element_by_name($field);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ($databoxField) {
|
|
||||||
$databoxFields[] = $databoxField;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$options->setFields($databoxFields);
|
|
||||||
$options->setStatus($status);
|
|
||||||
$options->onCollections($bas);
|
|
||||||
|
|
||||||
$options->setSearchType($request->request->get('search_type'));
|
|
||||||
$options->setRecordType($request->request->get('recordtype'));
|
|
||||||
|
|
||||||
$min_date = $max_date = null;
|
|
||||||
if ($request->request->get('datemin')) {
|
|
||||||
$min_date = \DateTime::createFromFormat('Y/m/d H:i:s', $request->request->get('datemin') . ' 00:00:00');
|
|
||||||
}
|
|
||||||
if ($request->request->get('datemax')) {
|
|
||||||
$max_date = \DateTime::createFromFormat('Y/m/d H:i:s', $request->request->get('datemax') . ' 23:59:59');
|
|
||||||
}
|
|
||||||
|
|
||||||
$options->setMinDate($min_date);
|
|
||||||
$options->setMaxDate($max_date);
|
|
||||||
|
|
||||||
$databoxDateFields = array();
|
|
||||||
|
|
||||||
foreach ($databoxes as $databox) {
|
|
||||||
foreach (explode('|', $request->request->get('datefield')) as $field) {
|
|
||||||
try {
|
|
||||||
$databoxField = $databox->get_meta_structure()->get_element_by_name($field);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ($databoxField) {
|
|
||||||
$databoxDateFields[] = $databoxField;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$options->setDateFields($databoxDateFields);
|
|
||||||
$options->setSort($request->request->get('sort'), $request->request->get('ord', PHRASEA_ORDER_DESC));
|
|
||||||
$options->useStemming($request->request->get('stemme'));
|
|
||||||
|
|
||||||
$form = $options->serialize();
|
$form = $options->serialize();
|
||||||
|
|
||||||
|
119
lib/Alchemy/Phrasea/Controller/SearchEngineRequest.php
Normal file
119
lib/Alchemy/Phrasea/Controller/SearchEngineRequest.php
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2012 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Controller;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Application;
|
||||||
|
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
class SearchEngineRequest
|
||||||
|
{
|
||||||
|
private $options;
|
||||||
|
|
||||||
|
public function __construct(SearchEngineOptions $options)
|
||||||
|
{
|
||||||
|
$this->options = $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOptions()
|
||||||
|
{
|
||||||
|
return $this->options;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fromRequest(Application $app, Request $request)
|
||||||
|
{
|
||||||
|
$options = new SearchEngineOptions();
|
||||||
|
|
||||||
|
$options->disallowBusinessFields();
|
||||||
|
|
||||||
|
$bas = $app['phraseanet.user']->ACL()->get_granted_base();
|
||||||
|
|
||||||
|
if (is_array($request->request->get('bases'))) {
|
||||||
|
$bas = array_map(function($base_id) use ($app) {
|
||||||
|
return \collection::get_from_base_id($app, $base_id);
|
||||||
|
}, $request->request->get('bases'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$databoxes = array();
|
||||||
|
|
||||||
|
foreach ($bas as $collection) {
|
||||||
|
if (!isset($databoxes[$collection->get_sbas_id()])) {
|
||||||
|
$databoxes[$collection->get_sbas_id()] = $collection->get_databox();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($app['phraseanet.user']->ACL()->has_right('modifyrecord')) {
|
||||||
|
$BF = array_filter($bas, function($collection) use ($app) {
|
||||||
|
return $app['phraseanet.user']->ACL()->has_right_on_base($collection->get_base_id(), 'canmodifrecord');
|
||||||
|
});
|
||||||
|
|
||||||
|
$options->allowBusinessFieldsOn($BF);
|
||||||
|
}
|
||||||
|
|
||||||
|
$status = is_array($request->request->get('status')) ? $request->request->get('status') : array();
|
||||||
|
$fields = is_array($request->request->get('fields')) ? $request->request->get('fields') : array();
|
||||||
|
|
||||||
|
$databoxFields = array();
|
||||||
|
|
||||||
|
foreach ($databoxes as $databox) {
|
||||||
|
foreach ($fields as $field) {
|
||||||
|
try {
|
||||||
|
$databoxField = $databox->get_meta_structure()->get_element_by_name($field);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($databoxField) {
|
||||||
|
$databoxFields[] = $databoxField;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$options->setFields($databoxFields);
|
||||||
|
$options->setStatus($status);
|
||||||
|
$options->onCollections($bas);
|
||||||
|
|
||||||
|
$options->setSearchType($request->request->get('search_type'));
|
||||||
|
$options->setRecordType($request->request->get('record_type'));
|
||||||
|
|
||||||
|
$min_date = $max_date = null;
|
||||||
|
if ($request->request->get('date_min')) {
|
||||||
|
$min_date = \DateTime::createFromFormat('Y/m/d H:i:s', $request->request->get('date_min') . ' 00:00:00');
|
||||||
|
}
|
||||||
|
if ($request->request->get('date_max')) {
|
||||||
|
$max_date = \DateTime::createFromFormat('Y/m/d H:i:s', $request->request->get('date_max') . ' 23:59:59');
|
||||||
|
}
|
||||||
|
|
||||||
|
$options->setMinDate($min_date);
|
||||||
|
$options->setMaxDate($max_date);
|
||||||
|
|
||||||
|
$databoxDateFields = array();
|
||||||
|
|
||||||
|
foreach ($databoxes as $databox) {
|
||||||
|
foreach (explode('|', $request->request->get('date_field')) as $field) {
|
||||||
|
try {
|
||||||
|
$databoxField = $databox->get_meta_structure()->get_element_by_name($field);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($databoxField) {
|
||||||
|
$databoxDateFields[] = $databoxField;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$options->setDateFields($databoxDateFields);
|
||||||
|
$options->setSort($request->request->get('sort'), $request->request->get('ord', SearchEngineOptions::SORT_MODE_DESC));
|
||||||
|
$options->useStemming((Boolean) $request->request->get('stemme'));
|
||||||
|
|
||||||
|
return new static($options);
|
||||||
|
}
|
||||||
|
}
|
@@ -109,7 +109,7 @@ class SearchEngineOptions
|
|||||||
*/
|
*/
|
||||||
public function setLocale($locale)
|
public function setLocale($locale)
|
||||||
{
|
{
|
||||||
if (!preg_match('/[a-z]{2,3}/', $locale)) {
|
if ($locale && !preg_match('/[a-z]{2,3}/', $locale)) {
|
||||||
throw new \InvalidArgumentException('Locale must be a valid i18n code');
|
throw new \InvalidArgumentException('Locale must be a valid i18n code');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -501,7 +501,7 @@ class SearchEngineOptions
|
|||||||
throw new \InvalidArgumentException('SearchEngineOptions data are corrupted');
|
throw new \InvalidArgumentException('SearchEngineOptions data are corrupted');
|
||||||
}
|
}
|
||||||
|
|
||||||
$options = new SearchEngineOptions();
|
$options = new static();
|
||||||
$options->disallowBusinessFields();
|
$options->disallowBusinessFields();
|
||||||
|
|
||||||
foreach ($serialized as $key => $value) {
|
foreach ($serialized as $key => $value) {
|
||||||
|
@@ -9,11 +9,11 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Controller\SearchEngineRequest;
|
||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
use Alchemy\Phrasea\Border\File;
|
use Alchemy\Phrasea\Border\File;
|
||||||
use Alchemy\Phrasea\Border\Attribute\Status;
|
use Alchemy\Phrasea\Border\Attribute\Status;
|
||||||
use Alchemy\Phrasea\Border\Manager as BorderManager;
|
use Alchemy\Phrasea\Border\Manager as BorderManager;
|
||||||
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1010,10 +1010,10 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$this->app['phraseanet.SE']->setOptions($options);
|
$this->app['phraseanet.SE']->setOptions($options);
|
||||||
$this->app['phraseanet.SE']->resetCache();
|
$this->app['phraseanet.SE']->resetCache();
|
||||||
|
|
||||||
$search_result = $this->app['phraseanet.SE']->query($params['query'], $params["offset_start"], $perPage);
|
$search_result = $this->app['phraseanet.SE']->query($request->get('query'), $offsetStart, $perPage);
|
||||||
|
|
||||||
$ret = array(
|
$ret = array(
|
||||||
'offset_start' => $params["offset_start"],
|
'offset_start' => $offsetStart,
|
||||||
'per_page' => $perPage,
|
'per_page' => $perPage,
|
||||||
'available_results' => $search_result->available(),
|
'available_results' => $search_result->available(),
|
||||||
'total_results' => $search_result->total(),
|
'total_results' => $search_result->total(),
|
||||||
|
@@ -116,12 +116,12 @@ class phrasea
|
|||||||
$parm["sel"] = '';
|
$parm["sel"] = '';
|
||||||
$parm["ord"] = null;
|
$parm["ord"] = null;
|
||||||
$parm["search_type"] = 0;
|
$parm["search_type"] = 0;
|
||||||
$parm["recordtype"] = '';
|
$parm["record_type"] = '';
|
||||||
$parm["status"] = array();
|
$parm["status"] = array();
|
||||||
$parm["fields"] = array();
|
$parm["fields"] = array();
|
||||||
$parm["datemin"] = '';
|
$parm["date_min"] = '';
|
||||||
$parm["datemax"] = '';
|
$parm["date_max"] = '';
|
||||||
$parm["datefield"] = '';
|
$parm["date_field"] = '';
|
||||||
}
|
}
|
||||||
if ($context == "client") {
|
if ($context == "client") {
|
||||||
$parm["mod"] = $app['phraseanet.user']->getPrefs('client_view');
|
$parm["mod"] = $app['phraseanet.user']->getPrefs('client_view');
|
||||||
@@ -133,10 +133,10 @@ class phrasea
|
|||||||
$parm["opAdv"] = array();
|
$parm["opAdv"] = array();
|
||||||
$parm["status"] = '';
|
$parm["status"] = '';
|
||||||
$parm["nba"] = '';
|
$parm["nba"] = '';
|
||||||
$parm["datemin"] = '';
|
$parm["date_min"] = '';
|
||||||
$parm["datemax"] = '';
|
$parm["date_max"] = '';
|
||||||
$parm["recordtype"] = '';
|
$parm["record_type"] = '';
|
||||||
$parm["datefield"] = '';
|
$parm["date_field"] = '';
|
||||||
$parm["sort"] = $app['phraseanet.registry']->get('GV_phrasea_sort');
|
$parm["sort"] = $app['phraseanet.registry']->get('GV_phrasea_sort');
|
||||||
$parm["stemme"] = '';
|
$parm["stemme"] = '';
|
||||||
$parm["dateminfield"] = array();
|
$parm["dateminfield"] = array();
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
onclick="cancelEvent(event);return false;"
|
onclick="cancelEvent(event);return false;"
|
||||||
onmousedown="infoSbas(this, {{sbas_id}}, false, event); return false;"
|
onmousedown="infoSbas(this, {{sbas_id}}, false, event); return false;"
|
||||||
id="ck_{{collection["base_id"]}}_{{unique_id}}" type="checkbox"
|
id="ck_{{collection["base_id"]}}_{{unique_id}}" type="checkbox"
|
||||||
name="bas[]" value="{{collection["base_id"]}}" {% if collection["selected"] %}checked="checked"{% endif %} />
|
name="bases[]" value="{{collection["base_id"]}}" {% if collection["selected"] %}checked="checked"{% endif %} />
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@@ -308,7 +308,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<input type="hidden" value="0" name="search_type" />
|
<input type="hidden" value="0" name="search_type" />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<select name="recordtype" id="recordtype_sel" class="input-small">
|
<select name="record_type" id="recordtype_sel" class="input-small">
|
||||||
<option value="">{% trans 'Tout type' %}</option>
|
<option value="">{% trans 'Tout type' %}</option>
|
||||||
<option value="image">{% trans 'Image' %}</option>
|
<option value="image">{% trans 'Image' %}</option>
|
||||||
<option value="video">{% trans 'Video' %}</option>
|
<option value="video">{% trans 'Video' %}</option>
|
||||||
@@ -412,7 +412,7 @@
|
|||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<select name="datefield" class="input-medium">
|
<select name="date_field" class="input-medium">
|
||||||
{% for field in app['phraseanet.SE'].getAvailableDateFields() %}
|
{% for field in app['phraseanet.SE'].getAvailableDateFields() %}
|
||||||
<option onchange="checkFilters(true);"
|
<option onchange="checkFilters(true);"
|
||||||
class="" value="{{ field }}">{{ field }}</option>
|
class="" value="{{ field }}">{{ field }}</option>
|
||||||
@@ -426,11 +426,11 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td style="padding-right: 5px;">
|
<td style="padding-right: 5px;">
|
||||||
<span>{% trans 'phraseanet::time:: de' %}</span><br />
|
<span>{% trans 'phraseanet::time:: de' %}</span><br />
|
||||||
<input onchange="checkFilters(true);" class="datepicker input-medium" type="text" name="datemin" style="height: 18px;" />
|
<input onchange="checkFilters(true);" class="datepicker input-medium" type="text" name="date_min" style="height: 18px;" />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span>{% trans 'phraseanet::time:: a' %}</span><br />
|
<span>{% trans 'phraseanet::time:: a' %}</span><br />
|
||||||
<input onchange="checkFilters(true);" class="datepicker input-medium" type="text" name="datemax" style="height: 18px;" />
|
<input onchange="checkFilters(true);" class="datepicker input-medium" type="text" name="date_max" style="height: 18px;" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@@ -776,7 +776,7 @@ function CXdblClick(e)
|
|||||||
function doThesSearch(type, sbid, term, field)
|
function doThesSearch(type, sbid, term, field)
|
||||||
{
|
{
|
||||||
var nck = 0;
|
var nck = 0;
|
||||||
$('#adv_search input[name="bas[]"]').each(
|
$('#adv_search input[name="bases[]"]').each(
|
||||||
function(i,n)
|
function(i,n)
|
||||||
{
|
{
|
||||||
var base_id = $(n).val();
|
var base_id = $(n).val();
|
||||||
|
@@ -9,7 +9,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
|
use Alchemy\Phrasea\Controller\SearchEngineRequest;
|
||||||
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
|
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -20,16 +22,17 @@ use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
|
|||||||
require_once __DIR__ . "/../../lib/bootstrap.php";
|
require_once __DIR__ . "/../../lib/bootstrap.php";
|
||||||
|
|
||||||
$app = new Application();
|
$app = new Application();
|
||||||
|
$request = Request::createFromGlobals();
|
||||||
|
|
||||||
if ( ! isset($parm)) {
|
if ( ! isset($parm)) {
|
||||||
|
|
||||||
$request = http_request::getInstance();
|
$http_request = http_request::getInstance();
|
||||||
$parm = $request->get_parms("mod", "bas"
|
$parm = $http_request->get_parms("mod", "bases"
|
||||||
, "pag"
|
, "pag"
|
||||||
, "qry", "search_type", "recordtype"
|
, "qry", "search_type", "record_type"
|
||||||
, "qryAdv", 'opAdv', 'status', 'datemin', 'datemax'
|
, "qryAdv", 'opAdv', 'status', 'date_min', 'date_max'
|
||||||
, 'dateminfield', 'datemaxfield'
|
, 'dateminfield', 'datemaxfield'
|
||||||
, 'datefield'
|
, 'date_field'
|
||||||
, 'sort'
|
, 'sort'
|
||||||
, 'stemme'
|
, 'stemme'
|
||||||
, 'infield'
|
, 'infield'
|
||||||
@@ -58,7 +61,7 @@ if ($qry == '')
|
|||||||
$parm['qry'] = $qry;
|
$parm['qry'] = $qry;
|
||||||
|
|
||||||
$qrySbas = array();
|
$qrySbas = array();
|
||||||
if (is_null($parm['bas'])) {
|
if (is_null($parm['bases'])) {
|
||||||
echo 'vous devez selectionner des collections dans lesquelles chercher';
|
echo 'vous devez selectionner des collections dans lesquelles chercher';
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -80,94 +83,8 @@ $mod_xy = $mod_col * $mod_row;
|
|||||||
|
|
||||||
$tbases = array();
|
$tbases = array();
|
||||||
|
|
||||||
$options = new SearchEngineOptions();
|
$searchRequest = SearchEngineRequest::fromRequest($app, $request);
|
||||||
$options->disallowBusinessFields();
|
$options = $searchRequest->getOptions();
|
||||||
|
|
||||||
$bas = $app['phraseanet.user']->ACL()->get_granted_base();
|
|
||||||
|
|
||||||
if (is_array($parm['bas'])) {
|
|
||||||
$bas = array_map(function($base_id) use ($app) {
|
|
||||||
return \collection::get_from_base_id($app, $base_id);
|
|
||||||
}, $parm['bas']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$databoxes = array();
|
|
||||||
|
|
||||||
foreach ($bas as $collection) {
|
|
||||||
if (!isset($databoxes[$collection->get_sbas_id()])) {
|
|
||||||
$databoxes[$collection->get_sbas_id()] = $collection->get_databox();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($app['phraseanet.user']->ACL()->has_right('modifyrecord')) {
|
|
||||||
$BF = array_filter($bas, function($collection) use ($app) {
|
|
||||||
return $app['phraseanet.user']->ACL()->has_right_on_base($collection->get_base_id(), 'canmodifrecord');
|
|
||||||
});
|
|
||||||
|
|
||||||
$options->allowBusinessFieldsOn($BF);
|
|
||||||
}
|
|
||||||
|
|
||||||
$status = is_array($parm['status']) ? $parm['status'] : array();
|
|
||||||
$fields = is_array($parm['infield']) ? $parm['infield'] : array();
|
|
||||||
|
|
||||||
$databoxFields = array();
|
|
||||||
|
|
||||||
foreach ($databoxes as $databox) {
|
|
||||||
foreach ($fields as $field) {
|
|
||||||
try {
|
|
||||||
$databoxField = $databox->get_meta_structure()->get_element_by_name($field);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ($databoxField) {
|
|
||||||
$databoxFields[] = $databoxField;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$options->setFields($databoxFields);
|
|
||||||
$options->setStatus($status);
|
|
||||||
$options->onCollections($bas);
|
|
||||||
|
|
||||||
$options->setSearchType($parm['search_type']);
|
|
||||||
$options->setRecordType($parm['recordtype']);
|
|
||||||
|
|
||||||
$min_date = $max_date = null;
|
|
||||||
if ($parm['datemin']) {
|
|
||||||
$min_date = \DateTime::createFromFormat('Y/m/d H:i:s', $parm['datemin'] . ' 00:00:00');
|
|
||||||
}
|
|
||||||
if ($parm['datemax']) {
|
|
||||||
$max_date = \DateTime::createFromFormat('Y/m/d H:i:s', $parm['datemax'] . ' 23:59:59');
|
|
||||||
}
|
|
||||||
|
|
||||||
$options->setMinDate($min_date);
|
|
||||||
$options->setMaxDate($max_date);
|
|
||||||
|
|
||||||
|
|
||||||
$databoxDateFields = array();
|
|
||||||
|
|
||||||
foreach ($databoxes as $databox) {
|
|
||||||
foreach (explode('|', $parm['datefield']) as $field) {
|
|
||||||
try {
|
|
||||||
$databoxField = $databox->get_meta_structure()->get_element_by_name($field);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ($databoxField) {
|
|
||||||
$databoxDateFields[] = $databoxField;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($parm['ord'] === NULL)
|
|
||||||
$parm['ord'] = \searchEngine_options::SORT_MODE_DESC;
|
|
||||||
else
|
|
||||||
$parm['ord'] = (int) $parm['ord'];
|
|
||||||
|
|
||||||
$options->setDateFields($databoxDateFields);
|
|
||||||
$options->setSort($parm['sort'], $parm['ord']);
|
|
||||||
$options->useStemming($parm['stemme']);
|
|
||||||
|
|
||||||
$form = $options->serialize();
|
$form = $options->serialize();
|
||||||
|
|
||||||
|
@@ -224,7 +224,7 @@ if ($app['phraseanet.registry']->get('GV_client_coll_ckbox') === 'popup') {
|
|||||||
$allbcol[] = $coll->get_base_id();
|
$allbcol[] = $coll->get_base_id();
|
||||||
$n_allbcol ++;
|
$n_allbcol ++;
|
||||||
|
|
||||||
echo '<input style="display:none;" checked="checked" type="checkbox" class="basItem checkbox basItem' . $databox->get_sbas_id() . '" name="bas[]" value="' . $coll->get_base_id() . '" id="basChk' . $coll->get_base_id() . '" />';
|
echo '<input style="display:none;" checked="checked" type="checkbox" class="basItem checkbox basItem' . $databox->get_sbas_id() . '" name="bases[]" value="' . $coll->get_base_id() . '" id="basChk' . $coll->get_base_id() . '" />';
|
||||||
|
|
||||||
$options .= '<option value="' . $coll->get_base_id() . '" checked="checked" >' . $coll->get_name() . '</option>';
|
$options .= '<option value="' . $coll->get_base_id() . '" checked="checked" >' . $coll->get_name() . '</option>';
|
||||||
|
|
||||||
@@ -392,9 +392,9 @@ if ($app['phraseanet.registry']->get('GV_thesaurus')) {
|
|||||||
'</td></tr>' .
|
'</td></tr>' .
|
||||||
'<tr><td style="width:50%;">' .
|
'<tr><td style="width:50%;">' .
|
||||||
'<input type="hidden" name="dateminfield[]" value="' . $databox->get_sbas_id() . '_' . $f . '">' .
|
'<input type="hidden" name="dateminfield[]" value="' . $databox->get_sbas_id() . '_' . $f . '">' .
|
||||||
' <input db="' . $databox->get_sbas_id() . '" onchange="checkFilters();" class="datepicker" type="text" name="datemin[]"></td><td style="width:50%;">' .
|
' <input db="' . $databox->get_sbas_id() . '" onchange="checkFilters();" class="datepicker" type="text" name="date_min[]"></td><td style="width:50%;">' .
|
||||||
'<input type="hidden" name="datemaxfield[]" value="' . $databox->get_sbas_id() . '_' . $f . '">' .
|
'<input type="hidden" name="datemaxfield[]" value="' . $databox->get_sbas_id() . '_' . $f . '">' .
|
||||||
' <input db="' . $databox->get_sbas_id() . '" onchange="checkFilters();" class="datepicker" type="text" name="datemax[]"></td></tr>' .
|
' <input db="' . $databox->get_sbas_id() . '" onchange="checkFilters();" class="datepicker" type="text" name="date_max[]"></td></tr>' .
|
||||||
'</table>' .
|
'</table>' .
|
||||||
'</div>';
|
'</div>';
|
||||||
} elseif ($field['type'] != 'date') {
|
} elseif ($field['type'] != 'date') {
|
||||||
@@ -422,7 +422,7 @@ if ($app['phraseanet.registry']->get('GV_thesaurus')) {
|
|||||||
?><div class="basGrp"><?php
|
?><div class="basGrp"><?php
|
||||||
foreach ($user->ACL()->get_granted_base(array(), array($databox->get_sbas_id())) as $coll) {
|
foreach ($user->ACL()->get_granted_base(array(), array($databox->get_sbas_id())) as $coll) {
|
||||||
$s = "checked";
|
$s = "checked";
|
||||||
echo '<div><input type="checkbox" class="checkbox basItem basItem' . $databox->get_sbas_id() . '" ' . $s . ' name="bas[]" id="basChk' . $coll->get_base_id() . '" value="' . $coll->get_base_id() . '"><label for="basChk' . $coll->get_base_id() . '">' . $coll->get_name() . '</label></div>';
|
echo '<div><input type="checkbox" class="checkbox basItem basItem' . $databox->get_sbas_id() . '" ' . $s . ' name="bases[]" id="basChk' . $coll->get_base_id() . '" value="' . $coll->get_base_id() . '"><label for="basChk' . $coll->get_base_id() . '">' . $coll->get_name() . '</label></div>';
|
||||||
}
|
}
|
||||||
?></div><?php
|
?></div><?php
|
||||||
if ($app['phraseanet.registry']->get('GV_view_bas_and_coll'))
|
if ($app['phraseanet.registry']->get('GV_view_bas_and_coll'))
|
||||||
|
@@ -265,9 +265,9 @@ function checkFilters(save)
|
|||||||
$('.status_filter', adv_box) .addClass('danger');
|
$('.status_filter', adv_box) .addClass('danger');
|
||||||
});
|
});
|
||||||
|
|
||||||
search.dates.minbound = $('.date_filter input[name=datemin]', adv_box).val();
|
search.dates.minbound = $('.date_filter input[name=date_min]', adv_box).val();
|
||||||
search.dates.maxbound = $('.date_filter input[name=datemax]', adv_box).val();
|
search.dates.maxbound = $('.date_filter input[name=date_max]', adv_box).val();
|
||||||
search.dates.field = $('.date_filter select[name=datefield]', adv_box).val();
|
search.dates.field = $('.date_filter select[name=date_field]', adv_box).val();
|
||||||
|
|
||||||
if($.trim(search.dates.minbound) || $.trim(search.dates.maxbound))
|
if($.trim(search.dates.minbound) || $.trim(search.dates.maxbound))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user