Mercurial > dirlist-php
comparison index.php @ 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 |
comparison
equal
deleted
inserted
replaced
| 44:2ec27751645e | 45:7de8f524d1e4 |
|---|---|
| 60 $return_unit = $thousand_units[$i]; | 60 $return_unit = $thousand_units[$i]; |
| 61 } | 61 } |
| 62 return sprintf($return_format, $size, $return_unit); | 62 return sprintf($return_format, $size, $return_unit); |
| 63 } | 63 } |
| 64 | 64 |
| 65 function hidden_data($data) { | 65 function hidden_data($data = "", $is_dir = false) { |
| 66 return "<i> " . $data . " </i>"; | 66 return "<i> " . ($is_dir === true ? 0 : 1) . " " . $data . " </i>"; |
| 67 } | 67 } |
| 68 // END UTILITY | 68 // END UTILITY |
| 69 | 69 |
| 70 function tree_link() { | 70 function tree_link() { |
| 71 global $uri; | 71 global $uri; |
| 94 function file_rows($files, $is_dir) { | 94 function file_rows($files, $is_dir) { |
| 95 global $dir, $uri; | 95 global $dir, $uri; |
| 96 | 96 |
| 97 $file_rows = ""; | 97 $file_rows = ""; |
| 98 $file_suffix = ""; | 98 $file_suffix = ""; |
| 99 $list_file_prefix = ""; | 99 $list_file_prefix = hidden_data("", $is_dir); |
| 100 | 100 |
| 101 if ($is_dir) { | 101 if ($is_dir) { |
| 102 $file_suffix = "/"; | 102 $file_suffix = "/"; |
| 103 $list_file_prefix = hidden_data(0); | |
| 104 } else { | |
| 105 $list_file_prefix = hidden_data(1); | |
| 106 } | 103 } |
| 107 | 104 |
| 108 foreach($files as $file) { | 105 foreach($files as $file) { |
| 109 $file_stat = @stat($dir . "/". $file); | 106 $file_stat = @stat($dir . "/". $file); |
| 110 | 107 |
| 111 $file_rows .= "<tr>"; | 108 $file_rows .= "<tr>"; |
| 112 $file_rows .= "<td>". $list_file_prefix . link_to($file . $file_suffix, $file . $file_suffix)."</td>"; | 109 $file_rows .= "<td>". $list_file_prefix . link_to($file . $file_suffix, $file . $file_suffix)."</td>"; |
| 113 | 110 |
| 114 $file_rows .= "<td>"; | 111 $file_rows .= "<td>"; |
| 115 if ($is_dir) { $file_rows .= hidden_data(0) . "[dir]"; } | 112 $file_rows .= hidden_data($file_stat["size"], $is_dir); |
| 116 else { $file_rows .= hidden_data($file_stat["size"]) . human_size($file_stat['size']); } | 113 if ($is_dir) { $file_rows .= "[dir]"; } |
| 114 else { $file_rows .= human_size($file_stat['size']); } | |
| 117 $file_rows .= "</td>"; | 115 $file_rows .= "</td>"; |
| 118 | 116 |
| 119 $file_rows .= "<td>".h(strftime("%Y-%m-%d %H:%M %Z", $file_stat['mtime']))."</td>"; | 117 $file_rows .= "<td>" . hidden_data("", $is_dir) . h(strftime("%Y-%m-%d %H:%M %Z", $file_stat['mtime'])) . "</td>"; |
| 120 | 118 |
| 121 $file_rows .= "</tr>"; | 119 $file_rows .= "</tr>"; |
| 122 } | 120 } |
| 123 return $file_rows; | 121 return $file_rows; |
| 124 } | 122 } |
