--- /dev/null
+<?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_versions')){
+ exit;
+}
+
+$file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : '';
+$maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '44';
+$maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '44';
+$version = array_key_exists('version', $_GET) ? $_GET['version'] : '';
+$scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true;
+
+if($file === '' && $version === '') {
+ \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_versions');
+ $preview->setFile($file.'.v'.$version);
+ $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
// Register with the capabilities API
OC_API::register('get', '/cloud/capabilities', array('OCA\Files_Versions\Capabilities', 'getCapabilities'), 'files_versions', OC_API::USER_AUTH);
+
+$this->create('core_ajax_versions_preview', '/preview.png')->action(
+function() {
+ require_once __DIR__ . '/../ajax/preview.php';
+});
\ No newline at end of file
var path = OC.filePath('files_versions', '', 'download.php');
+ var preview = '<img class="preview" src="'+revision.preview+'"/>';
+
var download ='<a href="' + path + "?file=" + files + '&revision=' + revision.version + '">';
download+='<img';
download+=' src="' + OC.imagePath('core', 'actions/download') + '"';
var version=$('<li/>');
version.attr('value', revision.version);
- version.html(download + revert);
+ version.html(preview + download + revert);
version.appendTo('#found_versions');
}
$versions[$key]['version'] = $version;
$versions[$key]['humanReadableTimestamp'] = self::getHumanReadableTimestamp($version);
$versions[$key]['path'] = $filename;
+ $versions[$key]['preview'] = \OCP\Util::linkToRoute('core_ajax_versions_preview', array('file' => $filename, 'version' => $version));
$versions[$key]['size'] = $versions_fileview->filesize($filename.'.v'.$version);
// if file with modified date exists, flag it in array as currently enabled version