Merge branch 'oc_preview' of github.com:owncloud/core into oc_preview

This commit is contained in:
Jan-Christoph Borchardt 2013-08-14 13:01:52 +02:00
commit 4845ef5ac6
6 changed files with 5 additions and 22 deletions

View File

@ -825,7 +825,9 @@ function getMimeIcon(mime, ready){
getMimeIcon.cache={};
function getPreviewIcon(path, ready){
ready(OC.Router.generate('core_ajax_preview', {file: encodeURIComponent(path), x:36, y:36}));
var x = $('#filestable').data('preview-x');
var y = $('#filestable').data('preview-y');
ready(OC.Router.generate('core_ajax_preview', {file: encodeURIComponent(path), x:x, y:y}));
}
function getUniqueName(name){

View File

@ -10,7 +10,7 @@
data-type='file'><p><?php p($l->t('Text file'));?></p></li>
<li style="background-image:url('<?php p(OCP\mimetype_icon('dir')) ?>')"
data-type='folder'><p><?php p($l->t('Folder'));?></p></li>
<li style="background-image:url('<?php p(OCP\image_path('core', 'web.png')) ?>')"
<li style="background-image:url('<?php p(OCP\image_path('core', 'web.svg')) ?>')"
data-type='web'><p><?php p($l->t('From link'));?></p></li>
</ul>
</div>
@ -59,7 +59,7 @@
<div id="emptyfolder"><?php p($l->t('Nothing in here. Upload something!'))?></div>
<?php endif; ?>
<table id="filestable" data-allow-public-upload="<?php p($_['publicUploadEnabled'])?>">
<table id="filestable" data-allow-public-upload="<?php p($_['publicUploadEnabled'])?>" data-preview-x="36" data-preview-y="36">
<thead>
<tr>
<th id='headerName'>

View File

@ -15,14 +15,12 @@ $scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] :
if($file === '') {
\OC_Response::setStatus(400); //400 Bad Request
\OC_Log::write('core-preview', 'No file parameter was passed', \OC_Log::DEBUG);
\OC\Preview::showErrorPreview();
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);
\OC\Preview::showErrorPreview();
exit;
}
@ -37,6 +35,5 @@ try{
}catch(\Exception $e) {
\OC_Response::setStatus(500);
\OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
\OC\Preview::showErrorPreview();
exit;
}

View File

@ -18,7 +18,6 @@ $token = array_key_exists('t', $_GET) ? (string) $_GET['t'] : '';
if($token === ''){
\OC_Response::setStatus(400); //400 Bad Request
\OC_Log::write('core-preview', 'No token parameter was passed', \OC_Log::DEBUG);
\OC\Preview::showErrorPreview();
exit;
}
@ -26,14 +25,12 @@ $linkedItem = \OCP\Share::getShareByToken($token);
if($linkedItem === false || ($linkedItem['item_type'] !== 'file' && $linkedItem['item_type'] !== 'folder')) {
\OC_Response::setStatus(404);
\OC_Log::write('core-preview', 'Passed token parameter is not valid', \OC_Log::DEBUG);
\OC\Preview::showErrorPreview();
exit;
}
if(!isset($linkedItem['uid_owner']) || !isset($linkedItem['file_source'])) {
\OC_Response::setStatus(500);
\OC_Log::write('core-preview', 'Passed token seems to be valid, but it does not contain all necessary information . ("' . $token . '")', \OC_Log::WARN);
\OC\Preview::showErrorPreview();
exit;
}
@ -50,7 +47,6 @@ if($linkedItem['item_type'] === 'folder') {
if(!$isvalid) {
\OC_Response::setStatus(400); //400 Bad Request
\OC_Log::write('core-preview', 'Passed filename is not valid, might be malicious (file:"' . $file . '";ip:"' . $_SERVER['REMOTE_ADDR'] . '")', \OC_Log::WARN);
\OC\Preview::showErrorPreview();
exit;
}
$sharedFile = \OC\Files\Filesystem::normalizePath($file);
@ -70,7 +66,6 @@ if(substr($path, 0, 1) === '/') {
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);
\OC\Preview::showErrorPreview();
exit;
}
@ -87,6 +82,5 @@ try{
} catch (\Exception $e) {
\OC_Response::setStatus(500);
\OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
\OC\Preview::showErrorPreview();
exit;
}

View File

@ -19,14 +19,12 @@ $scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] :
if($file === '') {
\OC_Response::setStatus(400); //400 Bad Request
\OC_Log::write('core-preview', 'No file parameter was passed', \OC_Log::DEBUG);
\OC\Preview::showErrorPreview();
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);
\OC\Preview::showErrorPreview();
exit;
}
@ -41,6 +39,5 @@ try{
}catch(\Exception $e) {
\OC_Response::setStatus(500);
\OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
\OC\Preview::showErrorPreview();
exit;
}

View File

@ -611,11 +611,4 @@ class Preview {
}
return false;
}
private static function showErrorPreview() {
$path = \OC::$SERVERROOT . '/core/img/actions/delete.png';
$preview = new \OC_Image($path);
$preview->preciseResize(36, 36);
$preview->show();
}
}