You are here

function search_files_helpers_validate_add_edit in Search Files 5

Same name and namespace in other branches
  1. 6.2 search_files.module \search_files_helpers_validate_add_edit()
  2. 7.2 search_files.module \search_files_helpers_validate_add_edit()

validate the existence of the helper app supplied by the helper_add or helper_edit form

Parameters

unknown_type $field:

File

./search_files.module, line 555
Used to index all files in directory(s) on the server

Code

function search_files_helpers_validate_add_edit($field) {
  if (!preg_match('/%file%/', $field['#value'])) {
    form_set_error($field['#title'], t('"%field" must contain the token %file%', array(
      '%field' => $field['#title'],
    )));
  }

  // Check to see if helper app can be found
  $helper_file = preg_replace('/\\s.+$/', '', $field['#value']);
  if (!file_exists($helper_file)) {
    form_set_error($field['#title'], t("Can't find helper app %helper -- please verify it is installed.", array(
      '%helper' => $helper_file,
    )));
  }
}