foto: common override of navigation root title
[minimedit.git] / foto / index.php
index eadda9103ac187690c09b7e04a6c942b06b050ff..cd939f3ab2e5e92ba73fbeff02dc0946ef24952a 100644 (file)
@@ -1,13 +1,13 @@
 <?php
 $intro = ob_get_clean();
 
-$rootdir = 'foto' . $Args;
+$rootdir = $Page . $Args;
 
 if (!empty($User['admin'])) {
        $access = '🔓 Openbaar';
        if (isset($PageAccess)) {
                $access = "🔒 Bewoners";
-               if ($PageAccess != $Page.$Args) {
+               if ($PageAccess != $rootdir) {
                        $access .= sprintf(' vanaf <a href="%s">%s</a>',
                                "/$PageAccess", pathinfo($PageAccess, PATHINFO_FILENAME)
                        );
@@ -16,16 +16,17 @@ if (!empty($User['admin'])) {
        print "<aside>$access</aside>\n\n";
 }
 
-$nav = explode('/', $Page.$Args);
+$nav = explode('/', $rootdir);
+$nav[0] = "Foto's"; # override of root 'foto'
 $title = array_pop($nav);
-$rootname = "Foto's"; # override of 'foto'
+
 $link = '';
 print "<h2>";
 foreach ($nav as $i => $linktitle) {
-       $link .= "/$linktitle";
-       printf('<a href="%s">%s</a> â†’'."\n", $link, $i ? $linktitle : $rootname);
+       $link .= '/' . ($i ? $linktitle : $Page);
+       printf('<a href="%s">%s</a> â†’'."\n", $link, $linktitle);
 }
-print $Args ? $title : $rootname;
+print $title;
 print "</h2>\n\n";
 
 print $intro;
@@ -34,7 +35,7 @@ function showthumb($path)
 {
        // assume all album entries are symlinks to archive originals
        $target = preg_replace('{^(\.\./)*}', '', readlink($path));
-       $thumb = preg_replace('{^data/}', 'thumb/200/', $target);
+       $thumb = 'thumb/200/' . $target;
 
        @list ($order, $size, $title) = explode(':', pathinfo($path, PATHINFO_FILENAME), 3);
        $imgtag = 'img src="/'.$thumb.'"';
@@ -57,7 +58,7 @@ if ($imgs = glob("$rootdir/*", GLOB_ONLYDIR)) {
                $cover = "$path/index.jpg";
                if (!file_exists($cover)) $cover = 'foto/index.jpg';
                if (is_link($cover)) {
-                       $cover = preg_replace('{^(?:\.\./)*data/}', 'thumb/100/', readlink($cover));
+                       $cover = preg_replace('{^(?:\.\./)*(?=data/)}', 'thumb/100/', readlink($cover));
                }
 
                $html = '<img src="/'.$cover.'" />';