From 269b942a2bf7b022795e591d9b0ad04526ee7e09 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Mon, 28 Jan 2008 21:00:20 +0000 Subject: added ability to "extend" helpers * modified Loader to check for prefixed helpers in application/helpers folder * surrounded provided helper functions with if (! function_exists('foo')) conditionals so the user's helper functions take precedent. --- system/helpers/directory_helper.php | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'system/helpers/directory_helper.php') diff --git a/system/helpers/directory_helper.php b/system/helpers/directory_helper.php index 4a499de5c..5a23944cb 100644 --- a/system/helpers/directory_helper.php +++ b/system/helpers/directory_helper.php @@ -39,29 +39,31 @@ * @param bool whether to limit the result to the top level only * @return array */ -function directory_map($source_dir, $top_level_only = FALSE) -{ - if ($fp = @opendir($source_dir)) - { - $filedata = array(); - while (FALSE !== ($file = readdir($fp))) +if (! function_exists('directory_map')) +{ + function directory_map($source_dir, $top_level_only = FALSE) + { + if ($fp = @opendir($source_dir)) { - if (@is_dir($source_dir.$file) && substr($file, 0, 1) != '.' AND $top_level_only == FALSE) + $filedata = array(); + while (FALSE !== ($file = readdir($fp))) { - $temp_array = array(); + if (@is_dir($source_dir.$file) && substr($file, 0, 1) != '.' AND $top_level_only == FALSE) + { + $temp_array = array(); - $temp_array = directory_map($source_dir.$file."/"); + $temp_array = directory_map($source_dir.$file."/"); - $filedata[$file] = $temp_array; - } - elseif (substr($file, 0, 1) != ".") - { - $filedata[] = $file; + $filedata[$file] = $temp_array; + } + elseif (substr($file, 0, 1) != ".") + { + $filedata[] = $file; + } } + return $filedata; } - return $filedata; } } - ?> \ No newline at end of file -- cgit v1.2.3-24-g4f1b