]> source.dussan.org Git - nextcloud-server.git/commitdiff
implemented relative file size and coloring
authorJan-Christoph Borchardt <JanCBorchardt@fsfe.org>
Thu, 28 Jul 2011 22:45:44 +0000 (00:45 +0200)
committerJan-Christoph Borchardt <JanCBorchardt@fsfe.org>
Thu, 28 Jul 2011 22:46:20 +0000 (00:46 +0200)
core/css/styles.css
files/templates/part.list.php
lib/template.php

index 33c1af4436238123ec0f47c66b9ea62879b636ba..35b65f9480d8731054a46edbeb311385037d23ca 100644 (file)
@@ -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; }
index 1d78b77ae3e6d9fcd38a58534c85177b8861ae26..a0ffb4b6073e15fa1ad383f829eaf7fbdf367cf5 100644 (file)
@@ -1,6 +1,9 @@
                <?php foreach($_['files'] as $file):
                        $simple_file_size = simple_file_size($file['size']);
-                       $simple_size_color = 200-intval(pow(($file['size']/(1024*1024)),2)); ?>
+                       $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; ?>
                        <tr data-file="<?php echo $file['name'];?>" data-type="<?php echo ($file['type'] == 'dir')?'dir':'file'?>" data-mime="<?php echo $file['mime']?>" data-size='<?php echo $file['size'];?>'>
                                <td class="filename">
                                        <input type="checkbox" />
@@ -15,6 +18,6 @@
                                        </a>
                                </td>
                                <td class="filesize" title="<?php echo human_file_size($file['size']); ?>" style="color:rgb(<?php echo $simple_size_color.','.$simple_size_color.','.$simple_size_color ?>)"><?php echo $simple_file_size; ?></td>
-                               <td class="date"><span class="modified"><?php echo $file['date']; ?></span></td>
+                               <td class="date"><span class="modified" title="<?php echo $file['date']; ?>" style="color:rgb(<?php echo $relative_date_color.','.$relative_date_color.','.$relative_date_color ?>)"><?php echo $relative_modified_date; ?></span></td>
                        </tr>
                <?php endforeach; ?>
index 3c0cdf7e16198aa52748717396397439d75603bb..99099d49d0f2a843df437c187982c6fb196d5360 100644 (file)
@@ -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.
  */