From 04292ff16c56d85216ddbd6f644e8055413c0170 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 8 Jul 2013 10:53:53 +0200 Subject: [PATCH] implement use of preview icons in thrashbin app --- apps/files_trashbin/lib/trash.php | 4 +++ apps/files_trashbin/templates/part.list.php | 2 +- core/routes.php | 2 ++ lib/preview.php | 35 ++++++++++++++++++--- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index 7b8d3cb4252..e82a597c61e 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -850,4 +850,8 @@ class Trashbin { //Listen to delete user signal \OCP\Util::connectHook('OC_User', 'pre_deleteUser', "OCA\Files_Trashbin\Hooks", "deleteUser_hook"); } + + public static function preview_icon($path) { + return \OC_Helper::linkToRoute( 'core_ajax_trashbin_preview', array('x' => 44, 'y' => 44, 'file' => $path)); + } } diff --git a/apps/files_trashbin/templates/part.list.php b/apps/files_trashbin/templates/part.list.php index 92a38bd2635..d53e38549d1 100644 --- a/apps/files_trashbin/templates/part.list.php +++ b/apps/files_trashbin/templates/part.list.php @@ -27,7 +27,7 @@ style="background-image:url()" - style="background-image:url()" + style="background-image:url()" > diff --git a/core/routes.php b/core/routes.php index 4b3ad53da01..41e82f8a73d 100644 --- a/core/routes.php +++ b/core/routes.php @@ -44,6 +44,8 @@ $this->create('core_ajax_routes', '/core/routes.json') ->action('OC_Router', 'JSRoutes'); $this->create('core_ajax_preview', '/core/preview.png') ->action('OC\Preview', 'previewRouter'); +$this->create('core_ajax_trashbin_preview', '/core/trashbinpreview.png') + ->action('OC\Preview', 'trashbinPreviewRouter'); $this->create('core_ajax_public_preview', '/core/publicpreview.png') ->action('OC\Preview', 'publicPreviewRouter'); OC::$CLASSPATH['OC_Core_LostPassword_Controller'] = 'core/lostpassword/controller.php'; diff --git a/lib/preview.php b/lib/preview.php index 87e2e78d1d8..f12107c9f57 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -519,10 +519,6 @@ class Preview { $file = ''; $maxX = 0; $maxY = 0; - /* - * use: ?scalingup=0 / ?scalingup = 1 - * do not use ?scalingup=false / ?scalingup = true as these will always be true - */ $scalingup = true; if(array_key_exists('file', $_GET)) $file = (string) urldecode($_GET['file']); @@ -610,6 +606,37 @@ class Preview { } } + public static function trashbinPreviewRouter() { + if(!\OC_App::isEnabled('files_trashbin')){ + exit; + } + \OC_Util::checkLoggedIn(); + + $file = ''; + $maxX = 0; + $maxY = 0; + $scalingup = true; + + if(array_key_exists('file', $_GET)) $file = (string) urldecode($_GET['file']); + if(array_key_exists('x', $_GET)) $maxX = (int) $_GET['x']; + if(array_key_exists('y', $_GET)) $maxY = (int) $_GET['y']; + if(array_key_exists('scalingup', $_GET)) $scalingup = (bool) $_GET['scalingup']; + + if($file !== '' && $maxX !== 0 && $maxY !== 0) { + try{ + $preview = new Preview(\OC_User::getUser(), 'files_trashbin/files', $file, $maxX, $maxY, $scalingup); + $preview->showPreview(); + }catch(\Exception $e) { + \OC_Response::setStatus(404); + \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); + exit; + } + }else{ + \OC_Response::setStatus(404); + exit; + } + } + public static function post_write($args) { self::post_delete($args); } -- 2.39.5