diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-02-12 15:42:59 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-02-12 15:42:59 +0000 |
commit | 2d889a3cc9b92fdb1c000236e8953f9d16fe8840 (patch) | |
tree | 6c2d8e6003236df75a1e62b1ad9ee9b466848d4c /engine/lib | |
parent | a2c37d05458bc25168bbfc892604208ffc17384b (diff) | |
download | elgg-2d889a3cc9b92fdb1c000236e8953f9d16fe8840.tar.gz elgg-2d889a3cc9b92fdb1c000236e8953f9d16fe8840.tar.bz2 |
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
Diffstat (limited to 'engine/lib')
-rw-r--r-- | engine/lib/elgglib.php | 37 |
1 files changed, 37 insertions, 0 deletions
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 @@ -1279,6 +1279,43 @@ function friendly_title($title) { */ /** + * @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. * |