264 $ff = $this->ui_factory->input()->field();
265
266 $title = $ff
267 ->text($this->
lng->txt(
'title'))
268 ->withValue($entry?->title() ?? '')
269 ->withRequired(true)
270 ->withMaxLength(255);
272
273 $des = $ff
274 ->textarea($this->
lng->txt(
'description'))
275 ->withValue($entry?->description() ?? '');
277
278 $usage = $ff
279 ->radio($this->
lng->txt(
'meta_copyright_usage'))
280 ->withOption(
'0', $this->
lng->txt(
'meta_copyright_in_use'))
281 ->withOption(
'1', $this->
lng->txt(
'meta_copyright_outdated'))
282 ->withValue((int) $entry?->isOutdated());
284
285 $cp_data = $entry?->copyrightData();
286
287 $full_name = $ff
288 ->text($this->
lng->txt(
'md_copyright_full_name'))
289 ->withValue($cp_data?->fullName() ?? '');
290
291 $link = $ff
292 ->url(
293 $this->
lng->txt(
'md_copyright_link'),
294 $this->lng->txt('md_copyright_link_info')
295 )
296 ->withValue((
string) $cp_data?->
link())
297 ->withAdditionalTransformation(
298 $this->
refinery->custom()->transformation(fn($v) => $v instanceof
URI ? $v :
null)
299 );
300
301 $image_link = $ff
302 ->url($this->
lng->txt(
'md_copyright_image_link'))
303 ->withValue((string) $cp_data?->imageLink())
304 ->withAdditionalTransformation($this->
refinery->custom()->transformation(
305 fn($v) => $v instanceof
URI ? $v :
null
306 ));
307
308 $file_id = empty($cp_data?->imageFile()) ? '' : $cp_data?->imageFile();
309 $image_file = $ff
310 ->file(
312 $this->
lng->txt(
'md_copyright_image_file')
313 )
314 ->withMaxFiles(1)
315 ->withAcceptedMimeTypes([MimeType::IMAGE__PNG, MimeType::IMAGE__JPEG]);
316 if ($file_id !== '') {
317 $image_file = $image_file->withValue([$file_id]);
318 };
319
320 $image_value = 'link_group';
321 if (!is_null($cp_data) && !$cp_data->isImageLink()) {
322 $image_value = 'file_group';
323 }
324 $image = $ff
325 ->switchableGroup(
326 [
327 'link_group' => $ff->group(
328 ['image_link' => $image_link],
329 $this->lng->txt('md_copyright_image_is_link')
330 ),
331 'file_group' => $ff->group(
332 ['image_file' => $image_file],
333 $this->lng->txt('md_copyright_image_is_file')
334 ),
335 ],
336 $this->lng->txt('md_copyright_image')
337 )
338 ->withValue($image_value);
339
340 $alt_text = $ff
341 ->text(
342 $this->
lng->txt(
'md_copyright_alt_text'),
343 $this->lng->txt('md_copyright_alt_text_info')
344 )
345 ->withValue($cp_data?->altText() ?? '');
346
347 $cop = $ff
348 ->section(
349 [
350 'full_name' => $full_name,
351 'link' => $link,
352 'image' => $image,
353 'alt_text' => $alt_text
354 ],
355 $this->
lng->txt(
'md_copyright_value')
356 );
358
359 if (!isset($entry)) {
360 $title = $this->
lng->txt(
'md_copyright_add');
361 $post_url = $this->
ctrl->getLinkTarget($this,
'saveEntry');
362 } else {
363 $title = $this->
lng->txt(
'md_copyright_edit');
364 $this->
ctrl->setParameter($this,
'entry_id', $entry->id());
365 $post_url = $this->
ctrl->getLinkTarget($this,
'updateEntry');
366 $this->
ctrl->clearParameters($this);
367 }
368
369 $modal = $this->ui_factory->modal()->roundtrip(
370 $title,
371 null,
373 $post_url
374 );
375 if ($open_on_load) {
376 $modal = $modal->withOnLoad($modal->getShowSignal());
377 }
378 return $modal;
379 }
link(string $caption, string $href, bool $new_viewport=false)