Refactors HTML return for date meta

This commit is contained in:
Rodrigo de Oliveira 2021-04-04 23:31:32 -03:00
parent a50f878725
commit 55afa4567c
2 changed files with 10 additions and 12 deletions

View File

@ -136,17 +136,15 @@ class Item_Metadata_Entity extends Entity {
* Get the value as a HTML string, with markup and links
* @return string
*/
public function get_value_as_html(){
public function get_value_as_html(){
$metadatum = $this->get_metadatum();
if (is_object($metadatum)) {
$fto = $metadatum->get_metadata_type_object();
if (is_object($fto)) {
if ( method_exists($fto, 'get_value_as_html') ) {
return $fto->get_value_as_html($this);
}
}
}
@ -163,7 +161,6 @@ class Item_Metadata_Entity extends Entity {
$separator = $this->get_multivalue_separator();
foreach ($value as $v) {
$return .= $prefix;
$return .= (string) $v;
@ -174,14 +171,12 @@ class Item_Metadata_Entity extends Entity {
if ($count < $total)
$return .= $separator;
}
} else {
$return = (string) $value;
}
return $return;
}
/**

View File

@ -80,20 +80,23 @@ class Date extends Metadata_Type {
if( empty( $el ) )
continue;
$return .= $prefix;
$return .= mysql2date(get_option('date_format'), ($el));
$return .= $this->format_date_value($el);
$return .= $suffix;
$count ++;
if ($count < $total)
$return .= $separator;
}
} else {
if( empty( $value ) )
return "";
$return = mysql2date(get_option('date_format'), ($value));
$return = $this->format_date_value($value);
}
return $return;
}
private function format_date_value($value) {
if (empty($value))
return "";
return mysql2date(get_option('date_format'), ($value));
}
}