Extracts compound meta return markup

This commit is contained in:
Rodrigo de Oliveira 2021-04-05 02:36:27 -03:00
parent f1d83ed0a4
commit 3392ddfa2d
3 changed files with 18 additions and 17 deletions

View File

@ -196,10 +196,11 @@ class Compound extends Metadata_Type {
foreach ( $compound_element as $meta_id => $meta ) {
$index = array_search( $meta_id, array_column( $order, 'id' ) );
if ( $meta instanceof Item_Metadata_Entity && $meta->get_value_as_html() != '' ) {
$html = $this->get_meta_html($meta);
if ( $index !== false ) {
$metadata_value[$index] = '<div class="tainacan-metadatum"><label class="label">' . $meta->get_metadatum()->get_name() . '</label> <p>' . $meta->get_value_as_html() . "</p></div>";
$metadata_value[$index] = $html;
} else {
$metadata_value_not_ordinate[] = '<div class="tainacan-metadatum"><label class="label">' . $meta->get_metadatum()->get_name() . '</label> <p>' . $meta->get_value_as_html() . "</p></div>";
$metadata_value_not_ordinate[] = $html;
}
}
}
@ -213,18 +214,27 @@ class Compound extends Metadata_Type {
foreach ( $value as $meta_id => $meta ) {
$index = array_search( $meta_id, array_column( $order, 'id' ) );
if ( $meta instanceof Item_Metadata_Entity && $meta->get_value_as_html() != '' ) {
$html = $this->get_meta_html($meta);
if ( $index !== false ) {
$metadata_value[intval($index)] = '<div class="tainacan-metadatum"><label class="label">' . $meta->get_metadatum()->get_name() . '</label> <p>' . $meta->get_value_as_html() . "</p></div>";
$metadata_value[intval($index)] = $html;
} else {
$metadata_value_not_ordinate[] = '<div class="tainacan-metadatum"><label class="label">' . $meta->get_metadatum()->get_name() . '</label> <p>' . $meta->get_value_as_html() . "</p></div>";
$metadata_value_not_ordinate[] = $html;
}
}
}
$return = '<div class="tainacan-compound-group">' . implode("\n", array_merge($metadata_value, $metadata_value_not_ordinate)) . "</div> \n";
}
$return = '<div class="tainacan-compound-group">' . implode("\n", array_merge($metadata_value, $metadata_value_not_ordinate)) . "</div> \n";
}
return $return;
}
private function get_meta_html(Item_Metadata_Entity $meta) {
$html = '';
if ($meta instanceof Item_Metadata_Entity && !empty($meta->get_value_as_html())) {
$html = '<div class="tainacan-metadatum"><label class="label">' . $meta->get_metadatum()->get_name() . '</label> <p>' . $meta->get_value_as_html() . "</p></div>";
}
return $html;
}
}

View File

@ -77,9 +77,9 @@ class Date extends Metadata_Type {
$return .= $separator;
}
} else {
$return = $this->format_date_value($value);
}
return $return;
}

View File

@ -338,7 +338,6 @@ class Taxonomy extends Metadata_Type {
$return = '';
if ( $item_metadata->is_multiple() ) {
$count = 1;
$total = sizeof($value);
$prefix = $item_metadata->get_multivalue_prefix();
@ -346,7 +345,6 @@ class Taxonomy extends Metadata_Type {
$separator = $item_metadata->get_multivalue_separator();
foreach ( $value as $term ) {
$count ++;
if ( is_integer($term) ) {
@ -355,29 +353,22 @@ class Taxonomy extends Metadata_Type {
if ( $term instanceof \Tainacan\Entities\Term ) {
$return .= $prefix;
$return .= $this->get_term_hierarchy_html($term);
$return .= $suffix;
if ( $count <= $total ) {
$return .= $separator;
}
}
}
} else {
if ( $value instanceof \Tainacan\Entities\Term ) {
$return .= $this->get_term_hierarchy_html($value);
}
}
return $return;
}
private function get_term_hierarchy_html( \Tainacan\Entities\Term $term ) {