/** * Read Directory Nested * * @param string $path Path directory to be scan * @param integer $directory_depth directory depth of nested to be scanned * @param boolean $hidden true if want to show hidden content * @return array path trees */ public static function readDirList($path, $directory_depth = 0, $hidden = false) { $filedata = false; if (static::isDir($path) && ($fp = opendir($path))) { $new_depth = $directory_depth - 1; $path = Path::cleanPath($path) . '/'; while (false !== ($file = readdir($fp))) { // Remove '.', '..', and hidden files [optional] if ($file === '.' || $file === '..' || $hidden === false && $file[0] === '.') { continue; } static::isDir($path . $file) && ($path .= '/'); if (($directory_depth < 1 || $new_depth > 0) && static::isDir($path . $file)) { $filedata[$file] = static::readDirList($path . $file, $new_depth, $hidden); } else { $filedata[] = $file; } } // close resource closedir($fp); } return $filedata; }
public function getActiveTemplatePathFileFor($file) { if (is_string($file)) { $template_dir = $this->getActiveTemplateDirectory(); $file = Path::cleanPath($file); $file = trim(preg_replace('/^' . preg_quote($template_dir, '/') . '/', '', $file), '/'); if (is_file("{$template_dir}/{$file}")) { return "{$template_dir}/{$file}"; } } }