2 $rootdir = $Page->link;
4 $nav = explode('/', $rootdir);
5 $nav[0] = "Foto's"; # override of root 'foto'
6 $title = array_pop($nav);
7 $Page->title = ($nav ? implode(' ', $nav) . ': ' : '') . $title;
9 if ($_SERVER['HTTP_ACCEPT'] === 'application/json') {
10 header('Access-Control-Allow-Origin: *');
12 foreach (glob("$rootdir/*.jpg") as $path) {
13 $target = preg_replace('{^(\.\./)*}', '', readlink($path));
14 $imgs[] = ["/$target"];
16 print json_encode($imgs);
20 $img = "$rootdir/index.jpg";
21 if (file_exists($img)) {
22 # cover image of current album
23 $Page->image = "/$img";
26 return array_map(function ($dir) {
27 return new ArchiveArticle($dir . '/index.html');
28 }, glob("$rootdir/*", GLOB_ONLYDIR)); #TODO: recurse
33 if ($User->admin('foto')) {
34 if ($Page->restricted) {
35 $access = '<span class="icon icon-locked">🔒</span> Bewoners';
36 if ($Page->restricted != $rootdir) {
37 $access .= sprintf(' vanaf <a href="%s">%s</a>',
38 "/{$Page->restricted}", pathinfo($Page->restricted, PATHINFO_FILENAME)
43 $access = '<span class="icon icon-locked">🔓</span> Openbaar';
45 print "<aside>$access</aside>\n\n";
50 foreach ($nav as $i => $linktitle) {
51 $link .= '/' . ($i ? $linktitle : $Page->handler);
52 printf('<a href="%s">%s</a> →'."\n", $link, $linktitle);
57 if (isset($Page->raw)) {
58 print $Page->raw; # page intro
61 if ($imgs = glob("$rootdir/*", GLOB_ONLYDIR)) {
63 print '<ul class="gallery cat">'."\n";
64 foreach ($imgs as $path) {
65 $album = htmlspecialchars(pathinfo($path, PATHINFO_FILENAME));
66 $cover = "$path/index.jpg";
67 if (!file_exists($cover)) $cover = 'foto/index.jpg';
68 if (is_link($cover)) {
69 $cover = preg_replace('{^(?:\.\./)*(?=data/)}', 'thumb/100/', readlink($cover));
72 $html = sprintf('<img src="/%s" />', htmlspecialchars($cover));
73 $html .= "<figcaption>$album</figcaption>";
74 if (!$User->login and file_exists("$path/.private")) {
75 $html = '<s title="bewoners">'.$html.'</s>';
77 $html = "<figure>$html</figure>";
79 printf('<li id="%s">', $album);
80 printf('<a href="/%s">%s</a>'."\n", htmlspecialchars($path), $html);
85 if ($imgs = glob("$rootdir/*.jpg")) {
86 print '<ul class="gallery album">'."\n";
87 foreach ($imgs as $path) {
88 if ($path == "$rootdir/index.jpg") {
89 # cover image of current album
90 $Page->image = "/$path";
93 if (!is_link($path)) continue;
95 // assume all album entries are symlinks to archive originals
96 $target = preg_replace('{^(\.\./)*}', '', readlink($path));
97 $thumb = 'thumb/262/' . $target;
99 @list ($order, $size, $title) = explode(':', pathinfo($path, PATHINFO_FILENAME), 3);
100 $imgtag = 'img src="/'.$thumb.'"';
102 $imgtag .= ' title="'.htmlspecialchars(urldecode($title)).'"';
105 $imgtag .= ' data-size="'.$size.'"';
109 printf('<a href="/%s"><%s /></a>'."\n", $target, $imgtag);
111 print '</ul>'."\n\n";
113 include 'foto/album.inc.php';