You are here

function geshifilter_admin_settings_form_validate in GeSHi Filter for syntax highlighting 5

File

./geshifilter.module, line 251

Code

function geshifilter_admin_settings_form_validate($form_id, $form_values) {

  // Check if geshi directory exists.
  if (!is_dir($form_values['geshifilter_geshi_dir'])) {
    form_set_error('geshifilter_geshi_dir', t('The directory "%geshi-directory" does not exist.', array(
      '%geshi-directory' => $form_values['geshifilter_geshi_dir'],
    )));
  }

  // Check if geshi.php exists
  if (!is_file($form_values['geshifilter_geshi_dir'] . '/geshi.php')) {
    form_set_error('geshifilter_geshi_dir', t('Unable to find the GeSHi library (geshi.php) in %geshi-directory.', array(
      '%geshi-directory' => $form_values['geshifilter_geshi_dir'],
    )));
  }

  // Check if languages directory exists.
  if (!is_dir($form_values['geshifilter_lang_dir'])) {
    form_set_error('geshifilter_lang_dir', t('The GeSHi languages directory %directory does not exist.', array(
      '%directory' => $form_values['geshifilter_lang_dir'],
    )));
  }

  // Check if there are some language files in the directory
  $files = file_scan_directory($form_values['geshifilter_lang_dir'], '\\.php$', array(
    '.',
    '..',
    'CVS',
    'geshi.php',
  ), 0, FALSE, 'name');
  if (count($files) == 0) {
    drupal_set_message(t('No language pattern files found. Are you sure to have correctly installed the GeShi package?'));
  }
}