You are here

function ip_geoloc_generator_settings_form in IP Geolocation Views & Maps 7

Same name and namespace in other branches
  1. 8 modules/ip_geoloc_generator/src/Form/ip_geoloc_generator.module \ip_geoloc_generator_settings_form()
1 string reference to 'ip_geoloc_generator_settings_form'
ip_geoloc_generator_menu in ip_geoloc_generator/ip_geoloc_generator.module
Implements hook_menu().

File

ip_geoloc_generator/ip_geoloc_generator.module, line 56
ip_geoloc_generator.module

Code

function ip_geoloc_generator_settings_form($form, &$form_state) {
  $form = array();
  $form['generation_pars'] = array(
    '#type' => 'fieldset',
    '#collapsible' => FALSE,
    '#title' => t('Geolocation generation parameters'),
  );
  $form['generation_pars']['ip_geoloc_generator_no_points'] = array(
    '#type' => 'textfield',
    '#title' => t('Number of random locations to generate'),
    '#default_value' => variable_get('ip_geoloc_generator_no_points', 10),
    '#description' => t(''),
  );
  $form['generation_pars']['ip_geoloc_generator_center_lat'] = array(
    '#type' => 'textfield',
    '#title' => t('Latitude of center of location cluster'),
    '#default_value' => variable_get('ip_geoloc_generator_center_lat', IP_GEOLOC_GENERATOR_GREENWICH_OBSERVATORY_LAT),
    '#field_suffix' => t('degrees'),
    '#description' => t('Must be in range -90..90 degrees.'),
  );
  $form['generation_pars']['ip_geoloc_generator_center_lon'] = array(
    '#type' => 'textfield',
    '#title' => t('Longitude of center of location cluster'),
    '#default_value' => variable_get('ip_geoloc_generator_center_lon', IP_GEOLOC_GENERATOR_GREENWICH_OBSERVATORY_LON),
    '#field_suffix' => t('degrees'),
    '#description' => t('Must be in range -180..180 degrees.'),
  );
  $form['generation_pars']['ip_geoloc_generator_range_lat'] = array(
    '#type' => 'textfield',
    '#title' => t('Latitude range'),
    '#default_value' => variable_get('ip_geoloc_generator_range_lat', 0.02),
    '#field_suffix' => t('degrees'),
    '#description' => t(''),
  );
  $form['generation_pars']['ip_geoloc_generator_range_lon'] = array(
    '#type' => 'textfield',
    '#title' => t('Longitude range'),
    '#default_value' => variable_get('ip_geoloc_generator_range_lon', 0.12),
    '#field_suffix' => t('degrees'),
    '#description' => t(''),
  );
  $form['generation_views'] = array(
    '#type' => 'fieldset',
    '#collapsible' => FALSE,
    '#title' => t('Affected Views'),
  );
  $options = array(
    '' => t('- None -'),
  );
  foreach (views_get_all_views() as $view) {
    $view_name = empty($view->human_name) ? $view->name : $view->human_name;
    foreach ($view->display as $display) {
      if (isset($display->display_options['style_plugin']) && in_array($display->display_options['style_plugin'], array(
        'ip_geoloc_map',
        'ip_geoloc_leaflet',
        'ip_geoloc_openlayers',
      ))) {
        $options[$view->name] = $view_name;
        if (views_view_is_disabled($view)) {
          $options[$view->name] .= ' [' . t('disabled') . ']';
        }
        break;
      }
    }
  }
  $form['generation_views']['ip_geoloc_generator_views'] = array(
    '#type' => 'select',
    '#multiple' => TRUE,
    '#size' => min(10, count($options)),
    '#title' => t('Views to add locations to'),
    '#options' => $options,
    '#default_value' => variable_get('ip_geoloc_generator_views', array(
      '',
    )),
    '#description' => t('Select the Views to add marker clusters to.'),
  );
  return system_settings_form($form);
}