Zeige Kurse im Mitgliederbereich und mach hochgeladene Fassungen ansehbar.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
b374335b3a
commit
4f2e5a5f3b
24 files changed
+413
-47
No files matched your search
@@ -22,11 +22,11 @@ class CompositionResource extends Resource
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Inhalte';
|
||||
|
||||
protected static ?string $navigationLabel = 'Kompositionen';
|
||||
protected static ?string $navigationLabel = 'Kurse und Übungen';
|
||||
|
||||
protected static ?string $modelLabel = 'Komposition';
|
||||
protected static ?string $modelLabel = 'Kurs oder Übung';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Kompositionen';
|
||||
protected static ?string $pluralModelLabel = 'Kurse und Übungen';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'designation';
|
||||
|
||||
|
||||
@@ -19,14 +19,14 @@ class ListCompositions extends ListRecords
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Eine freie Zusammenstellung fertiger Fassungen, zum Beispiel Übung oder Programm. Verkauf und Rechte entstehen erst am Lizenzartikel und am Angebot.';
|
||||
return 'Hier entsteht der Kurs: fertige Fassungen in einer Reihenfolge, zum Beispiel Film und Merkblatt. Dieselbe Fassung kann in weiteren Kursen stecken. Verkauf und Rechte entstehen am Lizenzartikel, am Paket und am Angebot.';
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('create')
|
||||
->label('Komposition anlegen')
|
||||
->label('Kurs anlegen')
|
||||
->visible(fn (): bool => ContentElementResource::editor())
|
||||
->schema([
|
||||
TextInput::make('designation')->label('Bezeichnung')->required(),
|
||||
@@ -34,7 +34,7 @@ protected function getHeaderActions(): array
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
app(ContentService::class)->createComposition($data['designation']);
|
||||
}, 'Die Komposition ist angelegt.');
|
||||
}, 'Der Kurs ist angelegt.');
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -27,10 +27,10 @@ protected function getHeaderActions(): array
|
||||
Action::make('publish')
|
||||
->label('Fassung veröffentlichen')
|
||||
->schema([
|
||||
Repeater::make('members')->label('Mitglieder')->schema([
|
||||
TextInput::make('role')->label('Rolle')->required(),
|
||||
Select::make('target')->label('Fassung')->options(fn (): array => CatalogOptions::readyTargets())->required(),
|
||||
])->minItems(1),
|
||||
Repeater::make('members')->label('Bausteine')->schema([
|
||||
TextInput::make('role')->label('Rolle im Kurs')->placeholder('Film, Merkblatt, Übung')->required(),
|
||||
Select::make('target')->label('Bereitgestellte Fassung')->options(fn (): array => CatalogOptions::readyTargets())->required(),
|
||||
])->minItems(1)->helperText('Nur bereitgestellte Fassungen. Eine Datei, die noch übernommen wird, erscheint hier noch nicht.'),
|
||||
TextInput::make('note')->label('Bestätigungsnotiz'),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
|
||||
@@ -19,7 +19,7 @@ class ListContentElements extends ListRecords
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Das Material selbst: Film, Text, PDF. Kompositionen und Lizenzartikel verweisen darauf.';
|
||||
return 'Das Material selbst: Film, Text, PDF. Unter Kurse und Übungen werden daraus Abläufe, unter Pakete verkaufbare Zusammenstellungen.';
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\ContentElements\Pages;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
@@ -11,6 +12,7 @@
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
class ViewContentElement extends ViewRecord
|
||||
{
|
||||
@@ -18,21 +20,58 @@ class ViewContentElement extends ViewRecord
|
||||
|
||||
protected static string $resource = ContentElementResource::class;
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Text und Datei gehören zur Fassung. Eine Filmfassung kann eine Entscheidungsmarke in Sekunden tragen. Zum Kurs wird das Element in einer Komposition, zum Paket über den Lizenzartikel.';
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('preview')
|
||||
->label('Ansehen')
|
||||
->url(function (): ?string {
|
||||
$version = $this->latestVersion();
|
||||
|
||||
return $version === null ? null : route('content.preview', $version);
|
||||
})
|
||||
->visible(fn (): bool => $this->latestVersion() !== null)
|
||||
->openUrlInNewTab(),
|
||||
Action::make('version')
|
||||
->label('Fassung veröffentlichen')
|
||||
->schema([
|
||||
Textarea::make('body')->label('Text'),
|
||||
FileUpload::make('incoming')->label('Datei')->disk('cms_incoming')->directory('inhalte'),
|
||||
FileUpload::make('incoming')
|
||||
->label('Datei')
|
||||
->disk('cms_incoming')
|
||||
->directory('inhalte')
|
||||
->helperText('Film, Audio oder PDF. Die Datei wird übernommen und ist danach unter Ansehen sichtbar.'),
|
||||
TextInput::make('decision_seconds')
|
||||
->label('Entscheidungsmarke in Sekunden')
|
||||
->numeric()
|
||||
->minValue(0)
|
||||
->helperText('Nur für Filme: der Kursplayer pausiert an dieser Stelle.'),
|
||||
TextInput::make('change_note')->label('Änderungsnotiz'),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
$metadata = filled($data['incoming'] ?? null) ? ['incoming' => $data['incoming']] : [];
|
||||
$metadata = [];
|
||||
$incoming = $data['incoming'] ?? null;
|
||||
|
||||
if (is_array($incoming)) {
|
||||
$incoming = array_values(array_filter($incoming, 'is_string'))[0] ?? null;
|
||||
}
|
||||
|
||||
if (is_string($incoming) && $incoming !== '') {
|
||||
$metadata['incoming'] = $incoming;
|
||||
}
|
||||
|
||||
if (is_numeric($data['decision_seconds'] ?? null)) {
|
||||
$metadata['decision_seconds'] = (int) $data['decision_seconds'];
|
||||
}
|
||||
|
||||
app(ContentService::class)->publishElementVersion(
|
||||
$element,
|
||||
$data['body'] ?? null,
|
||||
@@ -45,4 +84,12 @@ protected function getHeaderActions(): array
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
private function latestVersion(): ?ContentElementVersion
|
||||
{
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
|
||||
return $element->versions()->orderByDesc('number')->first();
|
||||
}
|
||||
}
|
||||
@@ -221,10 +221,30 @@ public function elementVersions(ContentElement $element): array
|
||||
return ['Noch keine Fassung.'];
|
||||
}
|
||||
|
||||
return $versions->map(function ($version): string {
|
||||
return $versions->flatMap(function ($version): array {
|
||||
$note = filled($version->change_note) ? ' · '.$version->change_note : '';
|
||||
$lines = ['Fassung '.$version->number.' · '.$this->status($version->status).$note];
|
||||
$metadata = is_array($version->metadata) ? $version->metadata : [];
|
||||
|
||||
return 'Fassung '.$version->number.' · '.$this->status($version->status).$note;
|
||||
if (filled($version->body)) {
|
||||
$lines[] = $version->body;
|
||||
}
|
||||
|
||||
if (is_string($metadata['file'] ?? null) && $metadata['file'] !== '') {
|
||||
$lines[] = 'Datei: '.basename($metadata['file']);
|
||||
} elseif (is_string($metadata['incoming'] ?? null) || is_array($metadata['incoming'] ?? null)) {
|
||||
$lines[] = 'Die Datei wird noch übernommen.';
|
||||
}
|
||||
|
||||
if (is_numeric($metadata['decision_seconds'] ?? null)) {
|
||||
$lines[] = 'Entscheidungsmarke bei '.(int) $metadata['decision_seconds'].' Sekunden';
|
||||
}
|
||||
|
||||
if (is_string($metadata['error'] ?? null) && $metadata['error'] !== '') {
|
||||
$lines[] = $metadata['error'];
|
||||
}
|
||||
|
||||
return $lines;
|
||||
})->all();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Identity\StaffRole;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\View\View;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
class ContentPreviewController extends Controller
|
||||
{
|
||||
public function __invoke(ContentElementVersion $version): View|StreamedResponse
|
||||
{
|
||||
$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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
use App\Domain\Entitlement\Grant;
|
||||
use App\Domain\Entitlement\GrantStatus;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\CourseOutline;
|
||||
use App\Http\SignedLink;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
@@ -20,7 +21,10 @@ class LibraryController extends Controller
|
||||
public function index(Request $request): View
|
||||
{
|
||||
return view('member.library', [
|
||||
'grants' => $this->grantQuery($request)->with('article.currentRelease')->get(),
|
||||
'grants' => $this->grantQuery($request)->with([
|
||||
'article.currentRelease.rootCompositionVersion.composition',
|
||||
'article.currentRelease.rootElementVersion.element',
|
||||
])->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -47,14 +51,21 @@ public function show(Request $request, LicenseArticle $article): View
|
||||
foreach ($release->contents as $content) {
|
||||
$version = $content->elementVersion;
|
||||
$class = $version->element->output_class;
|
||||
$metadata = is_array($version->metadata) ? $version->metadata : [];
|
||||
$action = $class === 'film' || $class === 'audio' ? 'streamen' : 'ansehen';
|
||||
$decision = app(DecideAccess::class)($request->user(), $article, $release, $version, $action);
|
||||
$file = $metadata['file'] ?? null;
|
||||
$entries[] = [
|
||||
'content' => $content,
|
||||
'version' => $version,
|
||||
'role' => $content->role,
|
||||
'action' => $action,
|
||||
'allowed' => $decision->allowed,
|
||||
'reason' => $decision->reason,
|
||||
'decision' => is_numeric($metadata['decision_seconds'] ?? null)
|
||||
? (int) $metadata['decision_seconds']
|
||||
: null,
|
||||
'playable' => $decision->allowed && is_string($file) && $file !== '' && ($class === 'film' || $class === 'audio'),
|
||||
'url' => $decision->allowed
|
||||
? SignedLink::temporary('member.media', now()->addMinutes(10), [
|
||||
'article' => $article->id,
|
||||
@@ -72,6 +83,7 @@ public function show(Request $request, LicenseArticle $article): View
|
||||
'article' => $article,
|
||||
'release' => $release,
|
||||
'entries' => $entries,
|
||||
'title' => app(CourseOutline::class)->title($article),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
|
||||
class CourseOutline
|
||||
{
|
||||
public function title(LicenseArticle $article): string
|
||||
{
|
||||
$release = $article->currentRelease;
|
||||
|
||||
if ($release === null) {
|
||||
return $article->code;
|
||||
}
|
||||
|
||||
$release->loadMissing([
|
||||
'rootCompositionVersion.composition',
|
||||
'rootElementVersion.element',
|
||||
]);
|
||||
|
||||
return $release->rootCompositionVersion?->composition?->designation
|
||||
?? $release->rootElementVersion?->element?->working_title
|
||||
?? $release->classification_note
|
||||
?? $article->code;
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ class UseStaffSessionCookie
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$referer = (string) $request->headers->get('referer', '');
|
||||
$staffRequest = $request->is('verwaltung', 'verwaltung/*')
|
||||
$staffRequest = $request->is('verwaltung', 'verwaltung/*', 'redaktion', 'redaktion/*')
|
||||
|| str_contains($referer, '/verwaltung');
|
||||
|
||||
if ($staffRequest) {
|
||||
|
||||
@@ -29,16 +29,20 @@ public function handle(): void
|
||||
return;
|
||||
}
|
||||
|
||||
$name = basename($this->source);
|
||||
$targetName = $this->storedName(basename($this->source));
|
||||
|
||||
if ($targetName === null) {
|
||||
$this->markFailed($version, 'Der Dateityp wird nicht übernommen.');
|
||||
|
||||
if (preg_match('/^[A-Za-z0-9._-]+$/', $name) !== 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
$target = 'inhalte/'.$version->id.'/'.$name;
|
||||
$target = 'inhalte/'.$version->id.'/'.$targetName;
|
||||
$incoming = Storage::disk('cms_incoming');
|
||||
|
||||
if (! $incoming->exists($this->source)) {
|
||||
$this->markFailed($version, 'Die hochgeladene Datei wurde nicht gefunden.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -55,4 +59,26 @@ public function handle(): void
|
||||
$version->status = ContentVersionStatus::Bereit;
|
||||
$version->save();
|
||||
}
|
||||
|
||||
private function storedName(string $name): ?string
|
||||
{
|
||||
$extension = strtolower(pathinfo($name, PATHINFO_EXTENSION));
|
||||
$stem = preg_replace('/[^A-Za-z0-9_-]+/', '-', pathinfo($name, PATHINFO_FILENAME)) ?? '';
|
||||
$stem = trim($stem, '-');
|
||||
|
||||
if (preg_match('/^[a-z0-9]{1,8}$/', $extension) !== 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return ($stem !== '' ? $stem : 'datei').'.'.$extension;
|
||||
}
|
||||
|
||||
private function markFailed(ContentElementVersion $version, string $reason): void
|
||||
{
|
||||
$metadata = $version->metadata ?? [];
|
||||
unset($metadata['incoming']);
|
||||
$metadata['error'] = $reason;
|
||||
$version->metadata = $metadata;
|
||||
$version->save();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user