function getlocations_settings_form in Get Locations 7.2
Same name and namespace in other branches
- 6.2 getlocations.admin.inc \getlocations_settings_form()
- 6 getlocations.admin.inc \getlocations_settings_form()
- 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 - Implements hook_menu().
File
- ./
getlocations.admin.inc, line 17 - getlocations.admin.inc @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function getlocations_settings_form() {
$getlocations_defaults = getlocations_defaults();
$getlocations_paths = getlocations_paths_get();
drupal_add_js($getlocations_paths['getlocations_admin_path']);
$form = array();
$pagetitle = '<div><h4>' . t('Getlocations base settings') . '</h4><p>' . t('The settings selected here will be used as the starting point for all other Google maps.') . '</p></div>';
$form['pagetitle'] = array(
'#markup' => $pagetitle,
);
$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 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,
);
if (file_default_scheme() != 'public') {
$form['rebuild']['getlocations_private_markerfile'] = getlocations_element_map_tf(t('Path to getlocations_markers.js'), variable_get('getlocations_private_markerfile', ''), 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>'), 60, 255, FALSE);
}
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',
),
);
$form['rebuild']['getlocations_flush'] = getlocations_element_map_checkbox(t('Flush marker cache'), variable_get('getlocations_flush', 1), t('Include the marker cache when the Drupal cache is flushed.'));
// google api3 key
$apikey = variable_get('getlocations_api3_key', '');
$apiclientID = variable_get('getlocations_api3_clientID', '');
$apisignature = variable_get('getlocations_api3_signature', '');
$apichannel = variable_get('getlocations_api3_channel', '');
$apisigned_in = variable_get('getlocations_api3_signed_in', 0);
$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'] = getlocations_element_map_tf(t('Your Google maps API Version 3 key'), $apikey, t('For more information about this key see this !u', array(
'!u' => l(t('page on google'), 'http://code.google.com/apis/maps/documentation/javascript/tutorial.html#api_key', array(
'attributes' => array(
'target' => '_blank',
),
)),
)), 95, 255, FALSE);
$form['api3']['getlocations_api3_clientID'] = getlocations_element_map_tf(t('Your Google maps API Version 3 clientID'), $apiclientID, t('For more information about this see this !u', array(
'!u' => l(t('page on google'), 'https://developers.google.com/maps/documentation/javascript/get-api-key#client-id', array(
'attributes' => array(
'target' => '_blank',
),
)),
)), 95, 255, FALSE);
$form['api3']['getlocations_api3_signature'] = getlocations_element_map_tf(t('Your Google maps API Version 3 signature'), $apisignature, t('For more information about this see this !u', array(
'!u' => l(t('page on google'), 'https://developers.google.com/maps/documentation/javascript/get-api-key#client_id_and_signature', array(
'attributes' => array(
'target' => '_blank',
),
)),
)), 95, 255, FALSE);
$form['api3']['getlocations_api3_channel'] = getlocations_element_map_tf(t('Your Google maps API Version 3 channel'), $apichannel, t('For more information about this see this !u', array(
'!u' => l(t('page on google'), 'https://developers.google.com/maps/documentation/javascript/get-api-key#channel-reports', array(
'attributes' => array(
'target' => '_blank',
),
)),
)), 95, 255, FALSE);
$form['api3']['getlocations_api3_signed_in'] = getlocations_element_map_checkbox(t('Signed in'), $apisigned_in, t('Provide the Sign in link on the map.'));
// mapquest
$mapquest_lic = variable_get('getlocations_mapquest_lic', array(
'key' => '',
'type' => 'l',
));
$form['getlocations_mapquest_lic'] = array(
'#type' => 'fieldset',
'#title' => t('Mapquest key'),
'#description' => t('This key is required if you want to use Mapquest maps and services.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#tree' => TRUE,
);
$form['getlocations_mapquest_lic']['key'] = getlocations_element_map_tf(t('Mapquest key'), $mapquest_lic['key'], '', 40);
$form['getlocations_mapquest_lic']['type'] = getlocations_element_dd(t('Mapquest type'), $mapquest_lic['type'], array(
'o' => t('Open'),
'l' => t('Licensed'),
));
// $what3words
$what3words_lic = variable_get('getlocations_what3words_lic', array(
'key' => '',
'url' => 'http://api.what3words.com',
));
$form['getlocations_what3words_lic'] = array(
'#type' => 'fieldset',
'#title' => t('What3Words API key'),
'#description' => t('This key is required if you want to use !u services.', array(
'!u' => l(t('What3Words'), 'http://developer.what3words.com/', array(
'attributes' => array(
'target' => '_blank',
),
)),
)),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#tree' => TRUE,
);
$form['getlocations_what3words_lic']['key'] = getlocations_element_map_tf(t('What3Words key'), $what3words_lic['key'], t('After entering the key you should save the form, this will present further settings.'), 40);
$form['getlocations_what3words_lic']['url'] = getlocations_element_map_tf(t('What3Words URL'), !empty($what3words_lic['url']) ? $what3words_lic['url'] : 'http://api.what3words.com', '', 40);
// map version
$map_version = variable_get('getlocations_map_version', '');
$form['map_version'] = array(
'#type' => 'fieldset',
'#title' => t('Google Map version'),
'#description' => t('The map version is normally provided automatically, only use this if you wish to override it.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['map_version']['getlocations_map_version'] = getlocations_element_map_tf(t('Google maps version number'), $map_version, '', 5, 10, FALSE);
// preview
$form['getlocations_preview'] = array(
'#type' => 'fieldset',
'#title' => t('Getlocations Preview'),
'#description' => t('A preview of the current map settings.') . '<br />' . t('You can adjust the default Map center, Zoom and Default map type 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_preview']['preview_map'] = array(
'#markup' => '',
);
$form['getlocations_default'] = array(
'#type' => 'fieldset',
'#title' => t('Getlocations Default map settings'),
// This will store all the defaults in one variable.
'#tree' => TRUE,
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['getlocations_default'] += getlocations_map_display_basics_form($getlocations_defaults);
$form['getlocations_default'] += getlocations_map_display_options_form($getlocations_defaults);
// default node marker
$markers = getlocations_get_marker_titles();
$desc = '';
$form['getlocations_default']['map_marker'] = getlocations_element_map_marker(t('Default Content Map marker'), $markers, $getlocations_defaults['map_marker'], $desc);
$fieldables = getlocations_get_fieldable_entity_types();
foreach ($fieldables as $entity_type) {
$entity_get_info = entity_get_info($entity_type);
$label = $entity_get_info['label'];
$desc = '';
if (getlocations_check_entity_type($entity_type)) {
$desc = t('In use');
}
$form['getlocations_default'][$entity_type . '_map_marker'] = getlocations_element_map_marker(t('Default !label Map marker', array(
'!label' => $label,
)), $markers, $getlocations_defaults[$entity_type . '_map_marker'], $desc);
}
if (module_exists('getlocations_fields')) {
// default input marker
$form['getlocations_default']['input_map_marker'] = getlocations_element_map_marker(t('Default Input Map marker'), $markers, $getlocations_defaults['input_map_marker'], t('The draggable marker used on add/edit maps.'));
}
$form['getlocations_default'] += getlocations_markeraction_form($getlocations_defaults);
if (module_exists('getdirections')) {
$form['getlocations_default']['getdirections_link'] = getlocations_element_map_checkbox(t('Link to Getdirections in bubble'), $getlocations_defaults['getdirections_link'], t('Include a link to the Getdirections page in InfoBubble/InfoWindow.'));
}
// views_search options
if (module_exists('getlocations_fields') && module_exists('views')) {
$form['getlocations_default'] += getlocations_fields_views_search_form($getlocations_defaults);
}
else {
$form['getlocations_default']['show_search_distance'] = array(
'#type' => 'value',
'#value' => 0,
);
$form['getlocations_default']['views_search_marker_enable'] = array(
'#type' => 'value',
'#value' => 0,
);
$form['getlocations_default']['views_search_radshape_enable'] = array(
'#type' => 'value',
'#value' => 0,
);
$form['getlocations_default']['views_search_center'] = array(
'#type' => 'value',
'#value' => 0,
);
}
$form['getlocations_default']['preload_data'] = getlocations_element_map_checkbox(t('Preload marker data'), $getlocations_defaults['preload_data'], t('This will load all the data for InfoBubble/InfoWindow or link beforehand. This may result in slower initial page loads but faster marker click response.'));
$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 managers
$form['getlocations_default']['markermanagertype'] = getlocations_element_markermanagertype($getlocations_defaults['markermanagertype']);
// markermanager
$form['getlocations_default'] += getlocations_markermanager_form($getlocations_defaults);
// markerclusterer
$form['getlocations_default'] += getlocations_markercluster_form($getlocations_defaults);
$form['getlocations_default']['pansetting'] = getlocations_element_map_pansetting($getlocations_defaults['pansetting']);
// return links
foreach ($fieldables as $entity_type) {
$entity_get_info = entity_get_info($entity_type);
$label = $entity_get_info['label'];
if (getlocations_check_entity_type($entity_type)) {
$form['getlocations_default']['returnlink_' . $entity_type . '_enable'] = getlocations_element_map_checkbox(t('Show link back to !label', array(
'!label' => $label,
)), $getlocations_defaults['returnlink_' . $entity_type . '_enable']);
$form['getlocations_default']['returnlink_' . $entity_type . '_link'] = getlocations_element_map_tf(t('Text of !label return link', array(
'!label' => $label,
)), $getlocations_defaults['returnlink_' . $entity_type . '_link'], t('Use %t to insert the !label title', array(
'!label' => $label,
)), 30, 64);
}
}
$form['getlocations_default']['getlocations_js_weight'] = getlocations_element_map_tf(t('Getlocations Javascript weight'), $getlocations_defaults['getlocations_js_weight'], t('Set the weight of the getlocations javascript loading, only change this if you are having problems. For advanced users only.'), 5, 99, TRUE);
$getlocations_markers = variable_get('getlocations_markers', array());
$type_markers = getlocations_get_type_markers();
if ($type_markers) {
$form['getlocations_markers'] = array(
'#type' => 'fieldset',
'#title' => t('Entity Type markers'),
// This will store all the defaults in one variable.
'#tree' => TRUE,
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
foreach ($type_markers as $entity_type => $bundles) {
// enable $entity_markers
$entity_get_info = entity_get_info($entity_type);
$entity_type_label = $entity_get_info['label'];
$form['getlocations_markers'][$entity_type]['enable'] = getlocations_element_map_checkbox(t('Enable Markers for !t types', array(
'!t' => $entity_type_label,
)), isset($getlocations_markers[$entity_type]['enable']) ? $getlocations_markers[$entity_type]['enable'] : 0);
foreach ($bundles as $bundle => $field_names) {
foreach ($field_names as $field_name => $marker_data) {
$bundle_label = $marker_data['bundle_label'];
$form['getlocations_markers'][$entity_type][$bundle][$field_name]['marker'] = getlocations_element_map_marker(t('Type %etl, Bundle %name, Field %field Map marker', array(
'%etl' => $entity_type_label,
'%name' => $bundle_label,
'%field' => $field_name,
)), $markers, isset($getlocations_markers[$entity_type][$bundle][$field_name]['marker']) ? $getlocations_markers[$entity_type][$bundle][$field_name]['marker'] : (isset($getlocations_defaults[$entity_type . '_map_marker']) ? $getlocations_defaults[$entity_type . '_map_marker'] : $getlocations_defaults['map_marker']));
}
}
}
}
// colorbox
if (module_exists('colorbox')) {
$getlocations_colorbox = getlocations_colorbox_settings();
$form['getlocations_colorbox'] = array(
'#type' => 'fieldset',
'#title' => t('Colorbox settings'),
// This will store all the defaults in one variable.
'#tree' => TRUE,
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['getlocations_colorbox']['enable'] = getlocations_element_map_checkbox(t('Enable Colorbox'), $getlocations_colorbox['enable'], t('Show Getlocations in a Colorbox.'));
$form['getlocations_colorbox']['width'] = getlocations_element_map_tf(t('Colorbox width'), $getlocations_colorbox['width'], '', 5, 10, TRUE);
// need this to get validation to work
$form['getlocations_colorbox']['width']['#parents'] = array(
'getlocations_colorbox',
'width',
);
$form['getlocations_colorbox']['height'] = getlocations_element_map_tf(t('Colorbox height'), $getlocations_colorbox['height'], '', 5, 10, TRUE);
// need this to get validation to work
$form['getlocations_colorbox']['height']['#parents'] = array(
'getlocations_colorbox',
'height',
);
$form['getlocations_colorbox']['marker_enable'] = getlocations_element_map_checkbox(t('Enable Marker picker'), $getlocations_colorbox['marker_enable'], t('Show Markers in a Colorbox.'));
$form['getlocations_colorbox']['marker_width'] = getlocations_element_map_tf(t('Marker Colorbox width'), $getlocations_colorbox['marker_width'], '', 5, 10, TRUE);
// need this to get validation to work
$form['getlocations_colorbox']['marker_width']['#parents'] = array(
'getlocations_colorbox',
'marker_width',
);
$form['getlocations_colorbox']['marker_height'] = getlocations_element_map_tf(t('Marker Colorbox height'), $getlocations_colorbox['marker_height'], '', 5, 10, TRUE);
// need this to get validation to work
$form['getlocations_colorbox']['marker_height']['#parents'] = array(
'getlocations_colorbox',
'marker_height',
);
}
$form['getlocations_ua'] = array(
'#type' => 'fieldset',
'#title' => t('User Agent detection'),
'#description' => t('For advanced users who want to edit the User Agent detection string.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
// This will store all the defaults in one variable.
'#tree' => TRUE,
);
$getlocations_ua = getlocations_ua_get();
$form['getlocations_ua']['ua_string'] = getlocations_element_map_tf(t('User Agent detection'), $getlocations_ua['ua_string'], t('User Agent detection is used to determine wether the browser is on a mobile device. Edit this regular expression with care.'), 60, 255, TRUE);
$getlocations_aggr = getlocations_aggr_get();
$form['getlocations_agg'] = array(
'#type' => 'fieldset',
'#title' => t('Javescript Aggregation'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
// This will store all the defaults in one variable.
'#tree' => FALSE,
);
$form['getlocations_agg']['getlocations_aggr'] = getlocations_element_map_checkbox(t('Allow Getlocations Javascript to be aggregated'), $getlocations_aggr);
$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,
);
$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_extended_path'] = getlocations_element_path(t('Path to InfoBubble extended javascript file'), $getlocations_paths['infobubble_extended_path'], 60, 128, t('Where the InfoBubble extended javascript file is located.'));
$form['getlocations_paths']['infowindow_options_path'] = getlocations_element_path(t('Path to InfoWindow options javascript file'), $getlocations_paths['infowindow_options_path'], 60, 128, t('Where the InfoWindow options javascript file is located. If this file does not exist the default settings will be used.'));
$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['getlocations_paths']['getlocations_polygons_path'] = getlocations_element_path(t('Path to getlocations Polygons javascript file'), $getlocations_paths['getlocations_polygons_path'], 60, 128, t('Where the getlocations polygons javascript file is located.'));
$form['getlocations_paths']['getlocations_rectangles_path'] = getlocations_element_path(t('Path to getlocations Rectangles javascript file'), $getlocations_paths['getlocations_rectangles_path'], 60, 128, t('Where the getlocations rectangles javascript file is located.'));
$form['getlocations_paths']['getlocations_circles_path'] = getlocations_element_path(t('Path to getlocations Circles javascript file'), $getlocations_paths['getlocations_circles_path'], 60, 128, t('Where the getlocations circles javascript file is located.'));
$form['getlocations_paths']['getlocations_polylines_path'] = getlocations_element_path(t('Path to getlocations Polylines javascript file'), $getlocations_paths['getlocations_polylines_path'], 60, 128, t('Where the getlocations polylines javascript file is located.'));
// categories
$form['getlocations_paths']['getlocations_categories_path'] = getlocations_element_path(t('Path to getlocations Categories javascript file'), $getlocations_paths['getlocations_categories_path'], 60, 128, t('Where the getlocations categories javascript file is located.'));
// search_places
$form['getlocations_paths']['getlocations_search_places_path'] = getlocations_element_path(t('Path to getlocations Search Places javascript file'), $getlocations_paths['getlocations_search_places_path'], 60, 128, t('Where the getlocations search places javascript file is located.'));
// geo
$form['getlocations_paths']['getlocations_geo_path'] = getlocations_element_path(t('Path to getlocations Geo javascript file'), $getlocations_paths['getlocations_geo_path'], 60, 128, t('Where the getlocations geo javascript file is located.'));
// preview
$form['getlocations_paths']['getlocations_preview_path'] = getlocations_element_path(t('Path to getlocations Preview javascript file'), $getlocations_paths['getlocations_preview_path'], 60, 128, t('Where the getlocations preview javascript file is located.'));
// geojson
$form['getlocations_paths']['getlocations_geojson_path'] = getlocations_element_path(t('Path to getlocations Geojson javascript file'), $getlocations_paths['getlocations_geojson_path'], 60, 128, t('Where the getlocations geojson javascript file is located.'));
// admin
$form['getlocations_paths']['getlocations_admin_path'] = getlocations_element_path(t('Path to getlocations Admin javascript file'), $getlocations_paths['getlocations_admin_path'], 60, 128, t('Where the getlocations admin javascript file is located.'));
// box
$form['getlocations_paths']['getlocations_box_path'] = getlocations_element_path(t('Path to getlocations Box javascript file'), $getlocations_paths['getlocations_box_path'], 60, 128, t('Where the getlocations box javascript file is located.'));
// colorbox
$form['getlocations_paths']['getlocations_colorbox_path'] = getlocations_element_path(t('Path to getlocations Colorbox javascript file'), $getlocations_paths['getlocations_colorbox_path'], 60, 128, t('Where the getlocations colorbox javascript file is located.'));
// marker_box
$form['getlocations_paths']['getlocations_marker_box_path'] = getlocations_element_path(t('Path to getlocations Markerbox javascript file'), $getlocations_paths['getlocations_marker_box_path'], 60, 128, t('Where the getlocations markerbox javascript file is located.'));
// views
$form['getlocations_paths']['getlocations_views_path'] = getlocations_element_path(t('Path to getlocations Views javascript file'), $getlocations_paths['getlocations_views_path'], 60, 128, t('Where the getlocations views javascript file is located.'));
// icons
$form['getlocations_paths']['getlocations_icons_path'] = getlocations_element_path(t('Path to getlocations Icons javascript file'), $getlocations_paths['getlocations_icons_path'], 60, 128, t('Where the getlocations icons javascript file is located.'));
// what3words
$form['getlocations_paths']['getlocations_what3words_path'] = getlocations_element_path(t('Path to getlocations What3Words javascript file'), $getlocations_paths['getlocations_what3words_path'], 60, 128, t('Where the getlocations what3words javascript file is located.'));
$form['getlocations_paths']['getlocations_path'] = getlocations_element_path(t('Path to getlocations javascript file'), $getlocations_paths['getlocations_path'], 60, 128, t('Where the getlocations javascript file is located.'));
$form['getlocations_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_settings_form';
$form['#validate'][] = 'getlocations_settings_validate';
return system_settings_form($form);
}