Lasse Bilder im Text den Rechten des Textes folgen, gib Bild- und PDF-Adressen ohne Ablauf aus und belege die Abnahme
- Bilder im Text folgen dem Recht am Text; eine eigene Fähigkeit für Bilder ist nicht nötig (ADR-51, fachliche Entscheidung zur Bestätigung). - Bildadresse und PDF-Adresse des Dokuments laufen nicht ab; jeder Abruf entscheidet neu. - Die Fähigkeit text:laden ist im Rechteprofil wählbar. - Dokumentkapitel in der Medienansicht verweisen auf ihr Dokument; die Pille nennt jetzt auch Dokumentkapitel (MedienFilterDialogTest bewusst angepasst). - Abnahmeprotokoll mit Bildern unter docs/ux/verwaltung/abnahme/dokumente. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8a44c5886b
commit
81037b9868
56 files changed
+222
-95
No files matched your search
@@ -26,7 +26,7 @@ public function build(User $user, LicenseArticle $article, ArticleRelease $relea
|
||||
{
|
||||
$document->loadMissing('composition');
|
||||
$library = app(LibraryCatalog::class);
|
||||
$images = app(EmbeddedImages::class)->forView($user, $article, $release);
|
||||
$embedded = app(EmbeddedImages::class);
|
||||
$chapters = [];
|
||||
|
||||
foreach ($this->reader->fromVersion($document) as $chapter) {
|
||||
@@ -45,7 +45,7 @@ public function build(User $user, LicenseArticle $article, ArticleRelease $relea
|
||||
'may_download' => $download->allowed,
|
||||
'download_grant' => $download->grant,
|
||||
'state' => $view->allowed ? 'ok' : ($version->status === ContentVersionStatus::Gesperrt ? 'gesperrt' : 'nicht_lizenziert'),
|
||||
'html' => $view->allowed ? $this->shiftHeadings(FormattedText::html($version->body, $images)) : null,
|
||||
'html' => $view->allowed ? $this->shiftHeadings(FormattedText::html($version->body, $embedded->forView($user, $article, $release, $version))) : null,
|
||||
'blocks' => $view->allowed ? FormattedText::blocks($version->body) : null,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -5,20 +5,24 @@
|
||||
use App\Domain\Entitlement\DecideAccess;
|
||||
use App\Domain\Entitlement\Grant;
|
||||
use App\Domain\Media\PdfImage;
|
||||
use App\Http\SignedLink;
|
||||
use App\Models\User;
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
/**
|
||||
* Bilder in formatierten Texten (ADR-51). Ein Text verweist auf eine Bildfassung; ob und wie sie erscheint, entscheidet
|
||||
* hier wie überall `DecideAccess` für den Stand des Mitglieds: Die Bildfassung gehört zum festgeschriebenen Inhalt des
|
||||
* Stands ({@see ContentResolver}), eine Sperre wirkt, die Berechtigung des Kontos für Bilder gilt.
|
||||
* hier für den Stand des Mitglieds:
|
||||
*
|
||||
* - Ansicht: ein kurzlebiger, signierter Link auf die Ausgabe des Bildes (`member.media`, Aktion `ansehen`).
|
||||
* - PDF: das Bild wird mit `laden` entschieden, aus dem abgeleiteten Bestand gelesen und für das PDF aufbereitet.
|
||||
* - Ein Bild im Text gehört zum Text. Wer den Text ansehen (PDF: laden) darf, darf die Bilder darin sehen. Es braucht kein
|
||||
* eigenes Recht für Bilder; bestehende Berechtigungen, die nur Texte nennen, zeigen die Bilder der Texte mit. Die Rechte
|
||||
* des Texts entscheidet wie überall `DecideAccess`.
|
||||
* - Das Bild muss zum festgeschriebenen Inhalt des Stands gehören ({@see ContentResolver}: ein Bild im Text steht als
|
||||
* ergänzende Zeile im Stand) und im Text tatsächlich vorkommen. So gibt die Adresse kein anderes Bild frei.
|
||||
* - Eine Sperre der Bildfassung wirkt: Das Bild entfällt, der Text bleibt lesbar.
|
||||
*
|
||||
* Ein Bild ohne Berechtigung ersetzt ein Hinweis an seiner Stelle; der übrige Text bleibt unverändert lesbar.
|
||||
* Ansicht: eine Adresse ohne Ablauf, die bei jedem Abruf neu entscheidet und die Datei ausliefert (`member.stand.image`);
|
||||
* eine lange Lektüre darf nicht an einer kurzlebigen Signatur scheitern. PDF: das Bild wird aus dem abgeleiteten Bestand
|
||||
* gelesen und für das PDF aufbereitet.
|
||||
*/
|
||||
final class EmbeddedImages
|
||||
{
|
||||
@@ -47,48 +51,69 @@ public static function forEditor(?string $value): string
|
||||
}
|
||||
|
||||
/**
|
||||
* Auflösung für {@see FormattedText::html()}.
|
||||
* Auflösung für {@see FormattedText::html()} eines Textes im Stand.
|
||||
*
|
||||
* @return Closure(int): ?array{src?: string, alt?: string, note?: string}
|
||||
*/
|
||||
public function forView(User $user, LicenseArticle $article, ArticleRelease $release): Closure
|
||||
public function forView(User $user, LicenseArticle $article, ArticleRelease $release, ContentElementVersion $text): Closure
|
||||
{
|
||||
return function (int $id) use ($user, $article, $release): ?array {
|
||||
$decision = $this->decide($user, $article, $release, $id, 'ansehen');
|
||||
return function (int $id) use ($user, $article, $release, $text): ?array {
|
||||
$found = $this->decide($user, $article, $release, $text, $id, 'ansehen');
|
||||
|
||||
if ($decision === null) {
|
||||
if ($found === null) {
|
||||
return ['note' => 'Dieses Bild gibt es nicht mehr.'];
|
||||
}
|
||||
|
||||
if (! $decision['allowed']) {
|
||||
if (! $found['allowed']) {
|
||||
return ['note' => 'Dieses Bild ist derzeit nicht verfügbar.'];
|
||||
}
|
||||
|
||||
return ['src' => SignedLink::temporary('member.media', now()->addMinutes(10), [
|
||||
'article' => $article->id,
|
||||
'release' => $release->id,
|
||||
'version' => $id,
|
||||
'action' => 'ansehen',
|
||||
'reader' => $user->id,
|
||||
])];
|
||||
return ['src' => route('member.stand.image', ['article' => $article->id, 'release' => $release->id, 'text' => $text->id, 'version' => $id])];
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Auflösung für das PDF. Die Bilder, die tatsächlich im PDF stehen, sammelt {@see PdfImages::used()} für den
|
||||
* Ausgabenachweis.
|
||||
* Die Bildfassung für die Auslieferung: nur wenn sie im Text vorkommt, zum Stand gehört, nicht gesperrt ist und der Text
|
||||
* für `ansehen` zulässig ist.
|
||||
*
|
||||
* @return array{version: ContentElementVersion, grant: Grant}|null
|
||||
*/
|
||||
public function forPdf(User $user, LicenseArticle $article, ArticleRelease $release): PdfImages
|
||||
public function serve(User $user, LicenseArticle $article, ArticleRelease $release, ContentElementVersion $text, int $id): ?array
|
||||
{
|
||||
return new PdfImages(function (int $id) use ($user, $article, $release): ?array {
|
||||
$decision = $this->decide($user, $article, $release, $id, 'laden');
|
||||
$found = $this->decide($user, $article, $release, $text, $id, 'ansehen');
|
||||
|
||||
if ($decision === null) {
|
||||
return ['note' => 'Bild nicht mehr vorhanden', 'grant' => null, 'version' => null];
|
||||
return $found !== null && $found['allowed'] && $found['grant'] instanceof Grant ? ['version' => $found['version'], 'grant' => $found['grant']] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Auflösung für das PDF. Ein Bild darf ins PDF, wenn ein Text, der es enthält, für `laden` zulässig ist. Die Bilder, die
|
||||
* tatsächlich im PDF stehen, sammelt {@see PdfImages::used()} für den Ausgabenachweis.
|
||||
*
|
||||
* @param list<ContentElementVersion> $texts die Texte des PDF
|
||||
*/
|
||||
public function forPdf(User $user, LicenseArticle $article, ArticleRelease $release, array $texts): PdfImages
|
||||
{
|
||||
return new PdfImages(function (int $id) use ($user, $article, $release, $texts): ?array {
|
||||
$decision = null;
|
||||
$exists = false;
|
||||
|
||||
foreach ($texts as $text) {
|
||||
if (! in_array($id, FormattedText::imageIds($text->body), true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$found = $this->decide($user, $article, $release, $text, $id, 'laden');
|
||||
$exists = $exists || $found !== null;
|
||||
|
||||
if ($found !== null && $found['allowed']) {
|
||||
$decision = $found;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $decision['allowed']) {
|
||||
return ['note' => 'Bild nicht verfügbar', 'grant' => null, 'version' => null];
|
||||
if ($decision === null) {
|
||||
return ['note' => $exists ? 'Bild nicht verfügbar' : 'Bild nicht mehr vorhanden', 'grant' => null, 'version' => null];
|
||||
}
|
||||
|
||||
$prepared = self::prepared($decision['version']);
|
||||
@@ -119,6 +144,14 @@ public static function forStaffPdf(): PdfImages
|
||||
});
|
||||
}
|
||||
|
||||
/** Pfad der Bilddatei im abgeleiteten Bestand, wenn sie vorliegt. */
|
||||
public static function file(ContentElementVersion $version): ?string
|
||||
{
|
||||
$file = $version->metadata['file'] ?? null;
|
||||
|
||||
return is_string($file) && $file !== '' && ! str_contains($file, '..') && Storage::disk('media_derived')->exists($file) ? $file : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Bilddatei aus dem abgeleiteten Bestand (der Web-Prozess liest nur dort), für das PDF aufbereitet.
|
||||
*
|
||||
@@ -126,27 +159,33 @@ public static function forStaffPdf(): PdfImages
|
||||
*/
|
||||
private static function prepared(ContentElementVersion $version): ?array
|
||||
{
|
||||
$file = $version->metadata['file'] ?? null;
|
||||
$disk = Storage::disk('media_derived');
|
||||
$file = self::file($version);
|
||||
|
||||
return is_string($file) && $file !== '' && ! str_contains($file, '..') && $disk->exists($file)
|
||||
? PdfImage::fromBytes((string) $disk->get($file))
|
||||
: null;
|
||||
return $file === null ? null : PdfImage::fromBytes((string) Storage::disk('media_derived')->get($file));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{allowed: bool, version: ContentElementVersion, grant: ?Grant}|null
|
||||
* @return array{allowed: bool, version: ContentElementVersion, grant: ?Grant}|null null = es gibt kein solches Bild im Text
|
||||
*/
|
||||
private function decide(User $user, LicenseArticle $article, ArticleRelease $release, int $id, string $action): ?array
|
||||
private function decide(User $user, LicenseArticle $article, ArticleRelease $release, ContentElementVersion $text, int $id, string $action): ?array
|
||||
{
|
||||
if (! in_array($id, FormattedText::imageIds($text->body), true)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$version = ContentElementVersion::query()->with('element')->find($id);
|
||||
|
||||
if (! $version instanceof ContentElementVersion || $version->element === null || $version->element->output_class !== 'bild') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$decision = ($this->access)($user, $article, $release, $version, $action);
|
||||
$inStand = $release->contents()->where('content_element_version_id', $id)->exists();
|
||||
$decision = ($this->access)($user, $article, $release, $text, $action);
|
||||
|
||||
return ['allowed' => $decision->allowed, 'version' => $version, 'grant' => $decision->grant];
|
||||
return [
|
||||
'allowed' => $inStand && $decision->allowed && $version->status === ContentVersionStatus::Bereit,
|
||||
'version' => $version,
|
||||
'grant' => $decision->grant,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,7 @@ public function build(User $user, LicenseArticle $article, ArticleRelease $relea
|
||||
{
|
||||
$exercise->loadMissing(['composition', 'variants', 'members.variant', 'members.contentElementVersion.element']);
|
||||
$library = app(LibraryCatalog::class);
|
||||
$images = app(EmbeddedImages::class)->forView($user, $article, $release);
|
||||
$embedded = app(EmbeddedImages::class);
|
||||
$offered = $exercise->variants->filter(fn (CompositionVersionVariant $variant): bool => $selection === null || in_array($variant->key, $selection, true))->values();
|
||||
$chosen = $offered->firstWhere('key', $variantKey) ?? $offered->first();
|
||||
$entries = [];
|
||||
@@ -147,7 +147,7 @@ public function build(User $user, LicenseArticle $article, ArticleRelease $relea
|
||||
'download_grant' => $download?->grant,
|
||||
'state' => $decision->allowed ? 'ok' : ($version->status === ContentVersionStatus::Gesperrt ? 'gesperrt' : 'nicht_lizenziert'),
|
||||
'blocks' => $decision->allowed && $class === 'text' ? FormattedText::blocks($version->body) : null,
|
||||
'html' => $decision->allowed && $class === 'text' ? FormattedText::html($version->body, $images) : null,
|
||||
'html' => $decision->allowed && $class === 'text' ? FormattedText::html($version->body, $embedded->forView($user, $article, $release, $version)) : null,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -439,7 +439,7 @@ private function table(array $rows, float $x): void
|
||||
$r += $span - 1;
|
||||
}
|
||||
|
||||
$this->y -= 14;
|
||||
$this->y -= 18;
|
||||
}
|
||||
|
||||
private function frame(float $x, float $y, float $w, float $h, bool $header): void
|
||||
|
||||
@@ -514,7 +514,7 @@ private function filterPills(): array
|
||||
$multi = $this->multiFields();
|
||||
|
||||
if ($this->arten === '') {
|
||||
$pills[] = ['feld' => 'arten', 'label' => 'Übungsabschnitte ausgeblendet', 'info' => true];
|
||||
$pills[] = ['feld' => 'arten', 'label' => 'Übungsabschnitte und Dokumentkapitel ausgeblendet', 'info' => true];
|
||||
} else {
|
||||
$selected = $this->selectedArten();
|
||||
|
||||
@@ -568,7 +568,7 @@ public function bestand(): array
|
||||
'weitere' => $this->singleFields(),
|
||||
'entwurf' => 'filterDraft',
|
||||
'gespeichert' => $gespeichert,
|
||||
'hinweis' => 'Mehrere Werte eines Felds zeigen Medien, auf die einer davon zutrifft. Verschiedene Felder gelten zusammen. Freigabe meint die Fassung des Mediums, nicht die Website und keinen Zugriff. Geschützte Medien haben eine Inhaltsfassung und laufen über Lizenzen. Öffentliche Medien sind eigenständige Präsentationsmedien ohne Fassung für die Website. Materialart und Einordnung sind die redaktionelle Klassifikation; Verwendung zeigt, wo das Medium tatsächlich eingebunden ist. Übungsabschnitte, die Texte der Übungen, erscheinen erst, wenn du sie unter Materialart ankreuzt. „Als Standard speichern“ merkt die Filter für dein Konto, ohne die Suche.',
|
||||
'hinweis' => 'Mehrere Werte eines Felds zeigen Medien, auf die einer davon zutrifft. Verschiedene Felder gelten zusammen. Freigabe meint die Fassung des Mediums, nicht die Website und keinen Zugriff. Geschützte Medien haben eine Inhaltsfassung und laufen über Lizenzen. Öffentliche Medien sind eigenständige Präsentationsmedien ohne Fassung für die Website. Materialart und Einordnung sind die redaktionelle Klassifikation; Verwendung zeigt, wo das Medium tatsächlich eingebunden ist. Übungsabschnitte und Dokumentkapitel, die Texte der Übungen und Dokumente, erscheinen erst, wenn du sie unter Materialart ankreuzt. „Als Standard speichern“ merkt die Filter für dein Konto, ohne die Suche.',
|
||||
];
|
||||
|
||||
return [
|
||||
@@ -576,7 +576,7 @@ public function bestand(): array
|
||||
'filterdialog' => $dialog,
|
||||
'zeilen' => array_map($this->zeile(...), $this->cards()),
|
||||
'einheit' => ['Medium', 'Medien'],
|
||||
'leerHinweis' => $keine ? 'Öffne den Filter und wähle mindestens eine Materialart aus, um Medien zu sehen. „Alle auswählen“ zeigt alles, auch die Übungsabschnitte.' : null,
|
||||
'leerHinweis' => $keine ? 'Öffne den Filter und wähle mindestens eine Materialart aus, um Medien zu sehen. „Alle auswählen“ zeigt alles, auch Übungsabschnitte und Dokumentkapitel.' : null,
|
||||
'leer' => ['titel' => 'Noch keine Medien', 'text' => 'Mit „Medium anlegen“ oben lädst du eine Datei hoch oder schreibst einen Text.'],
|
||||
'ansicht' => 'ansicht',
|
||||
];
|
||||
|
||||
@@ -19,6 +19,7 @@ final class CatalogLabels
|
||||
'pdf:ansehen' => 'PDF ansehen',
|
||||
'pdf:laden' => 'PDF herunterladen',
|
||||
'text:ansehen' => 'Text ansehen',
|
||||
'text:laden' => 'Text als PDF herunterladen (Übung, Dokument)',
|
||||
'bild:ansehen' => 'Bild ansehen',
|
||||
];
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
use App\Domain\Catalog\ReleaseContent;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Resources\Practices\PracticeResource;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@@ -593,7 +592,8 @@ private function exerciseOf(ContentElement $element, bool $canEdit): ?array
|
||||
|
||||
return [
|
||||
'title' => (string) ($exercise->display_title ?: $exercise->designation),
|
||||
'url' => $canEdit ? PracticeResource::getUrl('edit', ['record' => $exercise]) : null,
|
||||
'url' => $canEdit ? EditorialCatalog::editUrl($exercise) : null,
|
||||
'kind' => $exercise->kind instanceof CompositionKind ? $exercise->kind->deskLabel() : 'Übung',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
use App\Domain\Catalog\ArticleRelease;
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\DocumentGuide;
|
||||
use App\Domain\Catalog\DocumentPdf;
|
||||
use App\Domain\Catalog\EmbeddedImages;
|
||||
@@ -12,7 +13,6 @@
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Media\DeliveryLog;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\SignedLink;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
@@ -41,24 +41,18 @@ public function show(Request $request, LicenseArticle $article, ArticleRelease $
|
||||
'guide' => $guide,
|
||||
'reader' => $request->user()->name,
|
||||
'copy' => $shown ? $copy : null,
|
||||
'pdfUrl' => app(DocumentGuide::class)->pdfAllowed($guide) ? SignedLink::temporary('member.document.pdf', now()->addMinutes(10), [
|
||||
'article' => $article->id,
|
||||
'release' => $release->id,
|
||||
'path' => $path,
|
||||
'reader' => $request->user()->id,
|
||||
]) : null,
|
||||
// Ohne Ablauf der Adresse: Die Seite bleibt lange offen; bei jedem Abruf entscheidet `DecideAccess` neu.
|
||||
'pdfUrl' => app(DocumentGuide::class)->pdfAllowed($guide) ? route('member.document.pdf', ['article' => $article, 'release' => $release, 'path' => $path]) : null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function pdf(Request $request, LicenseArticle $article, ArticleRelease $release, string $path): Response
|
||||
{
|
||||
abort_unless((int) $request->query('reader') === $request->user()->id, 403);
|
||||
|
||||
[$guide, $located] = $this->load($request, $article, $release, $path);
|
||||
abort_unless(app(DocumentGuide::class)->pdfAllowed($guide), 403, 'Für dieses PDF fehlt die Berechtigung für ein Kapitel.');
|
||||
|
||||
$copy = DeliveryLog::newCopyId();
|
||||
$images = app(EmbeddedImages::class)->forPdf($request->user(), $article, $release);
|
||||
$images = app(EmbeddedImages::class)->forPdf($request->user(), $article, $release, array_map(fn (array $chapter): ContentElementVersion => $chapter['version'], $guide['chapters']));
|
||||
$content = app(DocumentPdf::class)->render($guide, $request->user()->name, $copy, $images);
|
||||
$checksum = hash('sha256', $content);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Domain\Catalog\ArticleRelease;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\EmbeddedImages;
|
||||
use App\Domain\Catalog\ExerciseGuide;
|
||||
use App\Domain\Catalog\ExercisePdf;
|
||||
@@ -77,7 +78,7 @@ public function pdf(Request $request, LicenseArticle $article, ArticleRelease $r
|
||||
|
||||
$copy = DeliveryLog::newCopyId();
|
||||
$variant = collect($guide['variants'])->firstWhere('key', $guide['chosen']);
|
||||
$images = app(EmbeddedImages::class)->forPdf($request->user(), $article, $release);
|
||||
$images = app(EmbeddedImages::class)->forPdf($request->user(), $article, $release, array_values(array_map(fn (array $section): ContentElementVersion => $section['version'], array_filter($sections, fn (array $section): bool => $section['class'] === 'text'))));
|
||||
$content = $pdf->render(
|
||||
$guide,
|
||||
$sections,
|
||||
|
||||
@@ -241,6 +241,7 @@ public function show(Request $request, LicenseArticle $article): View
|
||||
'class' => $class,
|
||||
'content' => $content,
|
||||
'version' => $version,
|
||||
'images' => $class === 'text' ? app(EmbeddedImages::class)->forView($request->user(), $article, $release, $version) : null,
|
||||
'role' => $content->role,
|
||||
'action' => $action,
|
||||
'allowed' => $decision->allowed,
|
||||
@@ -279,7 +280,6 @@ public function show(Request $request, LicenseArticle $article): View
|
||||
'entries' => $entries,
|
||||
'title' => app(CourseOutline::class)->title($article),
|
||||
'kind' => app(CourseOutline::class)->kindLabel($article),
|
||||
'images' => $release === null ? null : app(EmbeddedImages::class)->forView($request->user(), $article, $release),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -321,7 +321,7 @@ public function media(
|
||||
'article' => $article,
|
||||
'version' => $version,
|
||||
'license' => $decision->grant->rights_snapshot['purpose'] ?? null,
|
||||
'images' => app(EmbeddedImages::class)->forView($request->user(), $article, $release),
|
||||
'images' => app(EmbeddedImages::class)->forView($request->user(), $article, $release, $version),
|
||||
'reader' => $request->user()->name,
|
||||
'copy' => $delivery->copy_id,
|
||||
]);
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Member;
|
||||
|
||||
use App\Domain\Catalog\ArticleRelease;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\EmbeddedImages;
|
||||
use App\Domain\Catalog\ExerciseGuide;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Media\DeliveryLog;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\LibraryCatalog;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
/**
|
||||
* Ein Bild im Text eines erworbenen Stands (ADR-51). Die Adresse läuft nicht ab, weil eine Seite lange offen bleibt; dafür
|
||||
* entscheidet jeder Abruf neu: Konto, Stand, Text, Recht am Text, Zugehörigkeit des Bildes zum Text und zum Stand und die
|
||||
* Sperre der Bildfassung. Eine Datei liegt nie unter einem öffentlichen Pfad.
|
||||
*/
|
||||
class StandImageController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request, LicenseArticle $article, ArticleRelease $release, ContentElementVersion $text, ContentElementVersion $version): StreamedResponse
|
||||
{
|
||||
abort_unless(app(ExerciseGuide::class)->mayOpen($request->user(), $article, $release), 403);
|
||||
|
||||
$served = app(EmbeddedImages::class)->serve($request->user(), $article, $release, $text, $version->id);
|
||||
abort_if($served === null, 403);
|
||||
|
||||
$file = EmbeddedImages::file($served['version']);
|
||||
abort_if($file === null, 404);
|
||||
|
||||
$disk = Storage::disk('media_derived');
|
||||
$delivery = app(DeliveryLog::class)->write($served['grant'], $article, $release, $served['version'], 'ansehen', 'bestand', hash_file('sha256', $disk->path($file)) ?: null, 'k0');
|
||||
$title = app(LibraryCatalog::class)->text($served['version']->element)['title'];
|
||||
$name = ($title !== '' ? preg_replace('/[\x00-\x1F\x7F\/\\\\:*?"<>|]+/u', ' ', $title) : 'bild').'.'.strtolower(pathinfo($file, PATHINFO_EXTENSION));
|
||||
|
||||
return $disk->response($file, trim((string) $name), ['X-License-Copy' => $delivery->copy_id, 'Cache-Control' => 'private, max-age=300'], 'inline');
|
||||
}
|
||||
}
|
||||
@@ -477,7 +477,7 @@ private function countCompositions(array $nodes): int
|
||||
$count = 0;
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
if ($node['composition_id'] !== null) {
|
||||
if ($node['composition_id'] !== null && empty($node['document'])) {
|
||||
$count++;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user