You are here

function audiofield_admin_settings_form_validate in AudioField 7

Implements hook_validate().

File

./audiofield.admin.inc, line 81
Administrative pages for the Audiofield module.

Code

function audiofield_admin_settings_form_validate($form, &$form_state) {
  if (!empty($form_state['values']['audiofield_detail']['ffprobe_path'])) {
    if (!in_array(substr($form_state['values']['audiofield_detail']['ffprobe_path'], -1), array(
      '/',
      '\\',
    ))) {
      if (preg_match("@^(.*)(/|\\\\)(ffprobe|ffprobe.exe|ffmpeg|ffmpeg.exe)\$@", $form_state['values']['audiofield_detail']['ffprobe_path'], $preg)) {
        $form_state['values']['audiofield_detail']['ffprobe_path'] = $preg[1];
      }
      $form_state['values']['audiofield_detail']['ffprobe_path'] .= '/';
    }
    if (!audiofield_accessible_ffprobe($form_state['values']['audiofield_detail']['ffprobe_path'])) {
      form_set_error('ffprobe_path', t('Path for ffmpeg/ffprobe is not accessible.'));
      $form_state['values']['audiofield_detail']['ffprobe_path'] = '';
    }
  }
}