You are here

function getlocations_fields_field_formatter_settings_summary in Get Locations 7.2

Same name and namespace in other branches
  1. 7 modules/getlocations_fields/getlocations_fields.module \getlocations_fields_field_formatter_settings_summary()

Implements hook_field_formatter_settings_summary(). Returns a short summary for the current formatter settings of an instance.

If an empty result is returned, the formatter is assumed to have no configurable settings, and no UI will be provided to display a settings form.

The field structure.

Parameters

$instance: The instance structure.

$view_mode: The view mode for which a settings summary is requested.

Return value

A string containing a short summary of the formatter settings.

File

modules/getlocations_fields/getlocations_fields.module, line 811
getlocations_fields.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function getlocations_fields_field_formatter_settings_summary($field, $instance, $view_mode) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $entity_type = $instance['entity_type'];
  $bundle = $instance['bundle'];
  $field_name = $instance['field_name'];
  $summary = array();

  // map summary
  if ($settings['display_showmap']) {
    $summary[] = t('Show map: Yes');
    if ($settings['display_mapwidth'] && $settings['display_mapheight']) {
      $summary[] = t('Width: @w | Height: @h', array(
        '@w' => $settings['display_mapwidth'],
        '@h' => $settings['display_mapheight'],
      ));
    }
    if ($settings['display_onemap']) {
      $summary[] = t('Show all locations on one map');
    }
    if ($settings['controltype']) {
      $summary[] = t('Zoom control type: @c', array(
        '@c' => $settings['controltype'],
      ));
    }
    if ($settings['pancontrol']) {
      $summary[] = t('Show Pan control: Yes');
    }
    if ($settings['mtc']) {
      $summary[] = t('Map control type: @c', array(
        '@c' => $settings['mtc'],
      ));
    }
    if ($settings['maptype']) {
      $summary[] = t('Default map type: @c', array(
        '@c' => $settings['maptype'],
      ));
    }
    $types = array();
    foreach ($settings['baselayers'] as $key => $value) {
      if ($value) {
        $types[] = $key;
      }
    }
    if (count($types)) {
      $m = implode(', ', $types);
      $summary[] = t('Enabled map types: @m', array(
        '@m' => $m,
      ));
    }
    if ($settings['scale']) {
      $summary[] = t('Show scale: Yes');
    }
    if ($settings['overview']) {
      $summary[] = t('Show overview map: Yes');
    }
    if ($settings['scrollwheel']) {
      $summary[] = t('Enable scrollwheel zooming: Yes');
    }
    if ($settings['draggable']) {
      $summary[] = t('Enable dragging the map: Yes');
    }
    if ($settings['nokeyboard']) {
      $summary[] = t('Disable Keyboard shortcuts: Yes');
    }
    if ($settings['nodoubleclickzoom']) {
      $summary[] = t('Disable doubleclick zoom: Yes');
    }
    if ($settings['sv_show']) {
      $summary[] = t('Show streetview pegman: Yes');
    }
    if ($settings['sv_showfirst']) {
      $summary[] = t('Show streetview first: Yes');
    }
    if ($settings['fullscreen']) {
      $summary[] = t('Show Fullscreen button: Yes');
    }
    if ($settings['show_bubble_on_one_marker']) {
      $summary[] = t('Show bubble on one marker: Yes');
    }
    $info_display = array();
    if ($settings['trafficinfo']) {
      $info_display[] = t('Traffic');
    }
    if ($settings['bicycleinfo']) {
      $info_display[] = t('Bicycling');
    }
    if ($settings['transitinfo']) {
      $info_display[] = t('Transit');
    }
    if ($settings['poi_show']) {
      $info_display[] = t('Points of Interest');
    }
    if ($settings['transit_show']) {
      $info_display[] = t('Transit Points');
    }
    if (count($info_display)) {
      $summary[] = t("Enabled information layers:") . '<br />' . implode(', ', $info_display);
    }
    $getlocations_defaults = getlocations_defaults();
    $marker = $getlocations_defaults['map_marker'];
    $entity_get_info = entity_get_info($entity_type);
    $label = $entity_get_info['label'];
    if (isset($settings[$entity_type . '_map_marker'])) {
      $marker = $settings[$entity_type . '_map_marker'];
    }
    $getlocations_markers = variable_get('getlocations_markers', array());
    if (isset($getlocations_markers[$entity_type]['enable']) && $getlocations_markers[$entity_type]['enable']) {
      $type_markers = getlocations_get_type_markers();
      foreach ($type_markers as $et => $bundles) {
        if ($et == $entity_type) {
          foreach ($bundles as $bd => $field_names) {
            foreach ($field_names as $fn => $marker_data) {
              if ($bd == $bundle && $fn == $field_name) {
                if (isset($getlocations_markers[$entity_type][$bundle][$field_name]['marker']) && $getlocations_markers[$entity_type][$bundle][$field_name]['marker']) {
                  $marker = $getlocations_markers[$entity_type][$bundle][$field_name]['marker'];
                }
              }
            }
          }
        }
      }
    }
    $markers = getlocations_get_marker_titles();
    $summary[] = t('@l map marker: @c', array(
      '@l' => $label,
      '@c' => $markers[$marker],
    ));
    if ($settings['map_backgroundcolor']) {
      $summary[] = t('Map background color: @c', array(
        '@c' => $settings['map_backgroundcolor'],
      ));
    }
    if ($settings['markeraction'] > 0) {
      if ($settings['markeraction'] == 1) {
        $msg = t('InfoWindow');
      }
      elseif ($settings['markeraction'] == 2) {
        $msg = t('InfoBubble');
      }
      else {
        $msg = t('Link');
      }
      if ($settings['markeractiontype'] == 2) {
        $msg2 = t('Mouse over');
      }
      else {
        $msg2 = t('Click');
      }
      $summary[] = t('Marker action: @a on @b', array(
        '@a' => $msg,
        '@b' => $msg2,
      ));
      if ($settings['markeraction_click_zoom'] > -1) {
        $summary[] = t('Zoom on Marker click: @a', array(
          '@a' => $settings['markeraction_click_zoom'],
        ));
      }
      if ($settings['markeraction_click_center'] == 1) {
        $summary[] = t('Center on Marker click: Yes');
      }
      elseif ($settings['markeraction_click_center'] == 2) {
        $summary[] = t('Pan to on Marker click: Yes');
      }
    }
    $summary[] = t('Zoom level: @z', array(
      '@z' => $settings['nodezoom'],
    ));
    if ($settings['polygons_enable']) {
      $summary[] = t('Enable polygons: Yes');
      if ($settings['polygons_clickable']) {
        $summary[] = t('Polygons clickable: Yes');
      }
    }
    if ($settings['rectangles_enable']) {
      $summary[] = t('Enable rectangles: Yes');
      if ($settings['rectangles_clickable']) {
        $summary[] = t('Rectangles clickable: Yes');
      }
    }
    if ($settings['circles_enable']) {
      $summary[] = t('Enable circles: Yes');
      if ($settings['circles_clickable']) {
        $summary[] = t('Circles clickable: Yes');
      }
    }
    if ($settings['polylines_enable']) {
      $summary[] = t('Enable polylines: Yes');
      if ($settings['polylines_clickable']) {
        $summary[] = t('Polylines clickable: Yes');
      }
    }

    // search_places
    if ($settings['search_places']) {
      $summary[] = t('Enable Search Places: Yes');
    }
  }
  else {
    $summary[] = t('Show map: No');
    if ($settings['display_maplink']) {
      $summary[] = t('Show map link: Yes');
    }
  }

  // lat/long
  if ($settings['display_latlong']) {
    $summary[] = t('Show Latitude/Longitude: Yes');
  }
  if ($settings['display_dms']) {
    $summary[] = t('Show Latitude/Longitude in Degrees, minutes, seconds');
  }
  if ($settings['display_geo_microformat']) {
    $summary[] = t('Show Latitude/Longitude in accordance with Geo Microformat markup');
  }

  // address summary
  $address_display = array();
  if ($settings['display_name']) {
    $address_display[] = t("Name");
  }
  if ($settings['display_street']) {
    $address_display[] = t("Street");
  }
  if ($settings['display_additional']) {
    $address_display[] = t("Additional");
  }
  if ($settings['display_city']) {
    $address_display[] = t("City");
  }
  if ($settings['display_province']) {
    $address_display[] = t("Province");
  }
  if ($settings['display_postal_code']) {
    $address_display[] = t("Postcode");
  }
  if ($settings['display_country']) {
    $address_display[] = t("Country");
  }
  if ($settings['display_phone']) {
    $address_display[] = t("Phone");
  }
  if ($settings['display_mobile']) {
    $address_display[] = t("Mobile");
  }
  if ($settings['display_fax']) {
    $address_display[] = t("Fax");
  }
  if (count($address_display)) {
    $summary[] = t("Show in Address:") . '<br />' . implode(', ', $address_display);
  }
  if ($settings['country_full']) {
    $summary[] = t('Display full country name: Yes');
  }
  return implode('<br />', $summary);
}