diff options
author | Bartek Przybylski <bart.p.pl@gmail.com> | 2012-03-17 23:41:10 +0100 |
---|---|---|
committer | Bartek Przybylski <bart.p.pl@gmail.com> | 2012-03-17 23:41:10 +0100 |
commit | de09883d860d6507a2d287d0b8bae394963c4b94 (patch) | |
tree | 8ec442159474428d2b1eb9e66d0351c98f3a90dd /apps/gallery/lib | |
parent | 7ba8dbb92041d01ca70fca105897d3c374502343 (diff) | |
download | nextcloud-server-de09883d860d6507a2d287d0b8bae394963c4b94.tar.gz nextcloud-server-de09883d860d6507a2d287d0b8bae394963c4b94.zip |
creating and retrive thumbnails for intermediate galleries
Diffstat (limited to 'apps/gallery/lib')
-rw-r--r-- | apps/gallery/lib/album.php | 16 | ||||
-rw-r--r-- | apps/gallery/lib/scanner.php | 9 |
2 files changed, 21 insertions, 4 deletions
diff --git a/apps/gallery/lib/album.php b/apps/gallery/lib/album.php index e8698590e6d..070afdd6cd6 100644 --- a/apps/gallery/lib/album.php +++ b/apps/gallery/lib/album.php @@ -98,11 +98,19 @@ class OC_Gallery_Album { } public static function getAlbumSize($id){ - $sql = 'SELECT COUNT(*) as size FROM *PREFIX*gallery_photos WHERE album_id = ?'; - $stmt = OC_DB::prepare($sql); - $result=$stmt->execute(array($id))->fetchRow(); - return $result['size']; + $sql = 'SELECT COUNT(*) as size FROM *PREFIX*gallery_photos WHERE album_id = ?'; + $stmt = OC_DB::prepare($sql); + $result=$stmt->execute(array($id))->fetchRow(); + return $result['size']; } + + public static function getIntermediateGallerySize($path) { + $path .= '%'; + $sql = 'SELECT COUNT(*) as size FROM *PREFIX*gallery_photos photos, *PREFIX*gallery_albums albums WHERE photos.album_id = albums.album_id AND uid_owner = ? AND file_path LIKE ?'; + $stmt = OC_DB::prepare($sql); + $result = $stmt->execute(array(OC_User::getUser(), $path))->fetchRow(); + return $result['size']; + } } ?> diff --git a/apps/gallery/lib/scanner.php b/apps/gallery/lib/scanner.php index 929f8b7a2e3..c8825c267eb 100644 --- a/apps/gallery/lib/scanner.php +++ b/apps/gallery/lib/scanner.php @@ -95,6 +95,15 @@ class OC_Gallery_Scanner { foreach ($a as $e) { $p .= ($p == '/'?'':'/').$e; OC_Gallery_Album::create(OC_User::getUser(), $e, $p); + $arr = OC_FileCache::searchByMime('image','', OC_Filesystem::getRoot().$p); + $step = floor(count($arr)/10); + if ($step == 0) $step = 1; + $na = array(); + for ($j = 0; $j < count($arr); $j+=$step) { + $na[] = $p.$arr[$j]; + } + if (count($na)) + self::createThumbnails($e, $na); } } } |