You are here

function field_slideshow_field_formatter_settings_summary in Field Slideshow 7.2

Same name and namespace in other branches
  1. 7 field_slideshow.module \field_slideshow_field_formatter_settings_summary()

Implements hook_field_formatter_settings_summary().

File

./field_slideshow.module, line 511
Implement a slideshow formatter for fields.

Code

function field_slideshow_field_formatter_settings_summary($field, $instance, $view_mode) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $summary = array();
  $image_styles = image_style_options(FALSE);

  // Unset possible 'No defined styles' option.
  unset($image_styles['']);

  // Styles could be lost because of enabled/disabled modules that defines
  // their styles in code.
  if ($settings['slideshow_content_type'] == 'image') {
    if (isset($image_styles[$settings['slideshow_image_style']])) {
      $summary[] = t('Image style: @style', array(
        '@style' => $image_styles[$settings['slideshow_image_style']],
      ));
    }
    elseif (isset($settings['slideshow_file_style'])) {
      $summary[] = t('File style: @style', array(
        '@style' => $settings['slideshow_file_style'],
      ));
    }
    else {
      $summary[] = t('Original image');
    }
  }
  else {
    $entity_info = entity_get_info('field_collection_item');
    $view_mode = empty($settings['slideshow_view_mode']) ? 'full' : $settings['slideshow_view_mode'];
    $summary[] = t('Rendered entity: @viewmode', array(
      '@viewmode' => $entity_info['view modes'][$view_mode]['label'],
    ));
  }
  $link_types = array(
    'content' => t('content'),
    'file' => t('file'),
    'colorbox' => t('Colorbox'),
  );
  if ($field['type'] == 'media' || $field['type'] == 'field_collection') {
    $link_types += _field_slideshow_get_fields(array(
      'link_field',
      'node_reference',
    ), $field['type'], $field['field_name']);
  }

  // Display this setting only if image is linked.
  if (isset($link_types[$settings['slideshow_link']])) {
    $link_type_message = t('Link to: @link', array(
      '@link' => $link_types[$settings['slideshow_link']],
    ));
    if ($settings['slideshow_link'] == 'colorbox') {
      $link_type_message .= ' (';
      if (isset($image_styles[$settings['slideshow_colorbox_image_style']])) {
        $link_type_message .= t('Image style: @style', array(
          '@style' => $image_styles[$settings['slideshow_colorbox_image_style']],
        ));
      }
      else {
        $link_type_message .= t('Original image');
      }
      if (isset($settings['slideshow_colorbox_slideshow']) && $settings['slideshow_colorbox_slideshow']) {
        $colorbox_slideshow = array(
          'automatic' => t('Automatic'),
          'manual' => t('Manual'),
        );
        $link_type_message .= ', with Slideshow (' . $colorbox_slideshow[$settings['slideshow_colorbox_slideshow']] . ' - Speed: ' . $settings['slideshow_colorbox_slideshow_speed'] . ')';
      }
      $link_type_message .= ')';
    }
    $summary[] = $link_type_message;
  }
  if ($field['type'] == 'media' || $field['type'] == 'file' || $field['type'] == 'field_collection') {
    $caption_types = _field_slideshow_get_fields(array(
      'text',
    ), $field['type'], $field['field_name']);
  }
  else {
    $caption_types = array(
      'title' => t('Title text'),
      'alt' => t('Alt text'),
    );
  }

  // Display this setting only if there's a caption.
  if (isset($caption_types[$settings['slideshow_caption']])) {
    $caption_message = t('Caption: @caption', array(
      '@caption' => $caption_types[$settings['slideshow_caption']],
    ));
    if (isset($link_types[$settings['slideshow_caption_link']])) {
      $caption_message .= ' (' . t('Link to: @link', array(
        '@link' => $link_types[$settings['slideshow_caption_link']],
      )) . ')';
    }
    $summary[] = $caption_message;
  }
  $summary[] = t('Transition effect: @effect', array(
    '@effect' => $settings['slideshow_fx'],
  ));
  $summary[] = t('Speed: @speed', array(
    '@speed' => $settings['slideshow_speed'],
  ));
  $summary[] = t('Timeout: @timeout', array(
    '@timeout' => $settings['slideshow_timeout'],
  ));
  $orders = array(
    'reverse' => t('Reverse order'),
    'random' => t('Random order'),
  );
  if (isset($orders[$settings['slideshow_order']])) {
    $summary[] = $orders[$settings['slideshow_order']];
  }
  $pause_button_text = "";
  if (isset($settings['slideshow_controls_pause']) && $settings['slideshow_controls_pause']) {
    $pause_button_text = " " . t("(with play/pause)");
  }
  if (isset($settings['slideshow_controls']) && $settings['slideshow_controls']) {
    $summary[] = t('Create prev/next controls') . $pause_button_text;
  }
  if (isset($settings['slideshow_pause']) && $settings['slideshow_pause']) {
    $summary[] = t('Pause on hover');
  }
  if (isset($settings['slideshow_start_on_hover']) && $settings['slideshow_start_on_hover']) {
    $summary[] = t('Activate on hover');
  }
  switch ($settings['slideshow_pager']) {
    case 'number':
      $summary[] = t('Pager') . ': ' . t('Slide number');
      break;
    case 'image':
      $pager_image_message = t('Pager') . ': ' . t('Image') . ' (';
      if (isset($image_styles[$settings['slideshow_pager_image_style']])) {
        $pager_image_message .= t('Image style: @style', array(
          '@style' => $image_styles[$settings['slideshow_pager_image_style']],
        ));
      }
      else {
        $pager_image_message .= t('Original image');
      }
      $pager_image_message .= ')';
      $summary[] = $pager_image_message;
      break;
    case 'carousel':
      $pager_image_message = t('Pager') . ': ' . t('Carousel') . ' (';
      if (isset($image_styles[$settings['slideshow_carousel_image_style']])) {
        $pager_image_message .= t('Image style: @style', array(
          '@style' => $image_styles[$settings['slideshow_carousel_image_style']],
        ));
      }
      else {
        $pager_image_message .= t('Original image');
      }
      $pager_image_message .= ', ' . t('Number of visible images: @visible', array(
        '@visible' => $settings['slideshow_carousel_visible'],
      ));
      $pager_image_message .= ', ' . t('Number of images to scroll by: @scroll', array(
        '@scroll' => $settings['slideshow_carousel_scroll'],
      ));
      $pager_image_message .= ', ' . t('Transition speed: @speed', array(
        '@speed' => $settings['slideshow_carousel_speed'],
      ));
      if ($settings['slideshow_carousel_skin']) {
        $pager_image_message .= ', ' . t('Skin: @skin', array(
          '@skin' => $settings['slideshow_carousel_skin'],
        ));
      }
      if ($settings['slideshow_carousel_vertical']) {
        $pager_image_message .= ', ' . t('Vertical');
      }
      if ($settings['slideshow_carousel_circular']) {
        $pager_image_message .= ', ' . t('Circular');
      }
      if ($settings['slideshow_carousel_follow']) {
        $pager_image_message .= ', ' . t('Follow slide');
      }
      $pager_image_message .= ')';
      $summary[] = $pager_image_message;
      break;
  }
  return implode('<br />', $summary);
}