summaryrefslogtreecommitdiffstats
path: root/apps/gallery
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-06-04 23:02:05 +0200
committerBart Visscher <bartv@thisnet.nl>2012-06-04 23:02:05 +0200
commit4a5973662c78eb5769e7b06d7d559572f57e663f (patch)
tree774e2f775b3789f5f40bd2459ddec05df1b73c31 /apps/gallery
parent786325a4bb976d92de54c472c2c3bd8a73cbef22 (diff)
parent3fee3a4633e5d4d65f7eabf2d387e209efedbc70 (diff)
downloadnextcloud-server-4a5973662c78eb5769e7b06d7d559572f57e663f.tar.gz
nextcloud-server-4a5973662c78eb5769e7b06d7d559572f57e663f.zip
Merge branch 'unstable'
Conflicts: apps/files_external/tests/config.php apps/files_versions/ajax/getVersions.php apps/files_versions/appinfo/app.php apps/files_versions/history.php apps/files_versions/js/versions.js apps/files_versions/templates/history.php apps/files_versions/versions.php lib/base.php
Diffstat (limited to 'apps/gallery')
-rw-r--r--apps/gallery/ajax/galleryOp.php3
-rw-r--r--apps/gallery/ajax/sharing.php6
-rw-r--r--apps/gallery/index.php4
-rw-r--r--apps/gallery/js/album_cover.js16
-rw-r--r--apps/gallery/lib/album.php31
-rw-r--r--apps/gallery/lib/photo.php20
-rw-r--r--apps/gallery/lib/scanner.php3
7 files changed, 40 insertions, 43 deletions
diff --git a/apps/gallery/ajax/galleryOp.php b/apps/gallery/ajax/galleryOp.php
index 0cd825f3e50..b49e52f0bd2 100644
--- a/apps/gallery/ajax/galleryOp.php
+++ b/apps/gallery/ajax/galleryOp.php
@@ -42,7 +42,8 @@ function handleRemove($name) {
function handleGetThumbnails($albumname) {
OCP\Response::enableCaching(3600 * 24); // 24 hour
- $thumbnail = OC::$CONFIG_DATADIRECTORY.'/../gallery/'.urldecode($albumname).'.png';
+ $view = OCP\App::getStorage('gallery');
+ $thumbnail = $view->fopen(urldecode($albumname).'.png', 'r');
header('Content-Type: '.OC_Image::getMimeTypeForFile($thumbnail));
OCP\Response::sendFile($thumbnail);
}
diff --git a/apps/gallery/ajax/sharing.php b/apps/gallery/ajax/sharing.php
index 1223320120b..304757b9e91 100644
--- a/apps/gallery/ajax/sharing.php
+++ b/apps/gallery/ajax/sharing.php
@@ -80,7 +80,8 @@ function handleGetThumbnail($token, $imgpath) {
function handleGetAlbumThumbnail($token, $albumname)
{
$owner = OC_Gallery_Sharing::getTokenOwner($token);
- $file = OCP\Config::getSystemValue("datadirectory").'/'. $owner .'/gallery/'.$albumname.'.png';
+ $view = OCP\App::getStorage('gallery');
+ $file = $view->fopen($albumname.'.png', 'r');
$image = new OC_Image($file);
if ($image->valid()) {
$image->centerCrop();
@@ -93,7 +94,8 @@ function handleGetAlbumThumbnail($token, $albumname)
function handleGetPhoto($token, $photo) {
$owner = OC_Gallery_Sharing::getTokenOwner($token);
- $file = OCP\Config::getSystemValue( "datadirectory", OC::$SERVERROOT."/data" ).'/'.$owner.'/files'.urldecode($photo);
+ $view = OCP\App::getStorage('files');
+ $file = $view->fopen(urldecode($photo), 'r');
header('Content-Type: '.OC_Image::getMimeTypeForFile($file));
OCP\Response::sendFile($file);
}
diff --git a/apps/gallery/index.php b/apps/gallery/index.php
index e47fb3db5d6..a9fe200c4e4 100644
--- a/apps/gallery/index.php
+++ b/apps/gallery/index.php
@@ -27,10 +27,6 @@ OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('gallery');
OCP\App::setActiveNavigationEntry( 'gallery_index' );
-if (!file_exists(OCP\Config::getSystemValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery')) {
- mkdir(OCP\Config::getSystemValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery');
-}
-
if (!isset($_GET['view'])) {
$result = OC_Gallery_Album::find(OCP\USER::getUser());
diff --git a/apps/gallery/js/album_cover.js b/apps/gallery/js/album_cover.js
index d1809462f2f..905034f6fd1 100644
--- a/apps/gallery/js/album_cover.js
+++ b/apps/gallery/js/album_cover.js
@@ -78,14 +78,14 @@ function albumClickHandler(r) {
for (var i in r.photos) {
Albums.photos.push(r.photos[i]);
}
- Albums.shared = r.shared;
- if (Albums.shared) {
- Albums.recursive = r.recursive;
- Albums.token = r.token;
- } else {
- Albums.recursive = false;
- Albums.token = '';
- }
+ Albums.shared = r.shared;
+ if (Albums.shared) {
+ Albums.recursive = r.recursive;
+ Albums.token = r.token;
+ } else {
+ Albums.recursive = false;
+ Albums.token = '';
+ }
$(document).ready(function(){
var targetDiv = $('#gallery_list');
targetDiv.html('');
diff --git a/apps/gallery/lib/album.php b/apps/gallery/lib/album.php
index 5f962f12f12..8ac27b1a70d 100644
--- a/apps/gallery/lib/album.php
+++ b/apps/gallery/lib/album.php
@@ -77,7 +77,7 @@ class OC_Gallery_Album {
$sql .= ' AND parent_path = ?';
$args[] = $parent;
}
- $order = OCP\Config::getUserValue($owner, 'gallery', 'order', 'ASC');
+ $order = OCP\Config::getUserValue($owner, 'gallery', 'order', 'ASC');
$sql .= ' ORDER BY album_name ' . $order;
$stmt = OCP\DB::prepare($sql);
@@ -90,25 +90,22 @@ class OC_Gallery_Album {
}
public static function changeThumbnailPath($oldname, $newname) {
-
- $thumbpath = OC::$CONFIG_DATADIRECTORY.'/../gallery/';
- rename($thumbpath.$oldname.'.png', $thumbpath.$newname.'.png');
+ $view = OCP\App::getStorage('gallery');
+ $view->rename($oldname.'.png', $newname.'.png');
}
public static function getAlbumSize($id){
- $sql = 'SELECT COUNT(*) as size FROM *PREFIX*gallery_photos WHERE album_id = ?';
- $stmt = OCP\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 = OCP\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 = OCP\DB::prepare($sql);
- $result = $stmt->execute(array(OCP\USER::getUser(), $path))->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 = OCP\DB::prepare($sql);
+ $result = $stmt->execute(array(OCP\USER::getUser(), $path))->fetchRow();
+ return $result['size'];
+ }
}
-
-?>
diff --git a/apps/gallery/lib/photo.php b/apps/gallery/lib/photo.php
index 99384af621a..b4b37236b0e 100644
--- a/apps/gallery/lib/photo.php
+++ b/apps/gallery/lib/photo.php
@@ -68,17 +68,17 @@ class OC_Gallery_Photo {
public static function getThumbnail($image_name, $owner = null) {
if (!$owner) $owner = OCP\USER::getUser();
- $save_dir = OCP\Config::getSystemValue("datadirectory").'/'. $owner .'/gallery/';
- $save_dir .= dirname($image_name). '/';
- $image_path = $image_name;
- $thumb_file = $save_dir . basename($image_name);
- if (!is_dir($save_dir)) {
- mkdir($save_dir, 0777, true);
+ $view = OCP\App::getStorage('gallery');
+ $save_dir = dirname($image_name);
+ if (!$view->is_dir($save_dir)) {
+ $view->mkdir($save_dir);
}
- if (file_exists($thumb_file)) {
- $image = new OC_Image($thumb_file);
+ $view->chroot($view->getRoot().'/'.$save_dir);
+ $thumb_file = basename($image_name);
+ if ($view->file_exists($thumb_file)) {
+ $image = new OC_Image($view->fopen($thumb_file, 'r'));
} else {
- $image_path = OC_Filesystem::getLocalFile($image_path);
+ $image_path = OC_Filesystem::getLocalFile($image_name);
if(!file_exists($image_path)) {
return null;
}
@@ -86,7 +86,7 @@ class OC_Gallery_Photo {
if ($image->valid()) {
$image->centerCrop(200);
$image->fixOrientation();
- $image->save($thumb_file);
+ $image->save($view->getLocalFile($thumb_file));
}
}
if ($image->valid()) {
diff --git a/apps/gallery/lib/scanner.php b/apps/gallery/lib/scanner.php
index 7a137cb3f50..e11ba1da454 100644
--- a/apps/gallery/lib/scanner.php
+++ b/apps/gallery/lib/scanner.php
@@ -81,7 +81,8 @@ class OC_Gallery_Scanner {
$image->destroy();
}
}
- imagepng($thumbnail, OCP\Config::getSystemValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery/' . $albumName.'.png');
+ $view = OCP\App::getStorage('gallery');
+ imagepng($thumbnail, $view->getLocalFile($albumName.'.png'));
imagedestroy($thumbnail);
}