diff options
Diffstat (limited to 'apps/files_versions')
-rw-r--r-- | apps/files_versions/appinfo/app.php | 1 | ||||
-rw-r--r-- | apps/files_versions/css/versions.css | 5 | ||||
-rw-r--r-- | apps/files_versions/history.php | 39 | ||||
-rw-r--r-- | apps/files_versions/js/versions.js | 65 | ||||
-rw-r--r-- | apps/files_versions/templates/history.php | 4 | ||||
-rw-r--r-- | apps/files_versions/versions.php | 2 |
6 files changed, 93 insertions, 23 deletions
diff --git a/apps/files_versions/appinfo/app.php b/apps/files_versions/appinfo/app.php index 6e7a803252e..32e4c0ce81b 100644 --- a/apps/files_versions/appinfo/app.php +++ b/apps/files_versions/appinfo/app.php @@ -9,6 +9,7 @@ OC_App::register( array( 'name' => 'Versioning' )); OC_APP::registerAdmin('files_versions', 'settings'); +OC_UTIL::addScript('files_versions', 'versions'); // Listen to write signals OC_Hook::connect(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_write, "OCA_Versions\Storage", "write_hook"); diff --git a/apps/files_versions/css/versions.css b/apps/files_versions/css/versions.css index 139597f9cb0..b2279e9b05a 100644 --- a/apps/files_versions/css/versions.css +++ b/apps/files_versions/css/versions.css @@ -1,2 +1,3 @@ - - +#history { + margin: 2em 2em 0; +}
\ No newline at end of file diff --git a/apps/files_versions/history.php b/apps/files_versions/history.php index 6c7626ca4ed..b0aa8fdc982 100644 --- a/apps/files_versions/history.php +++ b/apps/files_versions/history.php @@ -20,40 +20,41 @@ * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ -require_once('../../lib/base.php'); +require_once( '../../lib/base.php' ); -OC_Util::checkLoggedIn(); +OC_Util::checkLoggedIn( ); +OC_Util::addStyle('files_versions','versions'); -if (isset($_GET['path'])) { +if ( isset( $_GET['path'] ) ) { $path = $_GET['path']; - $path = strip_tags($path); + $path = strip_tags( $path); // roll back to old version if button clicked - if(isset($_GET['revert'])) { - \OCA_Versions\Storage::rollback($path,$_GET['revert']); + if( isset( $_GET['revert'] ) ) { + \OCA_Versions\Storage::rollback( $path, $_GET['revert'] ); } // show the history only if there is something to show - if(OCA_Versions\Storage::isversioned($path)) { + if( OCA_Versions\Storage::isversioned( $path ) ) { $count=5; //show the newest revisions - $versions=OCA_Versions\Storage::getversions($path,$count); + $versions=OCA_Versions\Storage::getversions( $path, $count); - $tmpl = new OC_Template('files_versions', 'history', 'user'); - $tmpl->assign('path', $path); - $tmpl->assign('versions', array_reverse($versions)); - $tmpl->printPage(); + $tmpl = new OC_Template( 'files_versions', 'history', 'user' ); + $tmpl->assign( 'path', $path); + $tmpl->assign( 'versions', array_reverse( $versions) ); + $tmpl->printPage( ); }else{ - $tmpl = new OC_Template('files_versions', 'history', 'user'); - $tmpl->assign('path', $path); - $tmpl->assign('message', 'No old versions available'); - $tmpl->printPage(); + $tmpl = new OC_Template( 'files_versions', 'history', 'user' ); + $tmpl->assign( 'path', $path); + $tmpl->assign( 'message', 'No old versions available' ); + $tmpl->printPage( ); } }else{ - $tmpl = new OC_Template('files_versions', 'history', 'user'); - $tmpl->assign('message', 'No path specified'); - $tmpl->printPage(); + $tmpl = new OC_Template( 'files_versions', 'history', 'user' ); + $tmpl->assign( 'message', 'No path specified' ); + $tmpl->printPage( ); } diff --git a/apps/files_versions/js/versions.js b/apps/files_versions/js/versions.js index 139597f9cb0..325ef823a9c 100644 --- a/apps/files_versions/js/versions.js +++ b/apps/files_versions/js/versions.js @@ -1,2 +1,67 @@ +$(document).ready(function(){ + + // Add history button to files/index.php + FileActions.register('file','History',function(){return OC.imagePath('core','actions/history')},function(filename){ + + if (scanFiles.scanning){return;}//workaround to prevent additional http request block scanning feedback + + var file = $('#dir').val()+'/'+filename; + + createVersionsDropdown(filename, file) + //window.location='../apps/files_versions/history.php?path='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename); + + }); + +}); + +function createVersionsDropdown(filename, files) { + var historyUrl = '../apps/files_versions/history.php?path='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename); + //alert( historyUrl ); + var html = '<div id="dropdown" class="drop" data-file="'+files+'">'; + html += '<div id="private">'; + html += '<select data-placeholder="File Version" id="share_with" class="chzen-select">'; + html += '<option value=""></option>'; + html += '</select>'; + html += '<ul id="shared_list"></ul>'; + html += '</div>'; + html += '<div id="public">'; + html += '<input type="button" name="makelink" id="makelink" value="Revert file" />'; + html += '<input type="button" onclick="window.location=\''+historyUrl+'\'" name="makelink" id="makelink" value="More..." />'; + html += '<br />'; + html += '<input id="link" style="display:none; width:90%;" />'; + html += '</div>'; + + if (filename) { + $('tr').filterAttr('data-file',filename).addClass('mouseOver'); + $(html).appendTo($('tr').filterAttr('data-file',filename).find('td.filename')); + } else { + $(html).appendTo($('thead .share')); + } +// $.getJSON(OC.linkTo('files_sharing', 'ajax/userautocomplete.php'), function(users) { +// if (users) { +// $.each(users, function(index, row) { +// $(row).appendTo('#share_with'); +// }); +// $('#share_with').trigger('liszt:updated'); +// } +// }); +// $.getJSON(OC.linkTo('files_sharing', 'ajax/getitem.php'), { source: files }, function(users) { +// if (users) { +// $.each(users, function(index, row) { +// if (row.uid_shared_with == 'public') { +// showPublicLink(row.token, '/'+filename); +// } else if (isNaN(index)) { +// addUser(row.uid_shared_with, row.permissions, index.substr(0, index.lastIndexOf('-'))); +// } else { +// addUser(row.uid_shared_with, row.permissions, false); +// } +// }); +// } +// }); + + $('#dropdown').show('blind'); + $('#share_with').chosen(); + +}
\ No newline at end of file diff --git a/apps/files_versions/templates/history.php b/apps/files_versions/templates/history.php index 1b3de9ce77c..d33d2b0f68b 100644 --- a/apps/files_versions/templates/history.php +++ b/apps/files_versions/templates/history.php @@ -1,3 +1,4 @@ +<div id="history"> <?php if(isset($_['message'])){ @@ -10,9 +11,10 @@ echo('<strong>Versions of '.$_['path']).'</strong><br>'; echo('<p><em>You can click on the revert button to revert to the specific verson.</em></p><br />'); foreach ($_['versions'] as $v){ - echo(' '.OC_Util::formatDate($v).' <a href="history.php?path='.urlencode($_['path']).'&revert='.$v.'" class="button">revert</a><br /><br />'); + echo(' '.OC_Util::formatDate($v).' <a href="history.php?path='.urlencode($_['path']).'&revert='.$v.'" class="button">Revert</a><br /><br />'); } } ?> +</div> diff --git a/apps/files_versions/versions.php b/apps/files_versions/versions.php index 156a4f59c73..167c64a4345 100644 --- a/apps/files_versions/versions.php +++ b/apps/files_versions/versions.php @@ -36,7 +36,7 @@ class Storage { const DEFAULTFOLDER='versions'; const DEFAULTBLACKLIST='avi mp3 mpg mp4'; const DEFAULTMAXFILESIZE=1048576; // 10MB - const DEFAULTMININTERVAL=300; // 5 min + const DEFAULTMININTERVAL=1; // 5 min const DEFAULTMAXVERSIONS=50; /** |