diff options
author | Bartek Przybylski <bart.p.pl@gmail.com> | 2012-03-04 18:28:41 +0100 |
---|---|---|
committer | Bartek Przybylski <bart.p.pl@gmail.com> | 2012-03-04 18:28:41 +0100 |
commit | 0a78849391761a616f392b8ad5468318dd84b4ff (patch) | |
tree | 82d9e9e2b43fa9fc98300bb806985a08b3507d3f /apps/gallery/ajax | |
parent | c411826fe5e7662fb0f6dc5fbcb074c68b467ea4 (diff) | |
download | nextcloud-server-0a78849391761a616f392b8ad5468318dd84b4ff.tar.gz nextcloud-server-0a78849391761a616f392b8ad5468318dd84b4ff.zip |
multilevel gallery
Diffstat (limited to 'apps/gallery/ajax')
-rw-r--r-- | apps/gallery/ajax/galleryOp.php | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/apps/gallery/ajax/galleryOp.php b/apps/gallery/ajax/galleryOp.php index e768ce00c17..ee919daeacb 100644 --- a/apps/gallery/ajax/galleryOp.php +++ b/apps/gallery/ajax/galleryOp.php @@ -41,7 +41,6 @@ function handleRemove($name) { function handleGetThumbnails($albumname) { OC_Response::enableCaching(3600 * 24); // 24 hour - error_log(htmlentities($albumname)); $thumbnail = OC::$CONFIG_DATADIRECTORY.'/../gallery/'.urldecode($albumname).'.png'; header('Content-Type: '.OC_Image::getMimeTypeForFile($thumbnail)); OC_Response::sendFile($thumbnail); @@ -88,20 +87,36 @@ function handleStoreSettings($root, $order) { OC_JSON::success(array('rescan' => $rescan)); } - -function handleGetGalleries() { +function handleGetGallery($path) { $a = array(); - - $result = OC_Gallery_Album::find(OC_User::getUser()); + $root = OC_Preferences::getValue(OC_User::getUser(),'gallery', 'root', '/'); + if (strlen($root) > 1) + $path = $root.'/'.trim($path, '/'); + else + $path = '/'.ltrim($path, '/'); + if (strlen($path) > 1) $path = rtrim($path, '/'); + error_log($path); + $result = OC_Gallery_Album::find(OC_User::getUser(), null, $path); + $album_details = $result->fetchRow(); + + $result = OC_Gallery_Album::find(OC_User::getUser(), null, null, $path); while ($r = $result->fetchRow()) { $album_name = $r['album_name']; $tmp_res = OC_Gallery_Photo::find($r['album_id']); - $a[] = array('name' => utf8_encode($album_name), 'numOfItems' => min($tmp_res->numRows(), 10), 'bgPath' => OC::$WEBROOT.'/data/'.OC_User::getUser().'/gallery/'.$album_name.'.png'); + $a[] = array('name' => utf8_encode($album_name), 'numOfItems' => min($tmp_res->numRows(), 10)); } + + $result = OC_Gallery_Photo::find($album_details['album_id']); - OC_JSON::success(array('albums'=>$a)); + $p = array(); + + while ($r = $result->fetchRow()) { + $p[] = utf8_encode($r['file_path']); + } + + OC_JSON::success(array('albums'=>$a, 'photos'=>$p)); } if ($_GET['operation']) { @@ -130,7 +145,10 @@ if ($_GET['operation']) { handleStoreSettings($_GET['root'], $_GET['order']); break; case 'get_galleries': - handleGetGalleries(); + handleGetGalleries($_GET['path']); + break; + case 'get_gallery': + handleGetGallery($_GET['path']); break; default: OC_JSON::error(array('cause' => 'Unknown operation')); |