fix __list in Configure class

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5500 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2007-08-07 21:41:38 +00:00
parent 28ebd0bf66
commit 7cc6e815d9

View file

@ -144,25 +144,26 @@ class Configure extends Object {
* Returns an array of filenames of PHP files in given directory. * Returns an array of filenames of PHP files in given directory.
* *
* @param string $path Path to scan for files * @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) { function __list($path, $suffix = false) {
$dir = opendir($path); $Folder =& new Folder($path);
$items = array(); $contents = $Folder->read(false, true);
if(is_array($contents)) {
while (false !== ($item = readdir($dir))) { if(!$suffix) {
if (substr($item, 0, 1) != '.') { return $contents[0];
if (empty($suffix) || (!empty($suffix) && substr($item, -strlen($suffix)) == $suffix)) { } else {
if (!empty($suffix)) { foreach($content[1] as $item) {
if (substr($item, -strlen($suffix)) == $suffix) {
$item = substr($item, 0, strlen($item) - strlen($suffix)); $item = substr($item, 0, strlen($item) - strlen($suffix));
}
$items[] = $item; $items[] = $item;
} }
} }
}
closedir($dir);
return $items; return $items;
} }
}
}
/** /**
* Used to write a dynamic var in the Configure instance. * Used to write a dynamic var in the Configure instance.
* *