You are here

function yamaps_field_formatter_settings_summary in Yandex.Maps 7

Implements hook_field_formatter_settings_summary().

File

inc/yamaps.formatter.inc, line 405
Yandex Maps field formatter.

Code

function yamaps_field_formatter_settings_summary($field, $instance, $view_mode) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $summary = [];
  switch ($display['type']) {
    case YAMAPS_DYNAMIC_FORMATTER:
      $summary[] = t('Show controls: @controls', [
        '@controls' => $settings['controls'] ? t('yes') : t('no'),
      ]);
      $summary[] = t('Show traffic: @traffic', [
        '@traffic' => $settings['traffic'] ? t('yes') : t('no'),
      ]);
      $summary[] = t('Use clusterer: @clusterer', [
        '@clusterer' => $settings['clusterer'] ? t('yes') : t('no'),
      ]);
      $summary[] = t('Auto zoom: @auto_zoom', [
        '@auto_zoom' => $settings['auto_zoom'] ? t('yes') : t('no'),
      ]);
      $summary[] = t('Enable polygons: @enable_polygons', [
        '@enable_polygons' => $settings['enable_polygons'] ? t('yes') : t('no'),
      ]);
      $summary[] = t('Enable routes: @enable_routes', [
        '@enable_routes' => $settings['enable_routes'] ? t('yes') : t('no'),
      ]);
      $summary[] = t('Enable placemarks: @enable_placemarks', [
        '@enable_placemarks' => $settings['enable_placemarks'] ? t('yes') : t('no'),
      ]);
      $summary[] = t('Enable lines: @enable_lines', [
        '@enable_lines' => $settings['enable_lines'] ? t('yes') : t('no'),
      ]);
      $summary[] = t('Map size: @width x @height', [
        '@width' => $settings['width'],
        '@height' => $settings['height'],
      ]);
      $available_events = array_filter($display['settings']['behaviors']);
      if (count($available_events) > 0) {
        $behaviors_list = yamaps_get_behaviors_list();
        $active_behaviors = array_values(array_filter($display['settings']['behaviors']));
        $prepared_behaviors_list = [];
        foreach ($active_behaviors as $val) {
          $prepared_behaviors_list[] = $behaviors_list[$val];
        }
        $summary[] = t('Enabled mouse event: !list', [
          '!list' => implode(', ', $prepared_behaviors_list),
        ]);
      }
      else {
        $summary[] = t('All mouse events are disabled.');
      }
      $summary[] = t('Display type: @type', [
        '@type' => $settings['yamaps_display_options']['display_type'],
      ]);
      if ($settings['yamaps_display_options']['display_type'] == 'map_button') {
        $summary[] = t('"Open" button text: @text', [
          '@text' => $settings['yamaps_display_options']['open_button_text'],
        ]);
        $summary[] = t('"Close" button text: @text', [
          '@text' => $settings['yamaps_display_options']['close_button_text'],
        ]);
      }
      break;
    case YAMAPS_STATIC_FORMATTER:
      $summary[] = t('Show traffic: @traffic', [
        '@traffic' => $settings['s_traffic'] ? t('yes') : t('no'),
      ]);
      $summary[] = t('Use clusterer: @clusterer', [
        '@clusterer' => $settings['s_clusterer'] ? t('yes') : t('no'),
      ]);
      $summary[] = t('Auto zoom: @auto_zoom', [
        '@auto_zoom' => $settings['s_auto_zoom'] ? t('yes') : t('no'),
      ]);
      $summary[] = t('Enable polygons: @enable_polygons', [
        '@enable_polygons' => $settings['s_enable_polygons'] ? t('yes') : t('no'),
      ]);
      $summary[] = t('Enable routes: @enable_routes', [
        '@enable_routes' => $settings['s_enable_routes'] ? t('yes') : t('no'),
      ]);
      $summary[] = t('Enable placemarks: @enable_placemarks', [
        '@enable_placemarks' => $settings['s_enable_placemarks'] ? t('yes') : t('no'),
      ]);
      $summary[] = t('Enable lines: @enable_lines', [
        '@enable_lines' => $settings['s_enable_lines'] ? t('yes') : t('no'),
      ]);
      $summary[] = t('Map size: @width x @height', [
        '@width' => $settings['s_width'] . 'px',
        '@height' => $settings['s_height'] . 'px',
      ]);
      $summary[] = t('Display type: @type', [
        '@type' => $settings['yamaps_display_options_static']['display_type_static'],
      ]);
      if ($settings['yamaps_display_options_static']['display_type_static'] == 'map_button') {
        $summary[] = t('"Open" button text: @text', [
          '@text' => $settings['yamaps_display_options_static']['open_button_text_static'],
        ]);
        $summary[] = t('"Close" button text: @text', [
          '@text' => $settings['yamaps_display_options_static']['close_button_text_static'],
        ]);
      }
      break;
    case YAMAPS_TEXT_FORMATTER:
      $summary[] = t('Show controls: @controls', [
        '@controls' => $settings['control'] ? t('yes') : t('no'),
      ]);
      $summary[] = t('Show traffic: @traffic', [
        '@traffic' => $settings['traffic'] ? t('yes') : t('no'),
      ]);
      $summary[] = t('Use clusterer: @clusterer', [
        '@clusterer' => $settings['clusterer'] ? t('yes') : t('no'),
      ]);
      $summary[] = t('Auto zoom: @auto_zoom', [
        '@auto_zoom' => $settings['auto_zoom'] ? t('yes') : t('no'),
      ]);
      $summary[] = t('Enable polygons: @enable_polygons', [
        '@enable_polygons' => $settings['enable_polygons'] ? t('yes') : t('no'),
      ]);
      $summary[] = t('Enable routes: @enable_routes', [
        '@enable_routes' => $settings['enable_routes'] ? t('yes') : t('no'),
      ]);
      $summary[] = t('Enable placemarks: @enable_placemarks', [
        '@enable_placemarks' => $settings['enable_placemarks'] ? t('yes') : t('no'),
      ]);
      $summary[] = t('Enable lines: @enable_lines', [
        '@enable_lines' => $settings['enable_lines'] ? t('yes') : t('no'),
      ]);
      $summary[] = t('Map size: @width x @height', [
        '@width' => $settings['width'],
        '@height' => $settings['height'],
      ]);
      $summary[] = t('Display placemarks: @placemark', [
        '@placemark' => $settings['placemark']['placemark_display'] ? t('yes') : t('no'),
      ]);
      if ($settings['placemark']['placemark_display']) {
        $summary[] = t('Text on placemark: @text', [
          '@text' => $settings['placemark']['placemark_text'],
        ]);
        $summary[] = t('Placemark color: @color', [
          '@color' => t($settings['placemark']['placemark_color']),
        ]);
      }
      $behaviors = implode(', ', $settings['behaviors']);
      $summary[] = t('Available behaviors: @behaviors', [
        '@behaviors' => $behaviors,
      ]);
      break;
  }
  return implode('<br />', $summary);
}