You are here

function smart_trim_field_formatter_settings_summary in Smart Trim 7

Implements hook_field_formatter_settings_summary().

File

./smart_trim.module, line 302
Module functionality.

Code

function smart_trim_field_formatter_settings_summary($field, $instance, $view_mode) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $summary = intval($settings['trim_length']) . ' ' . ($settings['trim_type'] == 'chars' ? t('characters') : t('words'));
  if (drupal_strlen(trim($settings['trim_suffix']))) {
    $summary .= " " . t("with suffix");
  }
  switch ($settings['more_link']) {
    case SMART_TRIM_ALWAYS:
      $summary .= ', ' . t('with more link (always)');
      break;
    case SMART_TRIM_IFNEEDED:
      $summary .= ', ' . t('with more link (if needed)');
      break;
  }

  // Trim options summary.
  if (isset($settings['trim_link'])) {
    $summary .= $settings['trim_link'] == 1 ? ' ' . t('linked to content') : '';
  }
  return $summary;
}