ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCertificateSettingsScormFormRepository.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
24
26{
28
29 public function __construct(
30 private readonly ilObject $object,
31 string $certificatePath,
32 bool $hasAdditionalElements,
33 private readonly ilLanguage $language,
34 ilCtrlInterface $ctrl,
35 ilAccess $access,
36 ilToolbarGUI $toolbar,
37 ilCertificatePlaceholderDescription $placeholderDescriptionObject,
38 ?ilCertificateSettingsFormRepository $settingsFormRepository = null,
39 private readonly ilSetting $setting = new ilSetting('scorm')
40 ) {
41 global $DIC;
42
43 $this->settingsFormFactory = $settingsFormRepository ?? new ilCertificateSettingsFormRepository(
44 $object->getId(),
45 $certificatePath,
46 $hasAdditionalElements,
47 $language,
48 $ctrl,
49 $access,
50 $toolbar,
51 $placeholderDescriptionObject,
52 $DIC->ui()->factory(),
53 $DIC->ui()->renderer()
54 );
55 }
56
65 public function createForm(ilCertificateGUI $certificateGUI): ilPropertyFormGUI
66 {
67 $form = $this->settingsFormFactory->createForm($certificateGUI);
68
69 $short_name = new ilTextInputGUI($this->language->txt('certificate_short_name'), 'short_name');
70 $short_name->setRequired(true);
71 $short_name->setValue(ilStr::subStr($this->object->getTitle(), 0, 30));
72 $short_name->setSize(30);
73
74 $short_name_value = $this->setting->get(
75 'certificate_short_name_' . $this->object->getId(),
76 ''
77 );
78
79 $infoText = $this->language->txt('certificate_short_name_description');
80 if ($short_name_value !== '') {
81 $short_name->setInfo(str_replace(
82 '[SHORT_TITLE]',
83 $short_name_value,
84 $infoText
85 ));
86 } else {
87 $short_name->setInfo($infoText);
88 }
89
90 $form->addItem($short_name);
91
92 return $form;
93 }
94
95 public function save(array $formFields): void
96 {
97 $this->setting->set('certificate_' . $this->object->getId(), (string) ($formFields['certificate_enabled_scorm'] ?? '0'));
98 $this->setting->set('certificate_short_name_' . $this->object->getId(), (string) ($formFields['short_name'] ?? ''));
99 }
100
101 public function fetchFormFieldData(string $content): array
102 {
103 $formFields = $this->settingsFormFactory->fetchFormFieldData($content);
104 $formFields['certificate_enabled_scorm'] = $this->setting->get(
105 'certificate_' . $this->object->getId(),
106 (string) ($formFields['certificate_enabled_scorm'] ?? '0')
107 );
108 $formFields['short_name'] = $this->setting->get(
109 'certificate_short_name_' . $this->object->getId(),
110 (string) ($formFields['short_name'] ?? '')
111 );
112
113 return $formFields;
114 }
115}
Indicates that a file is missing or not found.
Indicates general problems with the input or output operations.
Definition: IOException.php:28
Class ilAccessHandler Checks access for ILIAS objects.
GUI class to create PDF certificates.
__construct(private readonly ilObject $object, string $certificatePath, bool $hasAdditionalElements, private readonly ilLanguage $language, ilCtrlInterface $ctrl, ilAccess $access, ilToolbarGUI $toolbar, ilCertificatePlaceholderDescription $placeholderDescriptionObject, ?ilCertificateSettingsFormRepository $settingsFormRepository=null, private readonly ilSetting $setting=new ilSetting('scorm'))
readonly ilCertificateSettingsFormRepository $settingsFormFactory
language handling
Class ilObject Basic functions for all objects.
This class represents a property form user interface.
ILIAS Setting Class.
static subStr(string $a_str, int $a_start, ?int $a_length=null)
Definition: class.ilStr.php:21
This class represents a text property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26