From f1616b0e629ec5fd59a859748e64418862691597 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Fri, 29 Jul 2011 00:45:44 +0200 Subject: [PATCH] implemented relative file size and coloring --- core/css/styles.css | 2 +- files/templates/part.list.php | 7 +++++-- lib/template.php | 23 +++++++++++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/core/css/styles.css b/core/css/styles.css index 33c1af44362..35b65f9480d 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -24,7 +24,7 @@ form input[type="button"], form input[type="text"] { font-size:0.9em; } fieldset { padding:1em; background-color:#f7f7f7; border:1px solid #ddd; max-width:600px; margin:2em 2em 2em 3em; } legend { padding:0.5em; font-size:1.2em; } -div.controls { width:100%; margin:0px; background-color:#f7f7f7; border-bottom:1px solid #eee; position:fixed; z-index:0; } +div.controls { width:100%; margin:0px; background-color:#f7f7f7; border-bottom:1px solid #eee; position:fixed; z-index:2; } /* LOG IN & INSTALLATION ------------------------------------------------------------ */ #body-login { width:100%; background-image:none; background-color:#ddd; } diff --git a/files/templates/part.list.php b/files/templates/part.list.php index 1d78b77ae3e..a0ffb4b6073 100644 --- a/files/templates/part.list.php +++ b/files/templates/part.list.php @@ -1,6 +1,9 @@ + $simple_size_color = 200-intval(pow(($file['size']/(1024*1024)),2)); + $relative_modified_date = relative_modified_date($file['mtime']); + $relative_date_color = round((time()-$file['mtime'])/60/60/24*5); //days ago + if($relative_date_color>200) $relative_date_color = 200; ?> '> @@ -15,6 +18,6 @@ - + diff --git a/lib/template.php b/lib/template.php index 3c0cdf7e161..99099d49d0f 100644 --- a/lib/template.php +++ b/lib/template.php @@ -75,6 +75,29 @@ function simple_file_size($bytes) { else { return number_format($mbytes, 1); } } +function relative_modified_date($timestamp) { + $timediff = time() - $timestamp; + $diffminutes = round($timediff/60); + $diffhours = round($diffminutes/60); + $diffdays = round($diffhours/24); + $diffmonths = round($diffdays/31); + $diffyears = round($diffdays/365); + if($timediff < 60) { return 'seconds ago'; } + else if($timediff < 120) { return '1 minute ago'; } + else if($timediff < 3600) { return $diffminutes.' minutes ago'; } + //else if($timediff < 7200) { return '1 hour ago'; } + //else if($timediff < 86400) { return $diffhours.' hours ago'; } + else if($timediff < 86400) { return 'today'; } + else if($timediff < 172800) { return 'yesterday'; } + else if($timediff < 2678400) { return $diffdays.' days ago'; } + else if($timediff < 5184000) { return 'last month'; } + //else if($timediff < 31556926) { return $diffmonths.' months ago'; } + else if($timediff < 31556926) { return 'months ago'; } + else if($timediff < 63113852) { return 'last year'; } + else { return $diffyears.' years ago'; } +} + + /** * This class provides the templates for owncloud. */