You are here

function file_entity_field_formatter_settings_summary in File Entity (fieldable files) 7.3

Same name and namespace in other branches
  1. 7 file_entity.field.inc \file_entity_field_formatter_settings_summary()
  2. 7.2 file_entity.field.inc \file_entity_field_formatter_settings_summary()

Implements hook_field_formatter_settings_summary().

File

./file_entity.field.inc, line 255
Field API integration for the file_entity module.

Code

function file_entity_field_formatter_settings_summary($field, $instance, $view_mode) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $summary = array();
  if ($display['type'] === 'file_rendered') {
    $view_mode_label = file_entity_view_mode_label($settings['file_view_mode'], t('Unknown'));
    $summary[] = t('View mode: %mode', array(
      '%mode' => $view_mode_label,
    ));
  }
  elseif ($display['type'] == 'file_download_link') {
    $summary[] = t('Link text: %text', array(
      '%text' => $settings['text'],
    ));
  }
  elseif ($display['type'] === 'file_audio') {
    if (isset($settings['controls'])) {
      $summary[] = t('Controls: %controls', array(
        '%controls' => $settings['controls'] ? 'visible' : 'hidden',
      ));
      if (!empty($settings['controls_list'])) {
        $controls_list = array();
        foreach ($settings['controls_list'] as $key => $value) {
          if ($value) {
            $controls_list[] = ucfirst(str_replace('_', ' ', $key));
          }
        }
        if (!empty($controls_list)) {
          $summary[] = t('Controls list: %controls_list', array(
            '%controls_list' => implode(', ', $controls_list),
          ));
        }
      }
    }
    if (isset($settings['autoplay'])) {
      $summary[] = t('Autoplay: %autoplay', array(
        '%autoplay' => $settings['autoplay'] ? t('yes') : t('no'),
      ));
    }
    if (isset($settings['loop'])) {
      $summary[] = t('Loop: %loop', array(
        '%loop' => $settings['loop'] ? t('yes') : t('no'),
      ));
    }
    if (!empty($settings['preload'])) {
      $summary[] = t('Preload: %preload', array(
        '%preload' => $settings['preload'],
      ));
    }
    if (isset($settings['multiple_file_behavior'])) {
      $summary[] = t('Multiple files: %multiple', array(
        '%multiple' => $settings['multiple_file_behavior'],
      ));
    }
  }
  elseif ($display['type'] === 'file_video') {
    if (isset($settings['controls'])) {
      $summary[] = t('Controls: %controls', array(
        '%controls' => $settings['controls'] ? 'visible' : 'hidden',
      ));
      if (!empty($settings['controls_list'])) {
        $controls_list = array();
        foreach ($settings['controls_list'] as $key => $value) {
          if ($value) {
            $controls_list[] = ucfirst(str_replace('_', ' ', $key));
          }
        }
        if (!empty($controls_list)) {
          $summary[] = t('Controls list: %controls_list', array(
            '%controls_list' => implode(', ', $controls_list),
          ));
        }
      }
    }
    if (isset($settings['autoplay'])) {
      $summary[] = t('Autoplay: %autoplay', array(
        '%autoplay' => $settings['autoplay'] ? t('yes') : t('no'),
      ));
    }
    if (isset($settings['playsinline'])) {
      $summary[] = t('Plays inline: %playsinline', array(
        '%playsinline' => $settings['playsinline'] ? t('yes') : t('no'),
      ));
    }
    if (isset($settings['loop'])) {
      $summary[] = t('Loop: %loop', array(
        '%loop' => $settings['loop'] ? t('yes') : t('no'),
      ));
    }
    if (isset($settings['muted'])) {
      $summary[] = t('Muted: %muted', array(
        '%muted' => $settings['muted'] ? t('yes') : t('no'),
      ));
    }
    if ($settings['width'] && $settings['height']) {
      $summary[] = t('Size: %width x %height', array(
        '%width' => $settings['width'],
        '%height' => $settings['height'],
      ));
    }
    if (!empty($settings['preload'])) {
      $summary[] = t('Preload: %preload', array(
        '%preload' => $settings['preload'],
      ));
    }
    if (isset($settings['multiple_file_behavior'])) {
      $summary[] = t('Multiple files: %multiple', array(
        '%multiple' => $settings['multiple_file_behavior'],
      ));
    }
  }
  return implode('<br />', $summary);
}