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 = 8; # em width per year
20 $mindate = strtotime($date) + ($year / $scale * 3); # first point plus about 3em for centered text
22 print '<ul class="timeline">'."\n";
23 foreach (array_reverse($cal, TRUE) as $group => $rows) {
24 if (count($rows) > 1) {
25 $time = ($mindate - strtotime("$group-12-31T23:59")) / $year * $scale;
26 printf('<li class="range" style="left:%.1fem; width:%sem">', $time, $scale);
27 print "<strong>$group</strong><ul>\n";
33 foreach ($rows as $title => $versions) {
34 $subtime = ($mindate - strtotime($title)) / $year * $scale - $time;
35 printf('<li style="left:%.1fem">', $subtime);
36 if ($url = @$versions['']) {
37 printf('<a href="/%s">%s</a>', $url, $title);
42 if ($versions and $User->admin("edit $Page$Args")) {
43 printf(' (%s)', implode(', ', array_map(
44 function ($format, $url) {
45 return sprintf('<a href="/%s">%s</a>', $url, $format);
47 array_keys($versions), $versions
55 if (count($rows) > 1) {