public static function cleanup() { $albums = self::find(OCP\USER::getUser()); while ($r = $albums->fetchRow()) { OC_Gallery_Photo::removeByAlbumId($r['album_id']); self::remove(OCP\USER::getUser(), $r['album_name']); } }
function handleGetThumbnail($token, $imgpath) { $owner = OC_Gallery_Sharing::getTokenOwner($token); $image = OC_Gallery_Photo::getThumbnail($imgpath, $owner); if ($image) { OCP\Response::enableCaching(3600 * 24); // 24 hour $image->show(); } }
public static function createThumbnails($albumName, $files) { // create gallery thumbnail $file_count = min(count($files), 10); $thumbnail = imagecreatetruecolor($file_count * 200, 200); for ($i = 0; $i < $file_count; $i++) { $image = OC_Gallery_Photo::getThumbnail($files[$i]); if ($image && $image->valid()) { imagecopyresampled($thumbnail, $image->resource(), $i * 200, 0, 0, 0, 200, 200, 200, 200); $image->destroy(); } } imagepng($thumbnail, OCP\Config::getSystemValue("datadirectory") . '/' . OCP\USER::getUser() . '/gallery/' . $albumName . '.png'); imagedestroy($thumbnail); }
public static function createThumbnails($albumName, $files) { // create gallery thumbnail $file_count = min(count($files), 10); $thumbnail = imagecreatetruecolor($file_count * 200, 200); for ($i = 0; $i < $file_count; $i++) { $image = OC_Gallery_Photo::getThumbnail($files[$i]); if ($image && $image->valid()) { imagecopyresampled($thumbnail, $image->resource(), $i * 200, 0, 0, 0, 200, 200, 200, 200); $image->destroy(); } } $view = OCP\Files::getStorage('gallery'); imagepng($thumbnail, $view->getLocalFile($albumName . '.png')); imagedestroy($thumbnail); }
function handleGetGallery($path) { $a = array(); $root = OCP\Config::getUserValue(OCP\USER::getUser(), 'gallery', 'root', '/'); $path = utf8_decode(rtrim($root . $path, '/')); if ($path == '') { $path = '/'; } $pathLen = strlen($path); $result = OC_Gallery_Album::find(OCP\USER::getUser(), null, $path); $album_details = $result->fetchRow(); $result = OC_Gallery_Album::find(OCP\USER::getUser(), null, null, $path); while ($r = $result->fetchRow()) { $album_name = $r['album_name']; $size = OC_Gallery_Album::getAlbumSize($r['album_id']); // this is a fallback mechanism and seems expensive if ($size == 0) { $size = OC_Gallery_Album::getIntermediateGallerySize($r['album_path']); } $a[] = array('name' => utf8_encode($album_name), 'numOfItems' => min($size, 10), 'path' => substr($r['album_path'], $pathLen)); } $result = OC_Gallery_Photo::find($album_details['album_id']); $p = array(); while ($r = $result->fetchRow()) { $p[] = utf8_encode($r['file_path']); } $r = OC_Gallery_Sharing::getEntryByAlbumId($album_details['album_id']); $shared = false; $recursive = false; $token = ''; if ($row = $r->fetchRow()) { $shared = true; $recursive = $row['recursive'] == 1 ? true : false; $token = $row['token']; } OCP\JSON::success(array('albums' => $a, 'photos' => $p, 'shared' => $shared, 'recursive' => $recursive, 'token' => $token)); }
<?php /** * ownCloud - gallery application * * @author Ike Devolder * @copyright 2012 Ike Devolder * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE * License as published by the Free Software Foundation; either * version 3 of the License, or any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('gallery'); $img = $_GET['img']; $image = OC_Gallery_Photo::getViewImage($img); if ($image) { OCP\Response::enableCaching(3600 * 24); // 24 hour $image->show(); }