diff --git a/3rdparty b/3rdparty index 21b466b72c..dc87ea6302 160000 --- a/3rdparty +++ b/3rdparty @@ -1 +1 @@ -Subproject commit 21b466b72cdd4c823c011669593ecef1defb1f3c +Subproject commit dc87ea630287f27502eba825fbb19fcc33c34c86 diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php index d224e79d01..76c03c87a5 100644 --- a/apps/files/ajax/newfile.php +++ b/apps/files/ajax/newfile.php @@ -79,7 +79,7 @@ if($source) { $success = false; if (!$content) { $templateManager = OC_Helper::getFileTemplateManager(); - $mimeType = OC_Helper::getMimeType($target); + $mimeType = OC_Helper::getMimetypeDetector()->detectPath($target); $content = $templateManager->getTemplate($mimeType); } diff --git a/apps/files/css/files.css b/apps/files/css/files.css index af0cb83581..498e34d70d 100644 --- a/apps/files/css/files.css +++ b/apps/files/css/files.css @@ -19,10 +19,13 @@ background:#f8f8f8; border:1px solid #ddd; border-radius:10px; border-top-left-radius:0; box-shadow:0 2px 7px rgba(170,170,170,.4); } -#new>ul>li { height:20px; margin:.3em; padding-left:2em; padding-bottom:0.1em; +#new>ul>li { height:36px; margin:.3em; padding-left:3em; padding-bottom:0.1em; background-repeat:no-repeat; cursor:pointer; } -#new>ul>li>p { cursor:pointer; } -#new>ul>li>form>input { padding:0.3em; margin:-0.3em; } +#new>ul>li>p { cursor:pointer; padding-top: 7px; padding-bottom: 7px;} +#new>ul>li>form>input { + padding: 5px; + margin: 2px 0; +} #trash { margin: 0 1em; z-index:1010; float: right; } @@ -72,7 +75,7 @@ color:#888; text-shadow:#fff 0 1px 0; } #filestable { position: relative; top:37px; width:100%; } -#filestable tbody tr { background-color:#fff; height:2.5em; } +tbody tr { background-color:#fff; height:2.5em; } tbody tr:hover, tbody tr:active { background-color: rgb(240,240,240); } @@ -85,54 +88,153 @@ span.extension { text-transform:lowercase; -ms-filter:"progid:DXImageTransform.M tr:hover span.extension { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; filter:alpha(opacity=100); opacity:1; color:#777; } table tr.mouseOver td { background-color:#eee; } table th { height:2em; padding:0 .5em; color:#999; } -table th .name { float:left; margin-left:.5em; } +table th .name { + position: absolute; + left: 55px; + top: 15px; +} table th, table td { border-bottom:1px solid #ddd; text-align:left; font-weight:normal; } -table td { border-bottom:1px solid #eee; font-style:normal; background-position:1em .5em; background-repeat:no-repeat; } -table th#headerName { width:100em; /* not really sure why this works better than 100% … table styling */ } -table th#headerSize, table td.filesize { min-width:3em; padding:0 1em; text-align:right; } -table th#headerDate, table td.date { min-width:11em; padding:0 .1em 0 1em; text-align:left; } +table td { + border-bottom: 1px solid #eee; + font-style: normal; + background-position: 8px center; + background-repeat: no-repeat; +} +table th#headerName { + position: relative; + width: 100em; /* not really sure why this works better than 100% … table styling */ + padding: 0; +} +#headerName-container { + position: relative; + height: 50px; +} +table th#headerSize, table td.filesize { + min-width: 3em; + padding: 0 1em; + text-align: right; +} +table th#headerDate, table td.date { + -moz-box-sizing: border-box; + box-sizing: border-box; + position: relative; + min-width: 11em; + display: block; + height: 51px; +} /* Multiselect bar */ -#filestable.multiselect { top:63px; } +#filestable.multiselect { + top: 88px; +} table.multiselect thead { position:fixed; top:82px; z-index:1; -moz-box-sizing: border-box; box-sizing: border-box; left: 0; padding-left: 80px; width:100%; } + table.multiselect thead th { background-color: rgba(210,210,210,.7); color: #000; font-weight: bold; border-bottom: 0; } -table.multiselect #headerName { width: 100%; } +table.multiselect #headerName { + position: relative; + width: 100%; +} table td.selection, table th.selection, table td.fileaction { width:2em; text-align:center; } -table td.filename a.name { display:block; height:1.5em; vertical-align:middle; margin-left:3em; } +table td.filename a.name { + position:relative; /* Firefox needs to explicitly have this default set … */ + -moz-box-sizing: border-box; + box-sizing: border-box; + display: block; + height: 50px; + vertical-align: middle; + padding: 0; +} table tr[data-type="dir"] td.filename a.name span.nametext {font-weight:bold; } -table td.filename input.filename { width:100%; cursor:text; } -table td.filename a, table td.login, table td.logout, table td.download, table td.upload, table td.create, table td.delete { padding:.2em .5em .5em 0; } +table td.filename input.filename { + width: 80%; + font-size: 14px; + margin-top: 8px; + margin-left: 2px; + cursor: text; +} +table td.filename a, table td.login, table td.logout, table td.download, table td.upload, table td.create, table td.delete { padding:.2em .5em .5em .3em; } table td.filename .nametext, .uploadtext, .modified { float:left; padding:.3em 0; } + +#modified { + position: absolute; + top: 15px; +} +.modified { + position: relative; + top: 11px; + left: 5px; +} + /* TODO fix usability bug (accidental file/folder selection) */ -table td.filename .nametext { overflow:hidden; text-overflow:ellipsis; max-width:800px; } +table td.filename .nametext { + position: absolute; + top: 16px; + left: 55px; + padding: 0; + overflow: hidden; + text-overflow: ellipsis; + max-width: 800px; +} table td.filename .uploadtext { font-weight:normal; margin-left:.5em; } table td.filename form { font-size:.85em; margin-left:3em; margin-right:3em; } + /* File checkboxes */ -#fileList tr td.filename>input[type="checkbox"]:first-child { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter:alpha(opacity=0); opacity:0; float:left; margin:.7em 0 0 1em; /* bigger clickable area doesn’t work in FF width:2.8em; height:2.4em;*/ -webkit-transition:opacity 200ms; -moz-transition:opacity 200ms; -o-transition:opacity 200ms; transition:opacity 200ms; } -#fileList tr td.filename>input[type="checkbox"]:hover:first-child { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=80)"; filter:alpha(opacity=80); opacity:.8; } -/* Always show checkbox when selected */ -#fileList tr td.filename>input[type="checkbox"]:checked:first-child { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; filter:alpha(opacity=100); opacity:1; } -#fileList tr.selected td.filename>input[type="checkbox"]:first-child { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; filter:alpha(opacity=100); opacity:1; } +#fileList tr td.filename>input[type="checkbox"]:first-child { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; + filter: alpha(opacity=0); + opacity: 0; + float: left; + margin: 32px 0 4px 32px; /* bigger clickable area doesn’t work in FF width:2.8em; height:2.4em;*/ +} +/* Show checkbox when hovering, checked, or selected */ +#fileList tr:hover td.filename>input[type="checkbox"]:first-child, +#fileList tr td.filename>input[type="checkbox"]:checked:first-child, +#fileList tr.selected td.filename>input[type="checkbox"]:first-child { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; + filter: alpha(opacity=100); + opacity: 1; +} +/* Use label to have bigger clickable size for checkbox */ +#fileList tr td.filename>input[type="checkbox"] + label, +#select_all + label { + height: 50px; + position: absolute; + width: 50px; + z-index: 5; +} +#fileList tr td.filename>input[type="checkbox"] + label { + left: 0; +} +#select_all + label { + top: 0; +} +#select_all { + position: absolute; + top: 18px; + left: 18px; +} + #fileList tr td.filename { position:relative; width:100%; -webkit-transition:background-image 500ms; -moz-transition:background-image 500ms; -o-transition:background-image 500ms; transition:background-image 500ms; } -#select_all { float:left; margin:.4em 0.6em 0 .5em; } + #uploadsize-message,#delete-confirm { display:none; } /* File actions */ .fileactions { - position:absolute; top:.6em; right:0; - font-size:.8em; + position: absolute; + top: 16px; + right: 0; + font-size: 11px; } -#fileList .name { position:relative; /* Firefox needs to explicitly have this default set … */ } #fileList tr:hover .fileactions { /* background to distinguish when overlaying with file names */ background-color: rgba(240,240,240,0.898); box-shadow: -5px 0 7px rgba(240,240,240,0.898); @@ -142,15 +244,39 @@ table td.filename form { font-size:.85em; margin-left:3em; margin-right:3em; } box-shadow: -5px 0 7px rgba(230,230,230,.9); } #fileList .fileactions a.action img { position:relative; top:.2em; } -#fileList a.action { display:inline; margin:-.5em 0; padding:1em .5em 1em .5em !important; } + #fileList img.move2trash { display:inline; margin:-.5em 0; padding:1em .5em 1em .5em !important; float:right; } -a.action.delete { float:right; } +#fileList a.action.delete { + position: absolute; + right: 0; + top: 0; + margin: 0; + padding: 15px 14px 19px !important; +} a.action>img { max-height:16px; max-width:16px; vertical-align:text-bottom; } -.selectedActions { display:none; float:right; } -.selectedActions a { display:inline; margin:-.5em 0; padding:.5em !important; } -.selectedActions a img { position:relative; top:.3em; } + +/* Actions for selected files */ +.selectedActions { + display: none; + position: absolute; + top: -1px; + right: 0; + padding: 15px 8px; +} +.selectedActions a { + display: inline; + padding: 17px 5px; +} +.selectedActions a img { + position:relative; + top:.3em; +} + #fileList a.action { + display: inline; + margin: -.5em 0; + padding: 18px 8px !important; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter: alpha(opacity=0); opacity: 0; @@ -185,9 +311,8 @@ a.action>img { max-height:16px; max-width:16px; vertical-align:text-bottom; } padding-bottom: 8px; border-bottom: none; } - .summary .info { - margin-left: 3em; + margin-left: 55px; } #scanning-message{ top:40%; left:40%; position:absolute; display:none; } diff --git a/apps/files/index.php b/apps/files/index.php index e4d8e35385..f1e120c872 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -74,6 +74,7 @@ foreach ($content as $i) { } } $i['directory'] = $dir; + $i['isPreviewAvailable'] = \OCP\Preview::isMimeSupported($i['mimetype']); $files[] = $i; } @@ -95,6 +96,7 @@ $list->assign('files', $files); $list->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir='); $list->assign('downloadURL', OCP\Util::linkToRoute('download', array('file' => '/'))); $list->assign('disableSharing', false); +$list->assign('isPublic', false); $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', ''); $breadcrumbNav->assign('breadcrumb', $breadcrumb); $breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir='); diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index 1e6ab74fb6..3d620c5640 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -227,7 +227,7 @@ $(document).ready(function() { $(this).data('text',text); $(this).children('p').remove(); var form=$('
'); - var input=$(''); + var input=$(''); form.append(input); $(this).append(form); input.focus(); @@ -268,8 +268,9 @@ $(document).ready(function() { tr.attr('data-mime',result.data.mime); tr.attr('data-id', result.data.id); tr.find('.filesize').text(humanFileSize(result.data.size)); - getMimeIcon(result.data.mime,function(path){ - tr.find('td.filename').attr('style','background-image:url('+path+')'); + var path = getPathForPreview(name); + lazyLoadPreview(path, result.data.mime, function(previewpath){ + tr.find('td.filename').attr('style','background-image:url('+previewpath+')'); }); } else { OC.dialogs.alert(result.data.message, t('core', 'Error')); @@ -330,8 +331,9 @@ $(document).ready(function() { var tr=$('tr').filterAttr('data-file',localName); tr.data('mime',mime).data('id',id); tr.attr('data-id', id); - getMimeIcon(mime,function(path){ - tr.find('td.filename').attr('style','background-image:url('+path+')'); + var path = $('#dir').val()+'/'+localName; + lazyLoadPreview(path, mime, function(previewpath){ + tr.find('td.filename').attr('style','background-image:url('+previewpath+')'); }); }); eventSource.listen('error',function(error){ diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index e11cc70802..05e3109450 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -15,9 +15,10 @@ var FileList={ // filename td td = $('').attr({ "class": "filename", - "style": 'background-image:url('+iconurl+'); background-size: 16px;' + "style": 'background-image:url('+iconurl+'); background-size: 32px;' }); - td.append(''); + var rand = Math.random().toString(16).slice(2); + td.append(''); var link_elem = $('').attr({ "class": "name", "href": linktarget @@ -187,8 +188,9 @@ var FileList={ if (id != null) { tr.attr('data-id', id); } - getMimeIcon(mime,function(path){ - tr.find('td.filename').attr('style','background-image:url('+path+')'); + var path = getPathForPreview(name); + lazyLoadPreview(path, mime, function(previewpath){ + tr.find('td.filename').attr('style','background-image:url('+previewpath+')'); }); tr.find('td.filename').draggable(dragOptions); }, @@ -200,7 +202,7 @@ var FileList={ tr=$('tr').filterAttr('data-file',name); tr.data('renaming',true); td=tr.children('td.filename'); - input=$('').val(name); + input=$('').val(name); form=$('
'); form.append(input); td.children('a.name').hide(); diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 87311237e3..d729077ea7 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -454,8 +454,9 @@ var createDragShadow = function(event){ if (elem.type === 'dir') { newtr.find('td.filename').attr('style','background-image:url('+OC.imagePath('core', 'filetypes/folder.png')+')'); } else { - getMimeIcon(elem.mime,function(path){ - newtr.find('td.filename').attr('style','background-image:url('+path+')'); + var path = getPathForPreview(elem.name); + lazyLoadPreview(path, elem.mime, function(previewpath){ + newtr.find('td.filename').attr('style','background-image:url('+previewpath+')'); }); } }); @@ -631,6 +632,23 @@ function getMimeIcon(mime, ready){ } getMimeIcon.cache={}; +function getPathForPreview(name) { + var path = $('#dir').val() + '/' + name; + return path; +} + +function lazyLoadPreview(path, mime, ready) { + getMimeIcon(mime,ready); + var x = $('#filestable').data('preview-x'); + var y = $('#filestable').data('preview-y'); + var previewURL = OC.Router.generate('core_ajax_preview', {file: encodeURIComponent(path), x:x, y:y}); + $.get(previewURL, function() { + previewURL = previewURL.replace('(','%28'); + previewURL = previewURL.replace(')','%29'); + ready(previewURL + '&reload=true'); + }); +} + function getUniqueName(name){ if($('tr').filterAttr('data-file',name).length>0){ var parts=name.split('.'); diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index 360874103f..2f7e0af4f2 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -10,7 +10,7 @@ data-type='file'>

t('Text file'));?>

  • t('Folder'));?>

  • -
  • t('From link'));?>

  • @@ -59,21 +59,24 @@
    t('Nothing in here. Upload something!'))?>
    - +
    - - t( 'Name' )); ?> - - - - Download" /> - t('Download'))?> - - - +
    + + + t( 'Name' )); ?> + + + + Download" /> + t('Download'))?> + + + +
    t('Size')); ?> diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php index 3e6f619868..4076c1bb33 100644 --- a/apps/files/templates/part.list.php +++ b/apps/files/templates/part.list.php @@ -1,5 +1,7 @@ 6 + $relativePath = substr($file['path'], 6); // the bigger the file, the darker the shade of grey; megabytes*2 $simple_size_color = intval(160-$file['size']/(1024*1024)*2); if($simple_size_color<0) $simple_size_color = 0; @@ -13,16 +15,38 @@ data-file="" data-type="" data-mime="" - data-size='' - data-permissions=''> + data-size="" + data-permissions=""> + + style="background-image:url()" - style="background-image:url()" + + + + style="background-image:url()" + + style="background-image:url()" + + + + style="background-image:url()" + + style="background-image:url()" + + > - + + + + diff --git a/apps/files_sharing/ajax/publicpreview.php b/apps/files_sharing/ajax/publicpreview.php new file mode 100644 index 0000000000..41a1c178a4 --- /dev/null +++ b/apps/files_sharing/ajax/publicpreview.php @@ -0,0 +1,85 @@ +setFile($sharedFile); + $preview->setMaxX($maxX); + $preview->setMaxY($maxY); + $preview->setScalingUp($scalingUp); + + $preview->show(); +} catch (\Exception $e) { + \OC_Response::setStatus(500); + \OC_Log::write('core', $e->getmessage(), \OC_Log::DEBUG); +} \ No newline at end of file diff --git a/apps/files_sharing/appinfo/routes.php b/apps/files_sharing/appinfo/routes.php new file mode 100644 index 0000000000..02815b5eb4 --- /dev/null +++ b/apps/files_sharing/appinfo/routes.php @@ -0,0 +1,5 @@ +create('core_ajax_public_preview', '/publicpreview.png')->action( +function() { + require_once __DIR__ . '/../ajax/publicpreview.php'; +}); \ No newline at end of file diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js index 7ffd5e0687..357c6fdf54 100644 --- a/apps/files_sharing/js/public.js +++ b/apps/files_sharing/js/public.js @@ -16,7 +16,7 @@ $(document).ready(function() { if (typeof FileActions !== 'undefined') { var mimetype = $('#mimetype').val(); // Show file preview if previewer is available, images are already handled by the template - if (mimetype.substr(0, mimetype.indexOf('/')) != 'image') { + if (mimetype.substr(0, mimetype.indexOf('/')) != 'image' && $('.publicpreview').length === 0) { // Trigger default action if not download TODO var action = FileActions.getDefault(mimetype, 'file', OC.PERMISSION_READ); if (typeof action === 'undefined') { diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index e9fdf6e4c9..ec6b4e815f 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -172,6 +172,7 @@ if (isset($path)) { } else { $i['extension'] = ''; } + $i['isPreviewAvailable'] = \OCP\Preview::isMimeSupported($i['mimetype']); } $i['directory'] = $getPath; $i['permissions'] = OCP\PERMISSION_READ; @@ -194,6 +195,9 @@ if (isset($path)) { $list->assign('baseURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&path='); $list->assign('downloadURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download&path='); + $list->assign('isPublic', true); + $list->assign('sharingtoken', $token); + $list->assign('sharingroot', $basePath); $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', ''); $breadcrumbNav->assign('breadcrumb', $breadcrumb); $breadcrumbNav->assign('baseURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&path='); diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php index 746a715f3c..c164b3ea2b 100644 --- a/apps/files_sharing/templates/public.php +++ b/apps/files_sharing/templates/public.php @@ -79,6 +79,10 @@ + +
    + +
    • diff --git a/apps/files_trashbin/ajax/preview.php b/apps/files_trashbin/ajax/preview.php new file mode 100644 index 0000000000..a0846b051c --- /dev/null +++ b/apps/files_trashbin/ajax/preview.php @@ -0,0 +1,42 @@ +setFile($file); + $preview->setMaxX($maxX); + $preview->setMaxY($maxY); + $preview->setScalingUp($scalingUp); + + $preview->showPreview(); +}catch(\Exception $e) { + \OC_Response::setStatus(500); + \OC_Log::write('core', $e->getmessage(), \OC_Log::DEBUG); +} \ No newline at end of file diff --git a/apps/files_trashbin/appinfo/routes.php b/apps/files_trashbin/appinfo/routes.php new file mode 100644 index 0000000000..b1c3f02741 --- /dev/null +++ b/apps/files_trashbin/appinfo/routes.php @@ -0,0 +1,5 @@ +create('core_ajax_trashbin_preview', '/preview.png')->action( +function() { + require_once __DIR__ . '/../ajax/preview.php'; +}); \ No newline at end of file diff --git a/apps/files_trashbin/index.php b/apps/files_trashbin/index.php index 27f8407db0..0baeab1de9 100644 --- a/apps/files_trashbin/index.php +++ b/apps/files_trashbin/index.php @@ -64,6 +64,7 @@ foreach ($result as $r) { $i['directory'] = ''; } $i['permissions'] = OCP\PERMISSION_READ; + $i['isPreviewAvailable'] = \OCP\Preview::isMimeSupported($r['mime']); $files[] = $i; } diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index 880832f9af..c79afdc0c2 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -904,4 +904,7 @@ class Trashbin { return true; } + public static function preview_icon($path) { + return \OC_Helper::linkToRoute( 'core_ajax_trashbin_preview', array('x' => 36, 'y' => 36, 'file' => urlencode($path) )); + } } diff --git a/apps/files_trashbin/templates/part.list.php b/apps/files_trashbin/templates/part.list.php index 254b08dd36..f7cc6b01bb 100644 --- a/apps/files_trashbin/templates/part.list.php +++ b/apps/files_trashbin/templates/part.list.php @@ -21,11 +21,19 @@ data-timestamp='' data-dirlisting=0 > + +
    style="background-image:url()" - style="background-image:url()" + + style="background-image:url()" + + style="background-image:url()" + > diff --git a/config/config.sample.php b/config/config.sample.php index f5cb33732f..5f748438bc 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -201,4 +201,17 @@ $CONFIG = array( 'customclient_desktop' => '', //http://owncloud.org/sync-clients/ 'customclient_android' => '', //https://play.google.com/store/apps/details?id=com.owncloud.android 'customclient_ios' => '', //https://itunes.apple.com/us/app/owncloud/id543672169?mt=8 + +// PREVIEW +'enable_previews' => true, +/* the max width of a generated preview, if value is null, there is no limit */ +'preview_max_x' => null, +/* the max height of a generated preview, if value is null, there is no limit */ +'preview_max_y' => null, +/* the max factor to scale a preview, default is set to 10 */ +'preview_max_scale_factor' => 10, +/* custom path for libreoffice / openoffice binary */ +'preview_libreoffice_path' => '/usr/bin/libreoffice', +/* cl parameters for libreoffice / openoffice */ +'preview_office_cl_parameters' => '', ); diff --git a/core/ajax/preview.php b/core/ajax/preview.php new file mode 100644 index 0000000000..af0f0493f4 --- /dev/null +++ b/core/ajax/preview.php @@ -0,0 +1,40 @@ +setFile($file); + $preview->setMaxX($maxX); + $preview->setMaxY($maxY); + $preview->setScalingUp($scalingUp); + + $preview->show(); +}catch(\Exception $e) { + \OC_Response::setStatus(500); + \OC_Log::write('core', $e->getmessage(), \OC_Log::DEBUG); +} \ No newline at end of file diff --git a/core/css/styles.css b/core/css/styles.css index 34e8e8ae41..85f65a2f42 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -145,7 +145,8 @@ a.disabled, a.disabled:hover, a.disabled:focus { .searchbox input[type="search"] { font-size:1.2em; padding:.2em .5em .2em 1.5em; background:#fff url('../img/actions/search.svg') no-repeat .5em center; border:0; -moz-border-radius:1em; -webkit-border-radius:1em; border-radius:1em; -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=70)"; filter:alpha(opacity=70);opacity:.7; -webkit-transition:opacity 300ms; -moz-transition:opacity 300ms; -o-transition:opacity 300ms; transition:opacity 300ms; margin-top:10px; float:right; } input[type="submit"].enabled { background:#66f866; border:1px solid #5e5; -moz-box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #cfc inset; -webkit-box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #cfc inset; box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #cfc inset; } -#select_all{ margin-top:.4em } + + /* CONTENT ------------------------------------------------------------------ */ #controls { diff --git a/core/img/filetypes/application-epub+zip.png b/core/img/filetypes/application-epub+zip.png new file mode 100644 index 0000000000..b3e3b28b4d Binary files /dev/null and b/core/img/filetypes/application-epub+zip.png differ diff --git a/core/img/filetypes/application-epub+zip.svg b/core/img/filetypes/application-epub+zip.svg new file mode 100644 index 0000000000..041f9f15e6 --- /dev/null +++ b/core/img/filetypes/application-epub+zip.svg @@ -0,0 +1,761 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/application-msexcel.png b/core/img/filetypes/application-msexcel.png deleted file mode 100644 index b977d7e52e..0000000000 Binary files a/core/img/filetypes/application-msexcel.png and /dev/null differ diff --git a/core/img/filetypes/application-mspowerpoint.png b/core/img/filetypes/application-mspowerpoint.png deleted file mode 100644 index c4eff0387d..0000000000 Binary files a/core/img/filetypes/application-mspowerpoint.png and /dev/null differ diff --git a/core/img/filetypes/application-msword.png b/core/img/filetypes/application-msword.png deleted file mode 100644 index ae8ecbf476..0000000000 Binary files a/core/img/filetypes/application-msword.png and /dev/null differ diff --git a/core/img/filetypes/application-pdf.png b/core/img/filetypes/application-pdf.png index 8f8095e46f..a9ab6d279b 100644 Binary files a/core/img/filetypes/application-pdf.png and b/core/img/filetypes/application-pdf.png differ diff --git a/core/img/filetypes/application-pdf.svg b/core/img/filetypes/application-pdf.svg new file mode 100644 index 0000000000..47c2caabda --- /dev/null +++ b/core/img/filetypes/application-pdf.svg @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/application-rss+xml.png b/core/img/filetypes/application-rss+xml.png index 315c4f4fa6..e5bb322c57 100644 Binary files a/core/img/filetypes/application-rss+xml.png and b/core/img/filetypes/application-rss+xml.png differ diff --git a/core/img/filetypes/application-rss+xml.svg b/core/img/filetypes/application-rss+xml.svg new file mode 100644 index 0000000000..4fd98545a7 --- /dev/null +++ b/core/img/filetypes/application-rss+xml.svg @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/application-sgf.png b/core/img/filetypes/application-sgf.png deleted file mode 100644 index 48996c5439..0000000000 Binary files a/core/img/filetypes/application-sgf.png and /dev/null differ diff --git a/core/img/filetypes/application-vnd.oasis.opendocument.formula.png b/core/img/filetypes/application-vnd.oasis.opendocument.formula.png deleted file mode 100644 index e0cf49542d..0000000000 Binary files a/core/img/filetypes/application-vnd.oasis.opendocument.formula.png and /dev/null differ diff --git a/core/img/filetypes/application-vnd.oasis.opendocument.graphics.png b/core/img/filetypes/application-vnd.oasis.opendocument.graphics.png deleted file mode 100644 index b326a0543a..0000000000 Binary files a/core/img/filetypes/application-vnd.oasis.opendocument.graphics.png and /dev/null differ diff --git a/core/img/filetypes/application-vnd.oasis.opendocument.presentation.png b/core/img/filetypes/application-vnd.oasis.opendocument.presentation.png deleted file mode 100644 index 7c6fd24684..0000000000 Binary files a/core/img/filetypes/application-vnd.oasis.opendocument.presentation.png and /dev/null differ diff --git a/core/img/filetypes/application-vnd.oasis.opendocument.spreadsheet.png b/core/img/filetypes/application-vnd.oasis.opendocument.spreadsheet.png deleted file mode 100644 index 8b0e85b067..0000000000 Binary files a/core/img/filetypes/application-vnd.oasis.opendocument.spreadsheet.png and /dev/null differ diff --git a/core/img/filetypes/application-vnd.oasis.opendocument.text.png b/core/img/filetypes/application-vnd.oasis.opendocument.text.png deleted file mode 100644 index 48452eb3e8..0000000000 Binary files a/core/img/filetypes/application-vnd.oasis.opendocument.text.png and /dev/null differ diff --git a/core/img/filetypes/application-x-7z-compressed.png b/core/img/filetypes/application-x-7z-compressed.png deleted file mode 100644 index 2cd08aebf9..0000000000 Binary files a/core/img/filetypes/application-x-7z-compressed.png and /dev/null differ diff --git a/core/img/filetypes/application-x-bzip-compressed-tar.png b/core/img/filetypes/application-x-bzip-compressed-tar.png deleted file mode 100644 index 2cd08aebf9..0000000000 Binary files a/core/img/filetypes/application-x-bzip-compressed-tar.png and /dev/null differ diff --git a/core/img/filetypes/application-x-bzip.png b/core/img/filetypes/application-x-bzip.png deleted file mode 100644 index 2cd08aebf9..0000000000 Binary files a/core/img/filetypes/application-x-bzip.png and /dev/null differ diff --git a/core/img/filetypes/application-x-compressed-tar.png b/core/img/filetypes/application-x-compressed-tar.png deleted file mode 100644 index 2cd08aebf9..0000000000 Binary files a/core/img/filetypes/application-x-compressed-tar.png and /dev/null differ diff --git a/core/img/filetypes/application-x-deb.png b/core/img/filetypes/application-x-deb.png deleted file mode 100644 index 2cd08aebf9..0000000000 Binary files a/core/img/filetypes/application-x-deb.png and /dev/null differ diff --git a/core/img/filetypes/application-x-debian-package.png b/core/img/filetypes/application-x-debian-package.png deleted file mode 100644 index 1d6db5f933..0000000000 Binary files a/core/img/filetypes/application-x-debian-package.png and /dev/null differ diff --git a/core/img/filetypes/application-x-gzip.png b/core/img/filetypes/application-x-gzip.png deleted file mode 100644 index 2cd08aebf9..0000000000 Binary files a/core/img/filetypes/application-x-gzip.png and /dev/null differ diff --git a/core/img/filetypes/application-x-lzma-compressed-tar.png b/core/img/filetypes/application-x-lzma-compressed-tar.png deleted file mode 100644 index 2cd08aebf9..0000000000 Binary files a/core/img/filetypes/application-x-lzma-compressed-tar.png and /dev/null differ diff --git a/core/img/filetypes/application-x-rar.png b/core/img/filetypes/application-x-rar.png deleted file mode 100644 index 2cd08aebf9..0000000000 Binary files a/core/img/filetypes/application-x-rar.png and /dev/null differ diff --git a/core/img/filetypes/application-x-rpm.png b/core/img/filetypes/application-x-rpm.png deleted file mode 100644 index 2cd08aebf9..0000000000 Binary files a/core/img/filetypes/application-x-rpm.png and /dev/null differ diff --git a/core/img/filetypes/application-x-tar.png b/core/img/filetypes/application-x-tar.png deleted file mode 100644 index 2cd08aebf9..0000000000 Binary files a/core/img/filetypes/application-x-tar.png and /dev/null differ diff --git a/core/img/filetypes/application-x-tarz.png b/core/img/filetypes/application-x-tarz.png deleted file mode 100644 index 2cd08aebf9..0000000000 Binary files a/core/img/filetypes/application-x-tarz.png and /dev/null differ diff --git a/core/img/filetypes/application-zip.png b/core/img/filetypes/application-zip.png deleted file mode 100644 index 2cd08aebf9..0000000000 Binary files a/core/img/filetypes/application-zip.png and /dev/null differ diff --git a/core/img/filetypes/application.png b/core/img/filetypes/application.png index 1dee9e3660..9152cc1b74 100644 Binary files a/core/img/filetypes/application.png and b/core/img/filetypes/application.png differ diff --git a/core/img/filetypes/application.svg b/core/img/filetypes/application.svg new file mode 100644 index 0000000000..870a4ac246 --- /dev/null +++ b/core/img/filetypes/application.svg @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/audio.png b/core/img/filetypes/audio.png index a8b3ede3df..3f56a7e2a9 100644 Binary files a/core/img/filetypes/audio.png and b/core/img/filetypes/audio.png differ diff --git a/core/img/filetypes/audio.svg b/core/img/filetypes/audio.svg new file mode 100644 index 0000000000..d5eda38e8a --- /dev/null +++ b/core/img/filetypes/audio.svg @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/calendar.png b/core/img/filetypes/calendar.png new file mode 100644 index 0000000000..d85b1db651 Binary files /dev/null and b/core/img/filetypes/calendar.png differ diff --git a/core/img/filetypes/calendar.svg b/core/img/filetypes/calendar.svg new file mode 100644 index 0000000000..0016749b93 --- /dev/null +++ b/core/img/filetypes/calendar.svg @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/code-script.png b/core/img/filetypes/code-script.png deleted file mode 100644 index 63fe6ceff5..0000000000 Binary files a/core/img/filetypes/code-script.png and /dev/null differ diff --git a/core/img/filetypes/code.png b/core/img/filetypes/code.png deleted file mode 100644 index 0c76bd1297..0000000000 Binary files a/core/img/filetypes/code.png and /dev/null differ diff --git a/core/img/filetypes/database.png b/core/img/filetypes/database.png index 3d09261a26..24788b2a37 100644 Binary files a/core/img/filetypes/database.png and b/core/img/filetypes/database.png differ diff --git a/core/img/filetypes/database.svg b/core/img/filetypes/database.svg new file mode 100644 index 0000000000..6dfac54e68 --- /dev/null +++ b/core/img/filetypes/database.svg @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/core/img/filetypes/file.png b/core/img/filetypes/file.png index 8b8b1ca000..c20f13c2e1 100644 Binary files a/core/img/filetypes/file.png and b/core/img/filetypes/file.png differ diff --git a/core/img/filetypes/file.svg b/core/img/filetypes/file.svg new file mode 100644 index 0000000000..3d91c34114 --- /dev/null +++ b/core/img/filetypes/file.svg @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/flash.png b/core/img/filetypes/flash.png index 9f5db634a4..bcde641da3 100644 Binary files a/core/img/filetypes/flash.png and b/core/img/filetypes/flash.png differ diff --git a/core/img/filetypes/flash.svg b/core/img/filetypes/flash.svg new file mode 100644 index 0000000000..cb823703d9 --- /dev/null +++ b/core/img/filetypes/flash.svg @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/folder-drag-accept.png b/core/img/filetypes/folder-drag-accept.png new file mode 100644 index 0000000000..19c2d2eebd Binary files /dev/null and b/core/img/filetypes/folder-drag-accept.png differ diff --git a/core/img/filetypes/folder-drag-accept.svg b/core/img/filetypes/folder-drag-accept.svg new file mode 100644 index 0000000000..a7885c80be --- /dev/null +++ b/core/img/filetypes/folder-drag-accept.svg @@ -0,0 +1,335 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/folder-external.png b/core/img/filetypes/folder-external.png new file mode 100644 index 0000000000..997f07b2ba Binary files /dev/null and b/core/img/filetypes/folder-external.png differ diff --git a/core/img/filetypes/folder-external.svg b/core/img/filetypes/folder-external.svg new file mode 100644 index 0000000000..89ec9a8eca --- /dev/null +++ b/core/img/filetypes/folder-external.svg @@ -0,0 +1,68 @@ + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/folder-public.png b/core/img/filetypes/folder-public.png new file mode 100644 index 0000000000..c716607e26 Binary files /dev/null and b/core/img/filetypes/folder-public.png differ diff --git a/core/img/filetypes/folder-public.svg b/core/img/filetypes/folder-public.svg new file mode 100644 index 0000000000..a949833f95 --- /dev/null +++ b/core/img/filetypes/folder-public.svg @@ -0,0 +1,68 @@ + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/folder-shared.png b/core/img/filetypes/folder-shared.png new file mode 100644 index 0000000000..e547a24206 Binary files /dev/null and b/core/img/filetypes/folder-shared.png differ diff --git a/core/img/filetypes/folder-shared.svg b/core/img/filetypes/folder-shared.svg new file mode 100644 index 0000000000..56aa9634d2 --- /dev/null +++ b/core/img/filetypes/folder-shared.svg @@ -0,0 +1,68 @@ + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/folder.png b/core/img/filetypes/folder.png index 784e8fa482..b7be63d583 100644 Binary files a/core/img/filetypes/folder.png and b/core/img/filetypes/folder.png differ diff --git a/core/img/filetypes/folder.svg b/core/img/filetypes/folder.svg new file mode 100644 index 0000000000..92d4cc2271 --- /dev/null +++ b/core/img/filetypes/folder.svg @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/font.png b/core/img/filetypes/font.png index 81e41de7d3..9404c3ca6a 100644 Binary files a/core/img/filetypes/font.png and b/core/img/filetypes/font.png differ diff --git a/core/img/filetypes/font.svg b/core/img/filetypes/font.svg new file mode 100644 index 0000000000..8fca5ff9ef --- /dev/null +++ b/core/img/filetypes/font.svg @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/image-svg+xml.png b/core/img/filetypes/image-svg+xml.png index a1291c2dfa..e3dd52489d 100644 Binary files a/core/img/filetypes/image-svg+xml.png and b/core/img/filetypes/image-svg+xml.png differ diff --git a/core/img/filetypes/image-svg+xml.svg b/core/img/filetypes/image-svg+xml.svg new file mode 100644 index 0000000000..06df5f54da --- /dev/null +++ b/core/img/filetypes/image-svg+xml.svg @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/image.png b/core/img/filetypes/image.png index 4a158fef7e..087f5dcdbd 100644 Binary files a/core/img/filetypes/image.png and b/core/img/filetypes/image.png differ diff --git a/core/img/filetypes/image.svg b/core/img/filetypes/image.svg new file mode 100644 index 0000000000..50991f7359 --- /dev/null +++ b/core/img/filetypes/image.svg @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/link.png b/core/img/filetypes/link.png deleted file mode 100644 index 68f21d3011..0000000000 Binary files a/core/img/filetypes/link.png and /dev/null differ diff --git a/core/img/filetypes/model.png b/core/img/filetypes/model.png deleted file mode 100644 index 7851cf34c9..0000000000 Binary files a/core/img/filetypes/model.png and /dev/null differ diff --git a/core/img/filetypes/ms-excel.png b/core/img/filetypes/ms-excel.png deleted file mode 100644 index b977d7e52e..0000000000 Binary files a/core/img/filetypes/ms-excel.png and /dev/null differ diff --git a/core/img/filetypes/ms-powerpoint.png b/core/img/filetypes/ms-powerpoint.png deleted file mode 100644 index c4eff0387d..0000000000 Binary files a/core/img/filetypes/ms-powerpoint.png and /dev/null differ diff --git a/core/img/filetypes/package-x-generic.png b/core/img/filetypes/package-x-generic.png new file mode 100644 index 0000000000..e08cc5480c Binary files /dev/null and b/core/img/filetypes/package-x-generic.png differ diff --git a/core/img/filetypes/package-x-generic.svg b/core/img/filetypes/package-x-generic.svg new file mode 100644 index 0000000000..13ab5b7550 --- /dev/null +++ b/core/img/filetypes/package-x-generic.svg @@ -0,0 +1,62 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/presentation.png b/core/img/filetypes/presentation.png deleted file mode 100644 index b4aaad9a45..0000000000 Binary files a/core/img/filetypes/presentation.png and /dev/null differ diff --git a/core/img/filetypes/readme-2.txt b/core/img/filetypes/readme-2.txt deleted file mode 100644 index 5a606f9a0b..0000000000 --- a/core/img/filetypes/readme-2.txt +++ /dev/null @@ -1,28 +0,0 @@ -15.02.2012 - -Following new icons have been added: -core/img/filetypes/application-vnd.oasis.opendocument.formula.png -core/img/filetypes/application-vnd.oasis.opendocument.graphics.png -core/img/filetypes/application-vnd.oasis.opendocument.presentation.png -core/img/filetypes/application-vnd.oasis.opendocument.spreadsheet.png -core/img/filetypes/application-vnd.oasis.opendocument.text.png - Download: http://odftoolkit.org/ODF-Icons#ODF_Icons - License: Apache 2.0 - -core/img/filetypes/application-x-7z-compressed.png -core/img/filetypes/application-x-bzip-compressed-tar.png -core/img/filetypes/application-x-bzip.png -core/img/filetypes/application-x-compressed-tar.png -core/img/filetypes/application-x-deb.png -core/img/filetypes/application-x-debian-package.png -core/img/filetypes/application-x-gzip.png -core/img/filetypes/application-x-lzma-compressed-tar.png -core/img/filetypes/application-x-rar.png -core/img/filetypes/application-x-rpm.png -core/img/filetypes/application-x-tar.png -core/img/filetypes/application-x-tarz.png -core/img/filetypes/application-zip.png - Author: Gomez Hyuuga - License: Creative Commons Attribution-Share Alike 3.0 Unported License - Download: http://kde-look.org/content/show.php/?content=101767 - diff --git a/core/img/filetypes/readme.txt b/core/img/filetypes/readme.txt deleted file mode 100644 index 400a64d785..0000000000 --- a/core/img/filetypes/readme.txt +++ /dev/null @@ -1,22 +0,0 @@ -Silk icon set 1.3 - -_________________________________________ -Mark James -http://www.famfamfam.com/lab/icons/silk/ -_________________________________________ - -This work is licensed under a -Creative Commons Attribution 2.5 License. -[ http://creativecommons.org/licenses/by/2.5/ ] - -This means you may use it for any purpose, -and make any changes you like. -All I ask is that you include a link back -to this page in your credits. - -Are you using this icon set? Send me an email -(including a link or picture if available) to -mjames@gmail.com - -Any other questions about this icon set please -contact mjames@gmail.com \ No newline at end of file diff --git a/core/img/filetypes/ruby.png b/core/img/filetypes/ruby.png deleted file mode 100644 index f59b7c4365..0000000000 Binary files a/core/img/filetypes/ruby.png and /dev/null differ diff --git a/core/img/filetypes/spreadsheet.png b/core/img/filetypes/spreadsheet.png deleted file mode 100644 index abcd93689a..0000000000 Binary files a/core/img/filetypes/spreadsheet.png and /dev/null differ diff --git a/core/img/filetypes/text-calendar.png b/core/img/filetypes/text-calendar.png deleted file mode 100644 index 658913852d..0000000000 Binary files a/core/img/filetypes/text-calendar.png and /dev/null differ diff --git a/core/img/filetypes/text-code.png b/core/img/filetypes/text-code.png new file mode 100644 index 0000000000..753d151f53 Binary files /dev/null and b/core/img/filetypes/text-code.png differ diff --git a/core/img/filetypes/text-code.svg b/core/img/filetypes/text-code.svg new file mode 100644 index 0000000000..61a5c19f51 --- /dev/null +++ b/core/img/filetypes/text-code.svg @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/text-css.png b/core/img/filetypes/text-css.png deleted file mode 100644 index 23f3101811..0000000000 Binary files a/core/img/filetypes/text-css.png and /dev/null differ diff --git a/core/img/filetypes/text-html.png b/core/img/filetypes/text-html.png index 55d1072eaf..dd17b75010 100644 Binary files a/core/img/filetypes/text-html.png and b/core/img/filetypes/text-html.png differ diff --git a/core/img/filetypes/text-html.svg b/core/img/filetypes/text-html.svg new file mode 100644 index 0000000000..c41964738d --- /dev/null +++ b/core/img/filetypes/text-html.svg @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/text-vcard.png b/core/img/filetypes/text-vcard.png index c02f315d20..2e52d1ecb3 100644 Binary files a/core/img/filetypes/text-vcard.png and b/core/img/filetypes/text-vcard.png differ diff --git a/core/img/filetypes/text-vcard.svg b/core/img/filetypes/text-vcard.svg new file mode 100644 index 0000000000..27054be57e --- /dev/null +++ b/core/img/filetypes/text-vcard.svg @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/text-x-c++.png b/core/img/filetypes/text-x-c++.png deleted file mode 100644 index a87cf847cb..0000000000 Binary files a/core/img/filetypes/text-x-c++.png and /dev/null differ diff --git a/core/img/filetypes/text-x-c.png b/core/img/filetypes/text-x-c.png index 34a05cccf0..b9edd1e866 100644 Binary files a/core/img/filetypes/text-x-c.png and b/core/img/filetypes/text-x-c.png differ diff --git a/core/img/filetypes/text-x-c.svg b/core/img/filetypes/text-x-c.svg new file mode 100644 index 0000000000..35a6a0cdfe --- /dev/null +++ b/core/img/filetypes/text-x-c.svg @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/text-x-csharp.png b/core/img/filetypes/text-x-csharp.png deleted file mode 100644 index ffb8fc932f..0000000000 Binary files a/core/img/filetypes/text-x-csharp.png and /dev/null differ diff --git a/core/img/filetypes/text-x-h.png b/core/img/filetypes/text-x-h.png index e902abb076..37a8805b50 100644 Binary files a/core/img/filetypes/text-x-h.png and b/core/img/filetypes/text-x-h.png differ diff --git a/core/img/filetypes/text-x-h.svg b/core/img/filetypes/text-x-h.svg new file mode 100644 index 0000000000..38ed04690f --- /dev/null +++ b/core/img/filetypes/text-x-h.svg @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/text-x-javascript.png b/core/img/filetypes/text-x-javascript.png new file mode 100644 index 0000000000..24d09ce978 Binary files /dev/null and b/core/img/filetypes/text-x-javascript.png differ diff --git a/core/img/filetypes/text-x-javascript.svg b/core/img/filetypes/text-x-javascript.svg new file mode 100644 index 0000000000..0cc52ce6ba --- /dev/null +++ b/core/img/filetypes/text-x-javascript.svg @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/text-x-php.png b/core/img/filetypes/text-x-php.png deleted file mode 100644 index 7868a25945..0000000000 Binary files a/core/img/filetypes/text-x-php.png and /dev/null differ diff --git a/core/img/filetypes/text-x-python.png b/core/img/filetypes/text-x-python.png new file mode 100644 index 0000000000..57148f4b90 Binary files /dev/null and b/core/img/filetypes/text-x-python.png differ diff --git a/core/img/filetypes/text-x-python.svg b/core/img/filetypes/text-x-python.svg new file mode 100644 index 0000000000..00755e6d0c --- /dev/null +++ b/core/img/filetypes/text-x-python.svg @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/text.png b/core/img/filetypes/text.png index 813f712f72..6b069c82c1 100644 Binary files a/core/img/filetypes/text.png and b/core/img/filetypes/text.png differ diff --git a/core/img/filetypes/text.svg b/core/img/filetypes/text.svg new file mode 100644 index 0000000000..69a1bcd98c --- /dev/null +++ b/core/img/filetypes/text.svg @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/video.png b/core/img/filetypes/video.png index b0ce7bb198..045754df26 100644 Binary files a/core/img/filetypes/video.png and b/core/img/filetypes/video.png differ diff --git a/core/img/filetypes/video.svg b/core/img/filetypes/video.svg new file mode 100644 index 0000000000..67691369ac --- /dev/null +++ b/core/img/filetypes/video.svg @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/web.png b/core/img/filetypes/web.png new file mode 100644 index 0000000000..c380231264 Binary files /dev/null and b/core/img/filetypes/web.png differ diff --git a/core/img/filetypes/web.svg b/core/img/filetypes/web.svg new file mode 100644 index 0000000000..67775a2233 --- /dev/null +++ b/core/img/filetypes/web.svg @@ -0,0 +1,45 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/x-.png b/core/img/filetypes/x-.png deleted file mode 100644 index 8443c23eb9..0000000000 Binary files a/core/img/filetypes/x-.png and /dev/null differ diff --git a/core/img/filetypes/x-office-document.png b/core/img/filetypes/x-office-document.png new file mode 100644 index 0000000000..fcd28e9a29 Binary files /dev/null and b/core/img/filetypes/x-office-document.png differ diff --git a/core/img/filetypes/x-office-document.svg b/core/img/filetypes/x-office-document.svg new file mode 100644 index 0000000000..fc51a3a1b7 --- /dev/null +++ b/core/img/filetypes/x-office-document.svg @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/x-office-presentation.png b/core/img/filetypes/x-office-presentation.png new file mode 100644 index 0000000000..7ee552ba7c Binary files /dev/null and b/core/img/filetypes/x-office-presentation.png differ diff --git a/core/img/filetypes/x-office-presentation.svg b/core/img/filetypes/x-office-presentation.svg new file mode 100644 index 0000000000..821798d50f --- /dev/null +++ b/core/img/filetypes/x-office-presentation.svg @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/x-office-spreadsheet.png b/core/img/filetypes/x-office-spreadsheet.png new file mode 100644 index 0000000000..dfdc74a8bf Binary files /dev/null and b/core/img/filetypes/x-office-spreadsheet.png differ diff --git a/core/img/filetypes/x-office-spreadsheet.svg b/core/img/filetypes/x-office-spreadsheet.svg new file mode 100644 index 0000000000..af40bb252a --- /dev/null +++ b/core/img/filetypes/x-office-spreadsheet.svg @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/routes.php b/core/routes.php index dd8222d437..f0f8ce571e 100644 --- a/core/routes.php +++ b/core/routes.php @@ -42,7 +42,8 @@ $this->create('js_config', '/core/js/config.js') // Routing $this->create('core_ajax_routes', '/core/routes.json') ->action('OC_Router', 'JSRoutes'); - +$this->create('core_ajax_preview', '/core/preview.png') + ->actionInclude('core/ajax/preview.php'); OC::$CLASSPATH['OC_Core_LostPassword_Controller'] = 'core/lostpassword/controller.php'; $this->create('core_lostpassword_index', '/lostpassword/') ->get() diff --git a/db_structure.xml b/db_structure.xml index f926ab44cd..24742c242e 100644 --- a/db_structure.xml +++ b/db_structure.xml @@ -383,7 +383,7 @@ user text - true + false 64 @@ -397,8 +397,6 @@ id_user_index - true - true fileid ascending diff --git a/lib/base.php b/lib/base.php index ef95909a31..b5c12a683f 100644 --- a/lib/base.php +++ b/lib/base.php @@ -492,6 +492,7 @@ class OC { self::registerCacheHooks(); self::registerFilesystemHooks(); + self::registerPreviewHooks(); self::registerShareHooks(); self::registerLogRotate(); @@ -579,6 +580,14 @@ class OC { OC_Hook::connect('OC_Filesystem', 'rename', 'OC_Filesystem', 'isBlacklisted'); } + /** + * register hooks for previews + */ + public static function registerPreviewHooks() { + OC_Hook::connect('OC_Filesystem', 'post_write', 'OC\Preview', 'post_write'); + OC_Hook::connect('OC_Filesystem', 'delete', 'OC\Preview', 'post_delete'); + } + /** * register hooks for sharing */ diff --git a/lib/helper.php b/lib/helper.php index cfb29028ee..5fb8fed345 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -185,7 +185,38 @@ class OC_Helper { * Returns the path to the image of this file type. */ public static function mimetypeIcon($mimetype) { - $alias = array('application/xml' => 'code/xml'); + $alias = array( + 'application/xml' => 'code/xml', + 'application/msword' => 'x-office/document', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'x-office/document', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.template' => 'x-office/document', + 'application/vnd.ms-word.document.macroEnabled.12' => 'x-office/document', + 'application/vnd.ms-word.template.macroEnabled.12' => 'x-office/document', + 'application/vnd.oasis.opendocument.text' => 'x-office/document', + 'application/vnd.oasis.opendocument.text-template' => 'x-office/document', + 'application/vnd.oasis.opendocument.text-web' => 'x-office/document', + 'application/vnd.oasis.opendocument.text-master' => 'x-office/document', + 'application/vnd.ms-powerpoint' => 'x-office/presentation', + 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'x-office/presentation', + 'application/vnd.openxmlformats-officedocument.presentationml.template' => 'x-office/presentation', + 'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => 'x-office/presentation', + 'application/vnd.ms-powerpoint.addin.macroEnabled.12' => 'x-office/presentation', + 'application/vnd.ms-powerpoint.presentation.macroEnabled.12' => 'x-office/presentation', + 'application/vnd.ms-powerpoint.template.macroEnabled.12' => 'x-office/presentation', + 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12' => 'x-office/presentation', + 'application/vnd.oasis.opendocument.presentation' => 'x-office/presentation', + 'application/vnd.oasis.opendocument.presentation-template' => 'x-office/presentation', + 'application/vnd.ms-excel' => 'x-office/spreadsheet', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'x-office/spreadsheet', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.template' => 'x-office/spreadsheet', + 'application/vnd.ms-excel.sheet.macroEnabled.12' => 'x-office/spreadsheet', + 'application/vnd.ms-excel.template.macroEnabled.12' => 'x-office/spreadsheet', + 'application/vnd.ms-excel.addin.macroEnabled.12' => 'x-office/spreadsheet', + 'application/vnd.ms-excel.sheet.binary.macroEnabled.12' => 'x-office/spreadsheet', + 'application/vnd.oasis.opendocument.spreadsheet' => 'x-office/spreadsheet', + 'application/vnd.oasis.opendocument.spreadsheet-template' => 'x-office/spreadsheet', + ); + if (isset($alias[$mimetype])) { $mimetype = $alias[$mimetype]; } @@ -219,6 +250,21 @@ 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' => 36, 'y' => 36, 'file' => urlencode($path) )); + } + + public static function publicPreviewIcon( $path, $token ) { + return self::linkToRoute( 'core_ajax_public_preview', array('x' => 36, 'y' => 36, 'file' => urlencode($path), 't' => $token)); + } + /** * @brief Make a human file size * @param int $bytes file size in bytes diff --git a/lib/image.php b/lib/image.php index fcb13a1fa1..badc30ab9a 100644 --- a/lib/image.php +++ b/lib/image.php @@ -522,6 +522,11 @@ class OC_Image { if (\OC_Util::fileInfoLoaded()) { $this->mimeType = $this->fileInfo->buffer($str); } + if(is_resource($this->resource)) { + imagealphablending($this->resource, false); + imagesavealpha($this->resource, true); + } + if(!$this->resource) { OC_Log::write('core', 'OC_Image->loadFromData, couldn\'t load', OC_Log::DEBUG); return false; diff --git a/lib/preview.php b/lib/preview.php new file mode 100755 index 0000000000..b40ba191fb --- /dev/null +++ b/lib/preview.php @@ -0,0 +1,627 @@ +configMaxX = \OC_Config::getValue('preview_max_x', null); + $this->configMaxY = \OC_Config::getValue('preview_max_y', null); + $this->maxScaleFactor = \OC_Config::getValue('preview_max_scale_factor', 2); + + //save parameters + $this->setFile($file); + $this->setMaxX($maxX); + $this->setMaxY($maxY); + $this->setScalingUp($scalingUp); + + //init fileviews + if($user === ''){ + $user = \OC_User::getUser(); + } + $this->fileView = new \OC\Files\View('/' . $user . '/' . $root); + $this->userView = new \OC\Files\View('/' . $user); + + $this->preview = null; + + //check if there are preview backends + if(empty(self::$providers)) { + self::initProviders(); + } + + if(empty(self::$providers)) { + \OC_Log::write('core', 'No preview providers exist', \OC_Log::ERROR); + throw new \Exception('No preview providers'); + } + } + + /** + * @brief returns the path of the file you want a thumbnail from + * @return string + */ + public function getFile() { + return $this->file; + } + + /** + * @brief returns the max width of the preview + * @return integer + */ + public function getMaxX() { + return $this->maxX; + } + + /** + * @brief returns the max height of the preview + * @return integer + */ + public function getMaxY() { + return $this->maxY; + } + + /** + * @brief returns whether or not scalingup is enabled + * @return bool + */ + public function getScalingUp() { + return $this->scalingup; + } + + /** + * @brief returns the name of the thumbnailfolder + * @return string + */ + public function getThumbnailsFolder() { + return self::THUMBNAILS_FOLDER; + } + + /** + * @brief returns the max scale factor + * @return integer + */ + public function getMaxScaleFactor() { + return $this->maxScaleFactor; + } + + /** + * @brief returns the max width set in ownCloud's config + * @return integer + */ + public function getConfigMaxX() { + return $this->configMaxX; + } + + /** + * @brief returns the max height set in ownCloud's config + * @return integer + */ + public function getConfigMaxY() { + return $this->configMaxY; + } + + /** + * @brief set the path of the file you want a thumbnail from + * @param string $file + * @return $this + */ + public function setFile($file) { + $this->file = $file; + return $this; + } + + /** + * @brief set the the max width of the preview + * @param int $maxX + * @return $this + */ + public function setMaxX($maxX=1) { + if($maxX <= 0) { + throw new \Exception('Cannot set width of 0 or smaller!'); + } + $configMaxX = $this->getConfigMaxX(); + if(!is_null($configMaxX)) { + if($maxX > $configMaxX) { + \OC_Log::write('core', 'maxX reduced from ' . $maxX . ' to ' . $configMaxX, \OC_Log::DEBUG); + $maxX = $configMaxX; + } + } + $this->maxX = $maxX; + return $this; + } + + /** + * @brief set the the max height of the preview + * @param int $maxY + * @return $this + */ + public function setMaxY($maxY=1) { + if($maxY <= 0) { + throw new \Exception('Cannot set height of 0 or smaller!'); + } + $configMaxY = $this->getConfigMaxY(); + if(!is_null($configMaxY)) { + if($maxY > $configMaxY) { + \OC_Log::write('core', 'maxX reduced from ' . $maxY . ' to ' . $configMaxY, \OC_Log::DEBUG); + $maxY = $configMaxY; + } + } + $this->maxY = $maxY; + return $this; + } + + /** + * @brief set whether or not scalingup is enabled + * @param bool $scalingUp + * @return $this + */ + public function setScalingup($scalingUp) { + if($this->getMaxScaleFactor() === 1) { + $scalingUp = false; + } + $this->scalingup = $scalingUp; + return $this; + } + + /** + * @brief check if all parameters are valid + * @return bool + */ + public function isFileValid() { + $file = $this->getFile(); + if($file === '') { + \OC_Log::write('core', 'No filename passed', \OC_Log::DEBUG); + return false; + } + + if(!$this->fileView->file_exists($file)) { + \OC_Log::write('core', 'File:"' . $file . '" not found', \OC_Log::DEBUG); + return false; + } + + return true; + } + + /** + * @brief deletes previews of a file with specific x and y + * @return bool + */ + public function deletePreview() { + $file = $this->getFile(); + + $fileInfo = $this->fileView->getFileInfo($file); + $fileId = $fileInfo['fileid']; + + $previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/' . $this->getMaxX() . '-' . $this->getMaxY() . '.png'; + $this->userView->unlink($previewPath); + return !$this->userView->file_exists($previewPath); + } + + /** + * @brief deletes all previews of a file + * @return bool + */ + public function deleteAllPreviews() { + $file = $this->getFile(); + + $fileInfo = $this->fileView->getFileInfo($file); + $fileId = $fileInfo['fileid']; + + $previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/'; + $this->userView->deleteAll($previewPath); + $this->userView->rmdir($previewPath); + return !$this->userView->is_dir($previewPath); + } + + /** + * @brief check if thumbnail or bigger version of thumbnail of file is cached + * @return mixed (bool / string) + * false if thumbnail does not exist + * path to thumbnail if thumbnail exists + */ + private function isCached() { + $file = $this->getFile(); + $maxX = $this->getMaxX(); + $maxY = $this->getMaxY(); + $scalingUp = $this->getScalingUp(); + $maxScaleFactor = $this->getMaxScaleFactor(); + + $fileInfo = $this->fileView->getFileInfo($file); + $fileId = $fileInfo['fileid']; + + if(is_null($fileId)) { + return false; + } + + $previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/'; + if(!$this->userView->is_dir($previewPath)) { + return false; + } + + //does a preview with the wanted height and width already exist? + if($this->userView->file_exists($previewPath . $maxX . '-' . $maxY . '.png')) { + return $previewPath . $maxX . '-' . $maxY . '.png'; + } + + $wantedAspectRatio = (float) ($maxX / $maxY); + + //array for usable cached thumbnails + $possibleThumbnails = array(); + + $allThumbnails = $this->userView->getDirectoryContent($previewPath); + foreach($allThumbnails as $thumbnail) { + $name = rtrim($thumbnail['name'], '.png'); + $size = explode('-', $name); + $x = (int) $size[0]; + $y = (int) $size[1]; + + $aspectRatio = (float) ($x / $y); + if($aspectRatio !== $wantedAspectRatio) { + continue; + } + + if($x < $maxX || $y < $maxY) { + if($scalingUp) { + $scalefactor = $maxX / $x; + if($scalefactor > $maxScaleFactor) { + continue; + } + }else{ + continue; + } + } + $possibleThumbnails[$x] = $thumbnail['path']; + } + + if(count($possibleThumbnails) === 0) { + return false; + } + + if(count($possibleThumbnails) === 1) { + return current($possibleThumbnails); + } + + ksort($possibleThumbnails); + + if(key(reset($possibleThumbnails)) > $maxX) { + return current(reset($possibleThumbnails)); + } + + if(key(end($possibleThumbnails)) < $maxX) { + return current(end($possibleThumbnails)); + } + + foreach($possibleThumbnails as $width => $path) { + if($width < $maxX) { + continue; + }else{ + return $path; + } + } + } + + /** + * @brief return a preview of a file + * @return \OC_Image + */ + public function getPreview() { + if(!is_null($this->preview) && $this->preview->valid()){ + return $this->preview; + } + + $this->preview = null; + $file = $this->getFile(); + $maxX = $this->getMaxX(); + $maxY = $this->getMaxY(); + $scalingUp = $this->getScalingUp(); + + $fileInfo = $this->fileView->getFileInfo($file); + $fileId = $fileInfo['fileid']; + + $cached = $this->isCached(); + + if($cached) { + $image = new \OC_Image($this->userView->file_get_contents($cached, 'r')); + $this->preview = $image->valid() ? $image : null; + $this->resizeAndCrop(); + } + + if(is_null($this->preview)) { + $mimetype = $this->fileView->getMimeType($file); + $preview = null; + + foreach(self::$providers as $supportedMimetype => $provider) { + if(!preg_match($supportedMimetype, $mimetype)) { + continue; + } + + \OC_Log::write('core', 'Generating preview for "' . $file . '" with "' . get_class($provider) . '"', \OC_Log::DEBUG); + + $preview = $provider->getThumbnail($file, $maxX, $maxY, $scalingUp, $this->fileView); + + if(!($preview instanceof \OC_Image)) { + continue; + } + + $this->preview = $preview; + $this->resizeAndCrop(); + + $previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/'; + $cachePath = $previewPath . $maxX . '-' . $maxY . '.png'; + + if($this->userView->is_dir($this->getThumbnailsFolder() . '/') === false) { + $this->userView->mkdir($this->getThumbnailsFolder() . '/'); + } + + if($this->userView->is_dir($previewPath) === false) { + $this->userView->mkdir($previewPath); + } + + $this->userView->file_put_contents($cachePath, $preview->data()); + + break; + } + } + + if(is_null($this->preview)) { + $this->preview = new \OC_Image(); + } + + return $this->preview; + } + + /** + * @brief show preview + * @return void + */ + public function showPreview() { + \OCP\Response::enableCaching(3600 * 24); // 24 hours + if(is_null($this->preview)) { + $this->getPreview(); + } + $this->preview->show(); + return; + } + + /** + * @brief show preview + * @return void + */ + public function show() { + $this->showPreview(); + return; + } + + /** + * @brief resize, crop and fix orientation + * @return void + */ + private function resizeAndCrop() { + $image = $this->preview; + $x = $this->getMaxX(); + $y = $this->getMaxY(); + $scalingUp = $this->getScalingUp(); + $maxscalefactor = $this->getMaxScaleFactor(); + + if(!($image instanceof \OC_Image)) { + \OC_Log::write('core', '$this->preview is not an instance of OC_Image', \OC_Log::DEBUG); + return; + } + + $image->fixOrientation(); + + $realx = (int) $image->width(); + $realy = (int) $image->height(); + + if($x === $realx && $y === $realy) { + $this->preview = $image; + return; + } + + $factorX = $x / $realx; + $factorY = $y / $realy; + + if($factorX >= $factorY) { + $factor = $factorX; + }else{ + $factor = $factorY; + } + + if($scalingUp === false) { + if($factor > 1) { + $factor = 1; + } + } + + if(!is_null($maxscalefactor)) { + if($factor > $maxscalefactor) { + \OC_Log::write('core', 'scalefactor reduced from ' . $factor . ' to ' . $maxscalefactor, \OC_Log::DEBUG); + $factor = $maxscalefactor; + } + } + + $newXsize = (int) ($realx * $factor); + $newYsize = (int) ($realy * $factor); + + $image->preciseResize($newXsize, $newYsize); + + if($newXsize === $x && $newYsize === $y) { + $this->preview = $image; + return; + } + + if($newXsize >= $x && $newYsize >= $y) { + $cropX = floor(abs($x - $newXsize) * 0.5); + //don't crop previews on the Y axis, this sucks if it's a document. + //$cropY = floor(abs($y - $newYsize) * 0.5); + $cropY = 0; + + $image->crop($cropX, $cropY, $x, $y); + + $this->preview = $image; + return; + } + + if($newXsize < $x || $newYsize < $y) { + if($newXsize > $x) { + $cropX = floor(($newXsize - $x) * 0.5); + $image->crop($cropX, 0, $x, $newYsize); + } + + if($newYsize > $y) { + $cropY = floor(($newYsize - $y) * 0.5); + $image->crop(0, $cropY, $newXsize, $y); + } + + $newXsize = (int) $image->width(); + $newYsize = (int) $image->height(); + + //create transparent background layer + $backgroundlayer = imagecreatetruecolor($x, $y); + $white = imagecolorallocate($backgroundlayer, 255, 255, 255); + imagefill($backgroundlayer, 0, 0, $white); + + $image = $image->resource(); + + $mergeX = floor(abs($x - $newXsize) * 0.5); + $mergeY = floor(abs($y - $newYsize) * 0.5); + + imagecopy($backgroundlayer, $image, $mergeX, $mergeY, 0, 0, $newXsize, $newYsize); + + //$black = imagecolorallocate(0,0,0); + //imagecolortransparent($transparentlayer, $black); + + $image = new \OC_Image($backgroundlayer); + + $this->preview = $image; + return; + } + } + + /** + * @brief register a new preview provider to be used + * @param string $provider class name of a Preview_Provider + * @param array $options + * @return void + */ + public static function registerProvider($class, $options=array()) { + self::$registeredProviders[]=array('class'=>$class, 'options'=>$options); + } + + /** + * @brief create instances of all the registered preview providers + * @return void + */ + private static function initProviders() { + if(!\OC_Config::getValue('enable_previews', true)) { + $provider = new Preview\Unknown(array()); + self::$providers = array($provider->getMimeType() => $provider); + return; + } + + if(count(self::$providers)>0) { + return; + } + + foreach(self::$registeredProviders as $provider) { + $class=$provider['class']; + $options=$provider['options']; + + $object = new $class($options); + + self::$providers[$object->getMimeType()] = $object; + } + + $keys = array_map('strlen', array_keys(self::$providers)); + array_multisort($keys, SORT_DESC, self::$providers); + } + + public static function post_write($args) { + self::post_delete($args); + } + + public static function post_delete($args) { + $path = $args['path']; + if(substr($path, 0, 1) === '/') { + $path = substr($path, 1); + } + $preview = new Preview(\OC_User::getUser(), 'files/', $path); + $preview->deleteAllPreviews(); + } + + public static function isMimeSupported($mimetype) { + if(!\OC_Config::getValue('enable_previews', true)) { + return false; + } + + //check if there are preview backends + if(empty(self::$providers)) { + self::initProviders(); + } + + //remove last element because it has the mimetype * + $providers = array_slice(self::$providers, 0, -1); + foreach($providers as $supportedMimetype => $provider) { + if(preg_match($supportedMimetype, $mimetype)) { + return true; + } + } + return false; + } +} \ No newline at end of file diff --git a/lib/preview/image.php b/lib/preview/image.php new file mode 100644 index 0000000000..9aec967282 --- /dev/null +++ b/lib/preview/image.php @@ -0,0 +1,36 @@ +getFileInfo($path); + if(!$fileInfo) { + return false; + } + + //check if file is encrypted + if($fileInfo['encrypted'] === true) { + $image = new \OC_Image(stream_get_contents($fileview->fopen($path, 'r'))); + }else{ + $image = new \OC_Image(); + $image->loadFromFile($fileview->getLocalFile($path)); + } + + return $image->valid() ? $image : false; + } +} + +\OC\Preview::registerProvider('OC\Preview\Image'); \ No newline at end of file diff --git a/lib/preview/movies.php b/lib/preview/movies.php new file mode 100644 index 0000000000..e2a1b8eddd --- /dev/null +++ b/lib/preview/movies.php @@ -0,0 +1,47 @@ +fopen($path, 'rb'); + + $firstmb = stream_get_contents($handle, 1048576); //1024 * 1024 = 1048576 + file_put_contents($absPath, $firstmb); + + //$cmd = 'ffmpeg -y -i ' . escapeshellarg($absPath) . ' -f mjpeg -vframes 1 -ss 1 -s ' . escapeshellarg($maxX) . 'x' . escapeshellarg($maxY) . ' ' . $tmpPath; + $cmd = 'ffmpeg -an -y -i ' . escapeshellarg($absPath) . ' -f mjpeg -vframes 1 -ss 1 ' . escapeshellarg($tmpPath); + + shell_exec($cmd); + + $image = new \OC_Image($tmpPath); + + unlink($absPath); + unlink($tmpPath); + + return $image->valid() ? $image : false; + } + } + + \OC\Preview::registerProvider('OC\Preview\Movie'); +} \ No newline at end of file diff --git a/lib/preview/mp3.php b/lib/preview/mp3.php new file mode 100644 index 0000000000..1eed566315 --- /dev/null +++ b/lib/preview/mp3.php @@ -0,0 +1,48 @@ +toTmpFile($path); + + $tags = $getID3->analyze($tmpPath); + \getid3_lib::CopyTagsToComments($tags); + if(isset($tags['id3v2']['APIC'][0]['data'])) { + $picture = @$tags['id3v2']['APIC'][0]['data']; + unlink($tmpPath); + $image = new \OC_Image($picture); + return $image->valid() ? $image : $this->getNoCoverThumbnail(); + } + + return $this->getNoCoverThumbnail(); + } + + private function getNoCoverThumbnail() { + $icon = \OC::$SERVERROOT . '/core/img/filetypes/audio.png'; + + if(!file_exists($icon)) { + return false; + } + + $image = new \OC_Image($icon); + return $image->valid() ? $image : false; + } + +} + +\OC\Preview::registerProvider('OC\Preview\MP3'); \ No newline at end of file diff --git a/lib/preview/office-cl.php b/lib/preview/office-cl.php new file mode 100644 index 0000000000..112909d652 --- /dev/null +++ b/lib/preview/office-cl.php @@ -0,0 +1,134 @@ +initCmd(); + if(is_null($this->cmd)) { + return false; + } + + $absPath = $fileview->toTmpFile($path); + + $tmpDir = get_temp_dir(); + + $defaultParameters = ' --headless --nologo --nofirststartwizard --invisible --norestore -convert-to pdf -outdir '; + $clParameters = \OCP\Config::getSystemValue('preview_office_cl_parameters', $defaultParameters); + + $exec = $this->cmd . $clParameters . escapeshellarg($tmpDir) . ' ' . escapeshellarg($absPath); + $export = 'export HOME=/' . $tmpDir; + + shell_exec($export . "\n" . $exec); + + //create imagick object from pdf + try{ + $pdf = new \imagick($absPath . '.pdf' . '[0]'); + $pdf->setImageFormat('jpg'); + } catch (\Exception $e) { + unlink($absPath); + unlink($absPath . '.pdf'); + \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); + return false; + } + + $image = new \OC_Image($pdf); + + unlink($absPath); + unlink($absPath . '.pdf'); + + return $image->valid() ? $image : false; + } + + private function initCmd() { + $cmd = ''; + + if(is_string(\OC_Config::getValue('preview_libreoffice_path', null))) { + $cmd = \OC_Config::getValue('preview_libreoffice_path', null); + } + + $whichLibreOffice = shell_exec('which libreoffice'); + if($cmd === '' && !empty($whichLibreOffice)) { + $cmd = 'libreoffice'; + } + + $whichOpenOffice = shell_exec('which openoffice'); + if($cmd === '' && !empty($whichOpenOffice)) { + $cmd = 'openoffice'; + } + + if($cmd === '') { + $cmd = null; + } + + $this->cmd = $cmd; + } +} + +//.doc, .dot +class MSOfficeDoc extends Office { + + public function getMimeType() { + return '/application\/msword/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\MSOfficeDoc'); + +//.docm, .dotm, .xls(m), .xlt(m), .xla(m), .ppt(m), .pot(m), .pps(m), .ppa(m) +class MSOffice2003 extends Office { + + public function getMimeType() { + return '/application\/vnd.ms-.*/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\MSOffice2003'); + +//.docx, .dotx, .xlsx, .xltx, .pptx, .potx, .ppsx +class MSOffice2007 extends Office { + + public function getMimeType() { + return '/application\/vnd.openxmlformats-officedocument.*/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\MSOffice2007'); + +//.odt, .ott, .oth, .odm, .odg, .otg, .odp, .otp, .ods, .ots, .odc, .odf, .odb, .odi, .oxt +class OpenDocument extends Office { + + public function getMimeType() { + return '/application\/vnd.oasis.opendocument.*/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\OpenDocument'); + +//.sxw, .stw, .sxc, .stc, .sxd, .std, .sxi, .sti, .sxg, .sxm +class StarOffice extends Office { + + public function getMimeType() { + return '/application\/vnd.sun.xml.*/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\StarOffice'); \ No newline at end of file diff --git a/lib/preview/office-fallback.php b/lib/preview/office-fallback.php new file mode 100644 index 0000000000..e69ab0ab8c --- /dev/null +++ b/lib/preview/office-fallback.php @@ -0,0 +1,142 @@ +toTmpFile($path); + + $transformdoc = new \TransformDoc(); + $transformdoc->setStrFile($tmpDoc); + $transformdoc->generatePDF($tmpDoc); + + $pdf = new \imagick($tmpDoc . '[0]'); + $pdf->setImageFormat('jpg'); + + unlink($tmpDoc); + + $image = new \OC_Image($pdf); + + return $image->valid() ? $image : false; + } + +} + +\OC\Preview::registerProvider('OC\Preview\DOCX'); + +class MSOfficeExcel extends Provider { + + public function getMimeType() { + return null; + } + + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { + require_once('PHPExcel/Classes/PHPExcel.php'); + require_once('PHPExcel/Classes/PHPExcel/IOFactory.php'); + + $absPath = $fileview->toTmpFile($path); + $tmpPath = \OC_Helper::tmpFile(); + + $rendererName = \PHPExcel_Settings::PDF_RENDERER_DOMPDF; + $rendererLibraryPath = \OC::$THIRDPARTYROOT . '/3rdparty/dompdf'; + + \PHPExcel_Settings::setPdfRenderer($rendererName, $rendererLibraryPath); + + $phpexcel = new \PHPExcel($absPath); + $excel = \PHPExcel_IOFactory::createWriter($phpexcel, 'PDF'); + $excel->save($tmpPath); + + $pdf = new \imagick($tmpPath . '[0]'); + $pdf->setImageFormat('jpg'); + + unlink($absPath); + unlink($tmpPath); + + $image = new \OC_Image($pdf); + + return $image->valid() ? $image : false; + } + +} + +class XLS extends MSOfficeExcel { + + public function getMimeType() { + return '/application\/vnd.ms-excel/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\XLS'); + +class XLSX extends MSOfficeExcel { + + public function getMimeType() { + return '/application\/vnd.openxmlformats-officedocument.spreadsheetml.sheet/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\XLSX'); + +/* //There is no (good) php-only solution for converting powerpoint documents to pdfs / pngs ... +class MSOfficePowerPoint extends Provider { + + public function getMimeType() { + return null; + } + + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { + return false; + } + +} + +class PPT extends MSOfficePowerPoint { + + public function getMimeType() { + return '/application\/vnd.ms-powerpoint/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\PPT'); + +class PPTX extends MSOfficePowerPoint { + + public function getMimeType() { + return '/application\/vnd.openxmlformats-officedocument.presentationml.presentation/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\PPTX'); +*/ \ No newline at end of file diff --git a/lib/preview/office.php b/lib/preview/office.php new file mode 100644 index 0000000000..5287bbd6ac --- /dev/null +++ b/lib/preview/office.php @@ -0,0 +1,22 @@ +toTmpFile($path); + + //create imagick object from pdf + try{ + $pdf = new \imagick($tmpPath . '[0]'); + $pdf->setImageFormat('jpg'); + } catch (\Exception $e) { + \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); + return false; + } + + unlink($tmpPath); + + //new image object + $image = new \OC_Image($pdf); + //check if image object is valid + return $image->valid() ? $image : false; + } + } + + \OC\Preview::registerProvider('OC\Preview\PDF'); +} diff --git a/lib/preview/provider.php b/lib/preview/provider.php new file mode 100644 index 0000000000..e4a730bafc --- /dev/null +++ b/lib/preview/provider.php @@ -0,0 +1,19 @@ +options=$options; + } + + abstract public function getMimeType(); + + /** + * search for $query + * @param string $query + * @return + */ + abstract public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview); +} diff --git a/lib/preview/svg.php b/lib/preview/svg.php new file mode 100644 index 0000000000..b49e51720f --- /dev/null +++ b/lib/preview/svg.php @@ -0,0 +1,46 @@ +setBackgroundColor(new \ImagickPixel('transparent')); + + $content = stream_get_contents($fileview->fopen($path, 'r')); + if(substr($content, 0, 5) !== '' . $content; + } + + $svg->readImageBlob($content); + $svg->setImageFormat('png32'); + } catch (\Exception $e) { + \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); + return false; + } + + + //new image object + $image = new \OC_Image(); + $image->loadFromData($svg); + //check if image object is valid + return $image->valid() ? $image : false; + } + } + + \OC\Preview::registerProvider('OC\Preview\SVG'); + +} \ No newline at end of file diff --git a/lib/preview/txt.php b/lib/preview/txt.php new file mode 100644 index 0000000000..a487330691 --- /dev/null +++ b/lib/preview/txt.php @@ -0,0 +1,73 @@ +fopen($path, 'r'); + $content = stream_get_contents($content); + + //don't create previews of empty text files + if(trim($content) === '') { + return false; + } + + $lines = preg_split("/\r\n|\n|\r/", $content); + + $fontSize = 5; //5px + $lineSize = ceil($fontSize * 1.25); + + $image = imagecreate($maxX, $maxY); + imagecolorallocate($image, 255, 255, 255); + $textColor = imagecolorallocate($image, 0, 0, 0); + + foreach($lines as $index => $line) { + $index = $index + 1; + + $x = (int) 1; + $y = (int) ($index * $lineSize) - $fontSize; + + imagestring($image, 1, $x, $y, $line, $textColor); + + if(($index * $lineSize) >= $maxY) { + break; + } + } + + $image = new \OC_Image($image); + + return $image->valid() ? $image : false; + } +} + +\OC\Preview::registerProvider('OC\Preview\TXT'); + +class PHP extends TXT { + + public function getMimeType() { + return '/application\/x-php/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\PHP'); + +class JavaScript extends TXT { + + public function getMimeType() { + return '/application\/javascript/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\JavaScript'); \ No newline at end of file diff --git a/lib/preview/unknown.php b/lib/preview/unknown.php new file mode 100644 index 0000000000..9e6cd68d40 --- /dev/null +++ b/lib/preview/unknown.php @@ -0,0 +1,27 @@ +getMimeType($path); + + $path = \OC_Helper::mimetypeIcon($mimetype); + $path = \OC::$SERVERROOT . substr($path, strlen(\OC::$WEBROOT)); + + return new \OC_Image($path); + } +} + +\OC\Preview::registerProvider('OC\Preview\Unknown'); \ No newline at end of file diff --git a/lib/public/preview.php b/lib/public/preview.php new file mode 100644 index 0000000000..e488eade4d --- /dev/null +++ b/lib/public/preview.php @@ -0,0 +1,34 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace Test; + +class Preview extends \PHPUnit_Framework_TestCase { + + public function testIsPreviewDeleted() { + $user = $this->initFS(); + + $rootView = new \OC\Files\View(''); + $rootView->mkdir('/'.$user); + $rootView->mkdir('/'.$user.'/files'); + + $samplefile = '/'.$user.'/files/test.txt'; + + $rootView->file_put_contents($samplefile, 'dummy file data'); + + $x = 50; + $y = 50; + + $preview = new \OC\Preview($user, 'files/', 'test.txt', $x, $y); + $preview->getPreview(); + + $fileinfo = $rootView->getFileInfo($samplefile); + $fileid = $fileinfo['fileid']; + + $thumbcachefile = '/' . $user . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileid . '/' . $x . '-' . $y . '.png'; + + $this->assertEquals($rootView->file_exists($thumbcachefile), true); + + $preview->deletePreview(); + + $this->assertEquals($rootView->file_exists($thumbcachefile), false); + } + + public function testAreAllPreviewsDeleted() { + $user = $this->initFS(); + + $rootView = new \OC\Files\View(''); + $rootView->mkdir('/'.$user); + $rootView->mkdir('/'.$user.'/files'); + + $samplefile = '/'.$user.'/files/test.txt'; + + $rootView->file_put_contents($samplefile, 'dummy file data'); + + $x = 50; + $y = 50; + + $preview = new \OC\Preview($user, 'files/', 'test.txt', $x, $y); + $preview->getPreview(); + + $fileinfo = $rootView->getFileInfo($samplefile); + $fileid = $fileinfo['fileid']; + + $thumbcachefolder = '/' . $user . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileid . '/'; + + $this->assertEquals($rootView->is_dir($thumbcachefolder), true); + + $preview->deleteAllPreviews(); + + $this->assertEquals($rootView->is_dir($thumbcachefolder), false); + } + + public function testIsMaxSizeWorking() { + $user = $this->initFS(); + + $maxX = 250; + $maxY = 250; + + \OC_Config::setValue('preview_max_x', $maxX); + \OC_Config::setValue('preview_max_y', $maxY); + + $rootView = new \OC\Files\View(''); + $rootView->mkdir('/'.$user); + $rootView->mkdir('/'.$user.'/files'); + + $samplefile = '/'.$user.'/files/test.txt'; + + $rootView->file_put_contents($samplefile, 'dummy file data'); + + $preview = new \OC\Preview($user, 'files/', 'test.txt', 1000, 1000); + $image = $preview->getPreview(); + + $this->assertEquals($image->width(), $maxX); + $this->assertEquals($image->height(), $maxY); + } + + private function initFS() { + if(\OC\Files\Filesystem::getView()){ + $user = \OC_User::getUser(); + }else{ + $user=uniqid(); + \OC_User::setUserId($user); + \OC\Files\Filesystem::init($user, '/'.$user.'/files'); + } + + \OC\Files\Filesystem::mount('OC\Files\Storage\Temporary', array(), '/'); + + return $user; + } +} \ No newline at end of file