You are here

function getdirections_default_settings in Get Directions 7.3

Default settings form

Return value

array form

2 calls to getdirections_default_settings()
getdirections_fields_field_formatter_settings_form in modules/getdirections_fields/getdirections_fields.module
Implements hook_field_formatter_settings_form(). Returns form elements for a formatter's settings.
getdirections_settings_form in ./getdirections.admin.inc
Function to display the getdirections admin settings form

File

./getdirections.module, line 2082
Fetches google map directions.

Code

function getdirections_default_settings($defaults, $parent = 'getdirections_default') {
  $form = array();
  $form['width'] = array(
    '#type' => 'textfield',
    '#title' => t('Default width'),
    '#default_value' => $defaults['width'],
    '#size' => 25,
    '#maxlength' => 25,
    '#description' => t('The default width of a Google map, as a CSS length or percentage. Examples: <em>50px</em>, <em>5em</em>, <em>2.5in</em>, <em>95%</em>'),
    '#required' => TRUE,
  );
  $form['height'] = array(
    '#type' => 'textfield',
    '#title' => t('Default height'),
    '#default_value' => $defaults['height'],
    '#size' => 25,
    '#maxlength' => 25,
    '#description' => t('The default height of a Google map, as a CSS length or percentage. Examples: <em>50px</em>, <em>5em</em>, <em>2.5in</em>, <em>95%</em>'),
    '#required' => TRUE,
  );
  $form['latlong'] = array(
    '#type' => 'textfield',
    '#title' => t('Map center'),
    '#default_value' => $defaults['latlong'],
    '#size' => 50,
    '#maxlength' => 255,
    '#description' => t('The default center coordinates of Google map, expressed as a decimal latitude and longitude, separated by a comma.'),
    '#required' => TRUE,
  );
  $form['zoom'] = array(
    '#type' => 'select',
    '#title' => t('Zoom'),
    '#default_value' => $defaults['zoom'],
    '#options' => drupal_map_assoc(range(0, 17)),
    '#description' => t('The default zoom level of a Google map.'),
  );

  // v3
  $opts = array(
    'none' => t('None'),
    'default' => t('Default'),
    'small' => t('Small'),
    'large' => t('Large'),
  );
  $form['controltype'] = array(
    '#type' => 'select',
    '#title' => t('Zoom Control type'),
    '#options' => $opts,
    '#default_value' => $defaults['controltype'],
  );
  $form['pancontrol'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show Pan control'),
    '#default_value' => $defaults['pancontrol'],
    '#return_value' => 1,
  );
  $opts2 = array(
    'none' => t('None'),
    'standard' => t('Horizontal bar'),
    'menu' => t('Dropdown'),
  );
  $form['mtc'] = array(
    '#type' => 'select',
    '#title' => t('Map Control Type'),
    '#options' => $opts2,
    '#default_value' => $defaults['mtc'],
  );
  $options = array();
  $layers = array(
    'Map' => t('Standard street map'),
    'Satellite' => t('Standard satellite map'),
    'Hybrid' => t('Hybrid satellite map'),
    'Physical' => t('Terrain map'),
    'OpenStreetMap' => t('OpenStreet map'),
  );
  foreach ($layers as $key => $layer) {
    if ($defaults['baselayers'][$key]) {
      $options[$key] = $layer;
    }
  }
  $form['maptype'] = array(
    '#type' => 'select',
    '#title' => t('Default map type'),
    '#default_value' => $defaults['maptype'],
    '#options' => $options,
  );
  $form['baselayers'] = array(
    '#type' => 'fieldset',
    '#title' => t('Enable map types'),
    '#description' => t('Select which maps you want to be available.'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['baselayers']['Map'] = array(
    '#type' => 'checkbox',
    '#title' => t('Standard street map'),
    '#description' => t('The standard default street map.'),
    '#default_value' => $defaults['baselayers']['Map'],
    '#return_value' => 1,
  );
  $form['baselayers']['Satellite'] = array(
    '#type' => 'checkbox',
    '#title' => t('Standard satellite map'),
    '#description' => t('Satellite view without street overlay.'),
    '#default_value' => $defaults['baselayers']['Satellite'],
    '#return_value' => 1,
  );
  $form['baselayers']['Hybrid'] = array(
    '#type' => 'checkbox',
    '#title' => t('Hybrid satellite map'),
    '#description' => t('Satellite view with street overlay.'),
    '#default_value' => $defaults['baselayers']['Hybrid'],
    '#return_value' => 1,
  );
  $form['baselayers']['Physical'] = array(
    '#type' => 'checkbox',
    '#title' => t('Terrain map'),
    '#description' => t('Map with physical data (terrain, vegetation.)'),
    '#default_value' => $defaults['baselayers']['Physical'],
    '#return_value' => 1,
  );
  $form['baselayers']['OpenStreetMap'] = array(
    '#type' => 'checkbox',
    '#title' => t('OpenStreet map'),
    '#description' => t('Map from the OpenStreetMap Foundation.'),
    '#default_value' => $defaults['baselayers']['OpenStreetMap'],
    '#return_value' => 1,
  );
  $form['unitsystem'] = array(
    '#type' => 'select',
    '#title' => t('Default distance units'),
    '#description' => t("Units to display distances in."),
    '#default_value' => $defaults['unitsystem'],
    '#options' => array(
      'metric' => t('Metric'),
      'imperial' => t('Imperial'),
    ),
  );
  $form['scale'] = array(
    '#type' => 'checkbox',
    '#title' => t('Scale'),
    '#description' => t('Show scale'),
    '#default_value' => $defaults['scale'],
    '#return_value' => 1,
  );
  $form['overview'] = array(
    '#type' => 'checkbox',
    '#title' => t('Overview map'),
    '#description' => t('Show overview map'),
    '#default_value' => $defaults['overview'],
    '#return_value' => 1,
  );
  $form['overview_opened'] = array(
    '#type' => 'checkbox',
    '#title' => t('Overview map state'),
    '#description' => t('Show overview map as open by default'),
    '#default_value' => $defaults['overview_opened'],
    '#return_value' => 1,
  );
  $form['scrollwheel'] = array(
    '#type' => 'checkbox',
    '#title' => t('Scrollwheel'),
    '#description' => t('Enable scrollwheel zooming'),
    '#default_value' => $defaults['scrollwheel'],
    '#return_value' => 1,
  );
  $form['draggable'] = array(
    '#type' => 'checkbox',
    '#title' => t('Draggable'),
    '#description' => t('Enable dragging on the map'),
    '#default_value' => $defaults['draggable'],
    '#return_value' => 1,
  );
  $form['nokeyboard'] = array(
    '#type' => 'checkbox',
    '#title' => t('Disable keyboard shortcuts'),
    '#description' => t('Enabling this will disable keyboard shortcuts on the map.'),
    '#default_value' => $defaults['nokeyboard'],
    '#return_value' => 1,
  );
  $form['nodoubleclickzoom'] = array(
    '#type' => 'checkbox',
    '#title' => t('Disable Doubleclick zoom'),
    '#description' => t('Enabling this will disable doubleclick zooming on the map.'),
    '#default_value' => $defaults['nodoubleclickzoom'],
    '#return_value' => 1,
  );
  $form['streetview_show'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show streetview button'),
    '#default_value' => $defaults['streetview_show'],
    '#return_value' => 1,
  );
  $form['travelmode_show'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show travel mode'),
    '#description' => t('Enable travel mode selector.'),
    '#default_value' => $defaults['travelmode_show'],
    '#return_value' => 1,
  );
  if (module_exists('date_popup')) {
    $form['transit_dates'] = array(
      '#type' => 'checkbox',
      '#title' => t('Show Public transport Dates'),
      '#description' => t('When "Public transport" has been selected as travel mode, allow user to enter a date and time.'),
      '#default_value' => $defaults['transit_dates'],
      '#return_value' => 1,
      '#prefix' => '<div id="getdirections_transit_dates_wrapper">',
    );
    $form['transit_date_format'] = array(
      '#type' => 'select',
      '#title' => t('Date format'),
      '#default_value' => $defaults['transit_date_format'],
      '#options' => array(
        'int' => t('International Format'),
        'usa' => t('American Format'),
      ),
      '#suffix' => '</div>',
    );
  }
  else {
    $form['transit_dates'] = array(
      '#type' => 'value',
      '#value' => 0,
    );
    $form['transit_date_format'] = array(
      '#type' => 'value',
      '#value' => 'int',
    );
  }
  $form['travelextras_show'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show travel extras'),
    '#description' => t('Enable travel extras checkboxes.'),
    '#default_value' => $defaults['travelextras_show'],
    '#return_value' => 1,
  );
  $form['map_backgroundcolor'] = array(
    '#type' => 'textfield',
    '#title' => t('Map background color'),
    '#default_value' => $defaults['map_backgroundcolor'],
    '#description' => t('Can be a color name or HTML hex, eg #FF0000. Leave empty for the default color.'),
    '#size' => 10,
  );
  $form['from_width'] = array(
    '#type' => 'textfield',
    '#title' => t('Width of From box'),
    '#default_value' => $defaults['from_width'],
    '#size' => 5,
    '#description' => t("The width of the Get directions 'From' box."),
    '#required' => TRUE,
  );
  if ($parent) {
    $form['from_width']['#parents'] = array(
      $parent,
      'from_width',
    );
  }
  $form['to_width'] = array(
    '#type' => 'textfield',
    '#title' => t('Width of To box'),
    '#default_value' => $defaults['to_width'],
    '#size' => 5,
    '#description' => t("The width of the Get directions 'To' box."),
    '#required' => TRUE,
  );
  if ($parent) {
    $form['to_width']['#parents'] = array(
      $parent,
      'to_width',
    );
  }
  if (module_exists('location') || module_exists('getlocations_fields')) {
    $form['use_country_dropdown'] = array(
      '#type' => 'checkbox',
      '#title' => t('Use Country dropdown'),
      '#description' => t('Use a dropdown list of countries on the form.'),
      '#default_value' => $defaults['use_country_dropdown'],
      '#return_value' => 1,
    );
  }
  else {
    $form['use_country_dropdown'] = array(
      '#type' => 'value',
      '#value' => 0,
    );
  }
  $form['use_advanced'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use advanced features'),
    '#description' => t('Advanced features include a clickable map, waypoints or draggable route.'),
    '#default_value' => $defaults['use_advanced'],
    '#return_value' => 1,
  );
  $waypoints_opts = range(0, GETDIRECTIONS_WAYPOINTS_MAX);
  $waypoints_opts[0] = t('None');
  $form['waypoints'] = array(
    '#type' => 'select',
    '#title' => t('Number of waypoints'),
    '#description' => t('The number of waypoints to display on the map.'),
    '#default_value' => $defaults['waypoints'],
    '#options' => $waypoints_opts,
    '#prefix' => '<div id="wrap-waypoints">',
  );
  $form['advanced_autocomplete_via'] = array(
    '#type' => 'checkbox',
    '#title' => t('Waypoints Autocomplete'),
    '#description' => t('Provides Autocomplete box for waypoints. Requires "Use Google Autocomplete" to be enabled.'),
    '#default_value' => $defaults['advanced_autocomplete_via'],
    '#return_value' => 1,
  );
  $form['advanced_autocomplete_via_width'] = array(
    '#type' => 'textfield',
    '#title' => t('Width of Waypoints box'),
    '#default_value' => $defaults['advanced_autocomplete_via_width'],
    '#size' => 5,
    '#description' => t("The width of the Waypoints Autocomplete box."),
    '#required' => TRUE,
  );
  if ($parent) {
    $form['advanced_autocomplete_via_width']['#parents'] = array(
      $parent,
      'advanced_autocomplete_via_width',
    );
  }
  $form['waypoints_optimise'] = array(
    '#type' => 'checkbox',
    '#title' => t('Optimise Waypoints'),
    '#description' => t("Re-orders the waypoints to minimize overall cost of the route."),
    '#default_value' => $defaults['waypoints_optimise'],
    '#return_value' => 1,
  );
  $form['waypoint_color'] = array(
    '#type' => 'select',
    '#title' => t('Color of waypoint markers'),
    '#description' => t('The color of waypoint markers used on the map.'),
    '#default_value' => $defaults['waypoint_color'],
    '#options' => array(
      'black' => t('Black'),
      'blue' => t('Blue'),
      'brown' => t('Brown'),
      'gray' => t('Gray'),
      'green' => t('Green'),
      'orange' => t('Orange'),
      'purple' => t('Purple'),
      'red' => t('Red'),
      'white' => t('White'),
      'yellow' => t('Yellow'),
    ),
  );
  $form['advanced_alternate'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use draggable route'),
    '#description' => t('An alternative to waypoints.'),
    '#default_value' => $defaults['advanced_alternate'],
    '#return_value' => 1,
  );
  $form['advanced_autocomplete'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use Google Autocomplete'),
    '#description' => t('An alternative method for collecting starting point and destination.'),
    '#default_value' => $defaults['advanced_autocomplete'],
    '#return_value' => 1,
  );
  $form['advanced_autocomplete_bias'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable Viewport bias'),
    '#description' => t('Bias the Google Autocomplete results to the area on the map.'),
    '#default_value' => $defaults['advanced_autocomplete_bias'],
    '#return_value' => 1,
    '#suffix' => '</div>',
  );
  $form['region_bias'] = array(
    '#type' => 'select',
    '#title' => t('Regional bias'),
    '#description' => t('Bias the maps to a particular country'),
    '#default_value' => $defaults['region_bias'],
    '#options' => array(
      '' => t('None'),
    ) + getdirections_get_countries_list(),
  );
  $form['uselatlons'] = array(
    '#type' => 'checkbox',
    '#title' => t('Only use Coordinates in searches'),
    '#default_value' => $defaults['uselatlons'],
    '#return_value' => 1,
  );
  global $is_https;
  $form['use_https'] = array(
    '#type' => 'value',
    '#value' => $is_https ? 1 : 0,
  );
  return $form;
}