You are here

function jqmulti_find_all_js_files in jQuery Multi 7

Same name and namespace in other branches
  1. 6 jqmulti.module \jqmulti_find_all_js_files()

Recursive function that returns a list of all JS files in a directory.

Parameters

$dir the full path to the directory:

1 call to jqmulti_find_all_js_files()
jqmulti_get_library_files in ./jqmulti.module
Returns a list of files for a given library. This is not a part of Libraries API for D6.

File

./jqmulti.module, line 197
Code for the jQuery Multi module.

Code

function jqmulti_find_all_js_files($dir) {
  $result = array();
  $root = scandir($dir);
  foreach ($root as $value) {
    if ($value === '.' || $value === '..') {
      continue;
    }
    $path = "{$dir}/{$value}";
    if (is_file($path)) {
      if (preg_match('/.js$/', $value)) {
        $result[] = $path;
      }
      continue;
    }
    foreach (jqmulti_find_all_js_files($path) as $value) {
      $result[] = $value;
    }
  }
  return $result;
}