Squashed commit of the following: committags/v6.0.0alpha20dc404a557
Author: Björn Schießle <schiessle@owncloud.com> Date: Thu Jul 25 10:26:48 2013 +0200 fix 'more versions' button for IE8 commit5836e65285
Author: Björn Schießle <schiessle@owncloud.com> Date: Wed Jul 24 16:56:46 2013 +0200 clean-up some unused code commitac83e53fa2
Author: Björn Schießle <schiessle@owncloud.com> Date: Wed Jul 24 16:49:03 2013 +0200 fix order of the versions, newest version should come first commitf150a88843
Merge:bc713c7
b8e399b
Author: Jan-Christoph Borchardt <hey@jancborchardt.net> Date: Wed Jul 24 16:19:36 2013 +0200 Merge branch 'new_versions_dropdown' of github.com:owncloud/core into new_versions_dropdown commitbc713c7b0c
Author: Jan-Christoph Borchardt <hey@jancborchardt.net> Date: Wed Jul 24 16:11:07 2013 +0200 fix position of more versions button commitb8e399b175
Merge:24825b0
7b6e39d
Author: Björn Schießle <schiessle@owncloud.com> Date: Wed Jul 24 16:04:08 2013 +0200 Merge branch 'new_versions_dropdown' of github.com:owncloud/core into new_versions_dropdown commit24825b0200
Author: Björn Schießle <schiessle@owncloud.com> Date: Wed Jul 24 16:02:53 2013 +0200 umark previous row if a new row gets selected commit7b6e39d293
Merge:5bfb0ac
7b54644
Author: Jan-Christoph Borchardt <hey@jancborchardt.net> Date: Wed Jul 24 15:37:19 2013 +0200 Merge branch 'new_versions_dropdown' of github.com:owncloud/core into new_versions_dropdown commit5bfb0ac5c1
Author: Jan-Christoph Borchardt <hey@jancborchardt.net> Date: Wed Jul 24 15:37:09 2013 +0200 more style adjustments for version dropdown commit7b54644d30
Author: Björn Schießle <schiessle@owncloud.com> Date: Wed Jul 24 15:12:53 2013 +0200 remove debug output commita75662bcfd
Author: Jan-Christoph Borchardt <hey@jancborchardt.net> Date: Wed Jul 24 15:12:26 2013 +0200 reword Revert to Restore commite784644dae
Merge:d07abfd
9978c96
Author: Björn Schießle <schiessle@owncloud.com> Date: Wed Jul 24 15:00:11 2013 +0200 Merge branch 'new_versions_dropdown' of github.com:owncloud/core into new_versions_dropdown commitd07abfdbb4
Author: Björn Schießle <schiessle@owncloud.com> Date: Wed Jul 24 14:59:17 2013 +0200 if another drop-down is already open, always close it first commit9978c967a6
Author: Jan-Christoph Borchardt <hey@jancborchardt.net> Date: Wed Jul 24 14:49:47 2013 +0200 more style improvements for versions commita13355f16e
Author: Jan-Christoph Borchardt <hey@jancborchardt.net> Date: Wed Jul 24 14:44:13 2013 +0200 position fixes for versioning commit02c1d6b5ea
Merge:c5a9462
203f544
Author: Jan-Christoph Borchardt <hey@jancborchardt.net> Date: Wed Jul 24 14:31:16 2013 +0200 merge versions style changes commitc5a946231a
Author: Jan-Christoph Borchardt <hey@jancborchardt.net> Date: Wed Jul 24 14:29:56 2013 +0200 bigger clickable area for versions commit203f544825
Author: Björn Schießle <schiessle@owncloud.com> Date: Wed Jul 24 14:15:38 2013 +0200 changes visual changes, as suggested by Jan commit90b1e93676
Author: Jan-Christoph Borchardt <hey@jancborchardt.net> Date: Wed Jul 24 14:12:23 2013 +0200 remove superfluous selector from ID commit9768254fe3
Merge:c961278
b91c682
Author: Björn Schießle <schiessle@owncloud.com> Date: Wed Jul 24 12:28:06 2013 +0200 Merge branch 'master' into new_versions_dropdown commitc9612781e1
Author: Björn Schießle <schiessle@owncloud.com> Date: Wed Jul 24 11:05:25 2013 +0200 replace modal dialog with a OC.Notification commit3dc7508a4c
Author: Björn Schießle <schiessle@owncloud.com> Date: Wed Jul 24 10:33:05 2013 +0200 use image path without extension for proper svg to png fallback commit23ea7ad46c
Author: Björn Schießle <schiessle@owncloud.com> Date: Tue Jul 23 17:53:58 2013 +0200 some css fixes commit8d01499ae1
Author: Björn Schießle <schiessle@owncloud.com> Date: Tue Jul 23 17:40:16 2013 +0200 small fixes and improvements according to @Kondou-ger comments commit985b6461e8
Author: Björn Schießle <schiessle@owncloud.com> Date: Tue Jul 23 15:58:19 2013 +0200 replace == with === commitbc8fc3b4a6
Merge:c1da183
a94c55b
Author: Björn Schießle <schiessle@owncloud.com> Date: Tue Jul 23 13:55:45 2013 +0200 Merge branch 'master' into new_versions_dropdown commitc1da183d13
Author: Björn Schießle <schiessle@owncloud.com> Date: Tue Jul 23 13:53:37 2013 +0200 translate timestamps into strings like "X minutes ago" for the versions drop-down commitc78d2b4bfb
Author: Björn Schießle <schiessle@owncloud.com> Date: Tue Jul 23 12:52:44 2013 +0200 download versions directly from the versions drop-down commit14aaf99076
Author: Björn Schießle <schiessle@owncloud.com> Date: Tue Jul 23 11:01:21 2013 +0200 only show 'more versions' button of necessary commita0d8cb46b2
Author: Björn Schießle <schiessle@owncloud.com> Date: Mon Jul 22 17:49:17 2013 +0200 remove unneeded code commit47eec0679c
Author: Björn Schießle <schiessle@owncloud.com> Date: Mon Jul 22 17:44:58 2013 +0200 add title for revert and download action commitdf87ccb243
Author: Björn Schießle <schiessle@owncloud.com> Date: Mon Jul 22 17:36:40 2013 +0200 add download button to versions drop-down commit622c87ec37
Author: Björn Schießle <schiessle@owncloud.com> Date: Mon Jul 22 17:36:08 2013 +0200 adapt css file for the new versions drop-down commit300699024f
Author: Björn Schießle <schiessle@owncloud.com> Date: Fri Jun 7 17:28:34 2013 +0200 revert on click commit6673ae6ed4
Author: Björn Schießle <schiessle@owncloud.com> Date: Fri Jun 7 16:50:08 2013 +0200 new versions list, show the latest 5 with a button to retrieve more versions if needed
@@ -2,24 +2,22 @@ | |||
OCP\JSON::checkAppEnabled('files_versions'); | |||
$source = $_GET['source']; | |||
$start = $_GET['start']; | |||
list ($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($source); | |||
$count = 5; //show the newest revisions | |||
if( ($versions = OCA\Files_Versions\Storage::getVersions($uid, $filename, $count)) ) { | |||
if( ($versions = OCA\Files_Versions\Storage::getVersions($uid, $filename)) ) { | |||
$versionsFormatted = array(); | |||
foreach ( $versions AS $version ) { | |||
$versionsFormatted[] = OCP\Util::formatDate( $version['version'] ); | |||
$endReached = false; | |||
if (count($versions) <= $start+$count) { | |||
$endReached = true; | |||
} | |||
$versionsSorted = array_reverse( $versions ); | |||
$versions = array_slice($versions, $start, $count); | |||
if ( !empty( $versionsSorted ) ) { | |||
OCP\JSON::encodedPrint($versionsSorted); | |||
} | |||
\OCP\JSON::success(array('data' => array('versions' => $versions, 'endReached' => $endReached))); | |||
} else { | |||
return; | |||
\OCP\JSON::success(array('data' => array('versions' => false, 'endReached' => true))); | |||
} |
@@ -3,8 +3,6 @@ | |||
OCP\JSON::checkAppEnabled('files_versions'); | |||
OCP\JSON::callCheck(); | |||
$userDirectory = "/".OCP\USER::getUser()."/files"; | |||
$file = $_GET['file']; | |||
$revision=(int)$_GET['revision']; | |||
@@ -6,6 +6,7 @@ OC::$CLASSPATH['OCA\Files_Versions\Hooks'] = 'files_versions/lib/hooks.php'; | |||
OC::$CLASSPATH['OCA\Files_Versions\Capabilities'] = 'files_versions/lib/capabilities.php'; | |||
OCP\Util::addscript('files_versions', 'versions'); | |||
OCP\Util::addStyle('files_versions', 'versions'); | |||
// Listen to write signals | |||
OCP\Util::connectHook('OC_Filesystem', 'write', "OCA\Files_Versions\Hooks", "write_hook"); |
@@ -1,16 +1,44 @@ | |||
#history { | |||
margin: 2em 2em 0; | |||
#found_versions li { | |||
width: 100%; | |||
cursor: default; | |||
height: 36px; | |||
float: left; | |||
border-bottom: 1px solid rgba(100,100,100,.1); | |||
} | |||
#found_versions li:last-child { | |||
border-bottom: none; | |||
} | |||
#found_versions li > * { | |||
padding: 7px; | |||
float: left; | |||
vertical-align: top; | |||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; | |||
filter: alpha(opacity=50); | |||
opacity: .5; | |||
} | |||
#found_versions li > *:hover, | |||
#found_versions li > *:focus { | |||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; | |||
filter: alpha(opacity=100); | |||
opacity: 1; | |||
} | |||
#feedback-messages h3 { | |||
font-size: 1.3em; | |||
font-style: italic; | |||
#found_versions img { | |||
cursor: pointer; | |||
padding-right: 4px; | |||
} | |||
.success { | |||
color: green; | |||
#found_versions .versionDate { | |||
min-width: 100px; | |||
vertical-align: text-bottom; | |||
} | |||
.failure { | |||
color: red; | |||
} | |||
#found_versions .revertVersion { | |||
cursor: pointer; | |||
float: right; | |||
} | |||
.drop-versions #makelink { | |||
float: left; | |||
} |
@@ -0,0 +1,50 @@ | |||
<?php | |||
/** | |||
* ownCloud - Download versions directly from the versions drop-down | |||
* | |||
* @author Bjoern Schiessle | |||
* @copyright 2013 Bjoern Schiessle schiessle@owncloud.com | |||
* | |||
* This library is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or any later version. | |||
* | |||
* This library is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. | |||
* | |||
* You should have received a copy of the GNU Affero General Public | |||
* License along with this library. If not, see <http://www.gnu.org/licenses/>. | |||
* | |||
*/ | |||
OCP\JSON::checkAppEnabled('files_versions'); | |||
//OCP\JSON::callCheck(); | |||
$file = $_GET['file']; | |||
$revision=(int)$_GET['revision']; | |||
list($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($file); | |||
$versionName = '/'.$uid.'/files_versions/'.$filename.'.v'.$revision; | |||
$view = new OC\Files\View('/'); | |||
$ftype = $view->getMimeType('/'.$uid.'/files/'.$filename); | |||
header('Content-Type:'.$ftype); | |||
if ( preg_match( "/MSIE/", $_SERVER["HTTP_USER_AGENT"] ) ) { | |||
header( 'Content-Disposition: attachment; filename="' . rawurlencode( basename($filename) ) . '"' ); | |||
} else { | |||
header( 'Content-Disposition: attachment; filename*=UTF-8\'\'' . rawurlencode( basename($filename) ) | |||
. '; filename="' . rawurlencode( basename($filename) ) . '"' ); | |||
} | |||
OCP\Response::disableCaching(); | |||
header('Content-Length: '.$view->filesize($versionName)); | |||
OC_Util::obEnd(); | |||
$view->readfile($versionName); |
@@ -1,78 +0,0 @@ | |||
<?php | |||
/** | |||
* ownCloud - History page of the Versions App | |||
* | |||
* @author Frank Karlitschek | |||
* @copyright 2012 Frank Karlitschek frank@owncloud.org | |||
* | |||
* This library is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or any later version. | |||
* | |||
* This library is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public | |||
* License along with this library. If not, see <http://www.gnu.org/licenses/>. | |||
* | |||
*/ | |||
OCP\User::checkLoggedIn( ); | |||
OCP\Util::addStyle('files_versions', 'versions'); | |||
$tmpl = new OCP\Template( 'files_versions', 'history', 'user' ); | |||
$l = OC_L10N::get('files_versions'); | |||
if ( isset( $_GET['path'] ) ) { | |||
$path = $_GET['path']; | |||
$tmpl->assign( 'path', $path ); | |||
$versions = new OCA\Files_Versions\Storage(); | |||
// roll back to old version if button clicked | |||
if( isset( $_GET['revert'] ) ) { | |||
if( $versions->rollback( $path, $_GET['revert'] ) ) { | |||
$tmpl->assign( 'outcome_stat', $l->t('success') ); | |||
$message = $l->t('File %s was reverted to version %s', | |||
array($_GET['path'], OCP\Util::formatDate( doubleval($_GET['revert']) ) ) ); | |||
$tmpl->assign( 'outcome_msg', $message); | |||
} else { | |||
$tmpl->assign( 'outcome_stat', $l->t('failure') ); | |||
$message = $l->t('File %s could not be reverted to version %s', | |||
array($_GET['path'], OCP\Util::formatDate( doubleval($_GET['revert']) ) ) ); | |||
$tmpl->assign( 'outcome_msg', $message); | |||
} | |||
} | |||
// show the history only if there is something to show | |||
$count = 999; //show the newest revisions | |||
list ($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($path); | |||
if( ($versions = OCA\Files_Versions\Storage::getVersions($uid, $filename, $count)) ) { | |||
$tmpl->assign( 'versions', array_reverse( $versions ) ); | |||
}else{ | |||
$tmpl->assign( 'message', $l->t('No old versions available') ); | |||
} | |||
}else{ | |||
$tmpl->assign( 'message', $l->t('No path specified') ); | |||
} | |||
$tmpl->printPage( ); |
@@ -1,4 +1,5 @@ | |||
$(document).ready(function(){ | |||
if (typeof FileActions !== 'undefined') { | |||
// Add versions button to 'files/index.php' | |||
FileActions.register( | |||
@@ -14,39 +15,68 @@ $(document).ready(function(){ | |||
if (scanFiles.scanning){return;}//workaround to prevent additional http request block scanning feedback | |||
var file = $('#dir').val()+'/'+filename; | |||
var createDropDown = true; | |||
// Check if drop down is already visible for a different file | |||
if (($('#dropdown').length > 0) && $('#dropdown').hasClass('drop-versions') ) { | |||
if (file != $('#dropdown').data('file')) { | |||
$('#dropdown').hide('blind', function() { | |||
$('#dropdown').remove(); | |||
$('tr').removeClass('mouseOver'); | |||
createVersionsDropdown(filename, file); | |||
}); | |||
if (($('#dropdown').length > 0) ) { | |||
if ( $('#dropdown').hasClass('drop-versions') && file == $('#dropdown').data('file')) { | |||
createDropDown = false; | |||
} | |||
} else { | |||
$('#dropdown').remove(); | |||
$('tr').removeClass('mouseOver'); | |||
} | |||
if(createDropDown === true) { | |||
createVersionsDropdown(filename, file); | |||
} | |||
} | |||
); | |||
} | |||
$(document).on("click", 'span[class="revertVersion"]', function() { | |||
var revision = $(this).attr('id'); | |||
var file = $(this).attr('value'); | |||
revertFile(file, revision); | |||
}); | |||
}); | |||
function revertFile(file, revision) { | |||
$.ajax({ | |||
type: 'GET', | |||
url: OC.linkTo('files_versions', 'ajax/rollbackVersion.php'), | |||
dataType: 'json', | |||
data: {file: file, revision: revision}, | |||
async: false, | |||
success: function(response) { | |||
if (response.status === 'error') { | |||
OC.Notification.show( t('files_version', 'Failed to revert {file} to revision {timestamp}.', {file:file, timestamp:formatDate(revision * 1000)}) ); | |||
} else { | |||
$('#dropdown').hide('blind', function() { | |||
$('#dropdown').remove(); | |||
$('tr').removeClass('mouseOver'); | |||
// TODO also update the modified time in the web ui | |||
}); | |||
} | |||
} | |||
}); | |||
} | |||
function goToVersionPage(url){ | |||
window.location.assign(url); | |||
} | |||
function createVersionsDropdown(filename, files) { | |||
var historyUrl = OC.linkTo('files_versions', 'history.php') + '?path='+encodeURIComponent( $( '#dir' ).val() ).replace( /%2F/g, '/' )+'/'+encodeURIComponent( filename ); | |||
var start = 0; | |||
var html = '<div id="dropdown" class="drop drop-versions" data-file="'+escapeHTML(files)+'">'; | |||
html += '<div id="private">'; | |||
html += '<select data-placeholder="Saved versions" id="found_versions" class="chzen-select" style="width:16em;">'; | |||
html += '<option value=""></option>'; | |||
html += '</select>'; | |||
html += '<ul id="found_versions">'; | |||
html += '</ul>'; | |||
html += '</div>'; | |||
html += '<input type="button" value="All versions..." name="makelink" id="makelink" />'; | |||
html += '<input id="link" style="display:none; width:90%;" />'; | |||
html += '<input type="button" value="'+ t('files_versions', 'More versions...') + '" name="show-more-versions" id="show-more-versions" style="display: none;" />'; | |||
if (filename) { | |||
$('tr').filterAttr('data-file',filename).addClass('mouseOver'); | |||
@@ -55,73 +85,72 @@ function createVersionsDropdown(filename, files) { | |||
$(html).appendTo($('thead .share')); | |||
} | |||
$("#makelink").click(function() { | |||
goToVersionPage(historyUrl); | |||
}); | |||
getVersions(start); | |||
start = start + 5; | |||
$.ajax({ | |||
type: 'GET', | |||
url: OC.filePath('files_versions', 'ajax', 'getVersions.php'), | |||
dataType: 'json', | |||
data: { source: files }, | |||
async: false, | |||
success: function( versions ) { | |||
if (versions) { | |||
$.each( versions, function(index, row ) { | |||
addVersion( row ); | |||
}); | |||
} else { | |||
$('#found_versions').hide(); | |||
$('#makelink').hide(); | |||
$('<div style="text-align:center;">No other versions available</div>').appendTo('#dropdown'); | |||
} | |||
$('#found_versions').change(function(){ | |||
var revision=parseInt($(this).val()); | |||
revertFile(files,revision); | |||
}); | |||
} | |||
$("#show-more-versions").click(function() { | |||
//get more versions | |||
getVersions(start); | |||
start = start + 5; | |||
}); | |||
function revertFile(file, revision) { | |||
function getVersions(start) { | |||
$.ajax({ | |||
type: 'GET', | |||
url: OC.linkTo('files_versions', 'ajax/rollbackVersion.php'), | |||
url: OC.filePath('files_versions', 'ajax', 'getVersions.php'), | |||
dataType: 'json', | |||
data: {file: file, revision: revision}, | |||
data: {source: files, start: start}, | |||
async: false, | |||
success: function(response) { | |||
if (response.status=='error') { | |||
OC.dialogs.alert('Failed to revert '+file+' to revision '+formatDate(revision*1000)+'.','Failed to revert'); | |||
success: function(result) { | |||
var versions = result.data.versions; | |||
if (result.data.endReached === true) { | |||
document.getElementById("show-more-versions").style.display="none"; | |||
} else { | |||
$('#dropdown').hide('blind', function() { | |||
$('#dropdown').remove(); | |||
$('tr').removeClass('mouseOver'); | |||
// TODO also update the modified time in the web ui | |||
document.getElementById("show-more-versions").style.display="block"; | |||
} | |||
if (versions) { | |||
$.each(versions, function(index, row) { | |||
addVersion(row); | |||
}); | |||
} else { | |||
$('<div style="text-align:center;">'+ t('files_versions', 'No other versions available') + '</div>').appendTo('#dropdown'); | |||
} | |||
$('#found_versions').change(function() { | |||
var revision = parseInt($(this).val()); | |||
revertFile(files, revision); | |||
}); | |||
} | |||
}); | |||
} | |||
function addVersion( revision ) { | |||
name=formatDate(revision.version*1000); | |||
var version=$('<option/>'); | |||
version.attr('value',revision.version); | |||
version.text(name); | |||
// } else { | |||
// var checked = ((permissions > 0) ? 'checked="checked"' : 'style="display:none;"'); | |||
// var style = ((permissions == 0) ? 'style="display:none;"' : ''); | |||
// var user = '<li data-uid_shared_with="'+uid_shared_with+'">'; | |||
// user += '<a href="" class="unshare" style="display:none;"><img class="svg" alt="Unshare" src="'+OC.imagePath('core','actions/delete')+'"/></a>'; | |||
// user += uid_shared_with; | |||
// user += '<input type="checkbox" name="permissions" id="'+uid_shared_with+'" class="permissions" '+checked+' />'; | |||
// user += '<label for="'+uid_shared_with+'" '+style+'>can edit</label>'; | |||
// user += '</li>'; | |||
// } | |||
title = formatDate(revision.version*1000); | |||
name ='<span class="versionDate" title="' + title + '">' + revision.humanReadableTimestamp + '</span>'; | |||
path = OC.filePath('files_versions', '', 'download.php'); | |||
download ='<a href="' + path + "?file=" + files + '&revision=' + revision.version + '">'; | |||
download+='<img'; | |||
download+=' src="' + OC.imagePath('core', 'actions/download') + '"'; | |||
download+=' id="' + revision.version + '"'; | |||
download+=' value="' + files + '"'; | |||
download+=' name="downloadVersion" />'; | |||
download+=name; | |||
download+='</a>'; | |||
revert='<span class="revertVersion"'; | |||
revert+=' id="' + revision.version + '"'; | |||
revert+=' value="' + files + '">'; | |||
revert+='<img'; | |||
revert+=' src="' + OC.imagePath('core', 'actions/history') + '"'; | |||
revert+=' id="' + revision.version + '"'; | |||
revert+=' value="' + files + '"'; | |||
revert+=' name="revertVersion"'; | |||
revert+='/>'+t('files_versions', 'Restore')+'</span>'; | |||
var version=$('<li/>'); | |||
version.attr('value', revision.version); | |||
version.html(download + revert); | |||
version.appendTo('#found_versions'); | |||
} |
@@ -239,10 +239,9 @@ class Storage { | |||
* @brief get a list of all available versions of a file in descending chronological order | |||
* @param $uid user id from the owner of the file | |||
* @param $filename file to find versions of, relative to the user files dir | |||
* @param $count number of versions to return | |||
* @returns array | |||
*/ | |||
public static function getVersions($uid, $filename, $count = 0 ) { | |||
public static function getVersions($uid, $filename ) { | |||
if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) { | |||
$versions_fileview = new \OC\Files\View('/' . $uid . '/files_versions'); | |||
$versionsName = $versions_fileview->getLocalFile($filename).'.v'; | |||
@@ -268,6 +267,7 @@ class Storage { | |||
$key = $version.'#'.$filename; | |||
$versions[$key]['cur'] = 0; | |||
$versions[$key]['version'] = $version; | |||
$versions[$key]['humanReadableTimestamp'] = self::getHumanReadableTimestamp($version); | |||
$versions[$key]['path'] = $filename; | |||
$versions[$key]['size'] = $versions_fileview->filesize($filename.'.v'.$version); | |||
@@ -276,6 +276,7 @@ class Storage { | |||
} | |||
// newest versions first | |||
$versions = array_reverse( $versions ); | |||
foreach( $versions as $key => $value ) { | |||
@@ -286,13 +287,6 @@ class Storage { | |||
} | |||
} | |||
$versions = array_reverse( $versions ); | |||
// only show the newest commits | |||
if( $count != 0 and ( count( $versions )>$count ) ) { | |||
$versions = array_slice( $versions, count( $versions ) - $count ); | |||
} | |||
return( $versions ); | |||
} else { | |||
@@ -302,6 +296,32 @@ class Storage { | |||
} | |||
/** | |||
* @brief translate a timestamp into a string like "5 days ago" | |||
* @param int $timestamp | |||
* @return string for example "5 days ago" | |||
*/ | |||
private static function getHumanReadableTimestamp($timestamp) { | |||
$diff = time() - $timestamp; | |||
if ($diff < 60) { // first minute | |||
return $diff . " seconds ago"; | |||
} elseif ($diff < 3600) { //first hour | |||
return round($diff / 60) . " minutes ago"; | |||
} elseif ($diff < 86400) { // first day | |||
return round($diff / 3600) . " hours ago"; | |||
} elseif ($diff < 604800) { //first week | |||
return round($diff / 86400) . " days ago"; | |||
} elseif ($diff < 2419200) { //first month | |||
return round($diff / 604800) . " weeks ago"; | |||
} elseif ($diff < 29030400) { // first year | |||
return round($diff / 2419200) . " months ago"; | |||
} else { | |||
return round($diff / 29030400) . " years ago"; | |||
} | |||
} | |||
/** | |||
* @brief deletes used space for files versions in db if user was deleted |
@@ -1,36 +0,0 @@ | |||
<div id="history"> | |||
<?php | |||
if( isset( $_['message'] ) ) { | |||
if( isset($_['path'] ) ) print_unescaped('<strong>File: '.OC_Util::sanitizeHTML($_['path']).'</strong><br>'); | |||
print_unescaped('<strong>'.OC_Util::sanitizeHTML($_['message']) .'</strong><br>'); | |||
}else{ | |||
if( isset( $_['outcome_stat'] ) ) { | |||
print_unescaped( '<div id="feedback-messages" class="'.OC_Util::sanitizeHTML($_['outcome_stat']).'"><h3>'.OC_Util::sanitizeHTML($_['outcome_msg']).'</h3></div><br>'); | |||
} | |||
print_unescaped( '<strong>Versions of '.OC_Util::sanitizeHTML($_['path']).'</strong><br>'); | |||
print_unescaped('<p><em>'.OC_Util::sanitizeHTML($l->t('Revert a file to a previous version by clicking on its revert button')).'</em></p><br />'); | |||
foreach ( $_['versions'] as $v ) { | |||
p(' '); | |||
p(OCP\Util::formatDate( doubleval($v['version']))); | |||
print_unescaped(' <a href="'.OCP\Util::linkTo('files_versions', 'history.php', | |||
array('path' => $_['path'], 'revert' => $v['version'])) .'" class="button">Revert</a><br /><br />'); | |||
if ( $v['cur'] ) { | |||
print_unescaped(' (<b>Current</b>)'); | |||
} | |||
print_unescaped('<br /><br />'); | |||
} | |||
} | |||
?> | |||
</div> |