Zeige Nutzbarkeit, Didaktik und oeffentliche Programmfassung
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
5e763d15ec
commit
c99a957e6f
17 files changed
+307
-6
No files matched your search
@@ -160,6 +160,7 @@ public function media(
|
||||
return view('member.read', [
|
||||
'article' => $article,
|
||||
'version' => $version,
|
||||
'license' => $decision->grant?->rights_snapshot['purpose'] ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||
use App\Domain\Catalog\CompositionStructureReader;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class PublicCatalogController extends Controller
|
||||
{
|
||||
public function index(): View
|
||||
{
|
||||
$kind = EditorialContentKind::query()->where('slug', 'programm')->first();
|
||||
$programs = Composition::query()
|
||||
->when($kind !== null, fn ($query) => $query->where('editorial_content_kind_id', $kind->id))
|
||||
->orderBy('designation')
|
||||
->get()
|
||||
->filter(fn (Composition $composition): bool => app(CompositionDisplayRelease::class)->highestReleasedVersion($composition) !== null);
|
||||
|
||||
return view('public.programs', ['programs' => $programs]);
|
||||
}
|
||||
|
||||
public function program(Composition $composition): View
|
||||
{
|
||||
$kind = $composition->editorialContentKind;
|
||||
abort_unless($kind?->slug === 'programm', 404);
|
||||
$version = app(CompositionDisplayRelease::class)->highestReleasedVersion($composition);
|
||||
abort_if($version === null, 404);
|
||||
|
||||
return view('public.program', [
|
||||
'composition' => $composition,
|
||||
'version' => $version,
|
||||
'nodes' => app(CompositionStructureReader::class)->tree($version),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||
use App\Domain\Catalog\CompositionStructureReader;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ReleaseStatus;
|
||||
use App\Domain\Catalog\StructureNode;
|
||||
@@ -71,16 +72,24 @@ public function program(User $user, Composition $composition): array
|
||||
$version = $this->display->highestReleasedVersion($composition);
|
||||
abort_if($version === null, 404);
|
||||
|
||||
$nodes = array_map(
|
||||
fn (StructureNode $node): array => $this->present($user, $node),
|
||||
$this->structure->tree($version),
|
||||
);
|
||||
$leaves = $this->leaves($nodes);
|
||||
$open = count(array_filter($leaves, fn (array $leaf): bool => $leaf['view_url'] !== null));
|
||||
|
||||
return [
|
||||
'composition' => $composition,
|
||||
'title' => filled($composition->display_title) ? $composition->display_title : $composition->designation,
|
||||
'summary' => $composition->summary,
|
||||
'kind' => $composition->editorialContentKind?->label
|
||||
?? ($composition->kind?->label()),
|
||||
'nodes' => array_map(
|
||||
fn (StructureNode $node): array => $this->present($user, $node),
|
||||
$this->structure->tree($version),
|
||||
),
|
||||
'learning_goal' => $version->learning_goal,
|
||||
'duration_minutes' => $version->duration_minutes,
|
||||
'material_note' => $version->material_note,
|
||||
'coverage' => $leaves === [] ? 'nicht nutzbar' : ($open === count($leaves) ? 'vollständig' : ($open === 0 ? 'nicht nutzbar' : 'teilweise')),
|
||||
'nodes' => $nodes,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -104,6 +113,7 @@ private function present(User $user, StructureNode $node): array
|
||||
'output_class' => $node->outputClass,
|
||||
'view_url' => $view,
|
||||
'download_url' => $download,
|
||||
'program_url' => $this->programUrl($node),
|
||||
'children' => array_map(
|
||||
fn (StructureNode $child): array => $this->present($user, $child),
|
||||
$node->children,
|
||||
@@ -111,6 +121,42 @@ private function present(User $user, StructureNode $node): array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $nodes
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
private function leaves(array $nodes): array
|
||||
{
|
||||
$leaves = [];
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
if ($node['children'] === []) {
|
||||
$leaves[] = $node;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$leaves = [...$leaves, ...$this->leaves($node['children'])];
|
||||
}
|
||||
|
||||
return $leaves;
|
||||
}
|
||||
|
||||
private function programUrl(StructureNode $node): ?string
|
||||
{
|
||||
if ($node->compositionId === null || $node->compositionVersionId === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$version = CompositionVersion::query()->find($node->compositionVersionId);
|
||||
|
||||
if ($version === null || ! $this->display->isReleased($version)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return route('member.program', $node->compositionId);
|
||||
}
|
||||
|
||||
private function viewAction(?string $outputClass): string
|
||||
{
|
||||
return in_array($outputClass, ['film', 'audio'], true) ? 'streamen' : 'ansehen';
|
||||
|
||||
Reference in new issue
Block a user