'; /** @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(); } catch (\Exception $e) { die('Fehler: ' . $e->getMessage().$footer.''); } /** @var string $token Tokens for which album(s) are visible in the dropdown */ $token = $_GET['token']; /** @var int $page Page number of photos to load */ $page = 1; /** @var int $count Number of pictures to load */ $count = 200; /** @var int $offset Tokens for which album(s) are visible in the dropdown */ $offset = ($page - 1) * $count; /** @var string $album_url URL path to the selected album */ $album_url = '/'; $votes_file = 'votes.json'; $contents = file_get_contents($votes_file); if ($contents === false) { $contents = '{}'; } $contents = json_decode($contents, true); $vote_counts = []; foreach ($contents as $votes) { foreach ($votes as $photo_uid => $vote_value) { if (!array_key_exists($photo_uid, $vote_counts)) { $vote_counts[$photo_uid] = 0; } $vote_counts[$photo_uid] += intval($vote_value); } } $page_sizes = array_values(array_unique([10, 20, 50, 100, $count])); sort($page_sizes); $link_class = $page === 1 ? 'pageLink disabled' : 'pageLink'; try { $album = $api->getAlbumByToken($token); if ($album === null) { die('Album nicht gefunden' . $footer . ''); } $photos = $api->getAlbumPhotos($album, $count, $offset); $photos = array_filter($photos, function (Photo $a) use ($vote_counts) { $vote_a = $vote_counts[$a->uid] ?? 0; return $vote_a >= 0; }); usort($photos, function (Photo $a, Photo $b) use ($vote_counts) { $vote_a = $vote_counts[$a->uid] ?? 0; $vote_b = $vote_counts[$b->uid] ?? 0; return $vote_b - $vote_a; }); ?> getThumbnailUrl();?>
getMessage() . ''); } ?>