You are here

function locationmap_admin_settings in Location Map 8.2

Same name and namespace in other branches
  1. 7.2 locationmap.module \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.admin.inc, line 6

Code

function locationmap_admin_settings($form, &$form_state) {
  $config = config('locationmap.settings');
  $path = drupal_get_path('module', 'locationmap');
  $locationmap_admin_css_options = array(
    'preprocess' => FALSE,
  );
  drupal_add_css($path . '/locationmap_admin.css', $locationmap_admin_css_options);
  $defaults = array(
    'value' => '',
    'format' => filter_default_format(),
  );
  drupal_add_js($path . '/locationmap_admin.js');
  $form['info'] = array(
    '#type' => 'fieldset',
    '#title' => t('Location information'),
    '#collapsible' => FALSE,
  );
  $form['info']['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#default_value' => $config
      ->get('title'),
    '#description' => t("The title of the automatically generated ") . l(t('map page'), 'locationmap') . '.',
  );
  $form['info']['address'] = array(
    '#type' => 'textfield',
    '#required' => TRUE,
    '#title' => t('Address of your location'),
    '#default_value' => $config
      ->get('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']['type'] = array(
    '#type' => 'select',
    '#title' => t('Map type'),
    '#default_value' => $config
      ->get('type'),
    '#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']['zoom'] = array(
    '#type' => 'select',
    '#title' => t('Map zoom level'),
    '#default_value' => $config
      ->get('zoom'),
    '#description' => NULL,
    '#options' => $zoom_levels,
  );
  $form['info']['width'] = array(
    '#type' => 'textfield',
    '#title' => t('Map Width'),
    '#default_value' => $config
      ->get('width'),
    '#field_suffix' => 'px',
    '#description' => NULL,
    '#size' => 10,
  );
  $form['info']['height'] = array(
    '#type' => 'textfield',
    '#title' => t('Map Height'),
    '#default_value' => $config
      ->get('height'),
    '#field_suffix' => 'px',
    '#description' => NULL,
    '#size' => 10,
  );
  $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' . ' ' . l(t('map page'), 'locationmap') . '. Under normal circumstances you would not set these coordinates manually.'),
  );
  $form['info']['latlng']['latitude'] = array(
    '#type' => 'textfield',
    '#title' => t('Latitude'),
    '#default_value' => $config
      ->get('latitude'),
  );
  $form['info']['latlng']['longitude'] = array(
    '#type' => 'textfield',
    '#title' => t('Longitude'),
    '#default_value' => $config
      ->get('longitude'),
  );
  $form['info']['info'] = array(
    '#type' => 'text_format',
    '#title' => t('Marker Information'),
    '#default_value' => $config
      ->get('info.value'),
    '#format' => $config
      ->get('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']['body'] = array(
    '#type' => 'text_format',
    '#title' => t('Additional information (displayed above map)'),
    '#required' => FALSE,
    '#default_value' => $config
      ->get('body.value'),
    '#format' => $config
      ->get('body.format'),
    '#description' => t('Any additional information that you would like to include above the map.'),
  );
  $form['info']['footer'] = array(
    '#type' => 'text_format',
    '#title' => t('Additional information (displayed below map)'),
    '#required' => FALSE,
    '#default_value' => $config
      ->get('footer.value'),
    '#format' => $config
      ->get('footer.format'),
    '#description' => t('Any additional information you would like to include below the map.'),
  );
  $form['#validate'][] = 'locationmap_admin_settings_validate';
  $form['#submit'][] = 'locationmap_admin_settings_submit';
  return system_config_form($form, $form_state);
}