19declare(strict_types=1);
74 private readonly
int $objectId,
90 $this->httpWrapper =
$DIC->http()->wrapper();
92 $this->
lng = $DIC[
'lng'];
93 $this->tpl =
$DIC[
'tpl'];
94 $this->
ctrl = $DIC[
'ilCtrl'];
95 $this->
ilias = $DIC[
'ilias'];
97 $this->irss =
$DIC->resourceStorage();
100 $this->tree =
$DIC[
'tree'];
101 $this->
access = $DIC[
'ilAccess'];
102 $this->
toolbar = $DIC[
'ilToolbar'];
105 $this->
lng->loadLanguageModule(
'certificate');
106 $this->
lng->loadLanguageModule(
'cert');
107 $this->
lng->loadLanguageModule(
'trac');
109 $this->ref_id = (
int)
$DIC->http()->wrapper()->query()->retrieve(
'ref_id',
$DIC->refinery()->kindlyTo()->int());
111 $this->
logger = $DIC->logger()->cert();
121 $placeholderDescriptionObject,
122 $DIC->ui()->factory(),
123 $DIC->ui()->renderer()
135 $this->templateRepository,
139 $this->templateRepository,
140 $placeholderValuesObject,
160 $cmd = $this->
ctrl->getCmd(self::EDITOR_COMMAND);
161 $next_class = $this->
ctrl->getNextClass($this);
166 switch ($next_class) {
167 case 'ilpropertyformgui':
169 $this->
ctrl->forwardCommand($form);
173 $ret = $this->$cmd();
188 $this->certificateEditor();
194 $this->previewAction->createPreviewPdf($this->objectId);
195 }
catch (Exception) {
196 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'error_creating_certificate_pdf'));
197 $this->certificateEditor();
209 $this->exportAction->export();
216 $cgui->setFormAction($this->
ctrl->getFormAction($this, self::EDITOR_COMMAND));
217 $cgui->setHeaderText($this->
lng->txt(
'certificate_confirm_deletion_text'));
218 $cgui->setCancel($this->
lng->txt(
'no'), self::EDITOR_COMMAND);
219 $cgui->setConfirm($this->
lng->txt(
'yes'),
'certificateDeleteConfirm');
221 $this->tpl->setContent($cgui->getHTML());
229 $template = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
230 $templateId = $template->getId();
232 $this->deleteAction->delete($templateId, $this->objectId);
233 $this->
ctrl->redirect($this, self::EDITOR_COMMAND);
249 $form = $this->settingsFormFactory->createForm(
253 $form->setValuesByPost();
255 $request =
$DIC->http()->request();
257 $formFields = $request->getParsedBody();
259 $this->tpl->setVariable(
'ADM_CONTENT', $form->getHTML());
275 $this->certificateEditor();
288 public function certificateEditor(): void
293 $messageBoxHtml =
'';
294 if ($enabledGlobalLearningProgress) {
295 $objectLearningProgressSettings =
new ilLPObjSettings($this->objectId);
296 $mode = $objectLearningProgressSettings->getMode();
304 $messageBox =
$DIC->ui()
307 ->info($this->
lng->txt(
'learning_progress_deactivated'))
310 $messageBoxHtml =
$renderer->render($messageBox);
311 $form->clearCommandButtons();
315 $formHtml = $form->getHTML();
317 $this->tpl->setVariable(
'ADM_CONTENT', $messageBoxHtml . $formHtml);
330 $certificateTemplate = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
332 $form = $this->settingsFormFactory->createForm(
338 $formFields[
'active'] = $certificateTemplate->isCurrentlyActive();
340 $form->setValuesByArray($formFields);
351 $this->global_certificate_settings,
354 $current_template = $this->templateRepository->fetchPreviousCertificate(
$objId);
355 $currentVersion = $current_template->getVersion();
356 $nextVersion = $currentVersion + 1;
357 $current_background_rid = $this->irss->manageContainer()->find(
358 $current_template->getBackgroundImageIdentification()
360 $current_tile_image_rid = $this->irss->manageContainer()->find(
361 $current_template->getTileImageIdentification()
363 $old_background_image = $current_background_rid ===
null
364 ? $current_template->getBackgroundImagePath() :
366 $old_tile_image = $current_tile_image_rid ===
null
367 ? $current_template->getTileImagePath() :
370 $should_delete_background =
371 $this->httpWrapper->post()->retrieve(
374 $this->refinery->kindlyTo()->bool(),
375 $this->refinery->always(
false)
378 $should_delete_tile_image =
379 $this->httpWrapper->post()->retrieve(
380 'certificate_card_tile_image_delete',
382 $this->refinery->kindlyTo()->bool(),
383 $this->refinery->always(
false)
387 $new_background_rid = $current_background_rid && !$should_delete_background ? $current_background_rid :
388 $this->global_certificate_settings->getBackgroundImageIdentification();
390 is_string($new_background_rid) &&
391 is_string($this->global_certificate_settings->getBackgroundImageIdentification()) &&
392 $new_background_rid === $this->global_certificate_settings->getBackgroundImageIdentification()
394 if ($this->file_system->has($new_background_rid)) {
395 $new_background_rid = $this->irss->manage()->stream(
396 $this->file_system->readStream($new_background_rid),
400 $old_background_image = $new_background_rid;
401 $new_background_rid =
null;
405 $new_tile_rid = !$should_delete_tile_image ? $current_tile_image_rid :
null;
408 $this->settingsFormFactory->save($form_fields);
410 $templateValues = $this->placeholderDescriptionObject->getPlaceholderDescriptions();
412 if ($this->fileUpload->hasUploads()) {
413 if (!$this->fileUpload->hasBeenProcessed()) {
414 $this->fileUpload->process();
416 $new_background = $form->
getInput(
'background')[
'tmp_name'] ??
'';
417 $new_tile_image = $form->
getInput(
'certificate_card_tile_image')[
'tmp_name'] ??
'';
418 $results = $this->fileUpload->getResults();
420 if ($new_background !==
'') {
421 $new_background_rid = $this->irss->manage()->upload(
427 if ($new_tile_image !==
'') {
428 $new_tile_rid = $this->irss->manage()->upload(
435 $jsonEncodedTemplateValues = json_encode($templateValues, JSON_THROW_ON_ERROR);
437 if (isset($new_background_rid)) {
438 $old_background_image =
'';
440 if (isset($new_tile_rid)) {
441 $old_tile_image =
'';
444 $xslfo = $this->xlsFoParser->parse($form_fields);
445 $newHashValue = hash(
449 isset($new_background_rid) ? $new_background_rid->serialize() :
'',
450 $jsonEncodedTemplateValues,
451 isset($new_tile_rid) ? $new_background_rid->serialize() :
'',
452 $old_background_image, $old_tile_image
456 $active = (bool) ($form_fields[
'active'] ??
false);
458 if ($newHashValue !== $current_template->getCertificateHash()) {
464 $jsonEncodedTemplateValues,
469 $old_background_image,
471 isset($new_background_rid) ? $new_background_rid->serialize() :
'',
472 isset($new_tile_rid) ? $new_tile_rid->serialize() :
'',
474 $this->templateRepository->save($certificateTemplate);
477 $certificate_handler->handleResourceChange($current_background_rid);
480 $certificate_handler->handleResourceChange($current_tile_image_rid);
483 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'),
true);
484 $this->
ctrl->redirect($this, self::EDITOR_COMMAND);
488 $current_template->getId() !==
null &&
489 $current_template->isCurrentlyActive() !== $active
491 $this->templateRepository->updateActivity($current_template, $active);
492 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'certificate_change_active_status'),
true);
493 $this->
ctrl->redirect($this, self::EDITOR_COMMAND);
496 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'certificate_same_not_saved'),
true);
497 $this->
ctrl->redirect($this, self::EDITOR_COMMAND);
498 }
catch (Exception
$e) {
499 $this->tpl->setOnScreenMessage(
503 $this->
logger->error($e->getTraceAsString());
509 $this->tpl->setVariable(
'ADM_CONTENT', $form->
getHTML());
515 $format = $this->
settings->get(
'pageformat',
'');
516 $formats = $this->pageFormats->fetchPageFormats();
519 'pageformat' => $format,
520 'pagewidth' => $formats[
'width'] ??
'',
521 'pageheight' => $formats[
'height'] ??
'',
530 return $this->settingsFormFactory->fetchFormFieldData($certificateTemplate->
getCertificateContent());
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.
certificateExportFO()
Exports the certificate.
readonly ilXlsFoParser $xlsFoParser
createFormatArray(ilCertificateTemplate $certificateTemplate)
readonly ilCertificateTemplateExportAction $exportAction
ilGlobalPageTemplate $tpl
ilCertificateTemplateStakeholder $stakeholder
readonly WrapperFactory $httpWrapper
readonly ilObjCertificateSettings $global_certificate_settings
__construct(private readonly ilCertificatePlaceholderDescription $placeholderDescriptionObject, ilCertificatePlaceholderValues $placeholderValuesObject, private readonly int $objectId, string $certificatePath, ?ilCertificateFormRepository $settingsFormFactory=null, ?ilCertificateDeleteAction $deleteAction=null, ?ilCertificateTemplateRepository $templateRepository=null, ?ilPageFormats $pageFormats=null, ?ilXlsFoParser $xlsFoParser=null, ?ilCertificateTemplateExportAction $exportAction=null, ?ilCertificateTemplatePreviewAction $previewAction=null, ?FileUpload $fileUpload=null, private readonly ilSetting $settings=new ilSetting('certificate'), ?Filesystem $file_system=null, ?Filesystem $tmp_file_system=null)
readonly ilCertificateTemplateRepository $templateRepository
readonly Factory $refinery
const string EDITOR_COMMAND
readonly ilCertificateTemplatePreviewAction $previewAction
readonly ilLogger $logger
readonly ilPageFormats $pageFormats
readonly Filesystem $file_system
saveCertificate(ilPropertyFormGUI $form, array $form_fields, int $objId)
ilCertificateTemplateDatabaseRepository $certificate_repo
certificateSave()
Saves the certificate.
readonly ilDBInterface $database
certificateDeleteConfirm()
Deletes the certificate and all its data.
readonly string $certificatePath
readonly ilCertificateDeleteAction $deleteAction
readonly FileUpload $fileUpload
readonly ilCertificateFormRepository $settingsFormFactory
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const LP_MODE_DEACTIVATED
Component logger with individual log levels by component id.
Class ilObjCertificateSettings.
static _enabledLearningProgress()
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupType(int $id, bool $reference=false)
final const DEFAULT_MARGIN_BODY_RIGHT
final const DEFAULT_MARGIN_BODY_BOTTOM
final const DEFAULT_MARGIN_BODY_TOP
final const DEFAULT_MARGIN_BODY_LEFT
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
const ILIAS_VERSION_NUMERIC
The filesystem interface provides the public interface for the Filesystem service API consumer.
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...
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
Class ilObjForumAdministration.