<?php
+global $User;
+
$cal = [];
foreach (glob("$Page$Args/2*") as $url) {
- $parts = pathinfo($url);
- @list ($date, $suffix) = explode('.', $parts['filename'], 2);
- $cal[$date][ $suffix ? '' : @$parts['extension'] ] =
- preg_replace('/\.html$/', '', $url);
+ $link = preg_replace('/\.html$/', '', $url);
+ $name = pathinfo($link, PATHINFO_BASENAME);
+ @list ($date, $suffix) = explode('.', $name, 2);
+ if (!filesize($url)) {
+ $cal[$date] = [];
+ }
+ else {
+ $cal[$date][$suffix] = $link;
+ }
}
print '<ul';
print ">\n";
foreach (array_reverse($cal) as $title => $versions) {
print '<li>';
- if ($url = @$versions['html']) {
+ if ($url = @$versions['']) {
printf('<a href="/%s">%s</a>', $url, $title);
}
- elseif (implode('', array_keys($versions))) {
- list ($format, $url) = each($versions);
- include_once('format.inc.php');
- printf('%s (<a href="/%s">%sB %s</a>)',
- $title, $url, showsize(filesize($url)), $format
- );
- }
else {
print $title;
+ if ($versions and $User->admin("edit $Page$Args")) {
+ printf(' (%s)', implode(', ', array_map(
+ function ($format, $url) {
+ return sprintf('<a href="/%s">%s</a>', $url, $format);
+ },
+ array_keys($versions), $versions)
+ ));
+ }
}
- print "\n";
+ print "</li>\n";
}
print "</ul>\n\n";