aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorz0rglub <z0rglub@piwigo.org>2004-01-13 22:36:56 +0000
committerz0rglub <z0rglub@piwigo.org>2004-01-13 22:36:56 +0000
commit1c59964dffbf3134c456df23b13eb1c2734c0bf3 (patch)
tree483252be7d32fb58b272bd6143e75b22355ccb53
parent0fa0c8bb07c80884ac8b79560ba4c4119abfcd5c (diff)
Adding functions to retrieve all files from a directory into an array :
- get_picture_files : returns an array with all picture files according to $conf['picture_ext'] - get_thumb_files : returns an array with all thumbnails according to $conf['picture_ext'] and $conf['prefix_thumbnail'] git-svn-id: http://piwigo.org/svn/branches/release-1_3@277 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/include/functions.php53
1 files changed, 52 insertions, 1 deletions
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 0207bd9b8..ecab3782f 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -53,7 +53,58 @@ function is_image( $filename, $create_thumbnail = false )
}
return false;
}
-
+
+/**
+ * returns an array with all picture files according to $conf['picture_ext']
+ *
+ * @param string $dir
+ * @return array
+ */
+function get_picture_files( $dir )
+{
+ global $conf;
+
+ $pictures = array();
+ if ( $opendir = opendir( $dir ) )
+ {
+ while ( $file = readdir( $opendir ) )
+ {
+ if ( in_array( get_extension( $file ), $conf['picture_ext'] ) )
+ {
+ array_push( $pictures, $file );
+ }
+ }
+ }
+ return $pictures;
+}
+
+/**
+ * returns an array with all thumbnails according to $conf['picture_ext']
+ * and $conf['prefix_thumbnail']
+ *
+ * @param string $dir
+ * @return array
+ */
+function get_thumb_files( $dir )
+{
+ global $conf;
+
+ $prefix_length = strlen( $conf['prefix_thumbnail'] );
+
+ $thumbnails = array();
+ if ( $opendir = @opendir( $dir ) )
+ {
+ while ( $file = readdir( $opendir ) )
+ {
+ if ( in_array( get_extension( $file ), $conf['picture_ext'] )
+ and substr($file,0,$prefix_length) == $conf['prefix_thumbnail'] )
+ {
+ array_push( $thumbnails, $file );
+ }
+ }
+ }
+ return $thumbnails;
+}
function TN_exists( $dir, $file )
{