3 if (isset($Page->place[0])) {
4 $Page->link .= '/'.$Page->place[0];
8 foreach (glob("{$Page->link}/2*") as $url) {
9 $link = preg_replace('/\.html$/', '', $url);
10 $name = pathinfo($link, PATHINFO_BASENAME);
11 @list ($date, $suffix) = explode('.', $name, 2);
12 $group = substr($date, 0, 4);
13 if (!isset($cal[$group][$date])) {
14 $cal[$group][$date] = [];
16 if (!is_dir($url) and filesize($url)) {
17 $cal[$group][$date][$suffix] = $link;
24 $year = 3600 * 24 * 365; # seconds per year
25 $scale = 7; # em width per year
26 $mindate = max(time(), strtotime($date) + ($year / $scale * 3)); # at least last entry plus 3em for centered text
27 $length = ($mindate - strtotime(key(current($cal)))) / $year * $scale; # earliest entry position
29 printf('<ul class="timeline" style="background-size:%.1fem">'."\n", $length);
30 foreach (array_reverse($cal, TRUE) as $group => $rows) {
31 if (count($rows) > 1) {
32 $time = ($mindate - strtotime("$group-12-31T23:59")) / $year * $scale;
33 printf('<li class="range" style="left:%.1fem; width:%.1fem">',
34 $time, $time + $scale > $length ? $length - $time + 2 : $scale
36 print "<strong>$group</strong><ul>\n";
42 foreach ($rows as $title => $versions) {
43 $subtime = ($mindate - strtotime($title)) / $year * $scale - $time;
44 printf('<li style="left:%.1fem">', $subtime);
45 if ($url = @$versions['']) {
46 printf('<a href="/%s">%s</a>', $url, $title);
51 if ($versions and $User->admin("edit {$Page->link}")) {
52 printf(' (%s)', implode(', ', array_map(
53 function ($format, $url) {
54 return sprintf('<a href="/%s">%s</a>', $url, $format);
56 array_keys($versions), $versions
64 if (count($rows) > 1) {