2 $rootdir = $Page->link;
4 $nav = explode('/', $rootdir);
5 if (count($nav) > 1 and $nav[1] == 'tag') {
6 $rootdir = preg_replace('{/}', '/.', $rootdir, 1);
8 $nav[0] = "Foto's"; # override of root 'foto'
9 $title = array_pop($nav);
10 $Page->title = ($nav ? implode(' ', $nav) . ': ' : '') . $title;
12 if ($_SERVER['HTTP_ACCEPT'] === 'application/json') {
13 header('Access-Control-Allow-Origin: *');
14 header('Cache-Control: max-age=10');
15 if (file_exists($rootdir)) {
16 header('Last-Modified: '.gmdate(DATE_RFC7231, filemtime($rootdir)));
19 http_response_code(404);
22 foreach (glob("$rootdir/*.jpg") as $path) {
23 $target = preg_replace('{^(\.\./)*}', '', readlink($path));
24 $imgs[] = ["/$target"];
26 print json_encode($imgs);
30 $img = "$rootdir/index.jpg";
31 if (file_exists($img)) {
32 # cover image of current album
33 $Page->image = "/$img";
36 return array_map(function ($dir) {
37 return new ArchiveArticle($dir . '/index.html');
38 }, glob("$rootdir/*", GLOB_ONLYDIR)); #TODO: recurse
43 if ($User->admin('foto')) {
44 if ($Page->restricted) {
45 $access = '<span class="icon icon-locked">🔒</span> Bewoners';
46 if ($Page->restricted != $rootdir) {
47 $access .= sprintf(' vanaf <a href="%s">%s</a>',
48 "/{$Page->restricted}", pathinfo($Page->restricted, PATHINFO_FILENAME)
53 $access = '<span class="icon icon-locked">🔓</span> Openbaar';
55 print "<aside>$access</aside>\n\n";
60 foreach ($nav as $i => $linktitle) {
61 $link .= '/' . ($i ? $linktitle : $Page->handler);
62 printf('<a href="%s">%s</a> →'."\n", $link, $linktitle);
67 if (isset($Page->raw)) {
68 print $Page->raw; # page intro
71 if ($imgs = glob("$rootdir/*", GLOB_ONLYDIR)) {
73 print '<ul class="gallery cat">'."\n";
74 foreach ($imgs as $path) {
75 $album = htmlspecialchars(pathinfo($path, PATHINFO_FILENAME));
76 $cover = "$path/index.jpg";
77 if (!file_exists($cover)) $cover = 'foto/index.jpg';
78 if (is_link($cover)) {
79 $cover = preg_replace('{^(?:\.\./)*(?=data/)}', 'thumb/100/', readlink($cover));
82 $html = sprintf('<img src="/%s" />', htmlspecialchars($cover));
83 $html .= "<figcaption>$album</figcaption>";
84 if (!$User->login and file_exists("$path/.private")) {
85 $html = '<s title="bewoners">'.$html.'</s>';
87 $html = "<figure>$html</figure>";
89 printf('<li id="%s">', $album);
90 printf('<a href="/%s">%s</a>'."\n", htmlspecialchars($path), $html);
95 if ($imgs = glob("$rootdir/*.jpg")) {
96 print '<ul class="gallery album">'."\n";
97 foreach ($imgs as $path) {
98 if ($path == "$rootdir/index.jpg") {
99 # cover image of current album
100 $Page->image = "/$path";
103 if (!is_link($path)) continue;
105 // assume all album entries are symlinks to archive originals
106 $target = preg_replace('{^(\.\./)*}', '', readlink($path));
107 $thumb = 'thumb/262/' . $target;
109 @list ($order, $size, $title) = explode(':', pathinfo($path, PATHINFO_FILENAME), 3);
110 $imgtag = 'img src="/'.$thumb.'"';
112 $imgtag .= ' title="'.htmlspecialchars(urldecode($title)).'"';
115 $imgtag .= ' data-size="'.$size.'"';
119 printf('<a href="/%s"><%s /></a>'."\n", $target, $imgtag);
121 print '</ul>'."\n\n";
123 include 'foto/album.inc.php';