0be9de5df5
Files app: - removed file list template, now rendering list from JSON response - FileList.addFile/addDir is now FileList.add() and takes a JS map with all required arguments instead of having a long number of function arguments - added unit tests for many FileList operations - fixed newfile.php, newfolder.php and rename.php to return the file's full JSON on success - removed obsolete/unused undo code - removed download_url / loading options, now using Files.getDownloadUrl() for that - server side now uses Helper::getFileInfo() to prepare file JSON response - previews are now client-side only Breadcrumbs are now JS only: - Added BreadCrumb class to handle breadcrumb rendering and events - Added unit test for BreadCrumb class - Moved all relevant JS functions to the BreadCrumb class Public page now uses ajax to load the file list: - Added Helper class in sharing app to make it easier to authenticate and retrieve the file's real path - Added ajax/list.php to retrieve the file list - Fixed FileActions and FileList to work with the ajax list Core: - Fixed file picker dialog to use the same list format as files app
58 lines
1.7 KiB
PHP
58 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* Copyright (c) 2013 Georg Ehrke georg@ownCloud.com
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
* later.
|
|
* See the COPYING-README file.
|
|
*/
|
|
\OC_Util::checkLoggedIn();
|
|
|
|
if(!\OC_App::isEnabled('files_trashbin')){
|
|
exit;
|
|
}
|
|
|
|
$file = array_key_exists('file', $_GET) ? (string) $_GET['file'] : '';
|
|
$maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '44';
|
|
$maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '44';
|
|
$scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true;
|
|
|
|
if($file === '') {
|
|
\OC_Response::setStatus(400); //400 Bad Request
|
|
\OC_Log::write('core-preview', 'No file parameter was passed', \OC_Log::DEBUG);
|
|
exit;
|
|
}
|
|
|
|
if($maxX === 0 || $maxY === 0) {
|
|
\OC_Response::setStatus(400); //400 Bad Request
|
|
\OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG);
|
|
exit;
|
|
}
|
|
|
|
try{
|
|
$preview = new \OC\Preview(\OC_User::getUser(), 'files_trashbin/files', $file);
|
|
$view = new \OC\Files\View('/'.\OC_User::getUser(). '/files_trashbin/files');
|
|
if ($view->is_dir($file)) {
|
|
$mimetype = 'httpd/unix-directory';
|
|
} else {
|
|
$pathInfo = pathinfo(ltrim($file, '/'));
|
|
$fileName = $pathInfo['basename'];
|
|
// if in root dir
|
|
if ($pathInfo['dirname'] === '.') {
|
|
// cut off the .d* suffix
|
|
$i = strrpos($fileName, '.');
|
|
if ($i !== false) {
|
|
$fileName = substr($fileName, 0, $i);
|
|
}
|
|
}
|
|
$mimetype = \OC_Helper::getFileNameMimeType($fileName);
|
|
}
|
|
$preview->setMimetype($mimetype);
|
|
$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);
|
|
}
|