5 foreach (glob("$Page$Args/2*") as $url) {
6 $link = preg_replace('/\.html$/', '', $url);
7 $name = pathinfo($link, PATHINFO_BASENAME);
8 @list ($date, $suffix) = explode('.', $name, 2);
9 $group = substr($date, 0, 4);
10 if (!isset($cal[$group][$date])) {
11 $cal[$group][$date] = [];
13 if (!is_dir($url) and filesize($url)) {
14 $cal[$group][$date][$suffix] = $link;
18 $year = 3600 * 24 * 365; # seconds per year
19 $scale = 7; # em width per year
20 $mindate = max(time(), strtotime($date) + ($year / $scale * 3)); # at least last entry plus 3em for centered text
21 $length = ($mindate - strtotime(key(current($cal)))) / $year * $scale; # earliest entry position
23 printf('<ul class="timeline" style="background-size:%.1fem">'."\n", $length);
24 foreach (array_reverse($cal, TRUE) as $group => $rows) {
25 if (count($rows) > 1) {
26 $time = ($mindate - strtotime("$group-12-31T23:59")) / $year * $scale;
27 printf('<li class="range" style="left:%.1fem; width:%.1fem">',
28 $time, $time + $scale > $length ? $length - $time + 2 : $scale
30 print "<strong>$group</strong><ul>\n";
36 foreach ($rows as $title => $versions) {
37 $subtime = ($mindate - strtotime($title)) / $year * $scale - $time;
38 printf('<li style="left:%.1fem">', $subtime);
39 if ($url = @$versions['']) {
40 printf('<a href="/%s">%s</a>', $url, $title);
45 if ($versions and $User->admin("edit $Page$Args")) {
46 printf(' (%s)', implode(', ', array_map(
47 function ($format, $url) {
48 return sprintf('<a href="/%s">%s</a>', $url, $format);
50 array_keys($versions), $versions
58 if (count($rows) > 1) {