You are here

function getlocations_settings_form in Get Locations 6

Same name and namespace in other branches
  1. 6.2 getlocations.admin.inc \getlocations_settings_form()
  2. 7.2 getlocations.admin.inc \getlocations_settings_form()
  3. 7 getlocations.admin.inc \getlocations_settings_form()

Function to display the getlocations admin settings form

Return value

Returns the form.

1 string reference to 'getlocations_settings_form'
getlocations_menu in ./getlocations.module
Implementation of hook_menu().

File

./getlocations.admin.inc, line 14
getlocations module administration functions. using version 3 googlemaps API

Code

function getlocations_settings_form() {
  $getlocations_defaults = getlocations_defaults();
  drupal_add_js(GETLOCATIONS_PATH . '/js/getlocations_admin.js');
  $form = array();
  $form['rebuild'] = array(
    '#type' => 'fieldset',
    '#title' => t('Regenerate Getlocations marker cache'),
    '#description' => t('If you are having problems with markers, or have changed anything in the markers library, click here to rebuild the marker cache file.'),
  );
  if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) != FILE_DOWNLOADS_PUBLIC) {
    $form['rebuild']['getlocations_private_markerfile'] = array(
      '#type' => 'textfield',
      '#title' => t('Path to getlocations_markers.js'),
      '#description' => t('You are using the <em>Private</em> download method. For markers to work properly. you must press the <em>Regenerate</em> button, manually copy js/getlocations_markers.js from the files directory to a location accessible by the webserver, and enter the file path relative to the Drupal root (including the filename) in this field. Example: <em>sites/default/misc/getlocations_markers.js</em>'),
      '#default_value' => variable_get('getlocations_private_markerfile', ''),
    );
  }
  if (!getlocations_get_markerfile()) {
    $form['rebuild']['errmsg'] = array(
      '#value' => '<p class="messages error">' . t('You need to regenerate the markers, file not found.') . '</p>',
    );
  }
  $form['rebuild']['rebuild_marker_js'] = array(
    '#type' => 'submit',
    '#value' => t('Regenerate'),
    '#submit' => array(
      '_getlocations_rebuild_marker_js_submit',
    ),
  );

  // google api3 key
  $apikey = variable_get('getlocations_api3_key', '');
  $form['api3'] = array(
    '#type' => 'fieldset',
    '#title' => t('Google API key'),
    '#description' => t('This key is currently not required by Google.'),
    '#collapsible' => TRUE,
    #'#collapsed' => ($apikey ? TRUE : FALSE),
    '#collapsed' => TRUE,
  );
  $form['api3']['getlocations_api3_key'] = array(
    '#type' => 'textfield',
    '#title' => t('Your Google maps API Version 3 key'),
    '#default_value' => $apikey,
    '#description' => t('For more information about this key see this !u', array(
      '!u' => l('page on google', 'http://code.google.com/apis/maps/documentation/javascript/tutorial.html#api_key', array(
        'attributes' => array(
          'target' => '_blank',
        ),
      )),
    )),
    '#size' => 95,
    '#required' => FALSE,
  );
  $form['getlocations_default'] = array(
    '#type' => 'fieldset',
    '#title' => t('Getlocations Default map settings'),
    // This will store all the defaults in one variable.
    '#tree' => TRUE,
  );
  $form['getlocations_default']['width'] = getlocations_element_map_tf(t('Default width'), $getlocations_defaults['width'], 10, 10, t('The default width of a Google map, as a CSS length or percentage. Examples: <em>50px</em>, <em>5em</em>, <em>2.5in</em>, <em>95%</em>'));
  $form['getlocations_default']['height'] = getlocations_element_map_tf(t('Default height'), $getlocations_defaults['height'], 10, 10, t('The default height of a Google map, as a CSS length or percentage. Examples: <em>50px</em>, <em>5em</em>, <em>2.5in</em>, <em>95%</em>'));
  $form['getlocations_default']['styles'] = array(
    '#type' => 'textarea',
    '#title' => t('Default styles'),
    '#default_value' => $getlocations_defaults['styles'],
    '#description' => t('The default styles of a Google map. Use !link for generating your styles', array(
      '!link' => l('http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/', 'http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/', array(
        'external' => TRUE,
      )),
    )),
  );
  $form['getlocations_default']['latlong'] = getlocations_element_map_tf(t('Map center'), $getlocations_defaults['latlong'], 30, 30, t('The default center coordinates of a Google map, expressed as a decimal latitude and longitude, separated by a comma. This must not be 0,0'));
  $form['getlocations_default']['zoom'] = getlocations_element_map_zoom(t('Zoom'), $getlocations_defaults['zoom'], t('The default zoom level of a Google map.'));
  $form['getlocations_default'] += getlocations_map_display_options_form($getlocations_defaults);

  // default marker
  $markers = getlocations_get_marker_titles();
  $form['getlocations_default']['node_map_marker'] = getlocations_element_map_marker(t('Default Content Map marker'), $markers, $getlocations_defaults['node_map_marker']);
  if (module_exists('location_user')) {
    $form['getlocations_default']['user_map_marker'] = getlocations_element_map_marker(t('Default User Map marker'), $markers, $getlocations_defaults['user_map_marker']);
  }
  $form['getlocations_default']['markeractiontype'] = getlocations_element_map_markeractiontype($getlocations_defaults['markeractiontype']);
  $form['getlocations_default']['markeraction'] = getlocations_element_map_markeraction($getlocations_defaults['markeraction']);
  $form['getlocations_default']['minzoom'] = getlocations_element_map_zoom(t('Minimum Zoom'), $getlocations_defaults['minzoom'], t('The Minimum zoom level at which markers will be visible.'));
  $form['getlocations_default']['maxzoom'] = getlocations_element_map_zoom(t('Maximum Zoom'), $getlocations_defaults['maxzoom'], t('The Maximum zoom level at which markers will be visible.'));
  $form['getlocations_default']['nodezoom'] = getlocations_element_map_zoom(t('Default Zoom for Single location'), $getlocations_defaults['nodezoom'], t('The Default zoom level for a single marker.'));

  // marker manager
  $form['getlocations_default']['markermanagertype'] = getlocations_element_markermanagertype($getlocations_defaults['markermanagertype']);
  $form['getlocations_default']['usemarkermanager'] = getlocations_element_map_checkbox(t('Use Marker manager'), $getlocations_defaults['usemarkermanager'], t('Use Marker manager. Switching this off will use no manager.'));
  $form['getlocations_default']['useclustermanager'] = getlocations_element_map_checkbox(t('Use Cluster manager'), $getlocations_defaults['useclustermanager'], t('Use Cluster manager. Switching this off will use no manager.'));
  if (file_exists(GETLOCATIONS_PATH . '/getlocations.markerclusterer_override.inc')) {
    module_load_include('inc', 'getlocations', 'getlocations.markercluster_override');
  }
  else {
    module_load_include('inc', 'getlocations', 'getlocations.markercluster');
  }
  $form['getlocations_default']['markerclusterer_style'] = getlocations_element_markerclusterer_style($getlocations_defaults['markerclusterer_style']);
  $form['getlocations_default']['markerclusterer_zoom'] = getlocations_element_markerclusterer_zoom($getlocations_defaults['markerclusterer_zoom']);
  $form['getlocations_default']['markerclusterer_size'] = getlocations_element_markerclusterer_size($getlocations_defaults['markerclusterer_size']);
  $form['getlocations_default']['markerclusterer_minsize'] = getlocations_element_markerclusterer_minsize($getlocations_defaults['markerclusterer_minsize']);
  $form['getlocations_default']['pansetting'] = getlocations_element_map_pansetting($getlocations_defaults['pansetting']);
  $form['getlocations_default']['returnlink_page_enable'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show link back to page'),
    '#default_value' => $getlocations_defaults['returnlink_page_enable'],
    '#return_value' => 1,
  );
  $form['getlocations_default']['returnlink_page_link'] = array(
    '#type' => 'textfield',
    '#title' => t('Text of page return link'),
    '#default_value' => $getlocations_defaults['returnlink_page_link'],
    '#size' => 30,
    '#description' => t('Use %t to insert the page title'),
    '#prefix' => '<div id="wrap-page-link">',
    '#suffix' => '</div>',
  );
  if (module_exists('location_user')) {
    $form['getlocations_default']['returnlink_user_enable'] = array(
      '#type' => 'checkbox',
      '#title' => t('Show link back to user'),
      '#default_value' => $getlocations_defaults['returnlink_user_enable'],
      '#return_value' => 1,
    );
    $form['getlocations_default']['returnlink_user_link'] = array(
      '#type' => 'textfield',
      '#title' => t('Text of user return link'),
      '#default_value' => $getlocations_defaults['returnlink_user_link'],
      '#size' => 30,
      '#description' => t('Use %n to insert the user name'),
      '#prefix' => '<div id="wrap-user-link">',
      '#suffix' => '</div>',
    );
  }
  $form['getlocations_default']['use_https'] = array(
    '#type' => 'value',
    '#value' => isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 1 : 0,
  );
  if (module_exists('location_cck')) {

    // node type markers
    if ($types = getlocations_get_types()) {
      $form['getlocations_node_marker'] = array(
        '#type' => 'fieldset',
        '#title' => t('Content type markers'),
        // This will store all the defaults in one variable.
        '#tree' => TRUE,
      );
      $getlocations_node_marker = variable_get('getlocations_node_marker', array(
        'enable' => 0,
      ));
      $form['getlocations_node_marker']['enable'] = array(
        '#type' => 'checkbox',
        '#title' => t('Enable Markers for Content types'),
        '#default_value' => $getlocations_node_marker['enable'],
        '#return_value' => 1,
      );
      $typect = 0;
      foreach ($types as $type => $name) {
        $form['getlocations_node_marker']['content_type'][$type]['map_marker'] = getlocations_element_map_marker(t('%name Map marker', array(
          '%name' => $name,
        )), $markers, isset($getlocations_node_marker['content_type'][$type]['map_marker']) ? $getlocations_node_marker['content_type'][$type]['map_marker'] : $getlocations_defaults['map_marker']);
        if (!$typect) {
          $form['getlocations_node_marker']['content_type'][$type]['map_marker']['#prefix'] = '<div id="wrap-getlocations-node-markers">';
        }
        $typect++;
      }
      $form['getlocations_node_marker']['content_type'][$type]['map_marker']['#suffix'] = '</div>';
    }
  }
  else {
    variable_set('getlocations_node_marker', array(
      'enable' => 0,
    ));
  }
  if (module_exists('colorbox')) {
    $form['getlocations_colorbox'] = array(
      '#type' => 'fieldset',
      '#title' => t('Colorbox settings'),
      // This will store all the defaults in one variable.
      '#tree' => TRUE,
    );
    $getlocations_colorbox = variable_get('getlocations_colorbox', array(
      'enable' => 0,
      'width' => 600,
      'height' => 600,
    ));
    $form['getlocations_colorbox']['enable'] = array(
      '#type' => 'checkbox',
      '#title' => t('Enable Colorbox'),
      '#default_value' => $getlocations_colorbox['enable'],
      '#return_value' => 1,
      '#description' => t('Show Getlocations in a Colorbox.'),
    );
    $form['getlocations_colorbox']['width'] = array(
      '#type' => 'textfield',
      '#title' => t('Colorbox width'),
      '#default_value' => $getlocations_colorbox['width'],
      '#size' => 5,
      '#required' => TRUE,
      // need this to get validation to work
      '#parents' => array(
        'getlocations_colorbox',
        'width',
      ),
      '#prefix' => '<div id="wrap-getlocations-colorbox">',
    );
    $form['getlocations_colorbox']['height'] = array(
      '#type' => 'textfield',
      '#title' => t('Colorbox height'),
      '#default_value' => $getlocations_colorbox['height'],
      '#size' => 5,
      '#required' => TRUE,
      // need this to get validation to work
      '#parents' => array(
        'getlocations_colorbox',
        'height',
      ),
      '#suffix' => '</div>',
    );
  }
  $form['getlocations_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,
  );
  $getlocations_paths = getlocations_paths_get();
  $form['getlocations_paths']['infobubble_path'] = getlocations_element_path(t('Path to InfoBubble javascript file'), $getlocations_paths['infobubble_path'], 60, 128, t('Where the InfoBubble javascript file is located.'));
  $form['getlocations_paths']['infobubble_options_path'] = getlocations_element_path(t('Path to InfoBubble options javascript file'), $getlocations_paths['infobubble_options_path'], 60, 128, t('Where the InfoBubble options javascript file is located. If this file does not exist the default settings will be used.'));
  $form['getlocations_paths']['markermanager_path'] = getlocations_element_path(t('Path to markermanager javascript file'), $getlocations_paths['markermanager_path'], 60, 128, t('Where the markermanager javascript file is located.'));
  $form['getlocations_paths']['markerclusterer_path'] = getlocations_element_path(t('Path to markerclusterer javascript file'), $getlocations_paths['markerclusterer_path'], 60, 128, t('Where the markerclusterer javascript file is located.'));
  $form['#validate'][] = 'getlocations_settings_validate';
  return system_settings_form($form);
}