Merge branch '3.8'

Conflicts:
	lib/Alchemy/Phrasea/Controller/Prod/Export.php
	lib/Alchemy/Phrasea/Core/Version.php
	lib/Alchemy/Phrasea/Helper/Prod.php
	lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php
	lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php
	lib/classes/User/Adapter.php
	lib/classes/caption/Field/Value.php
	lib/classes/collection.php
	lib/classes/module/report/filter.php
	lib/classes/task/period/ftp.php
	templates/web/common/dialog_export.html.twig
	templates/web/report/ajax_dashboard_content_child.html.twig
	tests/Alchemy/Tests/Phrasea/Controller/Admin/UsersTest.php
This commit is contained in:
Romain Neutron
2013-12-18 12:12:58 +01:00
44 changed files with 389 additions and 170 deletions

View File

@@ -76,6 +76,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
'warning_on_delete_story' => 'true',
'client_basket_status' => '1',
'css' => '000000',
'advanced_search_reload' => '1',
'start_page_query' => 'last',
'start_page' => 'QUERY',
'rollover_thumbnail' => 'caption',
@@ -1037,16 +1038,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
return $this;
}
$sql = 'SELECT prop, value FROM usr_settings WHERE usr_id= :id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute([':id' => $this->id]);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $row) {
$this->_prefs[$row['prop']] = $row['value'];
}
foreach (self::$def_values as $k => $v) {
if (!isset($this->_prefs[$k])) {
if ($k == 'start_page_query' && $this->app['phraseanet.registry']->get('GV_defaultQuery')) {
@@ -1068,6 +1059,16 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
);
}
$sql = 'SELECT prop, value FROM usr_settings WHERE usr_id= :id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute([':id' => $this->id]);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $row) {
$this->_prefs[$row['prop']] = $row['value'];
}
$this->preferences_loaded = true;
return $this;

View File

@@ -315,7 +315,7 @@ class User_Query implements User_QueryInterface
}
if ($this->last_model) {
$sql .= ' AND usr.lastModel = "' . mysql_real_escape_string($this->last_model) . '" ';
$sql .= ' AND usr.lastModel = ' . $this->app['phraseanet.appbox']->get_connection()->quote($this->last_model) . ' ';
}
$sql_like = [];

View File

@@ -0,0 +1,47 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class ThesaurusValue
{
/** @var string */
private $value;
/** @var \databox_field */
private $field;
/** @var string */
private $query;
public function __construct($value, \databox_field $field, $query)
{
$this->value = $value;
$this->field = $field;
$this->query = $query;
}
public function getValue()
{
return $this->value;
}
public function getField()
{
return $this->field;
}
public function getQuery()
{
return $this->query;
}
public function __toString()
{
return $this->value;
}
}

View File

@@ -346,73 +346,45 @@ class caption_Field_Value implements cache_cacheableInterface
return $value;
}
$DOM_branchs = $XPATH_thesaurus->query($tbranch);
$fvalue = $value;
$cleanvalue = str_replace(["<em>", "</em>", "'"], ["", "", "&apos;"], $fvalue);
// ---------------- new code ----------------------
$cleanvalue = str_replace(array("[[em]]", "[[/em]]", "'"), array("", "", "&apos;"), $value);
list($term_noacc, $context_noacc) = $this->splitTermAndContext($cleanvalue);
$term_noacc = $this->app['unicode']->remove_indexer_chars($term_noacc);
$context_noacc = $this->app['unicode']->remove_indexer_chars($context_noacc);
// find all synonyms in all related branches
$q = "(" . $tbranch . ")//sy[@w='" . $term_noacc . "'";
if ($context_noacc) {
$q = "//sy[@w='" . $term_noacc . "' and @k='" . $context_noacc . "']";
$q .= " and @k='" . $context_noacc . "']";
} else {
$q = "//sy[@w='" . $term_noacc . "' and not(@k)]";
$q .= " and not(@k)]";
}
$qjs = $link = "";
$q .= "/../sy";
// loop on each linked branch for field
foreach ($DOM_branchs as $DOM_branch) {
$nodes = $XPATH_thesaurus->cache_query($q, $DOM_branch);
$lngfound = false;
foreach ($nodes as $node) {
if ($node->getAttribute("lng") == $this->app['locale']) {
// le terme est dans la bonne langue, on le rend cliquable
list($term, $context) = $this->splitTermAndContext($fvalue);
$term = str_replace(["<em>", "</em>"], ["", ""], $term);
$context = str_replace(["<em>", "</em>"], ["", ""], $context);
$qjs = $term;
if ($context) {
$qjs .= " [" . $context . "]";
}
$link = $fvalue;
$nodes = $XPATH_thesaurus->query($q);
$lngfound = true;
break;
}
$synonyms = $XPATH_thesaurus->query("sy[@lng='" . $this->app['locale'] . "']", $node->parentNode);
foreach ($synonyms as $synonym) {
$k = $synonym->getAttribute("k");
if ($synonym->getAttribute("w") != $term_noacc || $k != $context_noacc) {
$link = $qjs = $synonym->getAttribute("v");
$lngfound = true;
break;
}
}
}
if (! $lngfound) {
list($term, $context) = $this->splitTermAndContext($fvalue);
$term = str_replace(["<em>", "</em>"], ["", ""], $term);
$context = str_replace(["<em>", "</em>"], ["", ""], $context);
$qjs = $term;
if ($context) {
$qjs .= " [" . $context . "]";
}
$link = $fvalue;
// loop on every sy found
$bestnode = null;
$bestnote = 0;
foreach ($nodes as $node) {
$note = 0;
$note += ($node->getAttribute("lng") == $this->app['locale.I18n']) ? 4 : 0;
$note += ($node->getAttribute("w") == $term_noacc) ? 2 : 0;
if($context_noacc != "")
$note += ($node->getAttribute("k") == $context_noacc) ? 1 : 0;
if($note > $bestnote)
{
$bestnote = $note;
$bestnode = $node;
}
}
if($bestnode)
{
list($term, $context) = $this->splitTermAndContext(str_replace(array("[[em]]", "[[/em]]"), array("", ""), $value));
$qjs = $term . ($context ? '['.$context.']' : '');
if ($qjs) {
$value = "<a class=\"bounce\" onclick=\"bounce('" . $databox->get_sbas_id() . "','"
. str_replace("'", "\'", $qjs)
. "', '"
. str_replace("'", "\'", $this->databox_field->get_name())
. "');return(false);\">"
. $link
. "</a>";
$value = new ThesaurusValue($bestnode->getAttribute('v'), $this->databox_field, $qjs);
}
return $value;

View File

@@ -560,6 +560,12 @@ class collection implements cache_cacheableInterface
</sugestedValues>
</baseprefs>';
$sql = "SELECT GREATEST(0, MAX(ord)) + 1 AS ord FROM bas WHERE sbas_id = :sbas_id";
$stmt = $conn->prepare($sql);
$stmt->execute(array(':sbas_id' => $sbas_id));
$ord = $stmt->fetch(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
$sql = "INSERT INTO coll (coll_id, asciiname, prefs, logo)
VALUES (null, :name, :prefs, '')";
@@ -574,11 +580,15 @@ class collection implements cache_cacheableInterface
$new_id = (int) $connbas->lastInsertId();
$sql = "INSERT INTO bas (base_id, active, server_coll_id, sbas_id, aliases)
$sql = "INSERT INTO bas (base_id, active, ord, server_coll_id, sbas_id, aliases)
VALUES
(null, 1, :server_coll_id, :sbas_id, '')";
(null, 1, :ord, :server_coll_id, :sbas_id, '')";
$stmt = $conn->prepare($sql);
$stmt->execute([':server_coll_id' => $new_id, ':sbas_id' => $sbas_id]);
$stmt->execute([
':server_coll_id' => $new_id,
':sbas_id' => $sbas_id,
':ord' => $ord['ord'] ?: 1,
]);
$stmt->closeCursor();
$new_bas = $conn->lastInsertId();
@@ -633,7 +643,7 @@ class collection implements cache_cacheableInterface
VALUES
(null, 1, :server_coll_id, :sbas_id, '')";
$stmt = $databox->get_appbox()->get_connection()->prepare($sql);
$stmt->execute([':server_coll_id' => $coll_id, ':sbas_id' => $sbas_id]);
$stmt->execute([':server_coll_id' => $coll_id, ':sbas_id' => $databox->get_sbas_id()]);
$stmt->closeCursor();
$new_bas = $databox->get_appbox()->get_connection()->lastInsertId();
@@ -641,7 +651,7 @@ class collection implements cache_cacheableInterface
$databox->delete_data_from_cache(databox::CACHE_COLLECTIONS);
cache_databox::update($app, $sbas_id, 'structure');
cache_databox::update($app, $databox->get_sbas_id(), 'structure');
phrasea::reset_baseDatas($databox->get_appbox());

View File

@@ -228,7 +228,7 @@ class ftpclient
{
$ret = @ftp_nb_put($this->connexion, $remotefile, $localfile, FTP_BINARY, $start);
while ($ret == FTP_MOREDATA) {
while ($ret === FTP_MOREDATA) {
set_time_limit(20);
$ret = ftp_nb_continue($this->connexion);
}
@@ -280,7 +280,7 @@ class ftpclient
$ret = @ftp_nb_get($this->connexion, $localfile, $remotefile, FTP_BINARY, $start);
while ($ret == FTP_MOREDATA) {
while ($ret === FTP_MOREDATA) {
set_time_limit(20);
$ret = ftp_nb_continue($this->connexion);
}

View File

@@ -11,10 +11,10 @@
use Alchemy\Phrasea\Application;
class patch_381alpha1a implements patchInterface
class patch_383alpha3a implements patchInterface
{
/** @var string */
private $release = '3.8.1-alpha.1';
private $release = '3.8.3-alpha.3';
/** @var array */
private $concern = [base::APPLICATION_BOX];