1
0
mirror of https://github.com/lrsjng/h5ai.git synced 2025-03-20 04:20:00 +01:00

Adds no-js fallback to PHP verison.

This commit is contained in:
Lars Jung 2012-07-15 23:29:21 +02:00
parent 1828855f63
commit 4724214b9e
5 changed files with 55 additions and 5 deletions

@ -1,4 +1,6 @@
<!-- generated code ends here -->
</div>
<script src="/_h5ai/config.js"></script>
<script src="/_h5ai/js/scripts.js"></script>
</body>
</html>

@ -31,8 +31,6 @@
<span class="right"></span>
<span class="center"></span>
</div>
<script src="/_h5ai/config.js"></script>
<script src="/_h5ai/js/scripts.js"></script>
<div id="data-apache-autoindex" class="hideOnJs">
<!--
The following code was generated by Apache's autoindex module. It is not valid HTML5, but gets

@ -1,5 +1,5 @@
#data-apache-autoindex {
#data-apache-autoindex, #data-php-no-js-fallback {
max-width: 960px;
margin: 0 auto;
@ -29,6 +29,11 @@
opacity: 0.9;
}
}
span {
color: #555;
font-weight: normal;
opacity: 0.4;
}
}
td {
border: 1px solid #ddd;

@ -32,8 +32,6 @@
<span class="right"></span>
<span class="center"></span>
</div>
<script src="/_h5ai/config.js"></script>
<script src="/_h5ai/js/scripts.js"></script>
<div id="data-generic-json" class="hidden">
<?php if (stripos($_SERVER["REQUEST_METHOD"], "HEAD") === false) {
@ -64,5 +62,13 @@
echo $h5ai->getGenericJson();
} ?>
</div>
<div id="data-php-no-js-fallback" class="hideOnJs">
<?php if (stripos($_SERVER["REQUEST_METHOD"], "HEAD") === false) {
echo $h5ai->getNoJsFallback();
} ?>
</div>
<script src="/_h5ai/config.js"></script>
<script src="/_h5ai/js/scripts.js"></script>
</body>
</html>

@ -292,6 +292,45 @@ class H5ai {
return $entries;
}
public function getNoJsFallback() {
date_default_timezone_set ("UTC");
function _cmp($entry1, $entry2) {
if ($entry1->isFolder && !$entry2->isFolder) {
return -1;
}
if (!$entry1->isFolder && $entry2->isFolder) {
return 1;
}
return strcasecmp($entry1->absHref, $entry2->absHref);
}
$folder = Entry::get($this, $this->absPath, $this->absHref);
$entries = $folder->getContent();
uasort($entries, "_cmp");
$html = "<table>";
$html .= "<tr><th></th><th><span>Name</span></th><th><span>Last modified</span></th><th><span>Size</span></th></tr>";
if ($folder->parent) {
$html .= "<tr><td></td><td><a href=\"..\">Parent Directory</a></td><td></td><td></td></tr>";
}
foreach ($entries as $entry) {
$html .= "<tr>";
$html .= "<td></td>";
$html .= "<td><a href=\"" . $entry->absHref . "\">" . basename($entry->absPath) . ($entry->isFolder ? "/" : "") . "</a></td>";
$html .= "<td>" . date("Y-m-d H:i", $entry->date) . "</td>";
$html .= "<td>" . ($entry->size !== null ? intval($entry->size / 1000) . " KB" : "" ) . "</td>";
$html .= "</tr>";
}
$html .= "</table>";
return $html;
}
}
?>