19declare(strict_types=1);
73 private readonly
int $objectId,
88 $this->httpWrapper =
$DIC->http()->wrapper();
90 $this->
lng = $DIC[
'lng'];
91 $this->tpl =
$DIC[
'tpl'];
92 $this->
ctrl = $DIC[
'ilCtrl'];
93 $this->
ilias = $DIC[
'ilias'];
95 $this->irss =
$DIC->resourceStorage();
98 $this->tree =
$DIC[
'tree'];
99 $this->
access = $DIC[
'ilAccess'];
100 $this->
toolbar = $DIC[
'ilToolbar'];
103 $this->
lng->loadLanguageModule(
'certificate');
104 $this->
lng->loadLanguageModule(
'cert');
105 $this->
lng->loadLanguageModule(
'trac');
107 $this->ref_id = (
int)
$DIC->http()->wrapper()->query()->retrieve(
'ref_id',
$DIC->refinery()->kindlyTo()->int());
109 $this->
logger = $DIC->logger()->cert();
119 $placeholderDescriptionObject,
120 $DIC->ui()->factory(),
121 $DIC->ui()->renderer()
133 $this->templateRepository,
137 $this->templateRepository,
138 $placeholderValuesObject,
157 $cmd = $this->
ctrl->getCmd(self::EDITOR_COMMAND);
158 $next_class = $this->
ctrl->getNextClass($this);
163 switch ($next_class) {
164 case 'ilpropertyformgui':
166 $this->
ctrl->forwardCommand($form);
170 $ret = $this->$cmd();
185 $this->certificateEditor();
191 $this->previewAction->createPreviewPdf($this->objectId);
192 }
catch (Exception) {
193 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'error_creating_certificate_pdf'));
194 $this->certificateEditor();
206 $this->exportAction->export();
213 $cgui->setFormAction($this->
ctrl->getFormAction($this, self::EDITOR_COMMAND));
214 $cgui->setHeaderText($this->
lng->txt(
'certificate_confirm_deletion_text'));
215 $cgui->setCancel($this->
lng->txt(
'no'), self::EDITOR_COMMAND);
216 $cgui->setConfirm($this->
lng->txt(
'yes'),
'certificateDeleteConfirm');
218 $this->tpl->setContent($cgui->getHTML());
226 $template = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
227 $templateId = $template->getId();
229 $this->deleteAction->delete($templateId, $this->objectId);
230 $this->
ctrl->redirect($this, self::EDITOR_COMMAND);
246 $form = $this->settingsFormFactory->createForm(
250 $form->setValuesByPost();
252 $request =
$DIC->http()->request();
254 $formFields = $request->getParsedBody();
256 $this->tpl->setVariable(
'ADM_CONTENT', $form->getHTML());
272 $this->certificateEditor();
285 public function certificateEditor(): void
290 $messageBoxHtml =
'';
291 if ($enabledGlobalLearningProgress) {
292 $objectLearningProgressSettings =
new ilLPObjSettings($this->objectId);
293 $mode = $objectLearningProgressSettings->getMode();
301 $messageBox =
$DIC->ui()
304 ->info($this->
lng->txt(
'learning_progress_deactivated'))
307 $messageBoxHtml =
$renderer->render($messageBox);
308 $form->clearCommandButtons();
312 $formHtml = $form->getHTML();
314 $this->tpl->setVariable(
'ADM_CONTENT', $messageBoxHtml . $formHtml);
327 $certificateTemplate = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
329 $form = $this->settingsFormFactory->createForm(
335 $formFields[
'active'] = $certificateTemplate->isCurrentlyActive();
337 $form->setValuesByArray($formFields);
348 $this->global_certificate_settings,
351 $current_template = $this->templateRepository->fetchPreviousCertificate(
$objId);
352 $currentVersion = $current_template->getVersion();
353 $nextVersion = $currentVersion + 1;
354 $current_background_rid = $this->irss->manageContainer()->find(
355 $current_template->getBackgroundImageIdentification()
357 $current_tile_image_rid = $this->irss->manageContainer()->find(
358 $current_template->getTileImageIdentification()
361 $should_delete_background =
362 $this->httpWrapper->post()->retrieve(
365 $this->refinery->kindlyTo()->bool(),
366 $this->refinery->always(
false)
369 $should_delete_tile_image =
370 $this->httpWrapper->post()->retrieve(
371 'certificate_card_tile_image_delete',
373 $this->refinery->kindlyTo()->bool(),
374 $this->refinery->always(
false)
378 $new_background_rid = $current_background_rid && !$should_delete_background ? $current_background_rid :
379 $this->global_certificate_settings->getBackgroundImageIdentification();
381 $new_tile_rid = !$should_delete_tile_image ? $current_tile_image_rid :
null;
384 $this->settingsFormFactory->save($form_fields);
386 $templateValues = $this->placeholderDescriptionObject->getPlaceholderDescriptions();
388 if ($this->fileUpload->hasUploads()) {
389 if (!$this->fileUpload->hasBeenProcessed()) {
390 $this->fileUpload->process();
392 $new_background = $form->
getInput(
'background')[
'tmp_name'] ??
'';
393 $new_tile_image = $form->
getInput(
'certificate_card_tile_image')[
'tmp_name'] ??
'';
394 $results = $this->fileUpload->getResults();
396 if ($new_background !==
'') {
397 $new_background_rid = $this->irss->manage()->upload(
403 if ($new_tile_image !==
'') {
404 $new_tile_rid = $this->irss->manage()->upload(
411 $jsonEncodedTemplateValues = json_encode($templateValues, JSON_THROW_ON_ERROR);
413 $xslfo = $this->xlsFoParser->parse($form_fields);
414 $newHashValue = hash(
418 isset($new_background_rid) ? $new_background_rid->serialize() :
'',
419 $jsonEncodedTemplateValues,
420 isset($new_tile_rid) ? $new_background_rid->serialize() :
''
424 $active = (bool) ($form_fields[
'active'] ??
false);
426 if ($newHashValue !== $current_template->getCertificateHash()) {
432 $jsonEncodedTemplateValues,
437 isset($new_background_rid) ? $new_background_rid->serialize() :
'',
438 isset($new_tile_rid) ? $new_tile_rid->serialize() :
'',
440 $this->templateRepository->save($certificateTemplate);
443 $certificate_handler->handleResourceChange($current_background_rid);
446 $certificate_handler->handleResourceChange($current_tile_image_rid);
449 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'),
true);
450 $this->
ctrl->redirect($this, self::EDITOR_COMMAND);
454 $current_template->getId() !==
null &&
455 $current_template->isCurrentlyActive() !== $active
457 $this->templateRepository->updateActivity($current_template, $active);
458 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'certificate_change_active_status'),
true);
459 $this->
ctrl->redirect($this, self::EDITOR_COMMAND);
462 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'certificate_same_not_saved'),
true);
463 $this->
ctrl->redirect($this, self::EDITOR_COMMAND);
464 }
catch (Exception
$e) {
465 $this->tpl->setOnScreenMessage(
469 $this->
logger->error($e->getTraceAsString());
475 $this->tpl->setVariable(
'ADM_CONTENT', $form->
getHTML());
481 $format = $this->
settings->get(
'pageformat',
'');
482 $formats = $this->pageFormats->fetchPageFormats();
485 'pageformat' => $format,
486 'pagewidth' => $formats[
'width'] ??
'',
487 'pageheight' => $formats[
'height'] ??
'',
496 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
__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 $tmp_file_system=null)
ilGlobalPageTemplate $tpl
ilCertificateTemplateStakeholder $stakeholder
readonly WrapperFactory $httpWrapper
readonly ilObjCertificateSettings $global_certificate_settings
readonly ilCertificateTemplateRepository $templateRepository
readonly Factory $refinery
const string EDITOR_COMMAND
readonly ilCertificateTemplatePreviewAction $previewAction
readonly ilLogger $logger
readonly ilPageFormats $pageFormats
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.