improving multi textarea metadata display (#227)

This commit is contained in:
leogermani 2019-04-16 14:50:11 -03:00
parent a0ac1fc429
commit fd6e21adb5
2 changed files with 51 additions and 3 deletions

View File

@ -53,7 +53,19 @@ class Item_Metadata_Entity extends Entity {
* @return string
*/
public function get_multivalue_prefix() {
return apply_filters('tainacan-item-metadata-get-multivalue-prefix', '', $this);
$metadatum = $this->get_metadatum();
$value = '';
if (is_object($metadatum)) {
$fto = $metadatum->get_metadata_type_object();
if (is_object($fto)) {
if ( method_exists($fto, 'get_multivalue_prefix') ) {
$value = $fto->get_multivalue_prefix();
}
}
}
return apply_filters('tainacan-item-metadata-get-multivalue-prefix', $value, $this);
}
/**
@ -63,7 +75,19 @@ class Item_Metadata_Entity extends Entity {
* @return string
*/
public function get_multivalue_suffix() {
return apply_filters('tainacan-item-metadata-get-multivalue-suffix', '', $this);
$metadatum = $this->get_metadatum();
$value = '';
if (is_object($metadatum)) {
$fto = $metadatum->get_metadata_type_object();
if (is_object($fto)) {
if ( method_exists($fto, 'get_multivalue_suffix') ) {
$value = $fto->get_multivalue_suffix();
}
}
}
return apply_filters('tainacan-item-metadata-get-multivalue-suffix', $value, $this);
}
/**
@ -73,7 +97,19 @@ class Item_Metadata_Entity extends Entity {
* @return string
*/
public function get_multivalue_separator() {
return apply_filters('tainacan-item-metadata-get-multivalue-separator', ', ', $this);
$metadatum = $this->get_metadatum();
$value = ', ';
if (is_object($metadatum)) {
$fto = $metadatum->get_metadata_type_object();
if (is_object($fto)) {
if ( method_exists($fto, 'get_multivalue_separator') ) {
$value = $fto->get_multivalue_separator();
}
}
}
return apply_filters('tainacan-item-metadata-get-multivalue-separator', $value, $this);
}
/**

View File

@ -39,6 +39,18 @@ class Textarea extends Metadata_Type {
value=\''.json_encode( $itemMetadata->get_value() ).'\'
name="'.$itemMetadata->get_metadatum()->get_name().'"></tainacan-textarea>';
}
public function get_multivalue_prefix() {
return '<p>';
}
public function get_multivalue_separator() {
return '';
}
public function get_multivalue_suffix() {
return '</p>';
}
/**
* Get the value as a HTML string with links and breakline tag.