diff index.php @ 52:f48a4fbb9cf9

Rewrite file rows generator.
author nanaya <me@myconan.net>
date Mon, 24 Aug 2015 21:34:58 +0900
parents 29543401ef18
children 8e6acb7d4e48
line wrap: on
line diff
--- a/index.php	Mon Aug 24 21:20:27 2015 +0900
+++ b/index.php	Mon Aug 24 21:34:58 2015 +0900
@@ -90,32 +90,31 @@
   }
 
   function file_rows($dir, $files, $is_dir) {
-    $file_rows = "";
     $file_suffix = "";
-    $list_file_prefix = hidden_data("", $is_dir);
+    if ($is_dir) { $file_suffix = "/"; }
 
-    if ($is_dir) {
-      $file_suffix = "/";
-    }
-
+    $file_rows = "";
     foreach($files as $file) {
       $file_path = $dir."/".$file;
 
       if (!file_exists($file_path)) { continue; }
       $file_stat = stat($file_path);
 
-      $file_rows .= "<tr>";
-      $file_rows .= "<td>". $list_file_prefix . link_to($file . $file_suffix, $file . $file_suffix)."</td>";
-
-      $file_rows .= "<td>";
-      $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>" . hidden_data("", $is_dir) . h(strftime("%Y-%m-%d %H:%M %Z", $file_stat['mtime'])) . "</td>";
-
-      $file_rows .= "</tr>";
+      $file_rows .=
+        "<tr>".
+          "<td>".
+            hidden_data("", $is_dir).
+            link_to($file.$file_suffix, $file.$file_suffix).
+          "</td>".
+          "<td>".
+            hidden_data($file_stat["size"], $is_dir).
+            ($is_dir ? "[dir]" : human_size($file_stat["size"])).
+          "</td>".
+          "<td>".
+            hidden_data("", $is_dir).$columns["date"].
+            h(strftime("%Y-%m-%d %H:%M %Z", $file_stat["mtime"])).
+          "</td>".
+        "</tr>";
     }
     return $file_rows;
   }