function getlocations_settings_validate in Get Locations 7
Same name and namespace in other branches
- 6.2 getlocations.admin.inc \getlocations_settings_validate()
- 6 getlocations.admin.inc \getlocations_settings_validate()
- 7.2 getlocations.admin.inc \getlocations_settings_validate()
1 string reference to 'getlocations_settings_validate'
- getlocations_settings_form in ./
getlocations.admin.inc - Function to display the getlocations admin settings form
File
- ./
getlocations.admin.inc, line 813 - getlocations.admin.inc @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function getlocations_settings_validate($form, &$form_state) {
if ($latlon = getlocations_latlon_check($form_state['values']['getlocations_default']['latlong'])) {
$form_state['values']['getlocations_default']['latlong'] = $latlon;
}
else {
form_set_error('getlocations_default][latlong', t('Map coordinates must be expressed as a decimal latitude and longitude, separated by a comma.'));
}
$found = FALSE;
foreach ($form_state['values']['getlocations_default']['baselayers'] as $l) {
if ($l) {
$found = TRUE;
break;
}
}
if (!$found) {
form_set_error('getlocations_default][baselayers', t('You must select at least one baselayer!'));
}
if (isset($form_state['values']['getlocations_default']['returnlink_page_enable']) && $form_state['values']['getlocations_default']['returnlink_page_enable'] && empty($form_state['values']['getlocations_default']['returnlink_page_link'])) {
form_set_error('getlocations_default][returnlink_page_link', t('Page return link must be filled in'));
}
if (module_exists('getlocations_fields')) {
if (isset($form_state['values']['getlocations_default']['returnlink_user_enable']) && $form_state['values']['getlocations_default']['returnlink_user_enable'] && empty($form_state['values']['getlocations_default']['returnlink_user_link'])) {
form_set_error('getlocations_default][returnlink_user_link', t('User return link must be filled in'));
}
if (isset($form_state['values']['getlocations_default']['returnlink_term_enable']) && $form_state['values']['getlocations_default']['returnlink_term_enable'] && empty($form_state['values']['getlocations_default']['returnlink_term_link'])) {
form_set_error('getlocations_default][returnlink_term_link', t('Term return link must be filled in'));
}
if (isset($form_state['values']['getlocations_default']['returnlink_comment_enable']) && $form_state['values']['getlocations_default']['returnlink_comment_enable'] && empty($form_state['values']['getlocations_default']['returnlink_comment_link'])) {
form_set_error('getlocations_default][returnlink_comment_link', t('Comment return link must be filled in'));
}
}
if (!$form_state['values']['getlocations_default']['markermanagertype']) {
$form_state['values']['getlocations_default']['usemarkermanager'] = 0;
$form_state['values']['getlocations_default']['useclustermanager'] = 0;
}
elseif ($form_state['values']['getlocations_default']['markermanagertype'] == 1) {
$form_state['values']['getlocations_default']['useclustermanager'] = 0;
}
elseif ($form_state['values']['getlocations_default']['markermanagertype'] == 2) {
$form_state['values']['getlocations_default']['usemarkermanager'] = 0;
}
if (!is_numeric($form_state['values']['getlocations_default']['getlocations_js_weight'])) {
form_set_error('getlocations_default][getlocations_js_weight', t('Getlocations js weight must be a number'));
}
if (module_exists('colorbox') && isset($form_state['values']['getlocations_colorbox']['enable']) && $form_state['values']['getlocations_colorbox']['enable']) {
if (empty($form_state['values']['getlocations_colorbox']['width']) || !is_numeric($form_state['values']['getlocations_colorbox']['width']) || $form_state['values']['getlocations_colorbox']['width'] < 1) {
form_set_error('getlocations_colorbox][width', t('Colorbox width must be a number'));
}
if (empty($form_state['values']['getlocations_colorbox']['height']) || !is_numeric($form_state['values']['getlocations_colorbox']['height']) || $form_state['values']['getlocations_colorbox']['height'] < 1) {
form_set_error('getlocations_colorbox][height', t('Colorbox height must be a number'));
}
}
if (module_exists('colorbox') && isset($form_state['values']['getlocations_colorbox']['marker_enable']) && $form_state['values']['getlocations_colorbox']['marker_enable']) {
if (empty($form_state['values']['getlocations_colorbox']['marker_width']) || !is_numeric($form_state['values']['getlocations_colorbox']['marker_width']) || $form_state['values']['getlocations_colorbox']['marker_width'] < 1) {
form_set_error('getlocations_colorbox][marker_width', t('Colorbox width must be a number'));
}
if (empty($form_state['values']['getlocations_colorbox']['marker_height']) || !is_numeric($form_state['values']['getlocations_colorbox']['marker_height']) || $form_state['values']['getlocations_colorbox']['marker_height'] < 1) {
form_set_error('getlocations_colorbox][marker_height', t('Colorbox height must be a number'));
}
}
$list = array(
'Map',
'Satellite',
'Hybrid',
'Physical',
'OpenStreetMap',
);
$found = FALSE;
foreach ($list as $maptype) {
if ($form_state['values']['getlocations_default']['maptype'] == $maptype && $form_state['values']['getlocations_default']['baselayers'][$maptype]) {
$found = TRUE;
break;
}
}
if (!$found) {
// force a setting
$form_state['values']['getlocations_default']['maptype'] = 'Map';
$form_state['values']['getlocations_default']['baselayers']['Map'] = 1;
}
// markers
if (isset($form_state['values']['getlocations_node_marker']) && !$form_state['values']['getlocations_node_marker']['enable']) {
unset($form_state['values']['getlocations_node_marker']);
$form_state['values']['getlocations_node_marker']['enable'] = 0;
}
if (isset($form_state['values']['getlocations_vocabulary_marker']) && !$form_state['values']['getlocations_vocabulary_marker']['enable']) {
unset($form_state['values']['getlocations_vocabulary_marker']);
$form_state['values']['getlocations_vocabulary_marker']['enable'] = 0;
}
if (isset($form_state['values']['getlocations_term_marker']) && !$form_state['values']['getlocations_term_marker']['enable']) {
unset($form_state['values']['getlocations_term_marker']);
$form_state['values']['getlocations_term_marker']['enable'] = 0;
$form_state['values']['getlocations_term_marker']['vids'] = 0;
$form_state['values']['getlocations_term_marker']['max_depth'] = '';
}
// search_places
if ($form_state['values']['getlocations_default']['search_places']) {
$form_state['values']['getlocations_default']['places'] = 1;
}
// css check
if (isset($form_state['values']['getlocations_default']['width'])) {
if ($check = getlocations_dim_check($form_state['values']['getlocations_default']['width'])) {
$form_state['values']['getlocations_default']['width'] = $check;
}
else {
form_set_error('getlocations_default][width', t('Width must be valid css'));
}
}
if (isset($form_state['values']['getlocations_default']['height'])) {
if ($check = getlocations_dim_check($form_state['values']['getlocations_default']['height'])) {
$form_state['values']['getlocations_default']['height'] = $check;
}
else {
form_set_error('getlocations_default][height', t('Height must be valid css'));
}
}
$reset = $form_state['values']['getlocations_paths']['reset'];
unset($form_state['values']['getlocations_paths']['reset']);
if ($reset == 1) {
$form_state['values']['getlocations_paths'] = getlocations_paths_get(TRUE);
}
elseif ($reset == 2) {
$form_state['values']['getlocations_paths'] = getlocations_paths_get(FALSE, TRUE);
}
}