Mercurial > dirlist-php
comparison index.php @ 50:5a4c9efd99fc
No more globals.
| author | nanaya <me@myconan.net> |
|---|---|
| date | Mon, 24 Aug 2015 21:13:56 +0900 |
| parents | 4e85d97e41b6 |
| children | 29543401ef18 |
comparison
equal
deleted
inserted
replaced
| 49:4e85d97e41b6 | 50:5a4c9efd99fc |
|---|---|
| 65 function hidden_data($data = "", $is_dir = false) { | 65 function hidden_data($data = "", $is_dir = false) { |
| 66 return "<i> " . ($is_dir === true ? 0 : 1) . " " . $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($uri) { |
| 71 global $uri; | |
| 72 | |
| 73 $uri_array = explode("/", trim($uri, "/")); | 71 $uri_array = explode("/", trim($uri, "/")); |
| 74 | 72 |
| 75 $tree_path = "/"; | 73 $tree_path = "/"; |
| 76 $tree_link = link_to($tree_path, "[root]"); | 74 $tree_link = link_to($tree_path, "[root]"); |
| 77 $tree_link .= "/"; | 75 $tree_link .= "/"; |
| 83 } | 81 } |
| 84 | 82 |
| 85 return $tree_link; | 83 return $tree_link; |
| 86 } | 84 } |
| 87 | 85 |
| 88 function up_link() { | 86 function up_link($uri) { |
| 89 global $uri; | |
| 90 if ($uri !== "/") { | 87 if ($uri !== "/") { |
| 91 return "<tr><td colspan=3>" . link_to(dirname($uri) . "/", "[up]") . "</td></tr>"; | 88 return "<tr><td colspan=3>" . link_to(dirname($uri) . "/", "[up]") . "</td></tr>"; |
| 92 } | 89 } |
| 93 } | 90 } |
| 94 | 91 |
| 95 function file_rows($files, $is_dir) { | 92 function file_rows($dir, $files, $is_dir) { |
| 96 global $dir, $uri; | |
| 97 | |
| 98 $file_rows = ""; | 93 $file_rows = ""; |
| 99 $file_suffix = ""; | 94 $file_suffix = ""; |
| 100 $list_file_prefix = hidden_data("", $is_dir); | 95 $list_file_prefix = hidden_data("", $is_dir); |
| 101 | 96 |
| 102 if ($is_dir) { | 97 if ($is_dir) { |
| 205 input { font-size: 18px; } | 200 input { font-size: 18px; } |
| 206 } | 201 } |
| 207 </style> | 202 </style> |
| 208 </head> | 203 </head> |
| 209 <body id="files"> | 204 <body id="files"> |
| 210 <h1>Index of <?php echo tree_link(); ?></h1> | 205 <h1>Index of <?php echo tree_link($uri); ?></h1> |
| 211 | 206 |
| 212 <input placeholder="search (non-recursive)" class="search" /> | 207 <input placeholder="search (non-recursive)" class="search" /> |
| 213 | 208 |
| 214 <table> | 209 <table> |
| 215 <thead> | 210 <thead> |
| 216 <tr> | 211 <tr> |
| 217 <th><span class="sort" data-sort="filename">File</span></th> | 212 <th><span class="sort" data-sort="filename">File</span></th> |
| 218 <th><span class="sort" data-sort="size">Size</span></th> | 213 <th><span class="sort" data-sort="size">Size</span></th> |
| 219 <th><span class="sort" data-sort="date">Date</span></th> | 214 <th><span class="sort" data-sort="date">Date</span></th> |
| 220 </tr> | 215 </tr> |
| 221 <?php echo up_link(); ?> | 216 <?php echo up_link($uri); ?> |
| 222 </thead> | 217 </thead> |
| 223 <tbody class="list"> | 218 <tbody class="list"> |
| 224 <?php echo file_rows($dirs, true); ?> | 219 <?php echo file_rows($dir, $dirs, true); ?> |
| 225 <?php echo file_rows($files, false); ?> | 220 <?php echo file_rows($dir, $files, false); ?> |
| 226 </tbody> | 221 </tbody> |
| 227 </table> | 222 </table> |
| 228 | 223 |
| 229 <footer> | 224 <footer> |
| 230 <hr> | 225 <hr> |
