You are here

function _yashare_field_formatter_settings_summary in Yandex.Share 7.2

Pseudo hook_field_formatter_settings_summary().

1 call to _yashare_field_formatter_settings_summary()
yashare_form_field_ui_display_overview_form_alter in ./yashare.module
Implements hook_form_FORM_ID_alter().

File

./yashare.module, line 330

Code

function _yashare_field_formatter_settings_summary($build, $summary = NULL) {
  $display_stored = field_bundle_settings($build['#entity_type'], $build['#bundle']);
  $display_defaults = yashare_field_extra_fields(TRUE);
  if (!empty($summary)) {
    $settings = $summary;
  }
  elseif (isset($display_stored['extra_fields']['display']['yashare'][$build['#view_mode']]['settings'])) {
    $settings = $display_stored['extra_fields']['display']['yashare'][$build['#view_mode']]['settings'];
  }
  else {
    $settings = $display_defaults['extra_fields']['display']['yashare']['settings'];
  }
  $summary = array();
  $field_instances = field_info_instances($build['#entity_type'], $build['#bundle']);
  if (isset($field_instances[$settings['image_field']])) {
    $summary[] = t('Image field to share: @field', array(
      '@field' => $field_instances[$settings['image_field']]['label'],
    ));
    $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 define
    // their styles in code.
    if (isset($image_styles[$settings['image_style']])) {
      $summary[] = t('Image style: @style', array(
        '@style' => $image_styles[$settings['image_style']],
      ));
    }
    else {
      $summary[] = t('Image style: @style', array(
        '@style' => t('Original image'),
      ));
    }
  }
  else {
    $summary[] = t('Image field to share: @field', array(
      '@field' => t('None'),
    ));
  }
  if (isset($settings['description'])) {
    $summary[] = t('Text to share: @description', array(
      '@description' => $settings['description'],
    ));
  }
  return implode('<br />', $summary);
}