implement server side use of previews

This commit is contained in:
Georg Ehrke 2013-06-26 18:04:18 +02:00
parent 9b7efef39d
commit 39c387eed4
4 changed files with 34 additions and 1 deletions

View file

@ -1,6 +1,7 @@
<input type="hidden" id="disableSharing" data-status="<?php p($_['disableSharing']); ?>">
<?php foreach($_['files'] as $file):
$relativePath = substr($file['path'], 6);
$simple_file_size = OCP\simple_file_size($file['size']);
// the bigger the file, the darker the shade of grey; megabytes*2
$simple_size_color = intval(160-$file['size']/(1024*1024)*2);
@ -23,7 +24,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(OCP\preview_icon($relativePath)); ?>)"
<?php endif; ?>
>
<?php if(!isset($_['readonly']) || !$_['readonly']): ?><input type="checkbox" /><?php endif; ?>

View file

@ -223,6 +223,17 @@ class OC_Helper {
}
}
/**
* @brief get path to preview of file
* @param string $path path
* @return string the url
*
* Returns the path to the preview of the file.
*/
public static function previewIcon($path) {
return self::linkToRoute( 'core_ajax_preview', array('x' => 32, 'y' => 32, 'file' => $path));
}
/**
* @brief Make a human file size
* @param int $bytes file size in bytes

View file

@ -54,6 +54,15 @@ function mimetype_icon( $mimetype ) {
return(\mimetype_icon( $mimetype ));
}
/**
* @brief make preview_icon available as a simple function
* Returns the path to the preview of the image.
* @param $path path of file
* @returns link to the preview
*/
function preview_icon( $path ) {
return(\preview_icon( $path ));
}
/**
* @brief make OC_Helper::humanFileSize available as a simple function

View file

@ -62,6 +62,18 @@ function image_path( $app, $image ) {
return OC_Helper::imagePath( $app, $image );
}
/**
* @brief make preview_icon available as a simple function
* Returns the path to the preview of the image.
* @param $path path of file
* @returns link to the preview
*
* For further information have a look at OC_Helper::previewIcon
*/
function preview_icon( $path ) {
return OC_Helper::previewIcon( $path );
}
/**
* @brief make OC_Helper::mimetypeIcon available as a simple function
* @param string $mimetype mimetype