edit/foto: admin option to set image as album cover
authorMischa POSLAWSKY <perl@shiar.org>
Mon, 18 Sep 2017 16:55:37 +0000 (18:55 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 19 Jun 2018 11:10:22 +0000 (13:10 +0200)
Copied from editcover at Lijtweg commit v2.5-20-g93cfc0a122 (2017-10-13).

edit/fotocover/index.php [new file with mode: 0644]
foto/album.inc.php

diff --git a/edit/fotocover/index.php b/edit/fotocover/index.php
new file mode 100644 (file)
index 0000000..feddc8d
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+ob_clean();
+
+if (empty($User['admin'])) {
+       http_response_code(403);
+       print "Beheerrechten verplicht voor instellen van covers\n";
+       exit;
+}
+
+$rootdir = 'foto' . $Args;
+$target = "$rootdir/index.jpg";
+
+if (is_link($target) or file_exists($target)) {
+       if (!unlink($target)) {
+               http_response_code(500);
+               print "Kon bestaande cover niet weghalen voor $Args\n";
+               exit;
+       }
+}
+
+if (isset($_GET['img'])) {
+       $img = str_repeat('../', substr_count($target, '/')); # up to docroot
+       $img .= ltrim($_GET['img'], '/');
+       if (!symlink($img, $target)) {
+               http_response_code(500);
+               print "Fout bij instellen van cover voor $Args\n";
+               exit;
+       }
+}
+
+$album = pathinfo($rootdir);
+header("Location: /{$album['dirname']}#{$album['basename']}");
+http_response_code(302);
index 597e9a4e343842974b4ced481ff8878c4565f23a..5e1a14845fe6a3a0a62d54bb3f6012aca9674c5f 100644 (file)
@@ -23,6 +23,13 @@ function openphotoswipe(index) {
                clickToCloseNonZoomable: false,
                closeElClasses: [], 
                shareButtons: [
+<?php
+if (!empty($User['admin'])) {
+       printf("\t\t\t{id:'%s', label:'%s', url:'%s'},\n",
+               'cover', 'Cover instellen', "/edit/fotocover$Args?img={{image_url}}"
+       );
+}
+?>
                        {id:'download', label:'Origineel downloaden', url:'{{raw_image_url}}', download:true}
                ],
        };