You are here

public function FieldSlideshow::settingsSummary in Field Slideshow 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/Field/FieldFormatter/FieldSlideshow.php \Drupal\field_slideshow\Plugin\Field\FieldFormatter\FieldSlideshow::settingsSummary()
  2. 8.2 src/Plugin/Field/FieldFormatter/FieldSlideshow.php \Drupal\field_slideshow\Plugin\Field\FieldFormatter\FieldSlideshow::settingsSummary()

Returns a short summary for the current formatter settings.

If an empty result is returned, a UI can still be provided to display a settings form in case the formatter has configurable settings.

Return value

string[] A short summary of the formatter settings.

Overrides ImageFormatter::settingsSummary

File

src/Plugin/Field/FieldFormatter/FieldSlideshow.php, line 289
Contains \Drupal\field_slideshow\Plugin\Field\FieldFormatter\Slideshow.

Class

FieldSlideshow
Plugin implementation of the 'slideshow' formatter.

Namespace

Drupal\field_slideshow\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {

  // get summary of image_style and image_link from parent method.
  $summary = parent::settingsSummary();
  $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.
  $image_style_setting = $this
    ->getSetting('image_style');

  //Colorbox
  $image_link_setting = $this
    ->getSetting('image_link');
  if (isset($image_link_setting) && $image_link_setting == 'colorbox') {
    $link_type_message = t('Link to: @link', array(
      '@link' => $this
        ->getSetting('image_link'),
    ));
    $link_type_message .= ' (';
    $colorbox_img_style_settings = $this
      ->getSetting('slideshow_colorbox_image_style');
    if (!empty($colorbox_img_style_settings)) {
      $link_type_message .= t('Image style: @style', array(
        '@style' => $image_styles[$this
          ->getSetting('slideshow_colorbox_image_style')],
      ));
    }
    else {
      $link_type_message .= t('Original image');
    }
    $colorbox_slideshow_settings = $this
      ->getSetting('slideshow_colorbox_slideshow');
    if (isset($colorbox_slideshow_settings)) {
      $colorbox_slideshow = array(
        'automatic' => t('Automatic'),
        'manual' => t('Manual'),
      );
      if (isset($colorbox_slideshow[$this
        ->getSetting('slideshow_colorbox_slideshow')])) {
        $link_type_message .= ', with Slideshow (' . $colorbox_slideshow[$this
          ->getSetting('slideshow_colorbox_slideshow')] . ' - Speed: ' . $this
          ->getSetting('slideshow_colorbox_slideshow_speed') . ')';
      }
    }
    $link_type_message .= ')';
    $summary[] = $link_type_message;
  }
  $caption_types = array(
    'title' => t('Title text'),
    'alt' => t('Alt text'),
  );

  // Display this setting only if there's a caption.
  $caption_types_settings = $this
    ->getSetting('slideshow_caption');
  if (isset($caption_types[$caption_types_settings])) {
    $caption_message = t('Caption: @caption', array(
      '@caption' => $caption_types[$caption_types_settings],
    ));
    $link_types_settings = $this
      ->getSetting('slideshow_caption_link');
    if (isset($link_types[$link_types_settings])) {
      $caption_message .= ' (' . t('Link to: @link', array(
        '@link' => $link_types[$link_types_settings],
      )) . ')';
    }
    $summary[] = $caption_message;
  }
  $summary[] = t('Transition effect: @effect', array(
    '@effect' => $this
      ->getSetting('slideshow_fx'),
  ));
  $summary[] = t('Speed: @speed', array(
    '@speed' => $this
      ->getSetting('slideshow_speed'),
  ));
  $summary[] = t('Timeout: @timeout', array(
    '@timeout' => $this
      ->getSetting('slideshow_timeout'),
  ));
  $orders = array(
    'reverse' => t('Reverse order'),
    'random' => t('Random order'),
  );
  $orders_settings = $this
    ->getSetting('slideshow_order');
  if (isset($orders[$orders_settings])) {
    $summary[] = $orders[$orders_settings];
  }
  $pause_button_text = "";
  $slideshow_controls_pause = $this
    ->getSetting('slideshow_controls_pause');
  $slideshow_controls = $this
    ->getSetting('slideshow_controls');
  $slideshow_pause = $this
    ->getSetting('slideshow_pause');
  $slideshow_start_on_hover = $this
    ->getSetting('slideshow_start_on_hover');
  if (isset($slideshow_controls_pause) && $slideshow_controls_pause) {
    $pause_button_text = " " . t("(with play/pause)");
  }
  if (isset($slideshow_controls) && $slideshow_controls) {
    $summary[] = t('Create prev/next controls') . $pause_button_text;
  }
  if (isset($slideshow_pause) && $slideshow_pause) {
    $summary[] = t('Pause on hover');
  }
  if (isset($slideshow_start_on_hover) && $slideshow_start_on_hover) {
    $summary[] = t('Activate on hover');
  }
  switch ($this
    ->getSetting('slideshow_pager')) {
    case 'number':
      $summary[] = t('Pager') . ': ' . t('Slide number');
      break;
    case 'image':
      $pager_image_message = t('Pager') . ': ' . t('Image') . ' (';
      if (isset($image_styles[$this
        ->getSetting('slideshow_pager_image_style')])) {
        $pager_image_message .= t('Image style: @style', array(
          '@style' => $image_styles[$this
            ->getSetting('slideshow_pager_image_style')],
        ));
      }
      else {
        $pager_image_message .= t('Original image');
      }
      $pager_image_message .= ')';
      $summary[] = $pager_image_message;
      break;
  }
  return $summary;
}