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);
}
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();
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);
}
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());
}
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){
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;
}
if ($image->valid()) {
$image->centerCrop(200);
$image->fixOrientation();
- $image->save($thumb_file);
+ $image->save($view->getLocalFile($thumb_file));
}
}
if ($image->valid()) {
$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);
}