You are here

function elfinder_get_libraries in elFinder file manager 7

Same name and namespace in other branches
  1. 6.2 elfinder.module \elfinder_get_libraries()
  2. 6 elfinder.module \elfinder_get_libraries()
  3. 7.3 elfinder.module \elfinder_get_libraries()
  4. 7.2 elfinder.module \elfinder_get_libraries()
1 call to elfinder_get_libraries()
elfinder_lib_path in ./elfinder.module
library files path

File

./elfinder.module, line 546

Code

function elfinder_get_libraries() {
  $directory = 'libraries';
  $searchdir = array();
  $profile = drupal_get_profile();
  $config = conf_path();

  // Similar to 'modules' and 'themes' directories in the root directory,
  // certain distributions may want to place libraries into a 'libraries'
  // directory in Drupal's root directory.
  $searchdir[] = $directory;

  // The 'profiles' directory contains pristine collections of modules and
  // themes as organized by a distribution.  It is pristine in the same way
  // that /modules is pristine for core; users should avoid changing anything
  // there in favor of sites/all or sites/<domain> directories.
  if (file_exists("profiles/{$profile}/{$directory}")) {
    $searchdir[] = "profiles/{$profile}/{$directory}";
  }

  // Always search sites/all/*.
  $searchdir[] = 'sites/all/' . $directory;

  // Also search sites/<domain>/*.
  if (file_exists("{$config}/{$directory}")) {
    $searchdir[] = "{$config}/{$directory}";
  }

  // Retrieve list of directories.
  // @todo Core: Allow to scan for directories.
  $directories = array();
  $nomask = array(
    'CVS',
  );
  foreach ($searchdir as $dir) {
    if (is_dir($dir) && ($handle = opendir($dir))) {
      while (FALSE !== ($file = readdir($handle))) {
        if (!in_array($file, $nomask) && $file[0] != '.') {
          if (is_dir("{$dir}/{$file}")) {
            $directories[$file] = "{$dir}/{$file}";
          }
        }
      }
      closedir($handle);
    }
  }
  return $directories;
}