You are here

function getlocations_leaflet_field_formatter_settings_form in Get Locations 7.2

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

Implements hook_field_formatter_settings_form(). Returns form elements for a formatter's settings.

Parameters

$field: The field structure being configured.

$instance: The instance structure being configured.

$view_mode: The view mode being configured.

$form: The (entire) configuration form array, which will usually have no use here.

$form_state: The form state of the (entire) configuration form.

Return value

The form elements for the formatter settings.

File

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

Code

function getlocations_leaflet_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $getlocations_leaflet_paths = getlocations_leaflet_paths_get();
  drupal_add_js($getlocations_leaflet_paths['getlocations_leaflet_formatter_path']);
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $locative_field_name = $instance['default_value'][0]['locative_field_name'];
  $element = array();
  switch ($display['type']) {
    case 'getlocations_leaflet_map':
      $settings['map_resize'] = 0;
      $settings['fullscreen_disable'] = 0;
      $settings['styles'] = '';
      $labels = array(
        'width' => t('Width'),
        'height' => t('Height'),
      );
      $element += getlocations_map_display_basics_form($settings, $labels);
      unset($element['map_resize']);
      unset($element['fullscreen_disable']);
      unset($element['styles']);
      $element['width']['#element_validate'] = array(
        'getlocations_element_validate_dim',
      );
      $element['height']['#element_validate'] = array(
        'getlocations_element_validate_dim',
      );
      $element['latlong']['#element_validate'] = array(
        'getlocations_element_validate_latlon',
      );
      unset($element['zoom']['#options']['21']);
      unset($element['zoom']['#options']['20']);
      unset($element['zoom']['#options']['19']);
      unset($element['minzoom_map']['#options']['21']);
      unset($element['minzoom_map']['#options']['20']);
      unset($element['minzoom_map']['#options']['19']);
      unset($element['maxzoom_map']['#options']['21']);
      unset($element['maxzoom_map']['#options']['20']);
      unset($element['maxzoom_map']['#options']['19']);
      $element += getlocations_leaflet_display_options_form($settings);
      unset($element['nodezoom']['#options']['21']);
      unset($element['nodezoom']['#options']['20']);
      unset($element['nodezoom']['#options']['19']);

      // awesome
      if ($settings['awesome'] && $settings['marker_type'] == 'fa') {
        $entity_type = $instance['entity_type'];
        $getlocations_markers = variable_get('getlocations_markers', array());
        $type_markers = getlocations_get_type_markers();
        $per_field_markers = FALSE;
        foreach ($type_markers as $et => $bundles) {
          if ($et == $entity_type) {
            if (isset($getlocations_markers[$entity_type]['enable']) && $getlocations_markers[$entity_type]['enable']) {
              $per_field_markers = TRUE;
              $entity_get_info = entity_get_info($entity_type);
              $entity_type_label = $entity_get_info['label'];
              foreach ($bundles as $bundle => $field_names) {
                foreach ($field_names as $field_name => $marker_data) {
                  if ($field_name == $locative_field_name) {
                    $bundle_label = $marker_data['bundle_label'];
                    $label = t('Type %etl, Bundle %name, Field %field Map marker', array(
                      '%etl' => $entity_type_label,
                      '%name' => $bundle_label,
                      '%field' => $field_name,
                    ));
                    $mkey = $entity_type . '__' . $bundle . '__' . $field_name;
                    $labels = array(
                      'awesome_icon' => t($label . ' Awesome icon'),
                      'awesome_icon_color' => t($label . ' Awesome icon color'),
                      'awesome_marker_color' => t($label . ' Awesome marker color'),
                      'awesome_title' => t($label . ' Awesome Fonts icon settings'),
                      'awesome_icon_spin' => t($label . ' Awesome icon spin'),
                      'awesome_icon_size' => t($label . ' Awesome icon size'),
                      'awesome_icon_type' => t($label . ' Awesome icon type'),
                      'awesome_icon_flip' => t($label . ' Awesome icon flip and rotate'),
                      'awesome_icon_html' => t($label . ' Awesome icon HTML'),
                      'awesome_icon_class' => t($label . ' Awesome icon class'),
                    );
                    $element += getlocations_leaflet_awesome_markers_elements_get($settings, $labels, $mkey);
                  }
                }
              }
            }
          }
        }
        if (!$per_field_markers) {
          $entity_get_info = entity_get_info($entity_type);
          $label = $entity_get_info['label'];
          $labels = array(
            'awesome_icon' => t($label . ' Awesome icon'),
            'awesome_icon_color' => t($label . ' Awesome icon color'),
            'awesome_marker_color' => t($label . ' Awesome marker color'),
            'awesome_title' => t($label . ' Awesome Fonts icon settings'),
            'awesome_icon_spin' => t($label . ' Awesome icon spin'),
            'awesome_icon_size' => t($label . ' Awesome icon size'),
            'awesome_icon_type' => t($label . ' Awesome icon type'),
            'awesome_icon_flip' => t($label . ' Awesome icon flip and rotate'),
            'awesome_icon_html' => t($label . ' Awesome icon HTML'),
            'awesome_icon_class' => t($label . ' Awesome icon class'),
          );
          $element += getlocations_leaflet_awesome_markers_elements_get($settings, $labels, $entity_type);
        }
      }
      break;
    case 'getlocations_leaflet_link':
      $element['text'] = array(
        '#type' => 'textfield',
        '#title' => t('Default text'),
        '#description' => t('The text to use if no other option is available.'),
        '#default_value' => $settings['text'],
        '#size' => 25,
      );
      $element['text_opt'] = array(
        '#type' => 'select',
        '#title' => t('Display format'),
        '#default_value' => $settings['text_opt'],
        '#options' => $settings['text_options'],
      );
      break;
  }
  return $element;
}