mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 12:03:14 +00:00
Moved vocabulary to Alchemy namespace
This commit is contained in:
@@ -117,6 +117,27 @@ class caption_Field_Value
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setVocab(\Alchemy\Phrasea\Vocabulary\ControlProvider\ControlProviderInterface $vocabulary, $vocab_id)
|
||||
{
|
||||
|
||||
$params = array(
|
||||
':VocabType' => $vocabulary->getType()
|
||||
, ':VocabularyId' => $vocab_id
|
||||
);
|
||||
|
||||
$sql_up = 'UPDATE metadatas
|
||||
SET VocabularyType = :VocabType, VocabularyId = :VocabularyId
|
||||
WHERE id = :meta_id';
|
||||
$stmt_up = $connbas->prepare($sql_up);
|
||||
$stmt_up->execute($params);
|
||||
$stmt_up->closeCursor();
|
||||
|
||||
$this->set_value($vocabulary->getValue($vocab_id));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function set_value($value)
|
||||
{
|
||||
$sbas_id = $this->databox_field->get_databox()->get_sbas_id();
|
||||
@@ -206,21 +227,24 @@ class caption_Field_Value
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function create(databox_field &$databox_field, record_Interface $record, $value)
|
||||
public static function create(databox_field &$databox_field, record_Interface $record, $value, \Alchemy\Phrasea\Vocabulary\ControlProvider\ControlProviderInterface $vocabulary = null, $vocabularyId = null)
|
||||
{
|
||||
|
||||
$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)
|
||||
$sql_ins = 'INSERT INTO metadatas
|
||||
(id, record_id, meta_struct_id, value, VocabularyType, VocabularyId)
|
||||
VALUES
|
||||
(null, :record_id, :field, :value)';
|
||||
(null, :record_id, :field, :value, :VocabType, :VocabId)';
|
||||
$stmt_ins = $connbas->prepare($sql_ins);
|
||||
$stmt_ins->execute(
|
||||
array(
|
||||
':record_id' => $record->get_record_id(),
|
||||
':field' => $databox_field->get_id(),
|
||||
':value' => $value
|
||||
':value' => $value,
|
||||
':VocabType' => $vocabulary ? $vocabulary->getType() : null,
|
||||
':VocabId' => $vocabulary ? $vocabularyId : null,
|
||||
)
|
||||
);
|
||||
$stmt_ins->closeCursor();
|
||||
|
@@ -185,7 +185,7 @@ class databox_field implements cache_cacheableInterface
|
||||
|
||||
try
|
||||
{
|
||||
$this->Vocabulary = databox_Field_VocabularyControl::get($row['VocabularyControlType']);
|
||||
$this->Vocabulary = \Alchemy\Phrasea\Vocabulary\Controller::get($row['VocabularyControlType']);
|
||||
$this->VocabularyRestriction = !!$row['RestrictToVocabularyControl'];
|
||||
}
|
||||
catch (Exception $e)
|
||||
@@ -498,7 +498,7 @@ class databox_field implements cache_cacheableInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setVocabularyControl(databox_Field_VocabularyControl_Interface $vocabulary = null)
|
||||
public function setVocabularyControl(\Alchemy\Phrasea\Vocabulary\ControlProvider\ControlProviderInterface $vocabulary = null)
|
||||
{
|
||||
$this->Vocabulary = $vocabulary;
|
||||
|
||||
|
@@ -1284,6 +1284,23 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
||||
|
||||
$caption_field = new caption_field($databox_field, $this);
|
||||
|
||||
$vocab = $vocab_id = null;
|
||||
|
||||
if ($params['vocabularyId'] && $databox_field->getVocabularyControl())
|
||||
{
|
||||
try
|
||||
{
|
||||
$vocab = $databox_field->getVocabularyControl();
|
||||
$vocab_id = $params['vocabularyId'];
|
||||
$vocab->validate($vocab_id);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$vocab = $vocab_id = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (trim($params['meta_id']) !== '')
|
||||
{
|
||||
$tmp_val = trim($params['value']);
|
||||
@@ -1298,11 +1315,15 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
||||
else
|
||||
{
|
||||
$caption_field_value->set_value($params['value']);
|
||||
if($vocab && $vocab_id)
|
||||
{
|
||||
$caption_field_value->setVocab($vocab, $vocab_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$caption_field_value = caption_Field_Value::create($databox_field, $this, $params['value']);
|
||||
$caption_field_value = caption_Field_Value::create($databox_field, $this, $params['value'], $vocab, $vocab_id);
|
||||
}
|
||||
|
||||
$this->caption_record = null;
|
||||
|
Reference in New Issue
Block a user