- App\Support\ImageCredit: Foto/Quelle-Zeile, KI-Hinweis mit Herkunft, Verantwortlich-Zeile nur mit Protokoll, sichere Links; PDF-Zeilen mit Bestätigungskennung - Artikelseite: Overlay (eigenes i-Zeichen, Alpine ohne Plugin, Bottom-Sheet auf Mobil) mit Nachweis, Lizenz, Quelle, KI-Hinweis, Verantwortlich-Zeile, „Bild melden" - Richtlinien 0.2: Prüfung als automatisiert beschrieben, Abschnitt „Bilder" (Decision-Update 3.5); Taglines, Suche, Newsrooms, Startseiten-CTA, Mails ohne „qualitätsgeprüft" - Cache-Invalidierung bei Bildwechsel an veröffentlichten Meldungen; PHPStan-Baseline für das Resource bereinigt Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
97 lines
3.5 KiB
PHP
97 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Api\V1;
|
|
|
|
use App\Enums\AiImageDeclaration;
|
|
use App\Services\Image\ImageRightsTextRenderer;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
use Illuminate\Validation\Validator;
|
|
|
|
class StorePressReleaseImageRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return $this->user()?->tokenCan('press-release-images:write') === true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* KI-Kennzeichnung je Bild (Art. 50 KI-VO) ist im v1-Vertrag Pflicht.
|
|
* Mit Formular v2 (Bildkennzeichnung Block C, Decision-Update S4) kommen
|
|
* Bildnachweis, Rechtebestätigung und die Kennung des bestätigten
|
|
* Wortlauts als Pflichtfelder dazu; Lizenz- und Quellenlink,
|
|
* Fokuspunkt und Letterbox bleiben optional.
|
|
*
|
|
* @return array<string, ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
$rightsV2 = (bool) config('images.rights_v2');
|
|
$maxKilobytes = $rightsV2 ? (int) ((int) config('images.max_bytes') / 1024) : 8192;
|
|
|
|
$rules = [
|
|
'image' => ['required', 'image', 'mimes:jpg,jpeg,png,webp', 'max:'.$maxKilobytes],
|
|
'ai_declaration' => ['required', Rule::enum(AiImageDeclaration::class)],
|
|
'title' => ['nullable', 'string', 'max:120'],
|
|
'description' => ['nullable', 'string', 'max:500'],
|
|
'copyright' => [$rightsV2 ? 'required' : 'nullable', 'string', 'max:255'],
|
|
'is_preview' => ['nullable', 'boolean'],
|
|
];
|
|
|
|
if ($rightsV2) {
|
|
$rules += [
|
|
'rights_confirmed' => ['required', 'accepted'],
|
|
'confirm_text_version' => ['required', 'string', 'max:40'],
|
|
'license_url' => ['nullable', 'url:http,https', 'max:2048'],
|
|
'source_url' => ['nullable', 'url:http,https', 'max:2048'],
|
|
'focus_x' => ['nullable', 'integer', 'between:0,100'],
|
|
'focus_y' => ['nullable', 'integer', 'between:0,100'],
|
|
'no_crop' => ['nullable', 'boolean'],
|
|
];
|
|
}
|
|
|
|
return $rules;
|
|
}
|
|
|
|
/**
|
|
* Die Kennung muss die heute aktive Fassung sein; sonst 422 mit Hinweis
|
|
* auf die aktuelle Kennung (Decision-Update 7.1: „sonst 422 mit Hinweis").
|
|
*/
|
|
public function after(): array
|
|
{
|
|
return [
|
|
function (Validator $validator): void {
|
|
if (! config('images.rights_v2') || $validator->errors()->has('confirm_text_version')) {
|
|
return;
|
|
}
|
|
|
|
$current = app(ImageRightsTextRenderer::class)->current();
|
|
$given = (string) $this->input('confirm_text_version');
|
|
|
|
if ($current === null || $given !== $current->key) {
|
|
$validator->errors()->add(
|
|
'confirm_text_version',
|
|
sprintf('The confirmation text version is not current. Current version: %s.', $current !== null ? $current->key : 'none'),
|
|
);
|
|
}
|
|
},
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'rights_confirmed.accepted' => 'The rights confirmation is required (rights_confirmed must be true).',
|
|
'copyright.required' => 'The image credit (copyright) is required.',
|
|
];
|
|
}
|
|
}
|