From 7cc6e815d9d79f2c599bc4c0d0ae2369f7e2f902 Mon Sep 17 00:00:00 2001 From: gwoo Date: Tue, 7 Aug 2007 21:41:38 +0000 Subject: [PATCH] fix __list in Configure class git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5500 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/configure.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/cake/libs/configure.php b/cake/libs/configure.php index ec8905b1f..f035a18d7 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -144,24 +144,25 @@ class Configure extends Object { * Returns an array of filenames of PHP files in given directory. * * @param string $path Path to scan for files - * @return array List of files in directory + * @param string $suffix if false, return only directories. if string, match and return files + * @return array List of directories or files in directory */ - function __list($path, $suffix = null) { - $dir = opendir($path); - $items = array(); - - while (false !== ($item = readdir($dir))) { - if (substr($item, 0, 1) != '.') { - if (empty($suffix) || (!empty($suffix) && substr($item, -strlen($suffix)) == $suffix)) { - if (!empty($suffix)) { + function __list($path, $suffix = false) { + $Folder =& new Folder($path); + $contents = $Folder->read(false, true); + if(is_array($contents)) { + if(!$suffix) { + return $contents[0]; + } else { + foreach($content[1] as $item) { + if (substr($item, -strlen($suffix)) == $suffix) { $item = substr($item, 0, strlen($item) - strlen($suffix)); + $items[] = $item; } - $items[] = $item; } + return $items; } } - closedir($dir); - return $items; } /** * Used to write a dynamic var in the Configure instance.