Mercurial > dirlist-php
comparison index.php @ 43:54c13838f8bb
Add spacing to before/after hidden data part.
And extract the generation to separate function.
| author | nanaya <me@myconan.net> |
|---|---|
| date | Sun, 24 May 2015 18:17:21 +0900 |
| parents | ddb5458658d2 |
| children | 2ec27751645e |
comparison
equal
deleted
inserted
replaced
| 42:ddb5458658d2 | 43:54c13838f8bb |
|---|---|
| 59 $return_format = "%.2f %s"; | 59 $return_format = "%.2f %s"; |
| 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 | |
| 65 function hidden_data($data) { | |
| 66 return "<i> " . $data . " </i>"; | |
| 67 } | |
| 64 // END UTILITY | 68 // END UTILITY |
| 65 | 69 |
| 66 function tree_link() { | 70 function tree_link() { |
| 67 global $uri; | 71 global $uri; |
| 68 | 72 |
| 94 $file_suffix = ""; | 98 $file_suffix = ""; |
| 95 $list_file_prefix = ""; | 99 $list_file_prefix = ""; |
| 96 | 100 |
| 97 if ($is_dir) { | 101 if ($is_dir) { |
| 98 $file_suffix = "/"; | 102 $file_suffix = "/"; |
| 99 $list_file_prefix = "<i>0</i>"; | 103 $list_file_prefix = hidden_data(0); |
| 100 } else { | 104 } else { |
| 101 $list_file_prefix = "<i>1</i>"; | 105 $list_file_prefix = hidden_data(1); |
| 102 } | 106 } |
| 103 | 107 |
| 104 foreach($files as $file) { | 108 foreach($files as $file) { |
| 105 $file_stat = @stat($dir . "/". $file); | 109 $file_stat = @stat($dir . "/". $file); |
| 106 | 110 |
| 107 $file_rows .= "<tr>"; | 111 $file_rows .= "<tr>"; |
| 108 $file_rows .= "<td>". $list_file_prefix . link_to($file . $file_suffix, $file . $file_suffix)."</td>"; | 112 $file_rows .= "<td>". $list_file_prefix . link_to($file . $file_suffix, $file . $file_suffix)."</td>"; |
| 109 | 113 |
| 110 $file_rows .= "<td>"; | 114 $file_rows .= "<td>"; |
| 111 if ($is_dir) { $file_rows .= "<i>0</i>[dir]"; } | 115 if ($is_dir) { $file_rows .= hidden_data(0) . "[dir]"; } |
| 112 else { $file_rows .= "<i>" . $file_stat["size"] . "</i>" . human_size($file_stat['size']); } | 116 else { $file_rows .= hidden_data($file_stat["size"]) . human_size($file_stat['size']); } |
| 113 $file_rows .= "</td>"; | 117 $file_rows .= "</td>"; |
| 114 | 118 |
| 115 $file_rows .= "<td>".h(strftime("%Y-%m-%d %H:%M %Z", $file_stat['mtime']))."</td>"; | 119 $file_rows .= "<td>".h(strftime("%Y-%m-%d %H:%M %Z", $file_stat['mtime']))."</td>"; |
| 116 | 120 |
| 117 $file_rows .= "</tr>"; | 121 $file_rows .= "</tr>"; |
