You are here

function hms_field_field_formatter_settings_summary in HMS Field 7

Implements hook_field_formatter_settings_summary().

File

./hms_field.module, line 145
Provides an hms_field functionality.

Code

function hms_field_field_formatter_settings_summary($field, $instance, $view_mode) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $summary = '';
  if ($display['type'] == 'hms_default_formatter') {
    $summary .= t('Format: @format', array(
      '@format' => $settings['format'],
    ));
    $summary .= '<br>';
    $summary .= t('Leading zero: @zero', array(
      '@zero' => $settings['leading_zero'] ? t('On') : t('Off'),
    ));
  }
  elseif ($display['type'] == 'hms_natural_language_formatter') {
    $factors = _hms_factor_map(TRUE);
    $fragments = $settings['display_formats'];
    $fragment_list = array();
    foreach ($fragments as $fragment) {
      if ($fragment) {
        $fragment_list[] = t($factors[$fragment]['label multiple']);
      }
    }
    $summary .= t('Displays: @display', array(
      '@display' => implode(', ', $fragment_list),
    ));
    $summary .= '<br>';
    $summary .= t('Separator: \'@separator\'', array(
      '@separator' => $settings['separator'],
    ));
    if (strlen($settings['last_separator'])) {
      $summary .= '<br>';
      $summary .= t('Last Separator: \'@last_separator\'', array(
        '@last_separator' => $settings['last_separator'],
      ));
    }
  }
  return $summary;
}