function sarnia_field_formatter_info in Sarnia 7
Implements hook_field_formatter_info().
Provide field formatters for the 'sarnia' Solr document field type. These are mainly used within the SarniaViewsHandlerField Views field handler, and in general format a single property of the Solr document field. This limits their utility should they be used in a more traditional entity-view situation, but there is no entity viewing built out at this point.
See also
SarniaViewsHandlerField::get_value()
File
- ./
sarnia.field_formatter.inc, line 19 - Field formatter hook implementations.
Code
function sarnia_field_formatter_info() {
$formatters = array(
'sarnia_formatter_plain' => array(
'label' => t('Plain'),
'description' => t('Output a Solr property as-is.'),
'field types' => array(
'sarnia',
),
'settings' => array(),
),
'sarnia_formatter_date' => array(
'label' => t('Reformatted date'),
'description' => t('Reformat a Solr property date string.'),
'field types' => array(
'sarnia',
),
'settings' => array(
'date_format_predefined' => '',
'date_format_custom' => 'M j, Y',
'data_is_timestamp' => FALSE,
),
),
'sarnia_formatter_number' => array(
'label' => t('Number'),
'description' => t('Format a Solr property as a number.'),
'field types' => array(
'sarnia',
),
'settings' => array(
'separate_thousands' => TRUE,
),
),
'sarnia_formatter_text' => array(
'label' => t('Filtered text'),
'description' => t('Format a Solr property using a Drupal input format.'),
'field types' => array(
'sarnia',
),
'settings' => array(
'input_format' => filter_fallback_format(),
),
),
'sarnia_formatter_count' => array(
'label' => t('Value count'),
'description' => t('Display the total number of values in this Solr property.'),
'field types' => array(
'sarnia',
),
'settings' => array(),
),
'sarnia_formatter_image' => array(
'label' => t('Image'),
'description' => t('Format a Solr property as an image.'),
'field types' => array(
'sarnia',
),
'settings' => array(
'base_path' => NULL,
'path_solr_property' => NULL,
'alt_solr_property' => NULL,
'title_solr_property' => NULL,
),
),
'sarnia_formatter_multimedia_count' => array(
'label' => t('Multimedia type count'),
'description' => t('Format a Solr property as a list of media types described by the property.'),
'field types' => array(
'sarnia',
),
'settings' => array(
'show_icon' => TRUE,
),
),
);
if (module_exists('mediaelement')) {
$formatters['sarnia_formatter_multimedia'] = array(
'label' => t('Multimedia'),
'description' => t('Format a Solr property as multimedia; display images, embed audio and video in players, and provide download links to other file types.'),
'field types' => array(
'sarnia',
),
'settings' => array(
'base_path' => NULL,
'path_solr_property' => NULL,
'alt_solr_property' => NULL,
'title_solr_property' => NULL,
),
);
}
if (module_exists('openlayers')) {
$formatters['sarnia_formatter_openlayers'] = array(
'label' => t('OpenLayers map'),
'description' => t('Display latitude and longitude Solr properties as a point on a map.'),
'field types' => array(
'sarnia',
),
'settings' => array(
'lat_solr_property' => NULL,
'lon_solr_property' => NULL,
'openlayers_map' => 'sarnia_formatter_map',
),
);
}
// Add a 'solr_property' setting for each formatter.
foreach ($formatters as &$formatter) {
$formatter['settings']['solr_property'] = NULL;
}
return $formatters;
}