You are here

function location_settings in Location 7.5

Same name and namespace in other branches
  1. 5.3 location.module \location_settings()
  2. 6.3 location.module \location_settings()
  3. 7.3 location.module \location_settings()
  4. 7.4 location.module \location_settings()

Get a form element for configuring location for an object.

2 calls to location_settings()
location_cck_field_settings_form in contrib/location_cck/location_cck.module
Implement hook_field_settings_form().
location_taxonomy_form_alter in contrib/location_taxonomy/location_taxonomy.module
Implements hook_form_alter().
1 string reference to 'location_settings'
_location_process_location_settings in ./location.module

File

./location.module, line 1724
Location module main routines. An implementation of a universal API for location manipulation. Provides functions for postal_code proximity searching, deep-linking into online mapping services. Currently, some options are configured through an…

Code

function location_settings($old = FALSE) {
  if (empty($old)) {
    $old = array();
  }
  $form = array(
    '#type' => 'fieldset',
    '#title' => t('Locative information'),
    '#tree' => TRUE,
  );
  $form['multiple'] = array(
    '#type' => 'fieldset',
    '#title' => t('Number of locations'),
    '#tree' => TRUE,
    '#weight' => 2,
  );
  $form['multiple']['min'] = array(
    '#type' => 'select',
    '#title' => t('Minimum number of locations'),
    '#options' => drupal_map_assoc(range(0, 100)),
    '#default_value' => isset($old['multiple']['min']) ? $old['multiple']['min'] : 0,
    '#description' => t('The number of locations that are required to be filled in.'),
  );
  $form['multiple']['max'] = array(
    '#type' => 'select',
    '#title' => t('Maximum number of locations'),
    '#options' => drupal_map_assoc(range(0, 100)),
    '#default_value' => isset($old['multiple']['max']) ? $old['multiple']['max'] : 1,
    '#description' => t('The maximum number of locations that can be associated.'),
  );

  // @@@ Dynamic location adding via ahah?
  $form['multiple']['add'] = array(
    '#type' => 'select',
    '#title' => t('Number of locations that can be added at once'),
    '#options' => drupal_map_assoc(range(0, 100)),
    '#default_value' => isset($old['multiple']['add']) ? $old['multiple']['add'] : 1,
    '#description' => t('The number of empty location forms to show when editing.'),
  );

  // Thought: What about prefilled names and fixed locations that way?
  // Then again, CCK would be cleaner.
  $form['form'] = array(
    '#type' => 'fieldset',
    '#title' => t('Collection settings'),
    '#tree' => TRUE,
    '#weight' => 4,
  );
  $form['form']['weight'] = array(
    '#type' => 'weight',
    '#title' => t('Location form weight'),
    '#default_value' => isset($old['form']['weight']) ? $old['form']['weight'] : 0,
    '#description' => t('Weight of the location box in the add / edit form. Lower values will be displayed higher in the form.'),
  );
  $form['form']['collapsible'] = array(
    '#type' => 'checkbox',
    '#title' => t('Collapsible'),
    '#default_value' => isset($old['form']['collapsible']) ? $old['form']['collapsible'] : TRUE,
    '#description' => t('Make the location box collapsible.'),
  );
  $form['form']['collapsed'] = array(
    '#type' => 'checkbox',
    '#title' => t('Collapsed'),
    '#default_value' => isset($old['form']['collapsed']) ? $old['form']['collapsed'] : TRUE,
    '#description' => t('Display the location box collapsed.'),
  );
  $form['form']['fields'] = array(
    '#type' => 'location_settings',
    '#default_value' => isset($old['form']['fields']) ? $old['form']['fields'] : array(),
  );
  $form['display'] = array(
    '#type' => 'fieldset',
    '#title' => t('Display Settings'),
    //    '#description' => t('Here, you can change how locative data appears in nodes when viewed.'),
    '#tree' => TRUE,
    '#weight' => 6,
  );
  $form['display']['weight'] = array(
    '#type' => 'weight',
    '#title' => t('Display Weight'),
    '#default_value' => isset($old['display']['weight']) ? $old['display']['weight'] : 0,
  );
  $fields = location_field_names(TRUE);
  $form['display']['hide'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Hide fields from display'),
    '#default_value' => isset($old['display']['hide']) ? $old['display']['hide'] : array(),
    '#options' => $fields,
  );
  return $form;
}