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
@@ -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