Index: modules/asset_content.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/asset/modules/asset_content.inc,v retrieving revision 1.1.2.5 diff -u -p -r1.1.2.5 asset_content.inc --- modules/asset_content.inc 20 May 2008 11:29:56 -0000 1.1.2.5 +++ modules/asset_content.inc 24 Jul 2008 22:27:34 -0000 @@ -44,24 +44,53 @@ function asset_field_settings($op, $fiel } /** - * Implementation of cck hook_field_formatter_info() + * Implementation of hook_field_formatter_info(). */ function asset_field_formatter_info() { - return array( + $formatters = array( 'default' => array( - 'label' => 'Default', + 'label' => t('Default'), 'field types' => array('asset'), ), ); + + $asset_formatters = asset_get_formatters(); + foreach ($asset_formatters as $type) { + foreach ($type as $ext) { + foreach ($ext as $formatter) { + $formatters[$formatter['module'] .':'. $formatter['format']] = array( + 'label' => $formatter['name'], + 'field types' => array('asset'), + ); + $formatters[$formatter['module'] .':'. $formatter['format'] .':link'] = array( + 'label' => $formatter['name'] . ' with link', + 'field types' => array('asset'), + ); + } + } + } + + return $formatters; } /** - * Prepare an individual item for viewing in a browser. + * Implementation of hook_field_formatter(). + * */ function asset_field_formatter($field, $item, $formatter, $node) { - if(!empty($item['aid'])) { - return asset_lightbox(array($item)); + $asset = asset_load($item['aid']); + $formatter_options = asset_formatter_options($asset->type, $asset->extension); + list($module, $format, $link) = explode(':', $formatter); + if (!isset($formatter_options[$module .':'. $format])) { + // If not a valid format for this extension then use the default format for this extension instead + list($module, $format) = explode(':', asset_get_default_formatter($asset->type, $asset->extension, true)); + $link = FALSE; + } + $html = module_invoke($module, 'asset_formatter', 'render', $asset, array('format' => $format)); + if ($link) { + return l($html, 'node/'. $node->nid, array(), NULL, NULL, FALSE, TRUE); } + return $html; } /**