You are here

function locationmap_admin_settings in Location Map 7.2

Same name and namespace in other branches
  1. 8.2 locationmap.admin.inc \locationmap_admin_settings()
  2. 7 locationmap.module \locationmap_admin_settings()

Callback for admin settings page

1 string reference to 'locationmap_admin_settings'
locationmap_menu in ./locationmap.module
Implements hook_menu().

File

./locationmap.module, line 57

Code

function locationmap_admin_settings($form, &$form_state) {
  $path = drupal_get_path('module', 'locationmap');
  $locationmap_admin_css_options = array(
    'preprocess' => FALSE,
  );
  drupal_add_css($path . '/locationmap_admin.css', $locationmap_admin_css_options);
  $form['locationmap_api_key'] = array(
    '#type' => 'textfield',
    '#title' => t('Google Map API Key'),
    '#description' => t('Enter the Google Map API Key. You can get Google Map API key from !google_api_console', array(
      '!google_api_console' => l(t('Google API Console'), 'https://developers.google.com/maps/documentation/javascript/get-api-key'),
    )),
    '#default_value' => variable_get('locationmap_api_key', ''),
    '#required' => TRUE,
  );
  $defaults = array(
    'value' => '',
    'format' => filter_default_format(),
  );
  $locationmap_title = variable_get('locationmap_title', t('Our Location'));
  $locationmap_info = variable_get('locationmap_info', $defaults);
  $locationmap_body = variable_get('locationmap_body', $defaults);
  $locationmap_footer = variable_get('locationmap_footer', $defaults);
  drupal_add_js($path . '/locationmap_admin.js');
  $form['info'] = array(
    '#type' => 'fieldset',
    '#title' => t('Location information'),
    '#collapsible' => FALSE,
  );
  $form['info']['locationmap_title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#default_value' => variable_get('locationmap_title', t('Our Location')),
    '#description' => t("The title of the automatically generated !map_page.", array(
      '!map_page' => l(t('map page'), 'locationmap'),
    )),
  );
  $form['info']['locationmap_address'] = array(
    '#type' => 'textfield',
    '#required' => TRUE,
    '#title' => t('Address of your location'),
    '#default_value' => variable_get('locationmap_address', ''),
    '#description' => t('Enter your address separated by commas. This will be sent to Google for geocoding to determine the geographical coordinates of your location. Include any suitable from: # Street, Suburb, City, Region/State, Postcode/Zip, Country.'),
  );
  $form['info']['locationmap_type'] = array(
    '#type' => 'select',
    '#title' => t('Map type'),
    '#default_value' => variable_get('locationmap_type', 'google.maps.MapTypeId.ROADMAP'),
    '#description' => NULL,
    '#options' => array(
      'google.maps.MapTypeId.ROADMAP' => 'the default view',
      'google.maps.MapTypeId.SATELLITE' => 'showing Google Earth satellite images',
      'google.maps.MapTypeId.HYBRID' => 'showing a mixture of normal and satellite views',
      'google.maps.MapTypeId.TERRAIN' => 'showing a physical map based on terrain information',
    ),
  );
  $zoom_levels = array(
    '0' => t('0 - minimum zoom level, whole world'),
  );
  for ($i = 1; $i < 17; $i++) {
    $zoom_levels["{$i}"] = "{$i}";
  }
  $zoom_levels['17'] = t('17 - maximum zoom level');
  $form['info']['locationmap_zoom'] = array(
    '#type' => 'select',
    '#title' => t('Map zoom level'),
    '#default_value' => variable_get('locationmap_zoom', '15'),
    '#description' => NULL,
    '#options' => $zoom_levels,
  );
  $form['info']['locationmap_width'] = array(
    '#type' => 'textfield',
    '#title' => t('Map Width'),
    '#default_value' => variable_get('locationmap_width', '500'),
    '#field_suffix' => 'px',
    '#description' => NULL,
    '#size' => 10,
  );
  $form['info']['locationmap_height'] = array(
    '#type' => 'textfield',
    '#title' => t('Map Height'),
    '#default_value' => variable_get('locationmap_height', '500'),
    '#field_suffix' => 'px',
    '#description' => NULL,
    '#size' => 10,
  );
  $form['info']['locationmap_scroll'] = array(
    '#type' => 'checkbox',
    '#title' => t('Scrollwheel zooming'),
    '#default_value' => variable_get('locationmap_scroll', 1),
    '#description' => t("Enable zooming on the map using the mouse's scrollwheel."),
  );
  $form['info']['latlng'] = array(
    '#type' => 'fieldset',
    '#title' => t('Geographical coordinates'),
    '#collapsible' => FALSE,
    '#description' => t('Geographical coordinates for your location. Location map will try to obtain this information from Google using the address above. You are also able to fine-tune this by dragging the marker on the !map_page. Under normal circumstances you would not set these coordinates manually.', array(
      '!map_page' => l(t('map page'), 'locationmap'),
    )),
  );
  $form['info']['latlng']['locationmap_lat'] = array(
    '#type' => 'textfield',
    '#title' => t('Latitude'),
    '#default_value' => variable_get('locationmap_lat', '-46.0868686'),
  );
  $form['info']['latlng']['locationmap_lng'] = array(
    '#type' => 'textfield',
    '#title' => t('Longitude'),
    '#default_value' => variable_get('locationmap_lng', '166.6822074'),
  );
  $form['info']['locationmap_info'] = array(
    '#type' => 'text_format',
    '#title' => t('Marker information'),
    '#default_value' => $locationmap_info['value'],
    '#format' => $locationmap_info['format'],
    '#description' => t('The description that will be shown when a user clicks on the marker. If this field is empty, the address will be used.'),
  );
  $form['info']['locationmap_popinfo'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display marker information on page load'),
    '#description' => t('This always applies to the page view.  The block must be set to interactive mode to see marker information.'),
    '#default_value' => variable_get('locationmap_popinfo', false),
  );
  $form['info']['locationmap_body'] = array(
    '#type' => 'text_format',
    '#title' => t('Additional information (displayed above map)'),
    '#required' => FALSE,
    '#default_value' => $locationmap_body['value'],
    '#format' => $locationmap_body['format'],
    '#description' => t('Any additional information that you would like to include above the map.'),
  );
  $form['info']['locationmap_footer'] = array(
    '#type' => 'text_format',
    '#title' => t('Additional information (displayed below map)'),
    '#required' => FALSE,
    '#default_value' => $locationmap_footer['value'],
    '#format' => $locationmap_footer['format'],
    '#description' => t('Any additional information you would like to include below the map.'),
  );
  $form['#validate'][] = 'locationmap_admin_settings_validate';
  return system_settings_form($form);
}