diff --git a/index.php b/index.php index f8a27c2..23ba3bf 100644 --- a/index.php +++ b/index.php @@ -10,7 +10,7 @@ use PhotoPrismUpload\Entities\Album; /** @var string $footer Footer text which links to the Gitea repo */ $footer = ''; + ''; ?>
@@ -43,13 +43,21 @@ $footer = .form-wrapper { display: grid; grid-template-rows: auto auto auto; - grid-auto-columns: minmax(auto, 300px) auto; + grid-auto-columns: minmax(auto, 400px) auto; } label[for="album"] { grid-column: 1; grid-row: 1; align-self: center; } + label[for="artist"], label[for="uploader"] { + grid-column: 1; + align-self: center; + } + input[type=text] { + grid-column: 2; + justify-self: right; + } #album { grid-column: 2; grid-row: 1; @@ -63,7 +71,7 @@ $footer = } input[type=submit] { grid-column: 2; - grid-row: 3; + grid-row: 5; justify-self: right; } #error, @@ -77,6 +85,7 @@ $footer = #uploadForm { grid-row: 1; grid-column: 1; + grid-auto-columns: minmax(100px, auto); } #error { grid-row: 2; @@ -149,13 +158,15 @@ if (!isset($_POST['submit'])) { @@ -187,6 +202,8 @@ if (!isset($_POST['submit'])) { const form = document.getElementById('uploadForm'); const submitButton = form.querySelector('input[type=submit]'); const albumInput = form.querySelector('select[name=album]'); + const artistInput = form.querySelector('input[name=artist]'); + const uploaderInput = form.querySelector('input[name=uploader]'); const input = document.getElementById('input'); const fileProgress = document.getElementById('fileProgress'); const totalProgress = document.getElementById('totalProgress'); @@ -247,6 +264,8 @@ if (!isset($_POST['submit'])) { formData.set(input.name, file); formData.set(submitButton.name, submitButton.value); formData.set(albumInput.name, albumInput.value); + formData.set(artistInput.name, artistInput.value); + formData.set(uploaderInput.name, uploaderInput.value); try { let resp = await postData(form.action, formData, form.method); } catch(e) { @@ -329,7 +348,24 @@ if (!isset($_POST['submit'])) { '); } try { - $api->uploadPhotos($_POST['album']); + $hashes = $api->uploadPhotos($_POST['album']); + foreach ($hashes as $hash) { + $photo = $api->getByHash($hash); + if (!isset($photo)) { + continue; + } + $details = [ + 'Artist' => $_POST['artist'], + 'ArtistSrc' => 'manual', + 'Copyright' => $_POST['artist'], + 'CopyrightSrc' => 'manual', + ]; + if (!empty($_POST['uploader'])) { + $details['Notes'] = 'Hochgeladen von: ' . $_POST['uploader']; + $details['NotesSrc'] = 'manual'; + } + $api->updatePhotoDetails($photo, $details); + } } catch (\Exception $e) { die('Fehler: ' . $footer . $e->getMessage() . '