function backstretch_field_formatter_settings_summary in Backstretch 7.2
Implements hook_field_formatter_settings_summary().
File
- ./
backstretch.module, line 233 - Main file for Backstretch Formatter module.
Code
function backstretch_field_formatter_settings_summary($field, $instance, $view_mode) {
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$options_info = backstretch_formatter_options();
$options = array();
foreach ($settings as $name => $value) {
if (array_key_exists($name, $options_info)) {
$option = $options_info[$name];
$label = $option['label'];
$suffix = isset($option['suffix']) ? $option['suffix'] : '';
$type = isset($option['type']) ? $option['type'] : '';
// We need some special handling with the element setting.
if ($name == 'element') {
continue;
}
if ($name == 'element_other') {
$value = $settings['element'] == '' ? t('Whole page') : $value;
}
if ($name == 'image_style' && $value == '') {
continue;
}
if ($name == 'duration' || $name == 'fade') {
$value .= ' ms';
}
if ($name == 'delta' && $value == '') {
continue;
}
if ($name == 'delta') {
switch ($value) {
case '1':
$suffix = 'st';
break;
case '2':
$suffix = 'nd';
break;
case '3':
$suffix = 'rd';
break;
default:
$suffix = 'th';
break;
}
}
// Display just the label when the setting is a boolean.
if ($type != 'bool') {
$options[$name] = $label . ': ' . $value . $suffix;
}
else {
$options[$name] = $label . $suffix;
}
}
}
// Remove slideshow specific settings when only one image is allowed.
if ($field['cardinality'] == '1') {
unset($options['duration'], $options['delta']);
}
// Remove image field setting when field type is not entityreference.
if ($field['type'] != 'entityreference') {
unset($options['field']);
}
$summary = '<h3>jQuery Backstretch</h3>';
$summary .= theme('item_list', array(
'items' => $options,
));
return $summary;
}