You are here

function getlocations_search_settings_validate in Get Locations 7

Same name and namespace in other branches
  1. 7.2 modules/getlocations_search/getlocations_search.admin.inc \getlocations_search_settings_validate()
1 string reference to 'getlocations_search_settings_validate'
getlocations_search_settings_form in modules/getlocations_search/getlocations_search.admin.inc
Function to display the getlocations_search admin settings form

File

modules/getlocations_search/getlocations_search.admin.inc, line 441
getlocations_search.admin.inc @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function getlocations_search_settings_validate($form, &$form_state) {

  // jquery_colorpicker munge
  if (isset($form_state['values']['getlocations_search_defaults'])) {
    if (!preg_match("/^#/", $form_state['values']['getlocations_search_defaults']['search_radshape_strokecolor'])) {
      $form_state['values']['getlocations_search_defaults']['search_radshape_strokecolor'] = '#' . $form_state['values']['getlocations_search_defaults']['search_radshape_strokecolor'];
    }
    if (!preg_match("/^#/", $form_state['values']['getlocations_search_defaults']['search_radshape_fillcolor'])) {
      $form_state['values']['getlocations_search_defaults']['search_radshape_fillcolor'] = '#' . $form_state['values']['getlocations_search_defaults']['search_radshape_fillcolor'];
    }
    if ($latlon = getlocations_latlon_check($form_state['values']['getlocations_search_defaults']['latlong'])) {
      $form_state['values']['getlocations_search_defaults']['latlong'] = $latlon;
    }
    else {
      form_set_error('getlocations_search_defaults][latlong', t('Map coordinates must be expressed as a decimal latitude and longitude, separated by a comma.'));
    }

    // css check
    if (isset($form_state['values']['getlocations_search_defaults']['width'])) {
      if ($check = getlocations_dim_check($form_state['values']['getlocations_search_defaults']['width'])) {
        $form_state['values']['getlocations_search_defaults']['width'] = $check;
      }
      else {
        form_set_error('getlocations_search_defaults][width', t('Width must be valid css'));
      }
    }
    if (isset($form_state['values']['getlocations_search_defaults']['height'])) {
      if ($check = getlocations_dim_check($form_state['values']['getlocations_search_defaults']['height'])) {
        $form_state['values']['getlocations_search_defaults']['height'] = $check;
      }
      else {
        form_set_error('getlocations_search_defaults][height', t('Height must be valid css'));
      }
    }
  }
  elseif (isset($form_state['values']['getlocations_search_block_defaults'])) {
    if (!preg_match("/^#/", $form_state['values']['getlocations_search_block_defaults']['search_radshape_strokecolor'])) {
      $form_state['values']['getlocations_search_block_defaults']['search_radshape_strokecolor'] = '#' . $form_state['values']['getlocations_search_block_defaults']['search_radshape_strokecolor'];
    }
    if (!preg_match("/^#/", $form_state['values']['getlocations_search_block_defaults']['search_radshape_fillcolor'])) {
      $form_state['values']['getlocations_search_block_defaults']['search_radshape_fillcolor'] = '#' . $form_state['values']['getlocations_search_block_defaults']['search_radshape_fillcolor'];
    }
    if ($latlon = getlocations_latlon_check($form_state['values']['getlocations_search_block_defaults']['latlong'])) {
      $form_state['values']['getlocations_search_block_defaults']['latlong'] = $latlon;
    }
    else {
      form_set_error('getlocations_search_block_defaults][latlong', t('Map coordinates must be expressed as a decimal latitude and longitude, separated by a comma.'));
    }

    // css check
    if (isset($form_state['values']['getlocations_search_block_defaults']['width'])) {
      if ($check = getlocations_dim_check($form_state['values']['getlocations_search_block_defaults']['width'])) {
        $form_state['values']['getlocations_search_block_defaults']['width'] = $check;
      }
      else {
        form_set_error('getlocations_search_block_defaults][width', t('Width must be valid css'));
      }
    }
    if (isset($form_state['values']['getlocations_search_block_defaults']['height'])) {
      if ($check = getlocations_dim_check($form_state['values']['getlocations_search_block_defaults']['height'])) {
        $form_state['values']['getlocations_search_block_defaults']['height'] = $check;
      }
      else {
        form_set_error('getlocations_search_block_defaults][height', t('Height must be valid css'));
      }
    }
  }
  $reset = $form_state['values']['getlocations_search_paths']['reset'];
  unset($form_state['values']['getlocations_search_paths']['reset']);
  if ($reset == 1) {
    $form_state['values']['getlocations_search_paths'] = getlocations_search_paths_get(TRUE);
  }
  elseif ($reset == 2) {
    $form_state['values']['getlocations_search_paths'] = getlocations_search_paths_get(FALSE, TRUE);
  }
}