mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
Merge remote-tracking branch 'upstream/master' into 20150306-elastic-indexer
Conflicts: bin/console bower.json composer.json composer.lock lib/Alchemy/Phrasea/Application.php lib/Alchemy/Phrasea/Border/Manager.php lib/Alchemy/Phrasea/Controller/Api/V1.php lib/Alchemy/Phrasea/Core/PhraseaEvents.php lib/Alchemy/Phrasea/SearchEngine/SearchEngineOptions.php lib/classes/caption/field.php lib/classes/record/Interface.php templates/web/prod/index.html.twig www/skins/prod/000000/prodcolor.css
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -367,10 +367,6 @@ class PhraseaEngine implements SearchEngineInterface
|
||||
$query = "all";
|
||||
}
|
||||
|
||||
if ($options->getRecordType()) {
|
||||
$query .= ' AND recordtype=' . $options->getRecordType();
|
||||
}
|
||||
|
||||
$sql = 'SELECT query, query_time, duration, total FROM cache WHERE session_id = :ses_id';
|
||||
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute([':ses_id' => $this->app['session']->get('phrasea_session_id')]);
|
||||
@@ -647,6 +643,18 @@ class PhraseaEngine implements SearchEngineInterface
|
||||
*/
|
||||
private function addQuery($query, SearchEngineOptions $options)
|
||||
{
|
||||
if ($options->getFields()) {
|
||||
$fields = array_map(function (\databox_field $field) {
|
||||
return $field->get_name();
|
||||
}, $options->getFields());
|
||||
if(count($fields) == 1) {
|
||||
$query .= ' IN ' . $fields[0];
|
||||
}
|
||||
else if(count($fields) > 1) {
|
||||
$query .= ' IN (' . implode(' OR ', $fields) . ')';
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($options->getDataboxes() as $databox) {
|
||||
$this->queries[$databox->get_sbas_id()] = $query;
|
||||
}
|
||||
@@ -654,44 +662,54 @@ class PhraseaEngine implements SearchEngineInterface
|
||||
$status = $options->getStatus();
|
||||
|
||||
foreach ($this->queries as $sbas => $qs) {
|
||||
if ($status) {
|
||||
$requestStat = 'xxxx';
|
||||
$clauses = array();
|
||||
|
||||
for ($i = 4; ($i <= 32); $i++) {
|
||||
if (!isset($status[$i])) {
|
||||
$requestStat = 'x' . $requestStat;
|
||||
continue;
|
||||
}
|
||||
// the main query
|
||||
$clauses[] = $query;
|
||||
|
||||
// status
|
||||
if ($status) {
|
||||
$requestStat = '';
|
||||
for ($i = 31; $i >= 4; $i--) {
|
||||
$val = 'x';
|
||||
if (isset($status[$i][$sbas])) {
|
||||
if (isset($status[$i]) && isset($status[$i][$sbas])) {
|
||||
if ($status[$i][$sbas] == '0') {
|
||||
$val = '0';
|
||||
} elseif ($status[$i][$sbas] == '1') {
|
||||
$val = '1';
|
||||
}
|
||||
}
|
||||
$requestStat = $val . $requestStat;
|
||||
$requestStat .= $val;
|
||||
}
|
||||
|
||||
$requestStat = ltrim($requestStat, 'x');
|
||||
$requestStat = ltrim($requestStat.'xxxx', 'x');
|
||||
|
||||
if ($requestStat !== '') {
|
||||
$this->queries[$sbas] .= ' AND (recordstatus=' . $requestStat . ')';
|
||||
$clauses[] = 'recordstatus=' . $requestStat . '';
|
||||
}
|
||||
}
|
||||
if ($options->getFields()) {
|
||||
$this->queries[$sbas] .= ' IN (' . implode(' OR ', array_map(function (\databox_field $field) {
|
||||
return $field->get_name();
|
||||
}, $options->getFields())) . ')';
|
||||
}
|
||||
|
||||
// date
|
||||
if (($options->getMinDate() || $options->getMaxDate()) && $options->getDateFields()) {
|
||||
if ($options->getMinDate()) {
|
||||
$this->queries[$sbas] .= ' AND ( ' . implode(' >= ' . $options->getMinDate()->format('Y-m-d') . ' OR ', array_map(function (\databox_field $field) { return $field->get_name(); }, $options->getDateFields())) . ' >= ' . $options->getMinDate()->format('Y-m-d') . ' ) ';
|
||||
$clauses[] = implode(' >= ' . $options->getMinDate()->format('Y-m-d') . ' OR ', array_map(function (\databox_field $field) { return $field->get_name(); }, $options->getDateFields())) . ' >= ' . $options->getMinDate()->format('Y-m-d');
|
||||
}
|
||||
if ($options->getMaxDate()) {
|
||||
$this->queries[$sbas] .= ' AND ( ' . implode(' <= ' . $options->getMaxDate()->format('Y-m-d') . ' OR ', array_map(function (\databox_field $field) { return $field->get_name(); }, $options->getDateFields())) . ' <= ' . $options->getMaxDate()->format('Y-m-d') . ' ) ';
|
||||
$clauses[] = implode(' <= ' . $options->getMaxDate()->format('Y-m-d') . ' OR ', array_map(function (\databox_field $field) { return $field->get_name(); }, $options->getDateFields())) . ' <= ' . $options->getMaxDate()->format('Y-m-d');
|
||||
}
|
||||
}
|
||||
|
||||
// record type
|
||||
if ($options->getRecordType()) {
|
||||
$clauses[] = 'recordtype=' . $options->getRecordType();
|
||||
}
|
||||
|
||||
// join clauses to build a query
|
||||
if(count($clauses) == 1) {
|
||||
$this->queries[$sbas] = $clauses[0];
|
||||
}
|
||||
else{
|
||||
$this->queries[$sbas] = '(' . join(') AND (', $clauses) . ')';
|
||||
}
|
||||
}
|
||||
|
||||
$this->singleParse('main', $query, $options);
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -729,8 +729,11 @@ class PhraseaEngineQueryParser
|
||||
$prophtml = "";
|
||||
$this->propAsHTML($domthe->documentElement, $prophtml, $path);
|
||||
$this->proposals["BASES"]["b$bid"]["TERMS"][$path]["HTML"] = $prophtml;
|
||||
} else {
|
||||
$tree = NULL;
|
||||
}
|
||||
|
||||
|
||||
return($ambigus);
|
||||
}
|
||||
|
||||
@@ -1767,7 +1770,7 @@ class PhraseaEngineQueryParser
|
||||
$c_utf8 = "";
|
||||
for ($i = 0; $i < $l; $i++) {
|
||||
if (!$this->app['unicode']->has_indexer_bad_char(($c_utf8 = mb_substr($this->phq, $i, 1, 'UTF-8')))) {
|
||||
$t .= $this->app['unicode']->remove_diacritics(mb_strtolower($c_utf8));
|
||||
$t .= mb_strtolower($c_utf8);
|
||||
} else
|
||||
break;
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -34,12 +34,12 @@ class PhraseaEngineSubscriber implements EventSubscriberInterface
|
||||
|
||||
public function onCollectionCreate(CreatedEvent $event)
|
||||
{
|
||||
$sql = 'SELECT u.usr_id, c.session_id
|
||||
FROM (usr u, Sessions s, basusr b)
|
||||
LEFT JOIN cache c ON (c.usr_id = u.usr_id)
|
||||
WHERE u.model_of = 0 AND u.usr_login NOT LIKE "(#deleted%"
|
||||
AND b.base_id = :base_id AND b.usr_id = u.usr_id AND b.actif=1
|
||||
AND s.usr_id = u.usr_id';
|
||||
$sql = 'SELECT Users.id, c.session_id
|
||||
FROM (Users, Sessions s, basusr b)
|
||||
LEFT JOIN cache c ON (c.usr_id = Users.id)
|
||||
WHERE Users.model_of = 0 AND Users.deleted = 0
|
||||
AND b.base_id = :base_id AND b.usr_id = Users.id AND b.actif=1
|
||||
AND s.usr_id = Users.id';
|
||||
|
||||
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute([':base_id' => $event->getCollection()->get_base_id()]);
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -622,11 +622,14 @@ class SearchEngineOptions
|
||||
}
|
||||
|
||||
$bas = array_filter($bas, function ($collection) use ($app) {
|
||||
if ($app['authentication']->isAuthenticated()) {
|
||||
return $app['acl']->get($app['authentication']->getUser())->has_access_to_base($collection->get_base_id());
|
||||
} else {
|
||||
return in_array($collection, $app->getOpenCollections());
|
||||
if($collection !== null) {
|
||||
if ($app['authentication']->isAuthenticated()) {
|
||||
return $app['acl']->get($app['authentication']->getUser())->has_access_to_base($collection->get_base_id());
|
||||
} else {
|
||||
return in_array($collection, $app->getOpenCollections());
|
||||
}
|
||||
}
|
||||
return false; // CollectionNotFound
|
||||
});
|
||||
|
||||
$databoxes = [];
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
Reference in New Issue
Block a user