function asset_views_handler_field_asset in Asset 5
Same name and namespace in other branches
- 5.2 modules/asset_views.inc \asset_views_handler_field_asset()
- 6 asset_views.inc \asset_views_handler_field_asset()
- 6 inc/asset_views.inc \asset_views_handler_field_asset()
- 6 modules/asset_views.inc \asset_views_handler_field_asset()
2 calls to asset_views_handler_field_asset()
File
- ./
asset_views.inc, line 115
Code
function asset_views_handler_field_asset($fieldinfo, $fielddata, $value, $data, $link = false) {
static $formatters;
if (!$formatters) {
$formatters = asset_get_formatters();
}
$asset = asset_load($value);
switch ($fielddata['options']) {
case 'full':
list($module, $format) = explode(':', asset_get_default_formatter($asset->type, $asset->extension, false));
break;
case 'teaser':
list($module, $format) = explode(':', asset_get_default_formatter($asset->type, $asset->extension, true));
break;
default:
list($module, $format) = explode(':', $fielddata['options']);
$found = false;
foreach ((array) $formatters[$asset->type][$asset->extension] as $formatter) {
if ($formatter['module'] == $module && $formatter['format'] == $format) {
$found = true;
break;
}
}
foreach ((array) $formatters[$asset->type]['*'] as $formatter) {
if ($formatter['module'] == $module && $formatter['format'] == $format) {
$found = true;
break;
}
}
foreach ((array) $formatters['*']['*'] as $formatter) {
if ($formatter['module'] == $module && $formatter['format'] == $format) {
$found = true;
break;
}
}
if (!$found) {
$module = 'asset';
$format = 'link';
}
break;
}
if ($link) {
if ($format == 'link') {
$html = $asset->title ? $asset->title : $asset->filename;
}
else {
$html = module_invoke($module, 'asset_formatter', 'render', $asset, array(
'format' => $format,
));
}
return l($html, $link, array(), null, null, false, true);
}
else {
return module_invoke($module, 'asset_formatter', 'render', $asset, array(
'format' => $format,
));
}
}