You are here

function _zenophile_populate_files in Zenophile 7

Same name and namespace in other branches
  1. 6.2 zenophile.module \_zenophile_populate_files()

Recursively create a list of files in a directory.

Parameters

$dir: Directory to add files from

$cur_path: Path to start from

Return value

An array of file names.

2 calls to _zenophile_populate_files()
zenophile_create_submit in ./zenophile.module
Submit function for zenophile_create().
zenophile_midnight_zenophile_alter in zenophile_midnight/zenophile_midnight.module
Implements hook_zenophile_alter() (a Zenophile hook).

File

./zenophile.module, line 419
Creates Zen subthemes quickly and easily.

Code

function _zenophile_populate_files($dir, $cur_path) {
  $files = array();
  if ($cur_path !== '') {
    $cur_path .= '/';
  }
  $h = opendir("{$dir}/{$cur_path}");
  while (($file = readdir($h)) !== FALSE) {
    if ($file !== 'CVS' && $file !== 'images-source' && $file[0] !== '.') {

      // Don't copy CVS directories, hidden files, or the images-source
      // directory - perhaps the latter should be a user-controllable option.
      if (is_dir("{$dir}/{$cur_path}{$file}")) {
        $files["{$cur_path}{$file}"] = 'dir';
        $files = array_merge($files, _zenophile_populate_files($dir, "{$cur_path}{$file}"));
      }
      else {
        $files["{$cur_path}{$file}"] = 'file';
      }
    }
  }
  return $files;
}