You are here

function jqp_scan_dir in jQuery Plugin Handler (JQP) 6.2

Same name and namespace in other branches
  1. 6 jqp.module \jqp_scan_dir()

Scan the 'js_libraries', 'modules' and 'themes' directories for .js and .css files

Return value

an array where key is file name and value is file path

Example: array('sites/all/modules/cck/content.js' => (object)array( 'filename' => 'sites/all/modules/cck/content.js', 'basename' => 'content.js', 'name' => 'content', );

LIKE MODULES, javascript libraries should have unique file names

See also

_jqp_autocomplete()

1 call to jqp_scan_dir()
_jqp_autocomplete in ./jqp.admin.inc
AJAX response function for #autocomplete form elements.

File

./jqp.module, line 281
Used to register and load javascript libraries and plugins from a cetral point

Code

function jqp_scan_dir() {
  static $files;
  if (!isset($files)) {
    if ($cache = cache_get('jqp')) {
      $files = $cache->data;
    }
    else {
      $profile = variable_get('install_profile', 'default');
      $config = conf_path();
      $file_dir = file_directory_path();
      $files = array();
      foreach (array(
        'modules',
        'js_libraries',
        'themes',
      ) as $directory) {
        $searchdir[] = "{$directory}";
        $searchdir[] = "sites/all/{$directory}";
        $searchdir[] = "profiles/{$profile}/{$directory}";
        $searchdir[] = "{$config}/{$directory}";
        $searchdir[] = "{$file_dir}/{$directory}";
      }
      foreach ($searchdir as $dir) {
        if (file_exists($dir)) {
          $files = array_merge($files, file_scan_directory($dir, '(\\.js$|\\.css$)', array(
            '.',
            '..',
            'CVS',
          ), 0, TRUE, 'filename', 0));
        }
      }
      cache_set('jqp', $files);
    }
  }
  return $files;
}