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: *');
15 foreach (glob("$rootdir/*.jpg") as $path) {
16 $target = preg_replace('{^(\.\./)*}', '', readlink($path));
17 $imgs[] = ["/$target"];
19 print json_encode($imgs);
23 $img = "$rootdir/index.jpg";
24 if (file_exists($img)) {
25 # cover image of current album
26 $Page->image = "/$img";
29 return array_map(function ($dir) {
30 return new ArchiveArticle($dir . '/index.html');
31 }, glob("$rootdir/*", GLOB_ONLYDIR)); #TODO: recurse
36 if ($User->admin('foto')) {
37 if ($Page->restricted) {
38 $access = '<span class="icon icon-locked">🔒</span> Bewoners';
39 if ($Page->restricted != $rootdir) {
40 $access .= sprintf(' vanaf <a href="%s">%s</a>',
41 "/{$Page->restricted}", pathinfo($Page->restricted, PATHINFO_FILENAME)
46 $access = '<span class="icon icon-locked">🔓</span> Openbaar';
48 print "<aside>$access</aside>\n\n";
53 foreach ($nav as $i => $linktitle) {
54 $link .= '/' . ($i ? $linktitle : $Page->handler);
55 printf('<a href="%s">%s</a> →'."\n", $link, $linktitle);
60 if (isset($Page->raw)) {
61 print $Page->raw; # page intro
64 if ($imgs = glob("$rootdir/*", GLOB_ONLYDIR)) {
66 print '<ul class="gallery cat">'."\n";
67 foreach ($imgs as $path) {
68 $album = htmlspecialchars(pathinfo($path, PATHINFO_FILENAME));
69 $cover = "$path/index.jpg";
70 if (!file_exists($cover)) $cover = 'foto/index.jpg';
71 if (is_link($cover)) {
72 $cover = preg_replace('{^(?:\.\./)*(?=data/)}', 'thumb/100/', readlink($cover));
75 $html = sprintf('<img src="/%s" />', htmlspecialchars($cover));
76 $html .= "<figcaption>$album</figcaption>";
77 if (!$User->login and file_exists("$path/.private")) {
78 $html = '<s title="bewoners">'.$html.'</s>';
80 $html = "<figure>$html</figure>";
82 printf('<li id="%s">', $album);
83 printf('<a href="/%s">%s</a>'."\n", htmlspecialchars($path), $html);
88 if ($imgs = glob("$rootdir/*.jpg")) {
89 print '<ul class="gallery album">'."\n";
90 foreach ($imgs as $path) {
91 if ($path == "$rootdir/index.jpg") {
92 # cover image of current album
93 $Page->image = "/$path";
96 if (!is_link($path)) continue;
98 // assume all album entries are symlinks to archive originals
99 $target = preg_replace('{^(\.\./)*}', '', readlink($path));
100 $thumb = 'thumb/262/' . $target;
102 @list ($order, $size, $title) = explode(':', pathinfo($path, PATHINFO_FILENAME), 3);
103 $imgtag = 'img src="/'.$thumb.'"';
105 $imgtag .= ' title="'.htmlspecialchars(urldecode($title)).'"';
108 $imgtag .= ' data-size="'.$size.'"';
112 printf('<a href="/%s"><%s /></a>'."\n", $target, $imgtag);
114 print '</ul>'."\n\n";
116 include 'foto/album.inc.php';