You are here

function itweak_upload_field_formatter_settings_summary in iTweak Upload 7.3

Implements hook_field_formatter_settings_summary().

File

./itweak_upload.module, line 408
iTweakUpload - Tweak attachments display and file upload forms.

Code

function itweak_upload_field_formatter_settings_summary($field, $instance, $view_mode) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $image_styles = _itweak_upload_image_style_options();
  $display_options = _itweak_upload_display_options();
  $gallery_type_options = _itweak_upload_gallery_type_options();
  $image_link_mode_options = _itweak_upload_lightbox_link_mode_options();
  $files_display_mode = $settings['files_display_mode'];
  $files_display_mode_name = isset($display_options[$files_display_mode]) ? $display_options[$files_display_mode] : $display_options[ITU_DISPLAY_DEFAULT];
  $gallery_type = !empty($settings['gallery_type']) ? $settings['gallery_type'] : _itweak_upload_gallery_type_default();
  $gallery_type_name = isset($gallery_type_options[$gallery_type]) ? $gallery_type_options[$gallery_type] : $gallery_type_options['itu'];
  $gallery_limit = !empty($settings['gallery_limit']) ? $settings['gallery_limit'] : '';
  $gallery_limit_name = empty($gallery_limit) ? '' : t(' limit @limit thumbnails', array(
    '@limit' => $gallery_limit,
  ));
  $thumbnail_style = $settings['thumbnail_style'];
  $thumbnail_style_name = $thumbnail_style != '_none' && isset($image_styles[$thumbnail_style]) ? t('@thumbnail thumbnails', array(
    '@thumbnail' => $image_styles[$thumbnail_style],
  )) : $image_styles['_none'];
  unset($image_styles['_none']);

  // $image_styles['_none'] = t('Download file');
  $open_image_style = $settings['open_image_style'] != '' ? $settings['open_image_style'] : t('Original image');
  $open_image_style_name = isset($image_styles[$open_image_style]) ? $image_styles[$open_image_style] : $image_styles['_none'];
  $image_link_mode = $settings['image_link_mode'] != '' ? $settings['image_link_mode'] : _itweak_upload_lightbox_link_default();
  $image_link_mode_name = $image_link_mode != 'none' && isset($image_link_mode_options[$image_link_mode]) ? t('open as @fullsize in @open frame', array(
    '@fullsize' => $open_image_style_name,
    '@open' => $image_link_mode_options[$image_link_mode],
  )) : t('@open @fullsize', array(
    '@fullsize' => $open_image_style_name,
    '@open' => $image_link_mode_options['none'],
  ));
  $mime_icon_directory = $files_display_mode < ITU_DISPLAY_GALLERY ? ', ' . (!empty($settings['mime_icon_directory']) ? t('file icons from "@dir" directory', array(
    '@dir' => $settings['mime_icon_directory'],
  )) : t('Drupal default file icons')) : '';

  //@todo: Implement summary for all settings:

  /*
  'files_display_mode' => ITU_DISPLAY_DEFAULT,
  'mime_icon_directory' => ITU_ICON_DIRECTORY_DEFAULT,
  'thumbnail_style' => 'AttachmentThumbnail',
          'show_caption' => FALSE,
  'gallery_type' => _itweak_upload_gallery_type_default(),
  'gallery_limit' => '',
  'image_link_mode' => _itweak_upload_lightbox_link_default(),
          'show_title' => TRUE,
  'open_image_style' => '_original',
  */
  $summary = $files_display_mode == ITU_DISPLAY_DISABLED ? $files_display_mode_name : t('@display_mode@gallery with @thumbnail @image_link_mode@mime_icon_directory', array(
    '@display_mode' => $files_display_mode_name,
    '@gallery' => $files_display_mode >= ITU_DISPLAY_FILES_AND_GALLERY ? t(' (@gallery_type@gallery_limit)', array(
      '@gallery_type' => $gallery_type_name,
      '@gallery_limit' => $gallery_limit_name,
    )) : '',
    '@thumbnail' => $thumbnail_style_name,
    '@image_link_mode' => $image_link_mode_name,
    '@fullsize' => $open_image_style_name,
    '@mime_icon_directory' => $mime_icon_directory,
  ));

  //  if ($settings['highslide_first']) $summary .= t(', first only');
  //  if ($settings['highslide_gallery']) $summary .= t(', gallery');
  return $summary;
}