]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #1510: Added elgg_get_file_list(). get_library_files() wraps to this function...
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 12 Feb 2010 15:42:59 +0000 (15:42 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 12 Feb 2010 15:42:59 +0000 (15:42 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@3935 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/elgglib.php

index 91334821da2360242aa3ed17d6139cbddc18119c..0da106b8a2e26e96ef73330d0dc22c1ef1540c7e 100644 (file)
@@ -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.