Added documentation

This commit is contained in:
2021-11-27 12:52:29 +01:00
parent ae4eb30a73
commit 29b429e239
4 changed files with 166 additions and 17 deletions

View File

@ -1,9 +1,13 @@
<?php
session_start();
/** require autoloading to manage namespaces */
require __DIR__ . '/vendor/autoload.php';
use PhotoPrismUpload\API\PhotoPrism;
use PhotoPrismUpload\Entities\Album;
/** @var string $footer Footer text which links to the Gitea repo */
$footer = '<footer style="position: fixed;bottom: 0;left: 0;">'
.'<a href="/git/phlaym/photoprismupload">Ich bin Open Source</a></footer>';
?>
@ -61,7 +65,11 @@ $footer = '<footer style="position: fixed;bottom: 0;left: 0;">'
grid-row: 3;
justify-self: right;
}
#error, #fileProgress, #totalProgress, label[for="fileProgress"], label[for="totalProgress"] {
#error,
#fileProgress,
#totalProgress,
label[for="fileProgress"],
label[for="totalProgress"] {
display:none;
grid-column: 1;
}
@ -88,7 +96,7 @@ $footer = '<footer style="position: fixed;bottom: 0;left: 0;">'
width: 100%;
}
#viewAlbum {
#grid-row: 7;
grid-row: 7;
}
footer {
margin: 8px;
@ -98,8 +106,13 @@ $footer = '<footer style="position: fixed;bottom: 0;left: 0;">'
<body>
<?php
/** @var array $config configuration options */
$config = require(__DIR__ . '/config.php');
/** @var PhotoPrism $api API object to interface with PhotoPrism */
$api = new PhotoPrism($config);
/** @var Album[] $albums List of PhotoPrism albums */
$albums = [];
try {
$api->login();
@ -111,9 +124,15 @@ if (!isset($_POST['submit'])) {
if (!isset($_GET['token'])) {
die('Sorry, kein Zugriff' . $footer . '</body></html>');
}
/** @var string $token Tokens for which album(s) are visible in the dropdown */
$token = $_GET['token'];
/** @var string[] $tokens List of album tokens */
$tokens = explode(',', $token);
$album_url = null;
/** @var string $album_url URL path to the selected album */
$album_url = '/';
try {
$albums = $api->getAlbumsByTokens($tokens);
} catch (\Exception $e) {
@ -128,10 +147,13 @@ if (!isset($_POST['submit'])) {
<label for="album">Zu Album hinzufügen</label>
<select name="album" id="album">
<option value="" data-url="/">---</option>
<?php foreach ($albums as $album) {
$selected = $album->token === $token ? ' selected' : '';
<?php
/** @var Album $album Current PhotoPrism albums */
foreach ($albums as $album) {
/** @var string $selected Selected attribute of the option */
$selected = $album->token === $token ? ' selected ' : '';
if ($album->token === $token) {
$album_url = $album->getUrlPath();
$album_url = $album->getUrlPath() ?? '/';
}
echo '<option value="'
. $album->uid
@ -143,7 +165,6 @@ if (!isset($_POST['submit'])) {
. $album->title
. '</option>\n';
}
$album_url ??= '/';
$album_url = "https://photos.phlaym.net{$album_url}";
?>
</select>