Merge branch 'release/0.17' of https://github.com/tainacan/tainacan into release/0.17
This commit is contained in:
commit
f33f1b9ee9
|
@ -892,6 +892,9 @@ class REST_Items_Controller extends REST_Controller {
|
|||
$collection_id = $request['collection_id'];
|
||||
$item = json_decode($request->get_body(), true);
|
||||
$metadata = $item['metadata'];
|
||||
foreach ($item as $key => $value) {
|
||||
$item[$key] = ( is_string($value) && !is_numeric($value) ? filter_var($value, FILTER_SANITIZE_STRING) : $value );
|
||||
}
|
||||
|
||||
$response_recaptcha = $this->submission_item_check_recaptcha($request);
|
||||
if ($response_recaptcha !== true) {
|
||||
|
@ -923,22 +926,36 @@ class REST_Items_Controller extends REST_Controller {
|
|||
foreach($value as $row) {
|
||||
$parent_meta_id = null;
|
||||
foreach($row as $child) {
|
||||
$child_value = $child['value'];
|
||||
if (is_array($child_value) == true) {
|
||||
$child_value = implode(' ', $child_value);
|
||||
}
|
||||
if (is_numeric($value) != true) {
|
||||
$child_value = filter_var($child_value, FILTER_SANITIZE_STRING);
|
||||
}
|
||||
$metadatum_child = $this->metadatum_repository->fetch( $child['metadatum_id'] );
|
||||
$item_metadata_child = new Entities\Item_Metadata_Entity($item, $metadatum_child, null, $parent_meta_id);
|
||||
$item_metadata_child->set_value(is_array($child['value']) ? implode(' ', $child['value']) : $child['value']);
|
||||
$item_metadata_child->set_value($child_value);
|
||||
$item_metadata_child = $this->submission_item_metadada($item_metadata_child, $request);
|
||||
if ($item_metadata_child instanceof \WP_REST_Response) {
|
||||
return $item_metadata_child;
|
||||
}
|
||||
}
|
||||
$parent_meta_id = $item_metadata_child->get_parent_meta_id();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$parent_meta_id = null;
|
||||
foreach($value as $child) {
|
||||
$child_value = $child['value'];
|
||||
if (is_array($child_value) == true) {
|
||||
$child_value = implode(' ', $child_value);
|
||||
}
|
||||
if (is_numeric($value) != true) {
|
||||
$child_value = filter_var($child_value, FILTER_SANITIZE_STRING);
|
||||
}
|
||||
$metadatum_child = $this->metadatum_repository->fetch( $child['metadatum_id'] );
|
||||
$item_metadata_child = new Entities\Item_Metadata_Entity($item, $metadatum_child, null, $parent_meta_id);
|
||||
$item_metadata_child->set_value(is_array($child['value']) ? implode(' ', $child['value']) : $child['value']);
|
||||
$item_metadata_child->set_value($child_value);
|
||||
$item_metadata_child = $this->submission_item_metadada($item_metadata_child, $request);
|
||||
if ($item_metadata_child instanceof \WP_REST_Response) {
|
||||
return $item_metadata_child;
|
||||
|
@ -947,6 +964,11 @@ class REST_Items_Controller extends REST_Controller {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (is_array($value) == true) {
|
||||
$value = array_map( function($v) { return is_numeric($v) ? $v : filter_var($v, FILTER_SANITIZE_STRING); }, $value);
|
||||
} else if (is_numeric($value) != true) {
|
||||
$value = filter_var($value, FILTER_SANITIZE_STRING);
|
||||
}
|
||||
if ($item_metadata->is_multiple()) {
|
||||
$item_metadata->set_value( is_array($value) ? $value : [$value] );
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue