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