You are here

function module_builder_get_doc_files in Module Builder 6.2

Same name and namespace in other branches
  1. 5 module_builder.module \module_builder_get_doc_files()
  2. 7 includes/process.inc \module_builder_get_doc_files()

Retrieve list of documentation files containing hook definitions.

Return value

array Array of files

1 call to module_builder_get_doc_files()
module_builder_admin_update in includes/module_builder.admin.inc
Admin hook update form.

File

includes/process.inc, line 205
Module builder code processing code.

Code

function module_builder_get_doc_files() {
  $dir = _module_builder_get_hooks_directory();
  if (!$dir) {
    drupal_set_message(t('Please configure the hook documentation path in <a href="!settings">module builder settings</a>.', array(
      '!settings' => url('admin/settings/module_builder'),
    )), 'error');
    return NULL;
  }
  $files = array();
  if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
      while (($file = readdir($dh)) !== FALSE) {

        // Ignore files that don't make sense to include
        // TODO: replace all the .foo with one of the arcane PHP string checking functions
        if (!in_array($file, array(
          '.',
          '..',
          '.DS_Store',
          'CVS',
          'hooks_processed.php',
        ))) {
          $files[] = $file;
        }
      }
      closedir($dh);
    }
    else {
      drupal_set_message(t('There was an error opening the hook documentation path. Please try again.'), 'error');
      return NULL;
    }
  }
  else {
    drupal_set_message(t('Hook documentation path is invalid. Please return to the <a href="!settings">module builder settings</a> page to try again.', array(
      '!settings' => url('admin/settings/module_builder'),
    )), 'error');
    return NULL;
  }
  return $files;
}