changeset 45:7de8f524d1e4

Always group by directory no matter what type of sorting.
author nanaya <me@myconan.net>
date Sun, 24 May 2015 18:33:45 +0900
parents 2ec27751645e
children 113f9121d38b
files index.php
diffstat 1 files changed, 7 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/index.php	Sun May 24 18:29:37 2015 +0900
+++ b/index.php	Sun May 24 18:33:45 2015 +0900
@@ -62,8 +62,8 @@
     return sprintf($return_format, $size, $return_unit);
   }
 
-  function hidden_data($data) {
-    return "<i> " . $data . " </i>";
+  function hidden_data($data = "", $is_dir = false) {
+    return "<i> " . ($is_dir === true ? 0 : 1) . " " . $data . " </i>";
   }
   // END UTILITY
 
@@ -96,13 +96,10 @@
 
     $file_rows = "";
     $file_suffix = "";
-    $list_file_prefix = "";
+    $list_file_prefix = hidden_data("", $is_dir);
 
     if ($is_dir) {
       $file_suffix = "/";
-      $list_file_prefix = hidden_data(0);
-    } else {
-      $list_file_prefix = hidden_data(1);
     }
 
     foreach($files as $file) {
@@ -112,11 +109,12 @@
       $file_rows .= "<td>". $list_file_prefix . link_to($file . $file_suffix, $file . $file_suffix)."</td>";
 
       $file_rows .= "<td>";
-      if ($is_dir) { $file_rows .= hidden_data(0) . "[dir]"; }
-      else { $file_rows .= hidden_data($file_stat["size"]) . human_size($file_stat['size']); }
+      $file_rows .= hidden_data($file_stat["size"], $is_dir);
+      if ($is_dir) { $file_rows .= "[dir]"; }
+      else { $file_rows .= human_size($file_stat['size']); }
       $file_rows .= "</td>";
 
-      $file_rows .= "<td>".h(strftime("%Y-%m-%d %H:%M %Z", $file_stat['mtime']))."</td>";
+      $file_rows .= "<td>" . hidden_data("", $is_dir) . h(strftime("%Y-%m-%d %H:%M %Z", $file_stat['mtime'])) . "</td>";
 
       $file_rows .= "</tr>";
     }