You are here

function clientside_validation_match_form in Clientside Validation 7.2

1 call to clientside_validation_match_form()
clientside_validation_form_alter in ./clientside_validation.module
Implements hook_form_alter().

File

./clientside_validation.module, line 293
Add client side validation to forms.

Code

function clientside_validation_match_form($form_id) {
  $page_match = TRUE;
  $path_filter = variable_get('clientside_validation_path_list', '');
  $in_or_exclude = variable_get('clientside_validation_filter_paths', CLIENTSIDE_VALIDATION_EXCLUDE_PATHS);
  if (!empty($path_filter)) {
    $current_path = current_path();
    $path = drupal_get_path_alias($current_path);

    // Compare with the internal and path alias (if any).
    $page_match = drupal_match_path($path, $path_filter);
    if ($path != $current_path) {
      $page_match = $page_match || drupal_match_path($current_path, $path_filter);
    }

    // When $in_or_exclude has a value of 0 (CLIENTSIDE_VALIDATION_EXCLUDE_PATHS),
    // Clientside Validation is added on all pages except those listed in $path_filter.
    // When set to 1 (CLIENTSIDE_VALIDATION_INCLUDE_PATHS), it is displayed only on
    // those pages listed in $path_filter.
    $page_match = !((bool) $in_or_exclude xor $page_match);
  }
  if (!$page_match) {
    return FALSE;
  }
  $validate_specific_setting = variable_get('clientside_validation_validate_specific', '');
  $validate_specific = preg_split('/(\\r\\n?|\\n)/', $validate_specific_setting, -1, PREG_SPLIT_NO_EMPTY);
  if (variable_get('clientside_validation_validate_all', CLIENTSIDE_VALIDATION_VALIDATE_ALL) == CLIENTSIDE_VALIDATION_VALIDATE_SPECIFIC && !in_array($form_id, $validate_specific)) {
    return FALSE;
  }
  elseif (variable_get('clientside_validation_validate_all', CLIENTSIDE_VALIDATION_VALIDATE_ALL) == CLIENTSIDE_VALIDATION_VALIDATE_ALL_EXCEPT && in_array($form_id, $validate_specific)) {
    return FALSE;
  }
  return TRUE;
}