implement use of preview icons in thrashbin app

This commit is contained in:
Georg Ehrke 2013-07-08 10:53:53 +02:00
parent 6e864e6599
commit 04292ff16c
4 changed files with 38 additions and 5 deletions

View 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));
}
}

View 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; ?>

View 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';

View File

@ -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);
}