Zeige Medienfassungen in der Verwaltung und halte Beschreibungen davon getrennt.
Deploy Test / test (push) Successful in 15s
Deploy Test / deploy (push) Successful in 22s

Eine Fassung bleibt nummeriert und kann deaktiviert werden. Beschreibung und fachliche Säulen gehören zum Medium und legen keine neue Fassung an.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-11-15 11:25:08 +01:00
1 parent 12f12117dd
commit af85a94cd5
28 files changed
+1002 -168

No files matched your search

@@ -11,25 +11,63 @@
class ContentPreviewController extends Controller
{
public function __invoke(ContentElementVersion $version): View|StreamedResponse
public function show(ContentElementVersion $version): View
{
$this->authorizeStaff();
$version->loadMissing('element');
return view('content.preview', [
'version' => $version,
'fileUrl' => $this->fileUrl($version),
'pending' => $this->isPending($version),
]);
}
public function file(ContentElementVersion $version): StreamedResponse
{
$this->authorizeStaff();
$path = $this->storedPath($version);
abort_unless(is_string($path), 404);
return Storage::disk('media_derived')->response($path, basename($path), [
'Content-Disposition' => 'inline',
]);
}
public function fileUrl(ContentElementVersion $version): ?string
{
return $this->storedPath($version) === null ? null : route('content.file', $version);
}
public function isPending(ContentElementVersion $version): bool
{
if ($this->storedPath($version) !== null) {
return false;
}
$metadata = is_array($version->metadata) ? $version->metadata : [];
$incoming = $metadata['incoming'] ?? null;
return (is_string($incoming) && $incoming !== '') || is_array($incoming);
}
private function storedPath(ContentElementVersion $version): ?string
{
$file = is_array($version->metadata) ? ($version->metadata['file'] ?? null) : null;
if (! is_string($file) || $file === '' || str_contains($file, '..') || ! str_starts_with($file, 'inhalte/')) {
return null;
}
return Storage::disk('media_derived')->exists($file) ? $file : null;
}
private function authorizeStaff(): void
{
$user = auth('staff')->user();
abort_unless(
$user instanceof User && ($user->hasStaffRole(StaffRole::Redakteur) || $user->hasStaffRole(StaffRole::Katalogverwalter)),
403,
);
$version->loadMissing('element');
$file = $version->metadata['file'] ?? null;
if (is_string($file) && $file !== '' && ! str_contains($file, '..') && Storage::disk('media_derived')->exists($file)) {
return Storage::disk('media_derived')->response($file, basename($file), [
'Content-Disposition' => 'inline',
]);
}
return view('content.preview', [
'version' => $version,
]);
}
}
@@ -44,7 +44,7 @@ public function grants(Request $request): View
public function show(Request $request, LicenseArticle $article): View
{
$release = $article->currentRelease()->with('contents.elementVersion.element')->first();
$release = $article->currentRelease()->with('contents.elementVersion.element.pillars')->first();
$entries = [];
if ($release !== null) {
@@ -66,6 +66,7 @@ public function show(Request $request, LicenseArticle $article): View
? (int) $metadata['decision_seconds']
: null,
'playable' => $decision->allowed && is_string($file) && $file !== '' && ($class === 'film' || $class === 'audio'),
'pillars' => $version->element->pillars->pluck('name')->all(),
'url' => $decision->allowed
? SignedLink::temporary('member.media', now()->addMinutes(10), [
'article' => $article->id,