diff options
author | Bartek Przybylski <bart.p.pl@gmail.com> | 2012-01-15 15:31:17 +0100 |
---|---|---|
committer | Bartek Przybylski <bart.p.pl@gmail.com> | 2012-01-15 15:31:37 +0100 |
commit | 07cf709eeb0be12376a1e471aa37bfd2cd8a9caf (patch) | |
tree | 289d21573350ef7df72f42f7a3bdf6118421ba09 /apps/gallery/lib | |
parent | 63d9c1a8179bdefa6c4b6f089af6ce91cd11a46a (diff) | |
download | nextcloud-server-07cf709eeb0be12376a1e471aa37bfd2cd8a9caf.tar.gz nextcloud-server-07cf709eeb0be12376a1e471aa37bfd2cd8a9caf.zip |
better scanning model for gallery, more feedback to user while scanning
Diffstat (limited to 'apps/gallery/lib')
-rw-r--r-- | apps/gallery/lib/scanner.php | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/apps/gallery/lib/scanner.php b/apps/gallery/lib/scanner.php index 3eba9260ac7..4ce38a99531 100644 --- a/apps/gallery/lib/scanner.php +++ b/apps/gallery/lib/scanner.php @@ -50,15 +50,14 @@ class OC_Gallery_Scanner { while (($filename = readdir($dh)) !== false) { $filepath = ($path[strlen($path)-1]=='/'?$path:$path.'/').$filename; if (substr($filename, 0, 1) == '.') continue; - if (OC_Filesystem::is_dir($filepath)) { - self::scanDir($filepath, $albums); - } elseif (self::isPhoto($path.'/'.$filename)) { + if (self::isPhoto($path.'/'.$filename)) { $current_album['images'][] = $filepath; } } } $current_album['imagesCount'] = count($current_album['images']); - $albums[] = $current_album; + $albums['imagesCount'] = $current_album['imagesCount']; + $albums['albumName'] = $current_album['name']; $result = OC_Gallery_Album::find(OC_User::getUser(), $current_album['name']); if ($result->numRows() == 0 && count($current_album['images'])) { @@ -92,5 +91,23 @@ class OC_Gallery_Scanner { return 1; return 0; } + + public static function find_paths($path) { + $ret = array(); + $dirres; + $addpath = FALSE; + if (($dirres = OC_Filesystem::opendir($path)) == FALSE) return $ret; + + while (($file = readdir($dirres)) != FALSE) { + if ($file[0] == '.') continue; + if (OC_Filesystem::is_dir($path.$file)) + $ret = array_merge($ret, self::find_paths($path.$file.'/')); + if (self::isPhoto($path.$file)) $addpath = TRUE; + } + + if ($addpath) $ret[] = $path; + + return $ret; + } } ?> |