mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 11:33:17 +00:00
Refactor caption_field
This commit is contained in:
@@ -1080,7 +1080,10 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$ret = array();
|
$ret = array();
|
||||||
foreach ($caption->get_fields() as $field)
|
foreach ($caption->get_fields() as $field)
|
||||||
{
|
{
|
||||||
$ret[$field->get_meta_id()] = $this->list_record_caption_field($field);
|
foreach($field->get_values as $value)
|
||||||
|
{
|
||||||
|
$ret[$value->getId()] = $this->list_record_caption_field($value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
@@ -1092,17 +1095,17 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
* @param caption_field $field
|
* @param caption_field $field
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function list_record_caption_field(caption_field $field)
|
protected function list_record_caption_field(caption_Field_Value $value, caption_field $field)
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @todo ajouter une option pour avoir les values serialisées
|
* @todo ajouter une option pour avoir les values serialisées
|
||||||
* dans un cas multi
|
* dans un cas multi
|
||||||
*/
|
*/
|
||||||
return array(
|
return array(
|
||||||
'meta_id' => $field->get_meta_id()
|
'meta_id' => $value->getId()
|
||||||
, 'meta_structure_id' => $field->get_meta_struct_id()
|
, 'meta_structure_id' => $field->get_meta_struct_id()
|
||||||
, 'name' => $field->get_name()
|
, 'name' => $field->get_name()
|
||||||
, 'value' => $field->get_value()
|
, 'value' => $value->getValue()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -235,7 +235,7 @@ abstract class Feed_XML_Abstract
|
|||||||
$title_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Title);
|
$title_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Title);
|
||||||
if ($title_field)
|
if ($title_field)
|
||||||
{
|
{
|
||||||
$str_title = $title_field->get_value(true, ' ');
|
$str_title = $title_field->get_serialized_values(' ');
|
||||||
$title = $this->addTag($document, $group, 'media:title', $str_title);
|
$title = $this->addTag($document, $group, 'media:title', $str_title);
|
||||||
$title->setAttribute('type', 'plain');
|
$title->setAttribute('type', 'plain');
|
||||||
}
|
}
|
||||||
@@ -243,7 +243,7 @@ abstract class Feed_XML_Abstract
|
|||||||
$desc_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Description);
|
$desc_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Description);
|
||||||
if ($desc_field)
|
if ($desc_field)
|
||||||
{
|
{
|
||||||
$str_desc = $desc_field->get_value(true, ' ');
|
$str_desc = $desc_field->get_serialized_values(' ');
|
||||||
$desc = $this->addTag($document, $group, 'media:description', $str_desc);
|
$desc = $this->addTag($document, $group, 'media:description', $str_desc);
|
||||||
$desc->setAttribute('type', 'plain');
|
$desc->setAttribute('type', 'plain');
|
||||||
}
|
}
|
||||||
@@ -251,7 +251,7 @@ abstract class Feed_XML_Abstract
|
|||||||
$contrib_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Contributor);
|
$contrib_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Contributor);
|
||||||
if ($contrib_field)
|
if ($contrib_field)
|
||||||
{
|
{
|
||||||
$str_contrib = $contrib_field->get_value(true, ' ');
|
$str_contrib = $contrib_field->get_serialized_values(' ');
|
||||||
$contrib = $this->addTag($document, $group, 'media:credit', $str_contrib);
|
$contrib = $this->addTag($document, $group, 'media:credit', $str_contrib);
|
||||||
$contrib->setAttribute('role', 'contributor');
|
$contrib->setAttribute('role', 'contributor');
|
||||||
$contrib->setAttribute('scheme', 'urn:ebu');
|
$contrib->setAttribute('scheme', 'urn:ebu');
|
||||||
@@ -260,7 +260,7 @@ abstract class Feed_XML_Abstract
|
|||||||
$director_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Creator);
|
$director_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Creator);
|
||||||
if ($director_field)
|
if ($director_field)
|
||||||
{
|
{
|
||||||
$str_director = $director_field->get_value(true, ' ');
|
$str_director = $director_field->get_serialized_values(' ');
|
||||||
$director = $this->addTag($document, $group, 'media:credit', $str_director);
|
$director = $this->addTag($document, $group, 'media:credit', $str_director);
|
||||||
$director->setAttribute('role', 'director');
|
$director->setAttribute('role', 'director');
|
||||||
$director->setAttribute('scheme', 'urn:ebu');
|
$director->setAttribute('scheme', 'urn:ebu');
|
||||||
@@ -269,7 +269,7 @@ abstract class Feed_XML_Abstract
|
|||||||
$publisher_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Publisher);
|
$publisher_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Publisher);
|
||||||
if ($publisher_field)
|
if ($publisher_field)
|
||||||
{
|
{
|
||||||
$str_publisher = $publisher_field->get_value(true, ' ');
|
$str_publisher = $publisher_field->get_serialized_values(' ');
|
||||||
$publisher = $this->addTag($document, $group, 'media:credit', $str_publisher);
|
$publisher = $this->addTag($document, $group, 'media:credit', $str_publisher);
|
||||||
$publisher->setAttribute('role', 'publisher');
|
$publisher->setAttribute('role', 'publisher');
|
||||||
$publisher->setAttribute('scheme', 'urn:ebu');
|
$publisher->setAttribute('scheme', 'urn:ebu');
|
||||||
@@ -278,14 +278,14 @@ abstract class Feed_XML_Abstract
|
|||||||
$rights_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Rights);
|
$rights_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Rights);
|
||||||
if ($rights_field)
|
if ($rights_field)
|
||||||
{
|
{
|
||||||
$str_rights = $rights_field->get_value(true, ' ');
|
$str_rights = $rights_field->get_serialized_values(' ');
|
||||||
$rights = $this->addTag($document, $group, 'media:copyright', $str_rights);
|
$rights = $this->addTag($document, $group, 'media:copyright', $str_rights);
|
||||||
}
|
}
|
||||||
|
|
||||||
$keyword_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Subject);
|
$keyword_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Subject);
|
||||||
if ($keyword_field)
|
if ($keyword_field)
|
||||||
{
|
{
|
||||||
$str_keywords = $keyword_field->get_value(true, ', ');
|
$str_keywords = $keyword_field->get_serialized_values(', ');
|
||||||
$keywords = $this->addTag($document, $group, 'media:keywords', $str_keywords);
|
$keywords = $this->addTag($document, $group, 'media:keywords', $str_keywords);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -381,7 +381,7 @@ class Feed_XML_Cooliris extends Feed_XML_Abstract implements Feed_XML_Interface
|
|||||||
$title_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Title);
|
$title_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Title);
|
||||||
if ($title_field)
|
if ($title_field)
|
||||||
{
|
{
|
||||||
$str_title = $title_field->get_value(true, ' ');
|
$str_title = $title_field->get_serialized_values(' ');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -394,7 +394,7 @@ class Feed_XML_Cooliris extends Feed_XML_Abstract implements Feed_XML_Interface
|
|||||||
$desc_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Description);
|
$desc_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Description);
|
||||||
if ($desc_field)
|
if ($desc_field)
|
||||||
{
|
{
|
||||||
$str_desc = $desc_field->get_value(true, ' ');
|
$str_desc = $desc_field->get_serialized_values(' ');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
236
lib/classes/caption/Field/Value.class.php
Normal file
236
lib/classes/caption/Field/Value.class.php
Normal file
@@ -0,0 +1,236 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class caption_Field_Value
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $id;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $value;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var databox_field
|
||||||
|
*/
|
||||||
|
protected $databox_field;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var record_adapter
|
||||||
|
*/
|
||||||
|
protected $record;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param databox_field $databox_field
|
||||||
|
* @param record_adapter $record
|
||||||
|
* @param type $id
|
||||||
|
* @return \caption_Field_Value
|
||||||
|
*/
|
||||||
|
public function __construct(databox_field $databox_field, record_adapter $record, $id)
|
||||||
|
{
|
||||||
|
$this->id = (int) $id;
|
||||||
|
$this->databox_field = $databox_field;
|
||||||
|
$this->record = $record;
|
||||||
|
|
||||||
|
$connbas = $databox_field->get_databox()->get_connection();
|
||||||
|
|
||||||
|
$sql = 'SELECT record_id, value FROM metadatas WHERE id = :id';
|
||||||
|
|
||||||
|
$stmt = $connbas->prepare($sql);
|
||||||
|
$stmt->execute(array(':id' => $id));
|
||||||
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
$this->value = $row ? $row['value'] : null;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
public function getId() {
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getValue() {
|
||||||
|
return $this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDatabox_field() {
|
||||||
|
return $this->databox_field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRecord() {
|
||||||
|
return $this->record;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete()
|
||||||
|
{
|
||||||
|
$connbas = $this->databox_field->get_connection();
|
||||||
|
|
||||||
|
$sql = 'DELETE FROM metadatas WHERE id = :id';
|
||||||
|
$stmt = $connbas->prepare($sql);
|
||||||
|
$stmt->execute(array(':id' => $this->id));
|
||||||
|
$stmt->closeCursor();
|
||||||
|
$this->delete_data_from_cache();
|
||||||
|
|
||||||
|
$sbas_id = $this->record->get_sbas_id();
|
||||||
|
$this->record->get_caption()->delete_data_from_cache();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$registry = registry::get_instance();
|
||||||
|
$sphinx_rt = sphinxrt::get_instance($registry);
|
||||||
|
|
||||||
|
$sbas_params = phrasea::sbas_params();
|
||||||
|
|
||||||
|
if (isset($sbas_params[$sbas_id]))
|
||||||
|
{
|
||||||
|
$params = $sbas_params[$sbas_id];
|
||||||
|
$sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
|
||||||
|
$sphinx_rt->delete(array("metadatas" . $sbas_crc, "metadatas" . $sbas_crc . "_stemmed_fr", "metadatas" . $sbas_crc . "_stemmed_en"), "metas_realtime" . $sbas_crc, $this->id);
|
||||||
|
$sphinx_rt->delete(array("documents" . $sbas_crc, "documents" . $sbas_crc . "_stemmed_fr", "documents" . $sbas_crc . "_stemmed_en"), "docs_realtime" . $sbas_crc, $this->record->get_record_id());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception $e)
|
||||||
|
{
|
||||||
|
unset($e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set_value($value)
|
||||||
|
{
|
||||||
|
$sbas_id = $this->databox_field->get_databox()->get_sbas_id();
|
||||||
|
$connbas = $this->databox_field->get_connection();
|
||||||
|
|
||||||
|
$params = array(
|
||||||
|
':meta_id' => $this->id
|
||||||
|
, ':value' => $value
|
||||||
|
);
|
||||||
|
|
||||||
|
$sql_up = 'UPDATE metadatas SET value = :value WHERE id = :meta_id';
|
||||||
|
$stmt_up = $connbas->prepare($sql_up);
|
||||||
|
$stmt_up->execute($params);
|
||||||
|
$stmt_up->closeCursor();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$registry = registry::get_instance();
|
||||||
|
$sphinx_rt = sphinxrt::get_instance($registry);
|
||||||
|
|
||||||
|
$sbas_params = phrasea::sbas_params();
|
||||||
|
|
||||||
|
if (isset($sbas_params[$sbas_id]))
|
||||||
|
{
|
||||||
|
$params = $sbas_params[$sbas_id];
|
||||||
|
$sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
|
||||||
|
$sphinx_rt->delete(array("metadatas" . $sbas_crc, "metadatas" . $sbas_crc . "_stemmed_fr", "metadatas" . $sbas_crc . "_stemmed_en"), "", $this->id);
|
||||||
|
$sphinx_rt->delete(array("documents" . $sbas_crc, "documents" . $sbas_crc . "_stemmed_fr", "documents" . $sbas_crc . "_stemmed_en"), "", $this->record->get_record_id());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception $e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->update_cache_value($value);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param array $value
|
||||||
|
* @return caption_field
|
||||||
|
*/
|
||||||
|
public function update_cache_value($value)
|
||||||
|
{
|
||||||
|
// $this->delete_data_from_cache();
|
||||||
|
$this->record->get_caption()->delete_data_from_cache();
|
||||||
|
$sbas_id = $this->databox_field->get_databox()->get_sbas_id();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$registry = registry::get_instance();
|
||||||
|
|
||||||
|
$sbas_params = phrasea::sbas_params();
|
||||||
|
|
||||||
|
if (isset($sbas_params[$sbas_id]))
|
||||||
|
{
|
||||||
|
$params = $sbas_params[$sbas_id];
|
||||||
|
$sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
|
||||||
|
|
||||||
|
$sphinx_rt = sphinxrt::get_instance($registry);
|
||||||
|
$sphinx_rt->replace_in_metas(
|
||||||
|
"metas_realtime" . $sbas_crc, $this->id, $this->databox_field->get_id(), $this->record->get_record_id(), $sbas_id, phrasea::collFromBas($this->record->get_base_id()), ($this->record->is_grouping() ? '1' : '0'), $this->record->get_type(), $value, $this->record->get_creation_date()
|
||||||
|
);
|
||||||
|
|
||||||
|
$all_datas = array();
|
||||||
|
foreach ($this->record->get_caption()->get_fields() as $field)
|
||||||
|
{
|
||||||
|
if (!$field->is_indexable())
|
||||||
|
continue;
|
||||||
|
$all_datas[] = $field->get_value(true);
|
||||||
|
}
|
||||||
|
$all_datas = implode(' ', $all_datas);
|
||||||
|
|
||||||
|
$sphinx_rt->replace_in_documents(
|
||||||
|
"docs_realtime" . $sbas_crc, //$this->id,
|
||||||
|
$this->record->get_record_id(), $all_datas, $sbas_id, phrasea::collFromBas($this->record->get_base_id()), ($this->record->is_grouping() ? '1' : '0'), $this->record->get_type(), $this->record->get_creation_date()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception $e)
|
||||||
|
{
|
||||||
|
unset($e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function create(databox_field &$databox_field, record_Interface $record, $value)
|
||||||
|
{
|
||||||
|
|
||||||
|
$sbas_id = $databox_field->get_databox()->get_sbas_id();
|
||||||
|
$connbas = $databox_field->get_connection();
|
||||||
|
|
||||||
|
$sql_ins = 'INSERT INTO metadatas (id, record_id, meta_struct_id, value)
|
||||||
|
VALUES
|
||||||
|
(null, :record_id, :field, :value)';
|
||||||
|
$stmt_ins = $connbas->prepare($sql_ins);
|
||||||
|
$stmt_ins->execute(
|
||||||
|
array(
|
||||||
|
':record_id' => $record->get_record_id(),
|
||||||
|
':field' => $databox_field->get_id(),
|
||||||
|
':value' => $value
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$stmt_ins->closeCursor();
|
||||||
|
$meta_id = $connbas->lastInsertId();
|
||||||
|
|
||||||
|
$caption_field_value = new self($databox_field, $record, $meta_id);
|
||||||
|
$caption_field_value->update_cache_value($value);
|
||||||
|
|
||||||
|
// $record->get_caption()->delete_data_from_cache();
|
||||||
|
|
||||||
|
return $caption_field_value;
|
||||||
|
}
|
||||||
|
}
|
@@ -15,7 +15,7 @@
|
|||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
class caption_field implements cache_cacheableInterface
|
class caption_field //implements cache_cacheableInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,13 +28,13 @@ class caption_field implements cache_cacheableInterface
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $value;
|
protected $values;
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
*
|
// *
|
||||||
* @var int
|
// * @var int
|
||||||
*/
|
// */
|
||||||
protected $id;
|
// protected $id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -49,44 +49,52 @@ class caption_field implements cache_cacheableInterface
|
|||||||
* @param int $id
|
* @param int $id
|
||||||
* @return caption_field
|
* @return caption_field
|
||||||
*/
|
*/
|
||||||
public function __construct(databox_field &$databox_field, record_Interface $record, $id)
|
public function __construct(databox_field &$databox_field, record_Interface $record)
|
||||||
{
|
{
|
||||||
$this->record = $record;
|
$this->record = $record;
|
||||||
$this->id = (int) $id;
|
// $this->id = (int) $id;
|
||||||
|
|
||||||
$row = false;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$row = $this->get_data_from_cache();
|
|
||||||
}
|
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
|
|
||||||
$connbas = $databox_field->get_connection();
|
|
||||||
|
|
||||||
$sql = 'SELECT record_id, value FROM metadatas WHERE id = :id';
|
|
||||||
$stmt = $connbas->prepare($sql);
|
|
||||||
$stmt->execute(array(':id' => $id));
|
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
$stmt->closeCursor();
|
|
||||||
$this->set_data_to_cache($row);
|
|
||||||
unset($e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
unset($e);
|
|
||||||
}
|
|
||||||
if (!$row)
|
|
||||||
throw new Exception('Unknown metadata');
|
|
||||||
|
|
||||||
$this->databox_field = $databox_field;
|
$this->databox_field = $databox_field;
|
||||||
$this->value = $row['value'];
|
$this->values = array();
|
||||||
|
|
||||||
|
$connbas = $databox_field->get_connection();
|
||||||
|
|
||||||
|
$sql = 'SELECT id FROM metadatas
|
||||||
|
WHERE record_id = :record_id
|
||||||
|
AND meta_struct_id = :meta_struct_id';
|
||||||
|
|
||||||
|
$params = array(
|
||||||
|
':record_id' => $record->get_record_id()
|
||||||
|
, ':meta_struct_id' => $databox_field->get_id()
|
||||||
|
);
|
||||||
|
|
||||||
|
$stmt = $connbas->prepare($sql);
|
||||||
|
$stmt->execute($params);
|
||||||
|
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
if (!$databox_field->is_multi() && count($rs) > 1)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* TRIGG CORRECTION;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($rs as $row)
|
||||||
|
{
|
||||||
|
$this->values[$row['id']] = new caption_Field_Value($databox_field, $record, $row['id']);
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return record_adapter
|
||||||
|
*/
|
||||||
|
public function get_record()
|
||||||
|
{
|
||||||
|
return $this->record;
|
||||||
|
}
|
||||||
|
|
||||||
public function is_required()
|
public function is_required()
|
||||||
{
|
{
|
||||||
@@ -103,208 +111,215 @@ class caption_field implements cache_cacheableInterface
|
|||||||
return $this->databox_field->is_readonly();
|
return $this->databox_field->is_readonly();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
*
|
// *
|
||||||
* @return caption_field
|
// * @return caption_field
|
||||||
*/
|
// */
|
||||||
public function delete()
|
// public function delete()
|
||||||
|
// {
|
||||||
|
// $connbas = $this->databox_field->get_connection();
|
||||||
|
//
|
||||||
|
// $sql = 'DELETE FROM metadatas WHERE id = :id';
|
||||||
|
// $stmt = $connbas->prepare($sql);
|
||||||
|
// $stmt->execute(array(':id' => $this->id));
|
||||||
|
// $stmt->closeCursor();
|
||||||
|
// $this->delete_data_from_cache();
|
||||||
|
//
|
||||||
|
// $sbas_id = $this->record->get_sbas_id();
|
||||||
|
// $this->record->get_caption()->delete_data_from_cache();
|
||||||
|
//
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// $registry = registry::get_instance();
|
||||||
|
// $sphinx_rt = sphinxrt::get_instance($registry);
|
||||||
|
//
|
||||||
|
// $sbas_params = phrasea::sbas_params();
|
||||||
|
//
|
||||||
|
// if (isset($sbas_params[$sbas_id]))
|
||||||
|
// {
|
||||||
|
// $params = $sbas_params[$sbas_id];
|
||||||
|
// $sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
|
||||||
|
// $sphinx_rt->delete(array("metadatas" . $sbas_crc, "metadatas" . $sbas_crc . "_stemmed_fr", "metadatas" . $sbas_crc . "_stemmed_en"), "metas_realtime" . $sbas_crc, $this->id);
|
||||||
|
// $sphinx_rt->delete(array("documents" . $sbas_crc, "documents" . $sbas_crc . "_stemmed_fr", "documents" . $sbas_crc . "_stemmed_en"), "docs_realtime" . $sbas_crc, $this->record->get_record_id());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// catch (Exception $e)
|
||||||
|
// {
|
||||||
|
// unset($e);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return $this;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Part of the cache_cacheableInterface
|
||||||
|
// *
|
||||||
|
// * @param string $option
|
||||||
|
// * @return string
|
||||||
|
// */
|
||||||
|
// public function get_cache_key($option = null)
|
||||||
|
// {
|
||||||
|
// return 'captionfield_' . $this->record->get_serialize_key()
|
||||||
|
// . $this->id . ($option ? '_' . $option : '');
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Part of the cache_cacheableInterface
|
||||||
|
// *
|
||||||
|
// * @param string $option
|
||||||
|
// * @return mixed
|
||||||
|
// */
|
||||||
|
// public function get_data_from_cache($option = null)
|
||||||
|
// {
|
||||||
|
// $databox = databox::get_instance($this->record->get_sbas_id());
|
||||||
|
//
|
||||||
|
// return $databox->get_data_from_cache($this->get_cache_key($option));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Part of the cache_cacheableInterface
|
||||||
|
// *
|
||||||
|
// * @param mixed $value
|
||||||
|
// * @param string $option
|
||||||
|
// * @param int $duration
|
||||||
|
// * @return caption_field
|
||||||
|
// */
|
||||||
|
// public function set_data_to_cache($value, $option = null, $duration = 0)
|
||||||
|
// {
|
||||||
|
// $databox = databox::get_instance($this->record->get_sbas_id());
|
||||||
|
// $databox->set_data_to_cache($value, $this->get_cache_key($option), $duration);
|
||||||
|
//
|
||||||
|
// return $this;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Part of the cache_cacheableInterface
|
||||||
|
// *
|
||||||
|
// * @param string $option
|
||||||
|
// * @return caption_field
|
||||||
|
// */
|
||||||
|
// public function delete_data_from_cache($option = null)
|
||||||
|
// {
|
||||||
|
// $databox = databox::get_instance($this->record->get_sbas_id());
|
||||||
|
// $databox->delete_data_from_cache($this->get_cache_key($option));
|
||||||
|
//
|
||||||
|
// return $this;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// *
|
||||||
|
// * @param array $value
|
||||||
|
// * @param databox_field $databox_field
|
||||||
|
// * @return string
|
||||||
|
// */
|
||||||
|
protected static function serialize_value(Array $values, $separator)
|
||||||
{
|
{
|
||||||
$connbas = $this->databox_field->get_connection();
|
if (strlen($separator) > 1)
|
||||||
|
|
||||||
$sql = 'DELETE FROM metadatas WHERE id = :id';
|
|
||||||
$stmt = $connbas->prepare($sql);
|
|
||||||
$stmt->execute(array(':id' => $this->id));
|
|
||||||
$stmt->closeCursor();
|
|
||||||
$this->delete_data_from_cache();
|
|
||||||
|
|
||||||
$sbas_id = $this->record->get_sbas_id();
|
|
||||||
$this->record->get_caption()->delete_data_from_cache();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$registry = registry::get_instance();
|
|
||||||
$sphinx_rt = sphinxrt::get_instance($registry);
|
|
||||||
|
|
||||||
$sbas_params = phrasea::sbas_params();
|
|
||||||
|
|
||||||
if (isset($sbas_params[$sbas_id]))
|
|
||||||
{
|
|
||||||
$params = $sbas_params[$sbas_id];
|
|
||||||
$sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
|
|
||||||
$sphinx_rt->delete(array("metadatas" . $sbas_crc, "metadatas" . $sbas_crc . "_stemmed_fr", "metadatas" . $sbas_crc . "_stemmed_en"), "metas_realtime" . $sbas_crc, $this->id);
|
|
||||||
$sphinx_rt->delete(array("documents" . $sbas_crc, "documents" . $sbas_crc . "_stemmed_fr", "documents" . $sbas_crc . "_stemmed_en"), "docs_realtime" . $sbas_crc, $this->record->get_record_id());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
unset($e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Part of the cache_cacheableInterface
|
|
||||||
*
|
|
||||||
* @param string $option
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function get_cache_key($option = null)
|
|
||||||
{
|
|
||||||
return 'captionfield_' . $this->record->get_serialize_key()
|
|
||||||
. $this->id . ($option ? '_' . $option : '');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Part of the cache_cacheableInterface
|
|
||||||
*
|
|
||||||
* @param string $option
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function get_data_from_cache($option = null)
|
|
||||||
{
|
|
||||||
$databox = databox::get_instance($this->record->get_sbas_id());
|
|
||||||
|
|
||||||
return $databox->get_data_from_cache($this->get_cache_key($option));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Part of the cache_cacheableInterface
|
|
||||||
*
|
|
||||||
* @param mixed $value
|
|
||||||
* @param string $option
|
|
||||||
* @param int $duration
|
|
||||||
* @return caption_field
|
|
||||||
*/
|
|
||||||
public function set_data_to_cache($value, $option = null, $duration = 0)
|
|
||||||
{
|
|
||||||
$databox = databox::get_instance($this->record->get_sbas_id());
|
|
||||||
$databox->set_data_to_cache($value, $this->get_cache_key($option), $duration);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Part of the cache_cacheableInterface
|
|
||||||
*
|
|
||||||
* @param string $option
|
|
||||||
* @return caption_field
|
|
||||||
*/
|
|
||||||
public function delete_data_from_cache($option = null)
|
|
||||||
{
|
|
||||||
$databox = databox::get_instance($this->record->get_sbas_id());
|
|
||||||
$databox->delete_data_from_cache($this->get_cache_key($option));
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param array $value
|
|
||||||
* @param databox_field $databox_field
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected static function serialize_value(Array $value, $separator)
|
|
||||||
{
|
|
||||||
if(strlen($separator) > 1)
|
|
||||||
$separator = $separator[0];
|
$separator = $separator[0];
|
||||||
|
|
||||||
if (trim($separator) === '')
|
if (trim($separator) === '')
|
||||||
$separator = ' ';
|
$separator = ' ';
|
||||||
else
|
else
|
||||||
$separator = ' ' . $separator . ' ';
|
$separator = ' ' . $separator . ' ';
|
||||||
|
|
||||||
|
$array_values = array();
|
||||||
|
|
||||||
|
foreach($values as $value)
|
||||||
|
{
|
||||||
|
$array_values[] = $value->get_value();
|
||||||
|
}
|
||||||
|
|
||||||
return implode($separator, $value);
|
return implode($separator, $array_values);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param array $value
|
|
||||||
* @return caption_field
|
|
||||||
*/
|
|
||||||
public function set_value(Array $value)
|
|
||||||
{
|
|
||||||
$sbas_id = $this->databox_field->get_databox()->get_sbas_id();
|
|
||||||
$connbas = $this->databox_field->get_connection();
|
|
||||||
|
|
||||||
$sql_up = 'UPDATE metadatas SET value = :value WHERE id = :meta_id';
|
|
||||||
$stmt_up = $connbas->prepare($sql_up);
|
|
||||||
$stmt_up->execute(array(':meta_id' => $this->get_meta_id(), ':value' => self::serialize_value($value, $this->databox_field->get_separator())));
|
|
||||||
$stmt_up->closeCursor();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$registry = registry::get_instance();
|
|
||||||
$sphinx_rt = sphinxrt::get_instance($registry);
|
|
||||||
|
|
||||||
$sbas_params = phrasea::sbas_params();
|
|
||||||
|
|
||||||
if (isset($sbas_params[$sbas_id]))
|
|
||||||
{
|
|
||||||
$params = $sbas_params[$sbas_id];
|
|
||||||
$sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
|
|
||||||
$sphinx_rt->delete(array("metadatas" . $sbas_crc, "metadatas" . $sbas_crc . "_stemmed_fr", "metadatas" . $sbas_crc . "_stemmed_en"), "", $this->get_meta_id());
|
|
||||||
$sphinx_rt->delete(array("documents" . $sbas_crc, "documents" . $sbas_crc . "_stemmed_fr", "documents" . $sbas_crc . "_stemmed_en"), "", $this->record->get_record_id());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->update_cache_value($value);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param array $value
|
|
||||||
* @return caption_field
|
|
||||||
*/
|
|
||||||
public function update_cache_value(Array $value)
|
|
||||||
{
|
|
||||||
$this->delete_data_from_cache();
|
|
||||||
$this->record->get_caption()->delete_data_from_cache();
|
|
||||||
$sbas_id = $this->databox_field->get_databox()->get_sbas_id();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$registry = registry::get_instance();
|
|
||||||
|
|
||||||
$sbas_params = phrasea::sbas_params();
|
|
||||||
|
|
||||||
if (isset($sbas_params[$sbas_id]))
|
|
||||||
{
|
|
||||||
$params = $sbas_params[$sbas_id];
|
|
||||||
$sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
|
|
||||||
|
|
||||||
$sphinx_rt = sphinxrt::get_instance($registry);
|
|
||||||
$sphinx_rt->replace_in_metas(
|
|
||||||
"metas_realtime" . $sbas_crc, $this->id, $this->databox_field->get_id(), $this->record->get_record_id(), $sbas_id, phrasea::collFromBas($this->record->get_base_id()), ($this->record->is_grouping() ? '1' : '0'), $this->record->get_type(), $value, $this->record->get_creation_date()
|
|
||||||
);
|
|
||||||
|
|
||||||
$all_datas = array();
|
|
||||||
foreach ($this->record->get_caption()->get_fields() as $field)
|
|
||||||
{
|
|
||||||
if (!$field->is_indexable())
|
|
||||||
continue;
|
|
||||||
$all_datas[] = $field->get_value(true);
|
|
||||||
}
|
|
||||||
$all_datas = implode(' ', $all_datas);
|
|
||||||
|
|
||||||
$sphinx_rt->replace_in_documents(
|
|
||||||
"docs_realtime" . $sbas_crc, //$this->id,
|
|
||||||
$this->record->get_record_id(), $all_datas, $sbas_id, phrasea::collFromBas($this->record->get_base_id()), ($this->record->is_grouping() ? '1' : '0'), $this->record->get_type(), $this->record->get_creation_date()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
unset($e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// *
|
||||||
|
// * @param array $value
|
||||||
|
// * @return caption_field
|
||||||
|
// */
|
||||||
|
// public function set_value(Array $value)
|
||||||
|
// {
|
||||||
|
// $sbas_id = $this->databox_field->get_databox()->get_sbas_id();
|
||||||
|
// $connbas = $this->databox_field->get_connection();
|
||||||
|
//
|
||||||
|
// $sql_up = 'UPDATE metadatas SET value = :value WHERE id = :meta_id';
|
||||||
|
// $stmt_up = $connbas->prepare($sql_up);
|
||||||
|
// $stmt_up->execute(array(':meta_id' => $this->get_meta_id(), ':value' => self::serialize_value($value, $this->databox_field->get_separator())));
|
||||||
|
// $stmt_up->closeCursor();
|
||||||
|
//
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// $registry = registry::get_instance();
|
||||||
|
// $sphinx_rt = sphinxrt::get_instance($registry);
|
||||||
|
//
|
||||||
|
// $sbas_params = phrasea::sbas_params();
|
||||||
|
//
|
||||||
|
// if (isset($sbas_params[$sbas_id]))
|
||||||
|
// {
|
||||||
|
// $params = $sbas_params[$sbas_id];
|
||||||
|
// $sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
|
||||||
|
// $sphinx_rt->delete(array("metadatas" . $sbas_crc, "metadatas" . $sbas_crc . "_stemmed_fr", "metadatas" . $sbas_crc . "_stemmed_en"), "", $this->get_meta_id());
|
||||||
|
// $sphinx_rt->delete(array("documents" . $sbas_crc, "documents" . $sbas_crc . "_stemmed_fr", "documents" . $sbas_crc . "_stemmed_en"), "", $this->record->get_record_id());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// catch (Exception $e)
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// $this->update_cache_value($value);
|
||||||
|
//
|
||||||
|
// return $this;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// *
|
||||||
|
// * @param array $value
|
||||||
|
// * @return caption_field
|
||||||
|
// */
|
||||||
|
// public function update_cache_value(Array $value)
|
||||||
|
// {
|
||||||
|
// $this->delete_data_from_cache();
|
||||||
|
// $this->record->get_caption()->delete_data_from_cache();
|
||||||
|
// $sbas_id = $this->databox_field->get_databox()->get_sbas_id();
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// $registry = registry::get_instance();
|
||||||
|
//
|
||||||
|
// $sbas_params = phrasea::sbas_params();
|
||||||
|
//
|
||||||
|
// if (isset($sbas_params[$sbas_id]))
|
||||||
|
// {
|
||||||
|
// $params = $sbas_params[$sbas_id];
|
||||||
|
// $sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
|
||||||
|
//
|
||||||
|
// $sphinx_rt = sphinxrt::get_instance($registry);
|
||||||
|
// $sphinx_rt->replace_in_metas(
|
||||||
|
// "metas_realtime" . $sbas_crc, $this->id, $this->databox_field->get_id(), $this->record->get_record_id(), $sbas_id, phrasea::collFromBas($this->record->get_base_id()), ($this->record->is_grouping() ? '1' : '0'), $this->record->get_type(), $value, $this->record->get_creation_date()
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// $all_datas = array();
|
||||||
|
// foreach ($this->record->get_caption()->get_fields() as $field)
|
||||||
|
// {
|
||||||
|
// if (!$field->is_indexable())
|
||||||
|
// continue;
|
||||||
|
// $all_datas[] = $field->get_value(true);
|
||||||
|
// }
|
||||||
|
// $all_datas = implode(' ', $all_datas);
|
||||||
|
//
|
||||||
|
// $sphinx_rt->replace_in_documents(
|
||||||
|
// "docs_realtime" . $sbas_crc, //$this->id,
|
||||||
|
// $this->record->get_record_id(), $all_datas, $sbas_id, phrasea::collFromBas($this->record->get_base_id()), ($this->record->is_grouping() ? '1' : '0'), $this->record->get_type(), $this->record->get_creation_date()
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// catch (Exception $e)
|
||||||
|
// {
|
||||||
|
// unset($e);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return $this;
|
||||||
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -312,60 +327,91 @@ class caption_field implements cache_cacheableInterface
|
|||||||
* @param record_Interface $record
|
* @param record_Interface $record
|
||||||
* @param array $value
|
* @param array $value
|
||||||
* @return caption_field
|
* @return caption_field
|
||||||
*/
|
// */
|
||||||
public static function create(databox_field &$databox_field, record_Interface $record, Array $value)
|
// public static function create(databox_field &$databox_field, record_Interface $record, Array $value)
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// $sbas_id = $databox_field->get_databox()->get_sbas_id();
|
||||||
|
// $connbas = $databox_field->get_connection();
|
||||||
|
// $sql_ins = 'INSERT INTO metadatas (id, record_id, meta_struct_id, value)
|
||||||
|
// VALUES
|
||||||
|
// (null, :record_id, :field, :value)';
|
||||||
|
// $stmt_ins = $connbas->prepare($sql_ins);
|
||||||
|
// $stmt_ins->execute(
|
||||||
|
// array(
|
||||||
|
// ':record_id' => $record->get_record_id(),
|
||||||
|
// ':field' => $databox_field->get_id(),
|
||||||
|
// ':value' => self::serialize_value($value, $databox_field->get_separator())
|
||||||
|
// )
|
||||||
|
// );
|
||||||
|
// $stmt_ins->closeCursor();
|
||||||
|
// $meta_id = $connbas->lastInsertId();
|
||||||
|
//
|
||||||
|
// $caption_field = new self($databox_field, $record, $meta_id);
|
||||||
|
// $caption_field->update_cache_value($value);
|
||||||
|
//
|
||||||
|
// $record->get_caption()->delete_data_from_cache();
|
||||||
|
//
|
||||||
|
// return $caption_field;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// *
|
||||||
|
// * @return string
|
||||||
|
// */
|
||||||
|
// public function get_value($as_string = false, $custom_separator = false)
|
||||||
|
// {
|
||||||
|
// if ($this->databox_field->is_multi() === true)
|
||||||
|
// {
|
||||||
|
// if ($as_string === true && $custom_separator === false)
|
||||||
|
// {
|
||||||
|
// return $this->value;
|
||||||
|
// }
|
||||||
|
// $separator = $this->databox_field->get_separator();
|
||||||
|
// $array_values = self::get_multi_values($this->value, $separator);
|
||||||
|
//
|
||||||
|
// if ($as_string === true && $custom_separator !== false)
|
||||||
|
// return self::serialize_value($array_values, $custom_separator);
|
||||||
|
// else
|
||||||
|
// return $array_values;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// return $this->value;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
public function get_values()
|
||||||
{
|
{
|
||||||
|
return $this->values;
|
||||||
$sbas_id = $databox_field->get_databox()->get_sbas_id();
|
|
||||||
$connbas = $databox_field->get_connection();
|
|
||||||
$sql_ins = 'INSERT INTO metadatas (id, record_id, meta_struct_id, value)
|
|
||||||
VALUES
|
|
||||||
(null, :record_id, :field, :value)';
|
|
||||||
$stmt_ins = $connbas->prepare($sql_ins);
|
|
||||||
$stmt_ins->execute(
|
|
||||||
array(
|
|
||||||
':record_id' => $record->get_record_id(),
|
|
||||||
':field' => $databox_field->get_id(),
|
|
||||||
':value' => self::serialize_value($value, $databox_field->get_separator())
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$stmt_ins->closeCursor();
|
|
||||||
$meta_id = $connbas->lastInsertId();
|
|
||||||
|
|
||||||
$caption_field = new self($databox_field, $record, $meta_id);
|
|
||||||
$caption_field->update_cache_value($value);
|
|
||||||
|
|
||||||
$record->get_caption()->delete_data_from_cache();
|
|
||||||
|
|
||||||
return $caption_field;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function get_value($meta_id)
|
||||||
*
|
{
|
||||||
* @return string
|
return $this->values[$meta_id];
|
||||||
*/
|
}
|
||||||
public function get_value($as_string = false, $custom_separator = false)
|
|
||||||
|
public function get_serialized_values($custom_separator = false)
|
||||||
{
|
{
|
||||||
if ($this->databox_field->is_multi() === true)
|
if ($this->databox_field->is_multi() === true)
|
||||||
{
|
{
|
||||||
if ($as_string === true && $custom_separator === false)
|
if($custom_separator !== false)
|
||||||
{
|
$separator = $custom_separator;
|
||||||
return $this->value;
|
|
||||||
}
|
|
||||||
$separator = $this->databox_field->get_separator();
|
|
||||||
$array_values = self::get_multi_values($this->value, $separator);
|
|
||||||
|
|
||||||
if ($as_string === true && $custom_separator !== false)
|
|
||||||
|
|
||||||
return self::serialize_value($array_values, $custom_separator);
|
|
||||||
else
|
else
|
||||||
|
$separator = $this->databox_field->get_separator();
|
||||||
|
|
||||||
return $array_values;
|
return self::serialize_value($this->values, $separator);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $this->value;
|
foreach($this->values as $value)
|
||||||
|
{
|
||||||
|
/* @var $value Caption_Field_Value */
|
||||||
|
return $value->get_value();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -395,14 +441,14 @@ class caption_field implements cache_cacheableInterface
|
|||||||
return $this->databox_field->is_indexable();
|
return $this->databox_field->is_indexable();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
*
|
// *
|
||||||
* @return int
|
// * @return int
|
||||||
*/
|
// */
|
||||||
public function get_meta_id()
|
// public function get_meta_id()
|
||||||
{
|
// {
|
||||||
return $this->id;
|
// return $this->id;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -619,7 +665,7 @@ class caption_field implements cache_cacheableInterface
|
|||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -85,7 +85,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
$databox_meta_struct = databox_field::get_instance($this->databox, $row['structure_id']);
|
$databox_meta_struct = databox_field::get_instance($this->databox, $row['structure_id']);
|
||||||
$metadata = new caption_field($databox_meta_struct, $this->record, $row['meta_id']);
|
$metadata = new caption_field($databox_meta_struct, $this->record);
|
||||||
|
|
||||||
$rec_fields[$databox_meta_struct->get_id()] = $metadata;
|
$rec_fields[$databox_meta_struct->get_id()] = $metadata;
|
||||||
$dces_element = $metadata->get_databox_field()->get_dces_element();
|
$dces_element = $metadata->get_databox_field()->get_dces_element();
|
||||||
|
@@ -132,14 +132,13 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
*/
|
*/
|
||||||
protected $modification_date;
|
protected $modification_date;
|
||||||
|
|
||||||
const CACHE_ORIGINAL_NAME = 'originalname';
|
const CACHE_ORIGINAL_NAME = 'originalname';
|
||||||
const CACHE_TECHNICAL_DATAS = 'technical_datas';
|
const CACHE_TECHNICAL_DATAS = 'technical_datas';
|
||||||
const CACHE_MIME = 'mime';
|
const CACHE_MIME = 'mime';
|
||||||
const CACHE_SHA256 = 'sha256';
|
const CACHE_SHA256 = 'sha256';
|
||||||
const CACHE_SUBDEFS = 'subdefs';
|
const CACHE_SUBDEFS = 'subdefs';
|
||||||
const CACHE_GROUPING = 'grouping';
|
const CACHE_GROUPING = 'grouping';
|
||||||
const CACHE_STATUS = 'status';
|
const CACHE_STATUS = 'status';
|
||||||
|
|
||||||
|
|
||||||
protected static $_regfields;
|
protected static $_regfields;
|
||||||
|
|
||||||
@@ -187,12 +186,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$connbas = $this->databox->get_connection();
|
$connbas = $this->databox->get_connection();
|
||||||
$sql = 'SELECT coll_id, record_id,credate , uuid, moddate, parent_record_id
|
$sql = 'SELECT coll_id, record_id,credate , uuid, moddate, parent_record_id
|
||||||
, type, originalname, bitly, sha256, mime
|
, type, originalname, bitly, sha256, mime
|
||||||
FROM record WHERE record_id = :record_id';
|
FROM record WHERE record_id = :record_id';
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(':record_id' => $this->record_id));
|
$stmt->execute(array(':record_id' => $this->record_id));
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
if (!$row)
|
if (!$row)
|
||||||
@@ -211,16 +210,16 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
$this->mime = $row['mime'];
|
$this->mime = $row['mime'];
|
||||||
|
|
||||||
$datas = array(
|
$datas = array(
|
||||||
'mime' => $this->mime
|
'mime' => $this->mime
|
||||||
, 'sha256' => $this->sha256
|
, 'sha256' => $this->sha256
|
||||||
, 'bitly_link' => $this->bitly_link
|
, 'bitly_link' => $this->bitly_link
|
||||||
, 'original_name' => $this->original_name
|
, 'original_name' => $this->original_name
|
||||||
, 'type' => $this->type
|
, 'type' => $this->type
|
||||||
, 'grouping' => $this->grouping
|
, 'grouping' => $this->grouping
|
||||||
, 'uuid' => $this->uuid
|
, 'uuid' => $this->uuid
|
||||||
, 'modification_date' => $this->modification_date
|
, 'modification_date' => $this->modification_date
|
||||||
, 'creation_date' => $this->creation_date
|
, 'creation_date' => $this->creation_date
|
||||||
, 'base_id' => $this->base_id
|
, 'base_id' => $this->base_id
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->set_data_to_cache($datas);
|
$this->set_data_to_cache($datas);
|
||||||
@@ -293,9 +292,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
|
|
||||||
$connbas = connection::getPDOConnection($this->get_sbas_id());
|
$connbas = connection::getPDOConnection($this->get_sbas_id());
|
||||||
|
|
||||||
$sql = 'UPDATE record SET type = :type WHERE record_id = :record_id';
|
$sql = 'UPDATE record SET type = :type WHERE record_id = :record_id';
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(':type' => $type, ':record_id' => $this->get_record_id()));
|
$stmt->execute(array(':type' => $type, ':record_id' => $this->get_record_id()));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
if ($old_type !== $type)
|
if ($old_type !== $type)
|
||||||
@@ -372,9 +371,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
{
|
{
|
||||||
$dstatus = databox_status::getDisplayStatus();
|
$dstatus = databox_status::getDisplayStatus();
|
||||||
$sbas_id = $this->get_sbas_id();
|
$sbas_id = $this->get_sbas_id();
|
||||||
$appbox = appbox::get_instance();
|
$appbox = appbox::get_instance();
|
||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
||||||
|
|
||||||
$status = '';
|
$status = '';
|
||||||
|
|
||||||
@@ -383,24 +382,24 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
foreach ($dstatus[$sbas_id] as $n => $statbit)
|
foreach ($dstatus[$sbas_id] as $n => $statbit)
|
||||||
{
|
{
|
||||||
if ($statbit['printable'] == '0' &&
|
if ($statbit['printable'] == '0' &&
|
||||||
!$user->ACL()->has_right_on_base($this->base_id, 'chgstatus'))
|
!$user->ACL()->has_right_on_base($this->base_id, 'chgstatus'))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$x = (substr((strrev($this->get_status())), $n, 1));
|
$x = (substr((strrev($this->get_status())), $n, 1));
|
||||||
|
|
||||||
$source0 = "/skins/icons/spacer.gif";
|
$source0 = "/skins/icons/spacer.gif";
|
||||||
$style0 = "visibility:hidden;display:none;";
|
$style0 = "visibility:hidden;display:none;";
|
||||||
$source1 = "/skins/icons/spacer.gif";
|
$source1 = "/skins/icons/spacer.gif";
|
||||||
$style1 = "visibility:hidden;display:none;";
|
$style1 = "visibility:hidden;display:none;";
|
||||||
if ($statbit["img_on"])
|
if ($statbit["img_on"])
|
||||||
{
|
{
|
||||||
$source1 = $statbit["img_on"];
|
$source1 = $statbit["img_on"];
|
||||||
$style1 = "visibility:auto;display:none;";
|
$style1 = "visibility:auto;display:none;";
|
||||||
}
|
}
|
||||||
if ($statbit["img_off"])
|
if ($statbit["img_off"])
|
||||||
{
|
{
|
||||||
$source0 = $statbit["img_off"];
|
$source0 = $statbit["img_off"];
|
||||||
$style0 = "visibility:auto;display:none;";
|
$style0 = "visibility:auto;display:none;";
|
||||||
}
|
}
|
||||||
if ($x == '1')
|
if ($x == '1')
|
||||||
{
|
{
|
||||||
@@ -417,19 +416,19 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$status .= '<img style="margin:1px;' . $style1 . '" ' .
|
$status .= '<img style="margin:1px;' . $style1 . '" ' .
|
||||||
'class="STAT_' . $this->base_id . '_'
|
'class="STAT_' . $this->base_id . '_'
|
||||||
. $this->record_id . '_' . $n . '_1" ' .
|
. $this->record_id . '_' . $n . '_1" ' .
|
||||||
'src="' . $source1 . '" title="' .
|
'src="' . $source1 . '" title="' .
|
||||||
(isset($statbit["labelon"]) ?
|
(isset($statbit["labelon"]) ?
|
||||||
$statbit["labelon"] :
|
$statbit["labelon"] :
|
||||||
$statbit["lib"]) . '"/>';
|
$statbit["lib"]) . '"/>';
|
||||||
$status .= '<img style="margin:1px;' . $style0 . '" ' .
|
$status .= '<img style="margin:1px;' . $style0 . '" ' .
|
||||||
'class="STAT_' . $this->base_id . '_'
|
'class="STAT_' . $this->base_id . '_'
|
||||||
. $this->record_id . '_' . $n . '_0" ' .
|
. $this->record_id . '_' . $n . '_0" ' .
|
||||||
'src="' . $source0 . '" title="' .
|
'src="' . $source0 . '" title="' .
|
||||||
(isset($statbit["labeloff"]) ?
|
(isset($statbit["labeloff"]) ?
|
||||||
$statbit["labeloff"] :
|
$statbit["labeloff"] :
|
||||||
("non-" . $statbit["lib"])) . '"/>';
|
("non-" . $statbit["lib"])) . '"/>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -482,8 +481,8 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
$sql = "UPDATE record SET coll_id = :coll_id WHERE record_id =:record_id";
|
$sql = "UPDATE record SET coll_id = :coll_id WHERE record_id =:record_id";
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
':coll_id' => $collection->get_coll_id(),
|
':coll_id' => $collection->get_coll_id(),
|
||||||
':record_id' => $this->get_record_id()
|
':record_id' => $this->get_record_id()
|
||||||
);
|
);
|
||||||
|
|
||||||
$stmt = $this->get_databox()->get_connection()->prepare($sql);
|
$stmt = $this->get_databox()->get_connection()->prepare($sql);
|
||||||
@@ -493,7 +492,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
$this->base_id = $collection->get_base_id();
|
$this->base_id = $collection->get_base_id();
|
||||||
|
|
||||||
$appbox->get_session()->get_logger($this->get_databox())
|
$appbox->get_session()->get_logger($this->get_databox())
|
||||||
->log($this, Session_Logger::EVENT_MOVE, $collection->get_coll_id(), '');
|
->log($this, Session_Logger::EVENT_MOVE, $collection->get_coll_id(), '');
|
||||||
|
|
||||||
$this->delete_data_from_cache();
|
$this->delete_data_from_cache();
|
||||||
|
|
||||||
@@ -568,18 +567,18 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
$sql = 'SELECT BIN(status) as status FROM record
|
$sql = 'SELECT BIN(status) as status FROM record
|
||||||
WHERE record_id = :record_id';
|
WHERE record_id = :record_id';
|
||||||
$stmt = $this->get_databox()->get_connection()->prepare($sql);
|
$stmt = $this->get_databox()->get_connection()->prepare($sql);
|
||||||
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
if (!$row)
|
if (!$row)
|
||||||
throw new Exception('status not found');
|
throw new Exception('status not found');
|
||||||
|
|
||||||
$status = $row['status'];
|
$status = $row['status'];
|
||||||
$n = strlen($status);
|
$n = strlen($status);
|
||||||
while ($n < 64)
|
while ($n < 64)
|
||||||
{
|
{
|
||||||
$status = '0' . $status;
|
$status = '0' . $status;
|
||||||
@@ -653,7 +652,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
|
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$subdefs = array('preview', 'thumbnail');
|
$subdefs = array('preview', 'thumbnail');
|
||||||
@@ -662,7 +661,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
{
|
{
|
||||||
$subdefs[] = $row['name'];
|
$subdefs[] = $row['name'];
|
||||||
}
|
}
|
||||||
$subdefs = array_unique($subdefs);
|
$subdefs = array_unique($subdefs);
|
||||||
$this->set_data_to_cache($subdefs, self::CACHE_SUBDEFS);
|
$this->set_data_to_cache($subdefs, self::CACHE_SUBDEFS);
|
||||||
|
|
||||||
return $subdefs;
|
return $subdefs;
|
||||||
@@ -695,10 +694,10 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
{
|
{
|
||||||
$this->technical_datas = array();
|
$this->technical_datas = array();
|
||||||
$connbas = $this->get_databox()->get_connection();
|
$connbas = $this->get_databox()->get_connection();
|
||||||
$sql = 'SELECT name, value FROM technical_datas WHERE record_id = :record_id';
|
$sql = 'SELECT name, value FROM technical_datas WHERE record_id = :record_id';
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
foreach ($rs as $row)
|
foreach ($rs as $row)
|
||||||
@@ -774,7 +773,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
$dom_doc->formatOutput = true;
|
$dom_doc->formatOutput = true;
|
||||||
$dom_doc->standalone = true;
|
$dom_doc->standalone = true;
|
||||||
|
|
||||||
$record = $dom_doc->createElement('record');
|
$record = $dom_doc->createElement('record');
|
||||||
$record->setAttribute('record_id', $this->get_record_id());
|
$record->setAttribute('record_id', $this->get_record_id());
|
||||||
$dom_doc->appendChild($record);
|
$dom_doc->appendChild($record);
|
||||||
$description = $dom_doc->createElement('description');
|
$description = $dom_doc->createElement('description');
|
||||||
@@ -784,16 +783,17 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
|
|
||||||
foreach ($caption->get_fields() as $field)
|
foreach ($caption->get_fields() as $field)
|
||||||
{
|
{
|
||||||
if ($field->is_multi())
|
$values = $field->get_values();
|
||||||
$values = $field->get_value();
|
// if ($field->is_multi())
|
||||||
else
|
// $values = $field->get_value();
|
||||||
$values = array($field->get_value());
|
// else
|
||||||
|
// $values = array($field->get_value());
|
||||||
|
|
||||||
foreach ($values as $value)
|
foreach ($values as $value)
|
||||||
{
|
{
|
||||||
$elem = $dom_doc->createElement($field->get_name());
|
$elem = $dom_doc->createElement($field->get_name());
|
||||||
$elem->appendChild($dom_doc->createTextNode($value));
|
$elem->appendChild($dom_doc->createTextNode($value->getValue()));
|
||||||
$elem->setAttribute('meta_id', $field->get_meta_id());
|
$elem->setAttribute('meta_id', $value->getId());
|
||||||
$elem->setAttribute('meta_struct_id', $field->get_meta_struct_id());
|
$elem->setAttribute('meta_struct_id', $field->get_meta_struct_id());
|
||||||
$description->appendChild($elem);
|
$description->appendChild($elem);
|
||||||
}
|
}
|
||||||
@@ -836,21 +836,34 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->set_metadatas(
|
/* @var $field caption_field */
|
||||||
array(
|
/**
|
||||||
'meta_struct_id' => $field->get_meta_struct_id()
|
* Replacing original name in multi values is non sense
|
||||||
, 'meta_id' => get_meta_id
|
*/
|
||||||
, 'value' => array($original_name)
|
if (!$field->is_multi())
|
||||||
)
|
{
|
||||||
);
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$value = array_pop($field->get_values());
|
||||||
|
|
||||||
|
$this->set_metadatas(
|
||||||
|
array(
|
||||||
|
'meta_struct_id' => $field->get_meta_struct_id()
|
||||||
|
, 'meta_id' => $value->getId()
|
||||||
|
, 'value' => array($original_name)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'UPDATE record
|
$sql = 'UPDATE record
|
||||||
SET originalname = :originalname WHERE record_id = :record_id';
|
SET originalname = :originalname WHERE record_id = :record_id';
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
':originalname' => $original_name
|
':originalname' => $original_name
|
||||||
, ':record_id' => $this->get_record_id()
|
, ':record_id' => $this->get_record_id()
|
||||||
);
|
);
|
||||||
|
|
||||||
$stmt = $this->get_databox()->get_connection()->prepare($sql);
|
$stmt = $this->get_databox()->get_connection()->prepare($sql);
|
||||||
@@ -868,7 +881,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
*/
|
*/
|
||||||
public function get_title($highlight = false, searchEngine_adapter $searchEngine = null)
|
public function get_title($highlight = false, searchEngine_adapter $searchEngine = null)
|
||||||
{
|
{
|
||||||
$sbas_id = $this->get_sbas_id();
|
$sbas_id = $this->get_sbas_id();
|
||||||
$record_id = $this->get_record_id();
|
$record_id = $this->get_record_id();
|
||||||
|
|
||||||
if ($this->is_grouping())
|
if ($this->is_grouping())
|
||||||
@@ -878,8 +891,8 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
return $regfield['regname'];
|
return $regfield['regname'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$title = '';
|
$title = '';
|
||||||
$appbox = appbox::get_instance();
|
$appbox = appbox::get_instance();
|
||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
|
|
||||||
$fields = $this->get_databox()->get_meta_structure();
|
$fields = $this->get_databox()->get_meta_structure();
|
||||||
@@ -897,14 +910,14 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
if (count($fields_to_retrieve) > 0)
|
if (count($fields_to_retrieve) > 0)
|
||||||
{
|
{
|
||||||
$retrieved_fields = $this->get_caption()->get_highlight_fields($highlight, $fields_to_retrieve, $searchEngine);
|
$retrieved_fields = $this->get_caption()->get_highlight_fields($highlight, $fields_to_retrieve, $searchEngine);
|
||||||
$titles = array();
|
$titles = array();
|
||||||
foreach ($retrieved_fields as $key => $value)
|
foreach ($retrieved_fields as $key => $value)
|
||||||
{
|
{
|
||||||
if (trim($value['value'] === ''))
|
if (trim($value['value'] === ''))
|
||||||
continue;
|
continue;
|
||||||
$titles[] = $value['value'];
|
$titles[] = $value['value'];
|
||||||
}
|
}
|
||||||
$title = trim(implode(' - ', $titles));
|
$title = trim(implode(' - ', $titles));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trim($title) === '')
|
if (trim($title) === '')
|
||||||
@@ -955,9 +968,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
|
|
||||||
foreach ($desc->get_fields() as $caption_field)
|
foreach ($desc->get_fields() as $caption_field)
|
||||||
{
|
{
|
||||||
|
/* @var $caption_field caption_field */
|
||||||
$meta_struct_id = $caption_field->get_meta_struct_id();
|
$meta_struct_id = $caption_field->get_meta_struct_id();
|
||||||
if (array_key_exists($meta_struct_id, $array))
|
if (array_key_exists($meta_struct_id, $array))
|
||||||
$fields[$array[$meta_struct_id]] = $caption_field->get_value();
|
{
|
||||||
|
$fields[$array[$meta_struct_id]] = $caption_field->get_serialized_values();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
@@ -988,7 +1004,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
*/
|
*/
|
||||||
protected function searchRegFields(databox_descriptionStructure $meta_struct)
|
protected function searchRegFields(databox_descriptionStructure $meta_struct)
|
||||||
{
|
{
|
||||||
$fields = null;
|
$fields = null;
|
||||||
$fields["regname"] = "";
|
$fields["regname"] = "";
|
||||||
$fields["regdesc"] = "";
|
$fields["regdesc"] = "";
|
||||||
$fields["regdate"] = "";
|
$fields["regdate"] = "";
|
||||||
@@ -1062,11 +1078,11 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
public function substitute_subdef($name, system_file $pathfile)
|
public function substitute_subdef($name, system_file $pathfile)
|
||||||
{
|
{
|
||||||
$newfilename = $this->record_id . '_0_' . $name
|
$newfilename = $this->record_id . '_0_' . $name
|
||||||
. '.' . $pathfile->get_extension();
|
. '.' . $pathfile->get_extension();
|
||||||
|
|
||||||
$base_url = '';
|
$base_url = '';
|
||||||
|
|
||||||
$original_file = $subdef_def = false;
|
$original_file = $subdef_def = false;
|
||||||
|
|
||||||
if ($name == 'document')
|
if ($name == 'document')
|
||||||
{
|
{
|
||||||
@@ -1116,7 +1132,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
$path = databox::dispatch($subdef_def->get_path());
|
$path = databox::dispatch($subdef_def->get_path());
|
||||||
system_file::mkdir($path);
|
system_file::mkdir($path);
|
||||||
$original_file = $path . $newfilename;
|
$original_file = $path . $newfilename;
|
||||||
}
|
}
|
||||||
@@ -1126,9 +1142,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
if (trim($subdef_def->get_baseurl()) !== '')
|
if (trim($subdef_def->get_baseurl()) !== '')
|
||||||
{
|
{
|
||||||
$base_url = str_replace(
|
$base_url = str_replace(
|
||||||
array((string) $subdef_def->get_path(), $newfilename)
|
array((string) $subdef_def->get_path(), $newfilename)
|
||||||
, array((string) $subdef_def->get_baseurl(), '')
|
, array((string) $subdef_def->get_baseurl(), '')
|
||||||
, $path_file_dest
|
, $path_file_dest
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1145,18 +1161,18 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$appbox = \appbox::get_instance();
|
$appbox = \appbox::get_instance();
|
||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
|
|
||||||
$connbas = connection::getPDOConnection($this->get_sbas_id());
|
$connbas = connection::getPDOConnection($this->get_sbas_id());
|
||||||
|
|
||||||
$sql = 'DELETE FROM subdef WHERE record_id= :record_id AND name=:name';
|
$sql = 'DELETE FROM subdef WHERE record_id= :record_id AND name=:name';
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(
|
$stmt->execute(
|
||||||
array(
|
array(
|
||||||
':record_id' => $this->record_id
|
':record_id' => $this->record_id
|
||||||
, ':name' => $name
|
, ':name' => $name
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$image_size = $system_file->get_technical_datas();
|
$image_size = $system_file->get_technical_datas();
|
||||||
@@ -1171,18 +1187,18 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
|
|
||||||
$stmt->execute(array(
|
$stmt->execute(array(
|
||||||
':record_id' => $this->record_id,
|
':record_id' => $this->record_id,
|
||||||
':name' => $name,
|
':name' => $name,
|
||||||
':baseurl' => $base_url,
|
':baseurl' => $base_url,
|
||||||
':filename' => $system_file->getFilename(),
|
':filename' => $system_file->getFilename(),
|
||||||
':width' => $image_size[system_file::TC_DATAS_WIDTH],
|
':width' => $image_size[system_file::TC_DATAS_WIDTH],
|
||||||
':height' => $image_size[system_file::TC_DATAS_HEIGHT],
|
':height' => $image_size[system_file::TC_DATAS_HEIGHT],
|
||||||
':mime' => $system_file->get_mime(),
|
':mime' => $system_file->get_mime(),
|
||||||
':path' => $system_file->getPath(),
|
':path' => $system_file->getPath(),
|
||||||
':filesize' => $system_file->getSize()
|
':filesize' => $system_file->getSize()
|
||||||
));
|
));
|
||||||
|
|
||||||
$sql = 'UPDATE record SET moddate=NOW() WHERE record_id=:record_id';
|
$sql = 'UPDATE record SET moddate=NOW() WHERE record_id=:record_id';
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
@@ -1201,7 +1217,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
$type = $name == 'document' ? 'HD' : $name;
|
$type = $name == 'document' ? 'HD' : $name;
|
||||||
|
|
||||||
$session->get_logger($this->get_databox())
|
$session->get_logger($this->get_databox())
|
||||||
->log($this, Session_Logger::EVENT_SUBSTITUTE, $type, '');
|
->log($this, Session_Logger::EVENT_SUBSTITUTE, $type, '');
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
@@ -1219,13 +1235,13 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
protected function set_xml(DOMDocument $dom_doc)
|
protected function set_xml(DOMDocument $dom_doc)
|
||||||
{
|
{
|
||||||
$connbas = $this->get_databox()->get_connection();
|
$connbas = $this->get_databox()->get_connection();
|
||||||
$sql = 'UPDATE record SET xml = :xml WHERE record_id= :record_id';
|
$sql = 'UPDATE record SET xml = :xml WHERE record_id= :record_id';
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(
|
$stmt->execute(
|
||||||
array(
|
array(
|
||||||
':xml' => $dom_doc->saveXML(),
|
':xml' => $dom_doc->saveXML(),
|
||||||
':record_id' => $this->record_id
|
':record_id' => $this->record_id
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->reindex();
|
$this->reindex();
|
||||||
@@ -1251,29 +1267,32 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_array($params['value']))
|
if (!is_scalar($params['value']))
|
||||||
throw new Exception();
|
throw new Exception('Metadata value should be scalar');
|
||||||
|
|
||||||
$databox_field = databox_field::get_instance($databox, $params['meta_struct_id']);
|
$databox_field = databox_field::get_instance($databox, $params['meta_struct_id']);
|
||||||
|
|
||||||
|
$caption_field = new caption_field($databox_field, $this);
|
||||||
|
|
||||||
if (trim($params['meta_id']) !== '')
|
if (trim($params['meta_id']) !== '')
|
||||||
{
|
{
|
||||||
$tmp_val = trim(implode('', $params['value']));
|
$tmp_val = trim($params['value']);
|
||||||
$caption_field = new caption_field($databox_field, $this, $params['meta_id']);
|
|
||||||
|
$caption_field_value = $caption_field->get_value($params['meta_id']);
|
||||||
|
|
||||||
if ($tmp_val === '')
|
if ($tmp_val === '')
|
||||||
{
|
{
|
||||||
$caption_field->delete();
|
$caption_field_value->delete();
|
||||||
unset($caption_field);
|
unset($caption_field_value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$caption_field->set_value($params['value']);
|
$caption_field_value->set_value($params['value']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$caption_field = caption_field::create($databox_field, $this, $params['value']);
|
$caption_field_value = caption_Field_Value::create($databox_field, $this, $params['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->caption_record = null;
|
$this->caption_record = null;
|
||||||
@@ -1319,9 +1338,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
public function reindex()
|
public function reindex()
|
||||||
{
|
{
|
||||||
$connbas = connection::getPDOConnection($this->get_sbas_id());
|
$connbas = connection::getPDOConnection($this->get_sbas_id());
|
||||||
$sql = 'UPDATE record SET status=(status & ~7 | 4)
|
$sql = 'UPDATE record SET status=(status & ~7 | 4)
|
||||||
WHERE record_id= :record_id';
|
WHERE record_id= :record_id';
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(':record_id' => $this->record_id));
|
$stmt->execute(array(':record_id' => $this->record_id));
|
||||||
$this->delete_data_from_cache(self::CACHE_STATUS);
|
$this->delete_data_from_cache(self::CACHE_STATUS);
|
||||||
|
|
||||||
@@ -1335,8 +1354,8 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
public function rebuild_subdefs()
|
public function rebuild_subdefs()
|
||||||
{
|
{
|
||||||
$connbas = connection::getPDOConnection($this->get_sbas_id());
|
$connbas = connection::getPDOConnection($this->get_sbas_id());
|
||||||
$sql = 'UPDATE record SET jeton=(jeton | ' . JETON_MAKE_SUBDEF . ') WHERE record_id = :record_id';
|
$sql = 'UPDATE record SET jeton=(jeton | ' . JETON_MAKE_SUBDEF . ') WHERE record_id = :record_id';
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@@ -1349,10 +1368,10 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
public function write_metas()
|
public function write_metas()
|
||||||
{
|
{
|
||||||
$connbas = connection::getPDOConnection($this->get_sbas_id());
|
$connbas = connection::getPDOConnection($this->get_sbas_id());
|
||||||
$sql = 'UPDATE record
|
$sql = 'UPDATE record
|
||||||
SET jeton = ' . (JETON_WRITE_META_DOC | JETON_WRITE_META_SUBDEF) . '
|
SET jeton = ' . (JETON_WRITE_META_DOC | JETON_WRITE_META_SUBDEF) . '
|
||||||
WHERE record_id= :record_id';
|
WHERE record_id= :record_id';
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(':record_id' => $this->record_id));
|
$stmt->execute(array(':record_id' => $this->record_id));
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@@ -1368,21 +1387,21 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
$connbas = connection::getPDOConnection($this->get_sbas_id());
|
$connbas = connection::getPDOConnection($this->get_sbas_id());
|
||||||
|
|
||||||
$registry = registry::get_instance();
|
$registry = registry::get_instance();
|
||||||
$sql = 'UPDATE record SET status = 0b' . $status . '
|
$sql = 'UPDATE record SET status = 0b' . $status . '
|
||||||
WHERE record_id= :record_id';
|
WHERE record_id= :record_id';
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(':record_id' => $this->record_id));
|
$stmt->execute(array(':record_id' => $this->record_id));
|
||||||
|
|
||||||
$sql = 'REPLACE INTO status (id, record_id, name, value) VALUES (null, :record_id, :name, :value)';
|
$sql = 'REPLACE INTO status (id, record_id, name, value) VALUES (null, :record_id, :name, :value)';
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
|
|
||||||
$status = strrev($status);
|
$status = strrev($status);
|
||||||
for ($i = 4; $i < strlen($status); $i++)
|
for ($i = 4; $i < strlen($status); $i++)
|
||||||
{
|
{
|
||||||
$stmt->execute(array(
|
$stmt->execute(array(
|
||||||
':record_id' => $this->get_record_id(),
|
':record_id' => $this->get_record_id(),
|
||||||
':name' => $i,
|
':name' => $i,
|
||||||
':value' => $status[$i]
|
':value' => $status[$i]
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
@@ -1392,10 +1411,10 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
$sphinx = sphinxrt::get_instance($registry);
|
$sphinx = sphinxrt::get_instance($registry);
|
||||||
|
|
||||||
$sbas_params = phrasea::sbas_params();
|
$sbas_params = phrasea::sbas_params();
|
||||||
$sbas_id = $this->get_sbas_id();
|
$sbas_id = $this->get_sbas_id();
|
||||||
if (isset($sbas_params[$sbas_id]))
|
if (isset($sbas_params[$sbas_id]))
|
||||||
{
|
{
|
||||||
$params = $sbas_params[$sbas_id];
|
$params = $sbas_params[$sbas_id];
|
||||||
$sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
|
$sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
|
||||||
$sphinx->update_status(array("metadatas" . $sbas_crc, "metadatas" . $sbas_crc . "_stemmed_en", "metadatas" . $sbas_crc . "_stemmed_fr", "documents" . $sbas_crc), $this->get_sbas_id(), $this->get_record_id(), strrev($status));
|
$sphinx->update_status(array("metadatas" . $sbas_crc, "metadatas" . $sbas_crc . "_stemmed_en", "metadatas" . $sbas_crc . "_stemmed_fr", "documents" . $sbas_crc), $this->get_sbas_id(), $this->get_record_id(), strrev($status));
|
||||||
}
|
}
|
||||||
@@ -1438,9 +1457,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$regname = '';
|
$regname = '';
|
||||||
if ($sxe = simplexml_load_string($this->get_xml()))
|
if ($sxe = simplexml_load_string($this->get_xml()))
|
||||||
$regname = (string) $sxe->description->$balisename;
|
$regname = (string) $sxe->description->$balisename;
|
||||||
|
|
||||||
return $regname;
|
return $regname;
|
||||||
}
|
}
|
||||||
@@ -1459,7 +1478,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
|
|
||||||
if ($is_grouping)
|
if ($is_grouping)
|
||||||
{
|
{
|
||||||
$uuid = uuid::generate_v4();
|
$uuid = uuid::generate_v4();
|
||||||
$sha256 = null;
|
$sha256 = null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1467,7 +1486,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
$uuid = $system_file->read_uuid();
|
$uuid = $system_file->read_uuid();
|
||||||
if (!uuid::is_valid($uuid))
|
if (!uuid::is_valid($uuid))
|
||||||
{
|
{
|
||||||
$uuid = uuid::generate_v4();
|
$uuid = uuid::generate_v4();
|
||||||
}
|
}
|
||||||
$sha256 = $system_file->get_sha256();
|
$sha256 = $system_file->get_sha256();
|
||||||
}
|
}
|
||||||
@@ -1491,32 +1510,32 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
|
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(
|
$stmt->execute(array(
|
||||||
':coll_id' => $coll_id
|
':coll_id' => $coll_id
|
||||||
, ':parent_record_id' => ($is_grouping ? 1 : 0)
|
, ':parent_record_id' => ($is_grouping ? 1 : 0)
|
||||||
, ':type' => $type
|
, ':type' => $type
|
||||||
, ':sha256' => $sha256
|
, ':sha256' => $sha256
|
||||||
, ':uuid' => $uuid
|
, ':uuid' => $uuid
|
||||||
, ':originalname' => $original_name
|
, ':originalname' => $original_name
|
||||||
, ':mime' => $system_file->get_mime()
|
, ':mime' => $system_file->get_mime()
|
||||||
));
|
));
|
||||||
|
|
||||||
$record_id = $connbas->lastInsertId();
|
$record_id = $connbas->lastInsertId();
|
||||||
$record = new self($sbas_id, $record_id);
|
$record = new self($sbas_id, $record_id);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance();
|
$appbox = appbox::get_instance();
|
||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
$log_id = $session->get_logger($databox)->get_id();
|
$log_id = $session->get_logger($databox)->get_id();
|
||||||
|
|
||||||
$sql = 'INSERT INTO log_docs (id, log_id, date, record_id, action, final, comment)
|
$sql = 'INSERT INTO log_docs (id, log_id, date, record_id, action, final, comment)
|
||||||
VALUES (null, :log_id, now(),
|
VALUES (null, :log_id, now(),
|
||||||
:record_id, "add", :coll_id,"")';
|
:record_id, "add", :coll_id,"")';
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(
|
$stmt->execute(array(
|
||||||
':log_id' => $log_id,
|
':log_id' => $log_id,
|
||||||
':record_id' => $record_id,
|
':record_id' => $record_id,
|
||||||
':coll_id' => $coll_id
|
':coll_id' => $coll_id
|
||||||
));
|
));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
}
|
}
|
||||||
@@ -1545,7 +1564,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
|
|
||||||
$tc_datas = $system_file->get_technical_datas();
|
$tc_datas = $system_file->get_technical_datas();
|
||||||
|
|
||||||
$sql = 'REPLACE INTO technical_datas (id, record_id, name, value)
|
$sql = 'REPLACE INTO technical_datas (id, record_id, name, value)
|
||||||
VALUES (null, :record_id, :name, :value)';
|
VALUES (null, :record_id, :name, :value)';
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
|
|
||||||
@@ -1555,9 +1574,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
$stmt->execute(array(
|
$stmt->execute(array(
|
||||||
':record_id' => $record_id
|
':record_id' => $record_id
|
||||||
, ':name' => $name
|
, ':name' => $name
|
||||||
, ':value' => $value
|
, ':value' => $value
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
@@ -1591,14 +1610,14 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
|
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute($params);
|
$stmt->execute($params);
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$records = array();
|
$records = array();
|
||||||
|
|
||||||
foreach ($rs as $row)
|
foreach ($rs as $row)
|
||||||
{
|
{
|
||||||
$k = count($records);
|
$k = count($records);
|
||||||
$records[$k] = new record_adapter($sbas_id, $row['record_id']);
|
$records[$k] = new record_adapter($sbas_id, $row['record_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1623,11 +1642,11 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
*/
|
*/
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
$connbas = $this->get_databox()->get_connection();
|
$connbas = $this->get_databox()->get_connection();
|
||||||
$sbas_id = $this->get_databox()->get_sbas_id();
|
$sbas_id = $this->get_databox()->get_sbas_id();
|
||||||
$appbox = appbox::get_instance();
|
$appbox = appbox::get_instance();
|
||||||
$registry = $appbox->get_registry();
|
$registry = $appbox->get_registry();
|
||||||
$conn = $appbox->get_connection();
|
$conn = $appbox->get_connection();
|
||||||
|
|
||||||
$ftodel = array();
|
$ftodel = array();
|
||||||
foreach ($this->get_subdefs() as $subdef)
|
foreach ($this->get_subdefs() as $subdef)
|
||||||
@@ -1635,30 +1654,30 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
if (!$subdef->is_physically_present())
|
if (!$subdef->is_physically_present())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$ftodel[] = $subdef->get_pathfile();
|
$ftodel[] = $subdef->get_pathfile();
|
||||||
$watermark = $subdef->get_path() . 'watermark_' . $subdef->get_file();
|
$watermark = $subdef->get_path() . 'watermark_' . $subdef->get_file();
|
||||||
if (file_exists($watermark))
|
if (file_exists($watermark))
|
||||||
$ftodel[] = $watermark;
|
$ftodel[] = $watermark;
|
||||||
$stamp = $subdef->get_path() . 'stamp_' . $subdef->get_file();
|
$stamp = $subdef->get_path() . 'stamp_' . $subdef->get_file();
|
||||||
if (file_exists($stamp))
|
if (file_exists($stamp))
|
||||||
$ftodel[] = $stamp;
|
$ftodel[] = $stamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
$origcoll = phrasea::collFromBas($this->get_base_id());
|
$origcoll = phrasea::collFromBas($this->get_base_id());
|
||||||
|
|
||||||
$appbox->get_session()->get_logger($this->get_databox())
|
$appbox->get_session()->get_logger($this->get_databox())
|
||||||
->log($this, Session_Logger::EVENT_DELETE, $origcoll, $this->get_xml());
|
->log($this, Session_Logger::EVENT_DELETE, $origcoll, $this->get_xml());
|
||||||
|
|
||||||
$sql = "DELETE FROM record WHERE record_id = :record_id";
|
$sql = "DELETE FROM record WHERE record_id = :record_id";
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
|
||||||
$sql = 'SELECT id FROM metadatas WHERE record_id = :record_id';
|
$sql = 'SELECT id FROM metadatas WHERE record_id = :record_id';
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
||||||
$rs = $stmt->fetchAll();
|
$rs = $stmt->fetchAll();
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -1669,7 +1688,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
|
|
||||||
if (isset($sbas_params[$sbas_id]))
|
if (isset($sbas_params[$sbas_id]))
|
||||||
{
|
{
|
||||||
$params = $sbas_params[$sbas_id];
|
$params = $sbas_params[$sbas_id];
|
||||||
$sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
|
$sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
|
||||||
foreach ($rs as $row)
|
foreach ($rs as $row)
|
||||||
{
|
{
|
||||||
@@ -1683,49 +1702,49 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
unset($e);
|
unset($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "DELETE FROM metadatas WHERE record_id = :record_id";
|
$sql = "DELETE FROM metadatas WHERE record_id = :record_id";
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$sql = "DELETE FROM prop WHERE record_id = :record_id";
|
$sql = "DELETE FROM prop WHERE record_id = :record_id";
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$sql = "DELETE FROM idx WHERE record_id = :record_id";
|
$sql = "DELETE FROM idx WHERE record_id = :record_id";
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$sql = "DELETE FROM permalinks
|
$sql = "DELETE FROM permalinks
|
||||||
WHERE subdef_id
|
WHERE subdef_id
|
||||||
IN (SELECT subdef_id FROM subdef WHERE record_id=:record_id)";
|
IN (SELECT subdef_id FROM subdef WHERE record_id=:record_id)";
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$sql = "DELETE FROM subdef WHERE record_id = :record_id";
|
$sql = "DELETE FROM subdef WHERE record_id = :record_id";
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$sql = "DELETE FROM technical_datas WHERE record_id = :record_id";
|
$sql = "DELETE FROM technical_datas WHERE record_id = :record_id";
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$sql = "DELETE FROM thit WHERE record_id = :record_id";
|
$sql = "DELETE FROM thit WHERE record_id = :record_id";
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$sql = "DELETE FROM regroup WHERE rid_parent = :record_id";
|
$sql = "DELETE FROM regroup WHERE rid_parent = :record_id";
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$sql = "DELETE FROM regroup WHERE rid_child = :record_id";
|
$sql = "DELETE FROM regroup WHERE rid_child = :record_id";
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
@@ -1785,7 +1804,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
echo 'Aucune sous definition a faire pour ' . $this->get_type() . "\n";
|
echo 'Aucune sous definition a faire pour ' . $this->get_type() . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$subdef_class = 'databox_subdef' . ucfirst($this->get_type());
|
$subdef_class = 'databox_subdef' . ucfirst($this->get_type());
|
||||||
$record_subdefs = $this->get_subdefs();
|
$record_subdefs = $this->get_subdefs();
|
||||||
|
|
||||||
foreach ($subdefs as $subdef)
|
foreach ($subdefs as $subdef)
|
||||||
@@ -1847,7 +1866,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
*/
|
*/
|
||||||
protected function generate_subdef(databox_subdefInterface $subdef_class, $pathdest)
|
protected function generate_subdef(databox_subdefInterface $subdef_class, $pathdest)
|
||||||
{
|
{
|
||||||
$registry = registry::get_instance();
|
$registry = registry::get_instance();
|
||||||
$generated = $subdef_class->generate($this, $pathdest, $registry);
|
$generated = $subdef_class->generate($this, $pathdest, $registry);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@@ -1899,12 +1918,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
(null, :log_id, now(), :rec, :referrer, :site)';
|
(null, :log_id, now(), :rec, :referrer, :site)';
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
':log_id' => $log_id
|
':log_id' => $log_id
|
||||||
, ':rec' => $this->get_record_id()
|
, ':rec' => $this->get_record_id()
|
||||||
, ':referrer' => $referrer
|
, ':referrer' => $referrer
|
||||||
, ':site' => $gv_sit
|
, ':site' => $gv_sit
|
||||||
);
|
);
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute($params);
|
$stmt->execute($params);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
@@ -1945,7 +1964,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
public function get_container_baskets()
|
public function get_container_baskets()
|
||||||
{
|
{
|
||||||
$Core = bootstrap::getCore();
|
$Core = bootstrap::getCore();
|
||||||
$em = $Core->getEntityManager();
|
$em = $Core->getEntityManager();
|
||||||
|
|
||||||
$repo = $em->getRepository('\Entities\Basket');
|
$repo = $em->getRepository('\Entities\Basket');
|
||||||
|
|
||||||
@@ -1963,15 +1982,15 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
public static function get_records_by_originalname(databox $databox, $original_name, $offset_start = 0, $how_many = 10)
|
public static function get_records_by_originalname(databox $databox, $original_name, $offset_start = 0, $how_many = 10)
|
||||||
{
|
{
|
||||||
$offset_start = (int) ($offset_start < 0 ? 0 : $offset_start);
|
$offset_start = (int) ($offset_start < 0 ? 0 : $offset_start);
|
||||||
$how_many = (int) (($how_many > 20 || $how_many < 1) ? 10 : $how_many);
|
$how_many = (int) (($how_many > 20 || $how_many < 1) ? 10 : $how_many);
|
||||||
|
|
||||||
$sql = sprintf('SELECT record_id FROM record
|
$sql = sprintf('SELECT record_id FROM record
|
||||||
WHERE original_name = :original_name LIMIT %d, %d'
|
WHERE original_name = :original_name LIMIT %d, %d'
|
||||||
, $offset_start, $how_many);
|
, $offset_start, $how_many);
|
||||||
|
|
||||||
$stmt = $databox->get_connection()->prepare($sql);
|
$stmt = $databox->get_connection()->prepare($sql);
|
||||||
$stmt->execute(array(':original_name' => $original_name));
|
$stmt->execute(array(':original_name' => $original_name));
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$records = array();
|
$records = array();
|
||||||
@@ -2008,18 +2027,18 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
ORDER BY g.ord ASC, dateadd ASC, record_id ASC';
|
ORDER BY g.ord ASC, dateadd ASC, record_id ASC';
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
':GV_site' => $appbox->get_registry()->get('GV_sit')
|
':GV_site' => $appbox->get_registry()->get('GV_sit')
|
||||||
, ':usr_id' => $appbox->get_session()->get_usr_id()
|
, ':usr_id' => $appbox->get_session()->get_usr_id()
|
||||||
, ':record_id' => $this->get_record_id()
|
, ':record_id' => $this->get_record_id()
|
||||||
);
|
);
|
||||||
|
|
||||||
$stmt = $this->get_databox()->get_connection()->prepare($sql);
|
$stmt = $this->get_databox()->get_connection()->prepare($sql);
|
||||||
$stmt->execute($params);
|
$stmt->execute($params);
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$set = new set_selection();
|
$set = new set_selection();
|
||||||
$i = 1;
|
$i = 1;
|
||||||
foreach ($rs as $row)
|
foreach ($rs as $row)
|
||||||
{
|
{
|
||||||
$set->add_element(new record_adapter($this->get_sbas_id(), $row['record_id'], $i));
|
$set->add_element(new record_adapter($this->get_sbas_id(), $row['record_id'], $i));
|
||||||
@@ -2052,14 +2071,14 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
|
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
':GV_site' => $appbox->get_registry()->get('GV_sit')
|
':GV_site' => $appbox->get_registry()->get('GV_sit')
|
||||||
, ':usr_id' => $appbox->get_session()->get_usr_id()
|
, ':usr_id' => $appbox->get_session()->get_usr_id()
|
||||||
, ':record_id' => $this->get_record_id()
|
, ':record_id' => $this->get_record_id()
|
||||||
);
|
);
|
||||||
|
|
||||||
$stmt = $this->get_databox()->get_connection()->prepare($sql);
|
$stmt = $this->get_databox()->get_connection()->prepare($sql);
|
||||||
$stmt->execute($params);
|
$stmt->execute($params);
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$set = new set_selection();
|
$set = new set_selection();
|
||||||
@@ -2105,9 +2124,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
VALUES (null, :parent_record_id, :record_id, NOW(), :ord)';
|
VALUES (null, :parent_record_id, :record_id, NOW(), :ord)';
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
':parent_record_id' => $this->get_record_id()
|
':parent_record_id' => $this->get_record_id()
|
||||||
, ':record_id' => $record->get_record_id()
|
, ':record_id' => $record->get_record_id()
|
||||||
, ':ord' => $ord
|
, ':ord' => $ord
|
||||||
);
|
);
|
||||||
|
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
@@ -2115,7 +2134,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
|
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$sql = 'UPDATE record SET moddate = NOW() WHERE record_id = :record_id';
|
$sql = 'UPDATE record SET moddate = NOW() WHERE record_id = :record_id';
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
@@ -2136,15 +2155,15 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
AND rid_child = :record_id";
|
AND rid_child = :record_id";
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
':parent_record_id' => $this->get_record_id()
|
':parent_record_id' => $this->get_record_id()
|
||||||
, ':record_id' => $record->get_record_id()
|
, ':record_id' => $record->get_record_id()
|
||||||
);
|
);
|
||||||
|
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute($params);
|
$stmt->execute($params);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$sql = 'UPDATE record SET moddate = NOW() WHERE record_id = :record_id';
|
$sql = 'UPDATE record SET moddate = NOW() WHERE record_id = :record_id';
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
$stmt->execute(array(':record_id' => $this->get_record_id()));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
Reference in New Issue
Block a user