]> source.dussan.org Git - nextcloud-server.git/commitdiff
implement use of preview icons in thrashbin app
authorGeorg Ehrke <developer@georgehrke.com>
Mon, 8 Jul 2013 08:53:53 +0000 (10:53 +0200)
committerGeorg Ehrke <developer@georgehrke.com>
Mon, 8 Jul 2013 08:53:53 +0000 (10:53 +0200)
apps/files_trashbin/lib/trash.php
apps/files_trashbin/templates/part.list.php
core/routes.php
lib/preview.php

index 7b8d3cb4252fbe173a3c28bcb74cc376c5f5835c..e82a597c61ef33e5e7d6b52b2c91959f39f5a7a9 100644 (file)
@@ -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));
+       }
 }
index 92a38bd26350ce2bca8c382eba06fa8db05372a8..d53e38549d10cd7bdab9fc2357b352bf28c09357 100644 (file)
@@ -27,7 +27,7 @@
                <?php if($file['type'] == 'dir'): ?>
                        style="background-image:url(<?php print_unescaped(OCP\mimetype_icon('dir')); ?>)"
                <?php else: ?>
-                       style="background-image:url(<?php print_unescaped(OCP\mimetype_icon($file['mimetype'])); ?>)"
+                       style="background-image:url(<?php print_unescaped(OCA\Files_Trashbin\Trashbin::preview_icon($file['name'].'.d'.$file['timestamp'])); ?>)"
                <?php endif; ?>
                        >
                <?php if(!isset($_['readonly']) || !$_['readonly']): ?><input type="checkbox" /><?php endif; ?>
index 4b3ad53da010943c6eb17cfe304a512d01e7e7ea..41e82f8a73d28fac9ff520a09201fb9fb1cc54f9 100644 (file)
@@ -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';
index 87e2e78d1d8a682af67f8a6d08d4a3aff064b98f..f12107c9f579e977de5419b914dbdac21a2ff42e 100755 (executable)
@@ -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);
        }