summaryrefslogtreecommitdiffstats
path: root/apps/gallery
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-03-03 22:04:34 +0100
committerRobin Appelman <icewind@owncloud.com>2012-03-03 22:04:34 +0100
commitaf214d9dcd0f4c6058c91875e10f38824582aa74 (patch)
tree87925e2b1c4ff852a980a37e60c35091fb6d6bdd /apps/gallery
parenta5df3f8ea74b53d914a9ebd2687f8ab73b0a201b (diff)
downloadnextcloud-server-af214d9dcd0f4c6058c91875e10f38824582aa74.tar.gz
nextcloud-server-af214d9dcd0f4c6058c91875e10f38824582aa74.zip
change gallary scanning to support gallaries inside archives
Diffstat (limited to 'apps/gallery')
-rw-r--r--apps/gallery/ajax/galleryOp.php2
-rw-r--r--apps/gallery/js/album_cover.js2
-rw-r--r--apps/gallery/lib/scanner.php27
3 files changed, 13 insertions, 18 deletions
diff --git a/apps/gallery/ajax/galleryOp.php b/apps/gallery/ajax/galleryOp.php
index f07814056a3..c19344c0fbb 100644
--- a/apps/gallery/ajax/galleryOp.php
+++ b/apps/gallery/ajax/galleryOp.php
@@ -62,7 +62,7 @@ function handleFilescan($cleanup) {
function handlePartialCreate($path) {
if (empty($path)) OC_JSON::error(array('cause' => 'No path specified'));
- if (!OC_Filesystem::is_dir($path)) OC_JSON::error(array('cause' => 'Invalid path given'));
+ if (!OC_Filesystem::is_dir($path.'/')) OC_JSON::error(array('cause' => 'Invalid path given'));
$album = OC_Gallery_Album::find(OC_User::getUser(), null, $path);
$albums = array();
diff --git a/apps/gallery/js/album_cover.js b/apps/gallery/js/album_cover.js
index 4ddac2f2111..d328a2d58e5 100644
--- a/apps/gallery/js/album_cover.js
+++ b/apps/gallery/js/album_cover.js
@@ -53,7 +53,7 @@ function scanForAlbums(cleanup) {
}
$('#scanprogressbar').progressbar({ value: (albumCounter/totalAlbums)*100 }).fadeIn();
for(var a in r.paths) {
- $.getJSON('ajax/galleryOp.php?operation=partial_create&path='+r.paths[a], function(r) {
+ $.getJSON('ajax/galleryOp.php',{operation:'partial_create','path':r.paths[a]}, function(r) {
if (r.status == 'success') {
Albums.add(r.album_details.albumName, r.album_details.imagesCount);
diff --git a/apps/gallery/lib/scanner.php b/apps/gallery/lib/scanner.php
index 64efb006ad1..9c381acf389 100644
--- a/apps/gallery/lib/scanner.php
+++ b/apps/gallery/lib/scanner.php
@@ -53,7 +53,7 @@ class OC_Gallery_Scanner {
$current_album = array('name'=> $path, 'imagesCount' => 0, 'images' => array());
$current_album['name'] = self::createName($current_album['name']);
- if ($dh = OC_Filesystem::opendir($path)) {
+ if ($dh = OC_Filesystem::opendir($path.'/')) {
while (($filename = readdir($dh)) !== false) {
$filepath = ($path[strlen($path)-1]=='/'?$path:$path.'/').$filename;
if (substr($filename, 0, 1) == '.') continue;
@@ -103,21 +103,16 @@ class OC_Gallery_Scanner {
}
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[] = urlencode($path);
-
- return $ret;
+ $images=OC_FileCache::searchByMime('image');
+ $paths=array();
+ foreach($images as $image){
+ $path=dirname($image);
+ if(array_search($path,$paths)===false){
+ error_log($path);
+ $paths[]=$path;
+ }
+ }
+ return $paths;
}
}
?>