function media_acquiadam_browser_convert_property_data in Media: Acquia DAM 7
Converts property data into something more functional for rendering.
Parameters
array $properties: An array of table-style column data where the first item is the label and the second item is the value, keyed by the property machine name.
Return value
array The more complex property table data.
1 call to media_acquiadam_browser_convert_property_data()
- media_acquiadam_browser_preprocess_media_acquiadam_browser_info_modal in modules/
media_acquiadam_browser/ includes/ media_acquiadam_browser.theme.inc - Theme preprocessor for media_acquiadam_browser_info_modal.
File
- modules/
media_acquiadam_browser/ includes/ media_acquiadam_browser.theme.inc, line 369 - Theme hooks and implementations.
Code
function media_acquiadam_browser_convert_property_data(array $properties) {
foreach ($properties as $key => $cols) {
// Only show properties that have a value set.
if (empty($cols[1]) && empty($cols[0]['header'])) {
unset($properties[$key]);
continue;
}
elseif (!isset($cols[1])) {
continue;
}
$properties[$key][0] = [
'data' => $cols[0],
'class' => drupal_html_class('property-' . $key . '-label'),
];
$properties[$key][1] = [
'data' => $cols[1],
'class' => drupal_html_class('property-' . $key . '-value'),
];
}
if (!empty($properties['keyword'][1]['data']) && user_access('access media acquiadam browser')) {
$keywords = explode(',', $properties['keyword'][1]['data']);
$keywords = array_map('trim', $keywords);
$keywords = array_filter($keywords);
$keywords = array_map(function ($keyword) {
$options = [
'query' => [
'search' => [
'keywords' => $keyword,
],
],
'attributes' => [
'title' => t('Search for @keyword', [
'@keyword' => $keyword,
]),
'class' => [
'property-keyword',
],
],
];
return l($keyword, '/admin/content/file/acquiadam', $options);
}, $keywords);
$properties['keyword'][1]['data'] = implode('', $keywords);
}
return $properties;
}