You are here

function getlocations_mapquest_settings_form in Get Locations 7

Same name and namespace in other branches
  1. 7.2 modules/getlocations_mapquest/getlocations_mapquest.module \getlocations_mapquest_settings_form()

Function

Return value

Returns

1 string reference to 'getlocations_mapquest_settings_form'
getlocations_mapquest_menu in modules/getlocations_mapquest/getlocations_mapquest.module
Implements hook_menu().

File

modules/getlocations_mapquest/getlocations_mapquest.module, line 1592
getlocations_mapquest.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function getlocations_mapquest_settings_form() {
  $form = array();
  $pagetitle = '<div><h4>' . t('Getlocations Mapquest') . '</h4><p>' . t('The settings selected here will be used as the starting point for all other Mapquest maps.') . '</p></div>';
  $form['pagetitle'] = array(
    '#markup' => $pagetitle,
  );
  $form['rebuild'] = array(
    '#type' => 'fieldset',
    '#title' => t('Regenerate Getlocations mapquest marker cache'),
    '#description' => t('If you are having problems with markers, or have changed anything in the markers library, click on the Regenerate button.'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $c = count(getlocations_get_marker_titles());
  if ($c) {
    $rebuildmsg = '<p>' . format_plural($c, 'You have 1 marker installed.', 'You have @count markers installed.') . '</p>';
  }
  else {
    $rebuildmsg = '<p class="error">' . t('WARNING! NO markers found.') . '</p>';
  }
  $form['rebuild']['msg'] = array(
    '#markup' => $rebuildmsg,
  );
  $form['rebuild']['rebuild_marker_js'] = array(
    '#type' => 'submit',
    '#value' => t('Regenerate'),
    '#submit' => array(
      '_getlocations_mapquest_rebuild_marker_js_submit',
    ),
  );
  $form['rebuild']['getlocations_mapquest_flush'] = getlocations_element_map_checkbox(t('Flush marker cache'), variable_get('getlocations_mapquest_flush', 1), t('Include the marker cache when the Drupal cache is flushed.'));
  $mapquest_lic = variable_get('getlocations_mapquest_lic', array(
    'key' => '',
    'type' => 'l',
  ));
  if ($mapquest_lic['key']) {
    $form['getlocations_mapquest_preview'] = array(
      '#type' => 'fieldset',
      '#title' => t('Getlocations Mapquest Preview'),
      #'#description' => t('A preview of the current map settings.') . '<br />' . t('You can adjust the default Map center and Zoom by changing the map.') . '<br />' . t('For all other changes use the form. Remember to Save configuration when you are done.'),

      // This will store all the defaults in one variable.
      '#tree' => FALSE,
    );
    $form['getlocations_mapquest_preview']['preview_map'] = array(
      '#markup' => '',
    );
  }
  else {
    $form['getlocations_mapquest_preview'] = array(
      '#markup' => '<p>' . t('No mapquest key found.') . '</p>',
    );
  }
  $settings = getlocations_mapquest_defaults();
  $form['getlocations_mapquest_defaults'] = array(
    '#type' => 'fieldset',
    '#title' => t('Default Page settings'),
    // This will store all the defaults in one variable.
    '#tree' => TRUE,
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $labels = array(
    'width' => t('Width'),
    'height' => t('Height'),
  );
  $form['getlocations_mapquest_defaults'] += getlocations_map_display_basics_form($settings, $labels);
  unset($form['getlocations_mapquest_defaults']['map_resize']);
  unset($form['getlocations_mapquest_defaults']['fullscreen_disable']);
  unset($form['getlocations_mapquest_defaults']['styles']);
  unset($form['getlocations_mapquest_defaults']['zoom']['#options']['21']);
  unset($form['getlocations_mapquest_defaults']['zoom']['#options']['20']);
  unset($form['getlocations_mapquest_defaults']['zoom']['#options']['19']);
  unset($form['getlocations_mapquest_defaults']['minzoom_map']['#options']['21']);
  unset($form['getlocations_mapquest_defaults']['minzoom_map']['#options']['20']);
  unset($form['getlocations_mapquest_defaults']['minzoom_map']['#options']['19']);
  unset($form['getlocations_mapquest_defaults']['maxzoom_map']['#options']['21']);
  unset($form['getlocations_mapquest_defaults']['maxzoom_map']['#options']['20']);
  unset($form['getlocations_mapquest_defaults']['maxzoom_map']['#options']['19']);
  $form['getlocations_mapquest_defaults'] += getlocations_mapquest_display_options_form($settings, TRUE);
  unset($form['getlocations_mapquest_defaults']['nodezoom']['#options']['21']);
  unset($form['getlocations_mapquest_defaults']['nodezoom']['#options']['20']);
  unset($form['getlocations_mapquest_defaults']['nodezoom']['#options']['19']);

  // search markers
  if (module_exists('getlocations_fields') && module_exists('views')) {
    $form['getlocations_mapquest_defaults'] += getlocations_fields_views_search_form($settings, 'mapquest');
  }

  // javascript paths
  $getlocations_mapquest_paths = getlocations_mapquest_paths_get();
  $form['getlocations_mapquest_paths'] = array(
    '#type' => 'fieldset',
    '#title' => t('Javascript paths'),
    '#description' => t('For advanced users who want to supply their own javascript.'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    // This will store all the defaults in one variable.
    '#tree' => TRUE,
  );
  $form['getlocations_mapquest_paths']['getlocations_mapquest_path'] = getlocations_element_path(t('Path to Getlocations mapquest javascript file'), $getlocations_mapquest_paths['getlocations_mapquest_path'], 80, 128, t('Where the Getlocations mapquest javascript file is located.'));
  $form['getlocations_mapquest_paths']['getlocations_mapquest_formatter_path'] = getlocations_element_path(t('Path to Getlocations mapquest formatter javascript file'), $getlocations_mapquest_paths['getlocations_mapquest_formatter_path'], 80, 128, t('Where the Getlocations mapquest formatter javascript file is located.'));
  $form['getlocations_mapquest_paths']['getlocations_mapquest_preview_path'] = getlocations_element_path(t('Path to Getlocations mapquest preview javascript file'), $getlocations_mapquest_paths['getlocations_mapquest_preview_path'], 80, 128, t('Where the Getlocations mapquest preview javascript file is located.'));
  $form['getlocations_mapquest_paths']['reset'] = getlocations_element_dd(t('Reset'), 0, array(
    0 => t('No'),
    1 => t('Reset'),
    2 => t('Reset to minified'),
  ), t('Reset the paths to the defaults.'));
  unset($form['#theme']);
  $form['#theme'] = 'getlocations_mapquest_settings_form';
  $form['#validate'][] = 'getlocations_mapquest_settings_validate';
  $form['#attached']['js'] = array(
    $getlocations_mapquest_paths['getlocations_mapquest_formatter_path'],
    $getlocations_mapquest_paths['getlocations_mapquest_preview_path'],
  );
  return system_settings_form($form);
}