From 2d889a3cc9b92fdb1c000236e8953f9d16fe8840 Mon Sep 17 00:00:00 2001 From: brettp Date: Fri, 12 Feb 2010 15:42:59 +0000 Subject: Fixes #1510: Added elgg_get_file_list(). get_library_files() wraps to this function with a deprecation notice for any plugin authors using it to auto-load files. git-svn-id: http://code.elgg.org/elgg/trunk@3935 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'engine') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 91334821d..0da106b8a 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -1278,6 +1278,43 @@ function friendly_title($title) { * Library loading and handling */ +/** + * @deprecated 1.7 + */ +function get_library_files($directory, $exceptions = array(), $list = array()) { + elgg_deprecated_notice('get_library_files() deprecated by elgg_get_file_list()', 1.7); + return elgg_get_file_list($directory, $exceptions, $list, array('.php')); +} + +/** + * Returns a list of files in $directory + * + * @param str $directory + * @param array $exceptions Array of filenames to ignore + * @param array $list Array of files to append to + * @param mixed $extensions Array of extensions to allow, NULL for all. (With a dot: array('.php')) + * @return array + */ +function elgg_get_file_list($directory, $exceptions = array(), $list = array(), $extensions = NULL) { + if ($handle = opendir($directory)) { + while (($file = readdir($handle)) !== FALSE) { + if (!is_file($file) || in_array($file, $exceptions)) { + continue; + } + + if (is_array($extensions)) { + if (in_array(strrchr($file, '.'), $extensions)) { + $list[] = $directory . "/" . $file; + } + } else { + $list[] = $directory . "/" . $file; + } + } + } + + return $list; +} + /** * Ensures that the installation has all the correct files, that PHP is configured correctly, and so on. * Leaves appropriate messages in the error register if not. -- cgit v1.2.3