function theme_brightcove_field_metadata in Brightcove Video Connect 7.6
Same name and namespace in other branches
- 7.7 brightcove_field.formatters.inc \theme_brightcove_field_metadata()
- 7.3 brightcove_field/brightcove_field.formatters.inc \theme_brightcove_field_metadata()
- 7.4 brightcove_field/brightcove_field.formatters.inc \theme_brightcove_field_metadata()
- 7.5 brightcove_field/brightcove_field.formatters.inc \theme_brightcove_field_metadata()
Theme function to render brightcove metadata.
Parameters
$variables:
Return value
null|string
File
- ./
brightcove_field.formatters.inc, line 182 - Formatters for video field.
Code
function theme_brightcove_field_metadata($variables) {
$output = NULL;
$elements = $variables['elements'];
$type = $elements['#brightcove_widget_type'] == BRIGHTCOVE_VIDEO_WIDGET ? 'video' : 'playlist';
if ($elements["#{$type}"]) {
if ($elements['#key'] === 'all') {
$keys = _brightcove_field_get_object_formatter_keys($type);
unset($keys['all']);
$val = [];
foreach ($keys as $key => $label) {
$v = $elements["#{$type}"]
->{'get' . ucfirst($key)}();
if (is_array($v)) {
if (array_values($v) === $v) {
$val[$label] = implode(', ', $v);
// this will go trough check_plain() later
}
else {
$val += $v;
}
}
else {
$val[$label] = $v;
}
}
}
else {
$val = $elements["#{$type}"]
->{'get' . ucfirst($elements['#key'])}();
}
if (is_array($val)) {
if (array_values($val) === $val) {
$text = implode(', ', array_map('check_plain', $val));
$output = "<p><strong>{$elements['#label']}</strong> {$text}</p>";
}
else {
$rows = '';
foreach ($val as $k => $v) {
$kp = check_plain($k);
$vp = $v instanceof \Brightcove\Object\Video\Link ? l(t($v
->getText()), $v
->getUrl()) : check_plain($v);
$rows .= "<tr><td><strong>{$kp}</strong></td><td>{$vp}</td></tr>";
}
$output = "<table><th colspan=\"2\">{$elements['#label']}</th>{$rows}</table>";
}
}
else {
if ($val instanceof \Brightcove\Object\Video\Link) {
$text = l(t($val
->getText()), $val
->getUrl());
}
else {
$text = check_plain($val);
}
$output = "<p><strong>{$elements['#label']}:</strong> {$text}</p>";
}
}
return $output;
}