Mache Medien, Übungen und Kurse in der Verwaltung bearbeitbar.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
4f2e5a5f3b
commit
3ee9f529ca
33 files changed
+1105
-284
No files matched your search
@@ -6,6 +6,7 @@
|
||||
use App\Domain\Catalog\BundleStatus;
|
||||
use App\Domain\Catalog\BundleVersion;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
@@ -24,6 +25,30 @@ public static function elements(): array
|
||||
return ContentElement::query()->orderBy('working_title')->pluck('working_title', 'id')->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function assignmentTargets(?int $exceptCompositionId = null): array
|
||||
{
|
||||
$options = [];
|
||||
|
||||
foreach (ContentElementVersion::query()->where('status', ContentVersionStatus::Bereit)->with('element')->orderBy('id')->get() as $version) {
|
||||
$options['element:'.$version->id] = 'Medium: '.$version->element->working_title.' · Fassung '.$version->number;
|
||||
}
|
||||
|
||||
foreach (CompositionVersion::query()->where('status', ContentVersionStatus::Bereit)->with('composition')->orderBy('id')->get() as $version) {
|
||||
if ($exceptCompositionId !== null && (int) $version->composition_id === $exceptCompositionId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$kind = $version->composition->kind;
|
||||
$label = $kind instanceof CompositionKind ? $kind->label() : 'Zusammenstellung';
|
||||
$options['composition:'.$version->id] = $label.': '.$version->composition->designation.' · Fassung '.$version->number;
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
use App\Domain\Catalog\BundleStatus;
|
||||
use App\Domain\Catalog\BundleVersion;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\CompositionMember;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
@@ -263,7 +264,7 @@ public function elementUsage(ContentElement $element): array
|
||||
->get();
|
||||
|
||||
foreach ($members as $member) {
|
||||
$lines[] = 'Komposition '.$member->compositionVersion->composition->designation
|
||||
$lines[] = self::compositionLabel($member->compositionVersion->composition)
|
||||
.' · Fassung '.$member->compositionVersion->number
|
||||
.' · Rolle '.$member->role;
|
||||
}
|
||||
@@ -310,7 +311,7 @@ public function compositionMembers(Composition $composition): array
|
||||
}
|
||||
|
||||
$nested = $member->nestedCompositionVersion;
|
||||
$lines[] = $member->role.' — Komposition '.($nested->composition->designation ?? 'fehlt');
|
||||
$lines[] = $member->role.' — '.($nested === null ? 'fehlt' : self::compositionLabel($nested->composition));
|
||||
}
|
||||
|
||||
return $lines;
|
||||
@@ -331,7 +332,7 @@ public function compositionUsage(Composition $composition): array
|
||||
->get();
|
||||
|
||||
foreach ($parents as $member) {
|
||||
$lines[] = 'Komposition '.$member->compositionVersion->composition->designation
|
||||
$lines[] = self::compositionLabel($member->compositionVersion->composition)
|
||||
.' · Fassung '.$member->compositionVersion->number
|
||||
.' · Rolle '.$member->role;
|
||||
}
|
||||
@@ -414,6 +415,14 @@ private function purpose(string $purpose): string
|
||||
};
|
||||
}
|
||||
|
||||
private static function compositionLabel(Composition $composition): string
|
||||
{
|
||||
$kind = $composition->kind;
|
||||
$label = $kind instanceof CompositionKind ? $kind->label() : 'Zusammenstellung';
|
||||
|
||||
return $label.': '.$composition->designation;
|
||||
}
|
||||
|
||||
private function status(mixed $status): string
|
||||
{
|
||||
return match (StatusValue::of($status)) {
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Support;
|
||||
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
|
||||
class IncomingFile
|
||||
{
|
||||
public static function store(mixed $value): ?string
|
||||
{
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $item) {
|
||||
$stored = self::store($item);
|
||||
|
||||
if ($stored !== null) {
|
||||
return $stored;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($value instanceof TemporaryUploadedFile || $value instanceof UploadedFile) {
|
||||
$extension = strtolower($value->getClientOriginalExtension());
|
||||
$stem = preg_replace('/[^A-Za-z0-9_-]+/', '-', pathinfo($value->getClientOriginalName(), PATHINFO_FILENAME)) ?? '';
|
||||
$stem = trim($stem, '-');
|
||||
$stem = ($stem !== '' ? $stem : 'datei').'-'.bin2hex(random_bytes(4));
|
||||
|
||||
if (preg_match('/^[a-z0-9]{1,8}$/', $extension) !== 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$path = $value->storeAs('inhalte', $stem.'.'.$extension, 'cms_incoming');
|
||||
|
||||
return is_string($path) && $path !== '' ? $path : null;
|
||||
}
|
||||
|
||||
if (! is_string($value) || $value === '' || str_contains($value, '..') || ! str_starts_with($value, 'inhalte/')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Storage::disk('cms_incoming')->exists($value) ? $value : null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user