You are here

function gmap_admin_settings_validate in GMap Module 7

Same name and namespace in other branches
  1. 5 gmap_settings_ui.inc \gmap_admin_settings_validate()
  2. 6.2 gmap_settings_ui.inc \gmap_admin_settings_validate()
  3. 6 gmap_settings_ui.inc \gmap_admin_settings_validate()
  4. 7.2 gmap_settings_ui.inc \gmap_admin_settings_validate()
1 string reference to 'gmap_admin_settings_validate'
gmap_admin_settings in ./gmap_settings_ui.inc
@file GMap settings form.

File

./gmap_settings_ui.inc, line 636
GMap settings form.

Code

function gmap_admin_settings_validate($form, &$form_state) {
  $found = FALSE;
  foreach ($form_state['values']['gmap_default']['baselayers'] as $l) {
    if ($l) {
      $found = TRUE;
      break;
    }
  }
  if (!$found) {
    form_set_error('gmap_default][baselayers', t('You must select at least one baselayer!'));
  }

  // Check that the default map type is sane.
  if (!$form_state['values']['gmap_default']['baselayers'][$form_state['values']['gmap_default']['maptype']]) {
    form_error($form['gmap_default']['baselayers']['maptype'], t('The default map type must be an enabled baselayer!'));
  }

  // Check that this is valid JSON, or an empty string.
  if ('' != $form_state['values']['gmap_markermanager']['markerclusterer']['styles'] && !is_array(json_decode($form_state['values']['gmap_markermanager']['markerclusterer']['styles']))) {
    form_error($form['gmap_markermanager']['markerclusterer']['styles'], t('The MarkerClusterer styles setting should be empty or a JSON array of !doc_link objects.', array(
      '!doc_link' => l('MarkerStyleOptions', 'http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/docs/reference.html#MarkerClustererOptions', array(
        'attributes' => array(
          'target' => '_blank',
        ),
      )),
    )));
  }
}