$formatProperty = function ($datafield, $name, $label) {
if (count($datafield) == 0) {
return '';
}
$that = $this;
$translate = function ($str) use ($that, $label) {
return $that->transEsc($label . $str);
};
return '(' . implode(', ', array_unique(array_map($translate, $datafield))) . ')';
};
$formattedAuthors = [];
?>
if (!empty($data[$type])): ?>
foreach ($data[$type] as $author => $dataFields): ?>
ob_start(); ?>
=$this->escapeHtml($author)?>
// Display additional data using the appropriate translation prefix
// (for example, to render author roles correctly):
if (!empty($requiredDataFields)) {
foreach ($requiredDataFields as $field) {
$name = $field['name'];
$prefix = isset($field['prefix']) ? $field['prefix'] : '';
if (isset($dataFields[$name])) {
echo $formatProperty($dataFields[$name], $name, $prefix);
}
}
}
?>
// Strip whitespace before close tags to avoid spaces in front of commas:
$formattedAuthors[] = trim(preg_replace('/\s+<\//', '', ob_get_contents()));
ob_end_clean();
?>
endforeach; ?>
endif; ?>
=implode('; ', $formattedAuthors)?>