19declare(strict_types=1);
51 private readonly
int $objectId,
52 string $certificatePath,
53 private readonly
bool $hasAdditionalElements,
60 ?UiRenderer $ui_renderer =
null,
70 $this->httpWrapper =
$DIC->http()->wrapper();
72 $this->page_template =
$DIC->ui()->mainTemplate();
76 $this->irss =
$DIC->resourceStorage();
83 $placeholderDescriptionObject,
84 $logger ??
$DIC->logger()->cert(),
90 $logger ??
$DIC->logger()->cert()
109 $certificateTemplate = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
111 $command = $this->
ctrl->getCmd() ??
'';
114 $form->setPreventDoubleSubmission(
false);
115 $form->setFormAction($this->
ctrl->getFormAction($certificateGUI,
'certificateEditor'));
116 $form->setTitle($this->
language->txt(
'cert_form_sec_availability'));
117 $form->setMultipart(
true);
118 $form->setTableWidth(
'100%');
119 $form->setId(
'certificate');
122 $form->addItem($active);
125 $import->setRequired(
false);
126 $import->setSuffixes([
'zip']);
129 if (!empty($_FILES[
'certificate_import'][
'name']) && $import->checkInput()) {
130 $result = $this->importAction->import(
131 $_FILES[
'certificate_import'][
'tmp_name'],
132 $_FILES[
'certificate_import'][
'name']
135 $this->page_template->setOnScreenMessage(
136 $this->page_template::MESSAGE_TYPE_SUCCESS,
137 $this->
language->txt(
'saved_successfully'),
140 $this->
ctrl->redirect($certificateGUI,
'certificateEditor');
142 $this->page_template->setOnScreenMessage(
143 $this->page_template::MESSAGE_TYPE_FAILURE,
144 $this->
language->txt(
'certificate_error_import'),
147 $this->
ctrl->redirect($certificateGUI,
'certificateEditor');
150 $form->addItem($import);
153 $formSection->setTitle($this->
language->txt(
'cert_form_sec_layout'));
154 $form->addItem($formSection);
157 $pageformats = $this->pageFormats->fetchPageFormats();
159 foreach ($pageformats as $format) {
160 $option =
new ilRadioOption($format[
'name'], $format[
'value']);
162 if (strcmp($format[
'value'],
'custom') === 0) {
164 $pageheight->setSize(6);
165 $pageheight->setValidationRegexp(
166 '/^(([1-9]+|([1-9]+[0]*[\.,]{0,1}[\d]+))|(0[\.,](0*[1-9]+[\d]*)))(cm|mm|in|pt|pc|px|em)$/is'
168 $pageheight->setInfo($this->
language->txt(
'certificate_unit_description'));
169 $pageheight->setRequired(
true);
170 $option->addSubItem($pageheight);
173 $pagewidth->setSize(6);
174 $pagewidth->setValidationRegexp(
175 '/^(([1-9]+|([1-9]+[0]*[\.,]{0,1}[\d]+))|(0[\.,](0*[1-9]+[\d]*)))(cm|mm|in|pt|pc|px|em)$/is'
177 $pagewidth->setInfo($this->
language->txt(
'certificate_unit_description'));
178 $pagewidth->setRequired(
true);
179 $option->addSubItem($pagewidth);
182 $pageformat->addOption($option);
185 $pageformat->setRequired(
true);
187 if (strcmp($command,
'certificateSave') === 0) {
188 $pageformat->checkInput();
191 $form->addItem($pageformat);
194 $bgimage->setRequired(
false);
195 $bgimage->setUseCache(
false);
197 $bgimage->setAllowDeletion(
true);
198 $bg_image_rid = $certificateTemplate->getBackgroundImageIdentification();
199 $bg_image_path = $certificateTemplate->getBackgroundImagePath();
202 $this->global_certificate_settings->getBackgroundImageIdentification() instanceof
ResourceIdentification &&
203 $bg_image_rid === $this->global_certificate_settings->getBackgroundImageIdentification()->
serialize()
205 !$certificateTemplate->getBackgroundImageIdentification() ||
206 !$this->irss->manage()->find(
207 $certificateTemplate->getBackgroundImageIdentification()
210 $identification = $this->global_certificate_settings->getBackgroundImageIdentification();
211 $bgimage->setAllowDeletion(
false);
213 $identification = $this->irss->manage()->find($bg_image_rid);
216 $background_flavour = $this->irss->flavours()->get(
218 $this->tile_image_definition
220 $flavour_urls = $this->irss->consume()->flavourUrls($background_flavour);
221 foreach ($flavour_urls->getURLs(
true) as
$url) {
223 $bgimage->setImage(
$url);
225 } elseif ($bg_image_path !==
'' && $this->
filesystem->has($bg_image_path)) {
233 $form->addItem($bgimage);
236 $this->
language->txt(
'certificate_card_tile_image'),
237 'certificate_card_tile_image'
239 $tile_image->setRequired(
false);
240 $tile_image->setUseCache(
false);
241 $tile_image->setSuffixes([
'svg']);
243 $allow_tile_image_deletion =
false;
245 $tile_image_identification = $certificateTemplate->getTileImageIdentification();
246 $old_tile_image_path = $certificateTemplate->getTileImagePath();
247 if (
'' !== $tile_image_identification) {
248 $identification = $this->irss->manage()->find($tile_image_identification);
250 $tile_image->setImage($this->irss->consume()->src($identification)->getSrc(
true));
251 $allow_tile_image_deletion =
true;
253 } elseif ($old_tile_image_path !==
'' && $this->
filesystem->has($old_tile_image_path)) {
254 $tile_image->setImage(
259 $allow_tile_image_deletion =
true;
262 $tile_image->setAllowDeletion($allow_tile_image_deletion);
264 $form->addItem($tile_image);
267 $rect->setRequired(
true);
268 $rect->setUseUnits(
true);
269 $rect->setInfo($this->
language->txt(
'certificate_unit_description'));
271 if (strcmp($command,
'certificateSave') === 0) {
275 $form->addItem($rect);
278 $certificate->setRequired(
true);
279 $certificate->setRows(20);
280 $certificate->setCols(80);
282 $certificate->setInfo(
283 $this->
language->txt(
'certificate_text_info') . $this->placeholderDescriptionObject->createPlaceholderHtmlDescription()
286 $certificate->setUseRte(
true,
'3.4.7');
301 $certificate->setRteTags($tags);
303 if (strcmp($command,
'certificateSave') === 0) {
304 $certificate->checkInput();
307 $form->addItem($certificate);
309 if ($this->hasAdditionalElements) {
311 $formSection->setTitle($this->
language->txt(
'cert_form_sec_add_features'));
312 $form->addItem($formSection);
315 if ($this->
access->checkAccess(
318 $this->httpWrapper->query()->retrieve(
'ref_id', $this->refinery->kindlyTo()->int())
320 if ($certificateTemplate->isCurrentlyActive()) {
321 $preview_button = $this->ui_factory->button()->standard(
322 $this->
language->txt(
'certificate_preview'),
323 $this->ctrl->getLinkTarget($certificateGUI,
'certificatePreview')
325 $export_button = $this->ui_factory->button()->standard(
326 $this->
language->txt(
'certificate_export'),
327 $this->ctrl->getLinkTarget($certificateGUI,
'certificateExportFO')
329 $delete_button = $this->ui_factory->button()->standard(
331 $this->ctrl->getLinkTarget($certificateGUI,
'certificateDelete')
334 $this->
toolbar->addStickyItem($preview_button);
335 $this->
toolbar->addComponent($export_button);
336 $this->
toolbar->addComponent($delete_button);
338 $form->addCommandButton(
'certificateSave', $this->
language->txt(
'save'));
344 public function save(array $formFields): void
353 return $this->formFieldParser->fetchDefaultFormFields($content);
Builds a Color from either hex- or rgb values.
Indicates that a file is missing or not found.
Indicates general problems with the input or output operations.
Class ResourceIdentification.
GUI class to create PDF certificates.
Component logger with individual log levels by component id.
Class ilObjCertificateSettings.
This class represents an option in a radio group.
This class represents a text area property in a property form.
This class represents a text property in a property form.
static signFile(string $path_to_file)
The filesystem interface provides the public interface for the Filesystem service API consumer.
An entity that renders components to a string output.
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...