207 $this->lng = $DIC[
'lng'];
208 $this->tpl = $DIC[
'tpl'];
209 $this->ctrl = $DIC[
'ilCtrl'];
210 $this->
ilias = $DIC[
'ilias'];
211 $this->tree = $DIC[
'tree'];
212 $this->access = $DIC[
'ilAccess'];
213 $this->toolbar = $DIC[
'ilToolbar'];
217 $this->lng->loadLanguageModule(
'certificate');
218 $this->lng->loadLanguageModule(
'cert');
219 $this->lng->loadLanguageModule(
"trac");
221 $this->ref_id = (int)
$_GET[
'ref_id'];
229 $logger = $DIC->logger()->cert();
240 $placeholderDescriptionObject
270 if (null === $upload) {
278 $this->backgroundImageUpload = $upload;
284 $this->templateRepository,
285 $DIC->filesystem()->web()
313 if (null === $imageFileService) {
315 $this->certificatePath,
322 $this->certificatePath,
339 $cmd = $this->ctrl->getCmd();
340 $next_class = $this->ctrl->getNextClass($this);
343 switch ($next_class) {
344 case 'ilpropertyformgui':
346 $this->ctrl->forwardCommand($form);
350 $ret = $this->$cmd();
369 $this->certificateEditor();
378 $this->previewAction->createPreviewPdf($this->objectId);
381 $this->certificateEditor();
390 $this->exportAction->export();
398 $this->backgroundImageDelete->deleteBackgroundImage(
'');
399 $this->certificateEditor();
409 $cgui->setFormAction($this->ctrl->getFormAction($this,
"certificateEditor"));
410 $cgui->setHeaderText($this->lng->txt(
"certificate_confirm_deletion_text"));
411 $cgui->setCancel($this->lng->txt(
"no"),
"certificateEditor");
412 $cgui->setConfirm($this->lng->txt(
"yes"),
"certificateDeleteConfirm");
414 $this->tpl->setContent($cgui->getHTML());
422 $template = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
423 $templateId = $template->getId();
425 $this->deleteAction->delete($templateId, $this->objectId);
426 $this->ctrl->redirect($this,
"certificateEditor");
436 $form = $this->settingsFormFactory->createForm(
440 $form->setValuesByPost();
442 $request = $DIC->http()->request();
444 $formFields = $request->getParsedBody();
446 $this->tpl->setVariable(
'ADM_CONTENT', $form->getHTML());
448 $this->saveCertificate($form, $formFields, $this->objectId);
456 $this->certificateEditor();
470 $certificateTemplate = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
472 $form = $this->settingsFormFactory->createForm(
478 $formFields[
'active'] = $certificateTemplate->isCurrentlyActive();
480 $form->setValuesByArray($formFields);
488 public function certificateEditor()
493 $messageBoxHtml =
'';
494 if ($enabledGlobalLearningProgress) {
495 $objectLearningProgressSettings =
new ilLPObjSettings($this->objectId);
496 $mode = $objectLearningProgressSettings->getMode();
503 $renderer = $DIC->ui()->renderer();
504 $messageBox = $DIC->ui()
507 ->info($this->lng->txt(
'learning_progress_deactivated'));
509 $messageBoxHtml = $renderer->render($messageBox);
510 $form->clearCommandButtons();
514 $formHtml = $form->getHTML();
516 $this->tpl->setVariable(
"ADM_CONTENT", $messageBoxHtml . $formHtml);
526 $previousCertificateTemplate = $this->templateRepository->fetchPreviousCertificate(
$objId);
527 $currentVersion = $previousCertificateTemplate->getVersion();
528 $nextVersion = $currentVersion + 1;
530 if (
$_POST[
"background_delete"]) {
531 $this->backgroundImageDelete->deleteBackgroundImage($currentVersion);
536 $this->settingsFormFactory->save($form_fields);
538 $templateValues = $this->placeholderDescriptionObject->getPlaceholderDescriptions();
541 $backgroundImagePath =
'';
542 $temporaryFileName = $_FILES[
'background'][
'tmp_name'];
543 if (strlen($temporaryFileName)) {
545 $backgroundImagePath = $this->backgroundImageUpload->uploadBackgroundImage(
551 $form->
getItemByPostVar(
'background')->setAlert($this->lng->txt(
"certificate_error_upload_bgimage"));
553 if (
false === $this->fileSystem->has($backgroundImagePath)) {
554 $form->
getItemByPostVar(
'background')->setAlert($this->lng->txt(
"certificate_error_upload_bgimage"));
555 $backgroundImagePath =
'';
558 if ($backgroundImagePath ===
'') {
559 if (
$_POST[
'background_delete'] || $previousCertificateTemplate->getBackgroundImagePath() ===
'') {
560 $backgroundImagePath = $this->globalCertificateSettings->getDefaultBackgroundImagePath(
true);
562 $backgroundImagePath = $previousCertificateTemplate->getBackgroundImagePath();
567 $cardThumbnailImagePath =
'';
568 $temporaryFileName = $_FILES[
'certificate_card_thumbnail_image'][
'tmp_name'];
569 if (strlen($temporaryFileName) && $this->fileUpload->hasUploads()) {
571 if (
false === $this->fileUpload->hasBeenProcessed()) {
572 $this->fileUpload->process();
576 $uploadResults = $this->fileUpload->getResults();
577 $pending_card_file = $form->
getInput(
'certificate_card_thumbnail_image');
578 $cardThumbnailFileName =
'card_thumbnail_image_' . $nextVersion .
'.svg';
579 if (isset($uploadResults[$temporaryFileName])) {
580 $result = $uploadResults[$temporaryFileName];
582 $this->fileUpload->moveOneFileTo(
584 $this->certificatePath,
585 \
ILIAS\FileUpload\Location::WEB,
586 $cardThumbnailFileName,
590 $cardThumbnailImagePath = $this->certificatePath . $cardThumbnailFileName;
592 } elseif ($pending_card_file !== null && !empty($pending_card_file)) {
593 $stream = $this->tmp_file_system->readStream(basename($pending_card_file[
'tmp_name']));
594 $this->fileSystem->writeStream($this->certificatePath .
'/' . $cardThumbnailFileName, $stream);
595 $cardThumbnailImagePath = $this->certificatePath . $cardThumbnailFileName;
597 throw new ilException($this->lng->txt(
'upload_error_file_not_found'));
600 $form->
getItemByPostVar(
'certificate_card_thumbnail_image')->setAlert($this->lng->txt(
"certificate_error_upload_ctimage"));
602 if (
false === $this->fileSystem->has($cardThumbnailImagePath)) {
603 $form->
getItemByPostVar(
'certificate_card_thumbnail_image')->setAlert($this->lng->txt(
"certificate_error_upload_ctimage"));
604 $cardThumbnailImagePath =
'';
607 if ($cardThumbnailImagePath ===
'' && !
$_POST[
'certificate_card_thumbnail_image_delete']) {
608 $cardThumbnailImagePath = $previousCertificateTemplate->getThumbnailImagePath();
611 $jsonEncodedTemplateValues = json_encode($templateValues);
613 $xslfo = $this->xlsFoParser->parse($form_fields);
615 $newHashValue =
hash(
619 $backgroundImagePath,
620 $jsonEncodedTemplateValues,
621 $cardThumbnailImagePath
625 $active = (bool) $form_fields[
'active'];
627 if ($newHashValue !== $previousCertificateTemplate->getCertificateHash()) {
633 $jsonEncodedTemplateValues,
638 $backgroundImagePath,
639 $cardThumbnailImagePath
642 $this->templateRepository->save($certificateTemplate);
643 ilUtil::sendSuccess($this->lng->txt(
"saved_successfully"),
true);
644 $this->ctrl->redirect($this,
"certificateEditor");
647 if ($previousCertificateTemplate->getId() !== null && $previousCertificateTemplate->isCurrentlyActive() !== $active) {
648 $this->templateRepository->updateActivity($previousCertificateTemplate, $active);
649 ilUtil::sendInfo($this->lng->txt(
'certificate_change_active_status'),
true);
650 $this->ctrl->redirect($this,
"certificateEditor");
654 $this->ctrl->redirect($this,
"certificateEditor");
662 $this->tpl->setVariable(
"ADM_CONTENT", $form->
getHTML());
672 $form_fields = $this->settingsFormFactory->fetchFormFieldData($certificate->
getCertificateContent());
677 $this->tpl->setVariable(
"ADM_CONTENT", $form->
getHTML());
688 $formats = $this->pageFormats->fetchPageFormats();
690 $formFieldArray = array(
701 return $formFieldArray;
703 return $this->settingsFormFactory->fetchFormFieldData($certificateTemplate->
getCertificateContent());
getCommand($cmd)
Retrieves the ilCtrl command.
certificateSave()
Saves the certificate.
$globalCertificateSettings
const ILIAS_VERSION_NUMERIC
certificatePreview()
Creates a certificate preview.
const DEFAULT_MARGIN_BODY_TOP
Class ChatMainBarProvider .
const DEFAULT_MARGIN_BODY_LEFT
executeCommand()
execute command
createFormatArray(ilCertificateTemplate $certificateTemplate)
certificateDeleteConfirm()
Deletes the certificate and all its data.
Class ilObjCertificateSettings.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static _enabledLearningProgress()
check wether learing progress is enabled or not
certificateExportFO()
Exports the certificate.
certificateImport()
Import a certificate from a ZIP archive.
certificateUpload()
Uploads the certificate.
GUI class to create PDF certificates.
redirection script todo: (a better solution should control the processing via a xml file) ...
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupType($a_id, $a_reference=false)
lookup object type
certificateRemoveBackground()
Removes the background image of a certificate.
const DEFAULT_MARGIN_BODY_BOTTOM
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
const LP_MODE_DEACTIVATED
setTemplateContent(ilCertificateTemplate $certificate, ilPropertyFormGUI $form)
__construct(ilCertificatePlaceholderDescription $placeholderDescriptionObject, ilCertificatePlaceholderValues $placeholderValuesObject, $objectId, $certificatePath, ilCertificateFormRepository $settingsFormFactory=null, ilCertificateDeleteAction $deleteAction=null, ilCertificateTemplateRepository $templateRepository=null, ilPageFormats $pageFormats=null, ilXlsFoParser $xlsFoParser=null, ilFormFieldParser $formFieldParser=null, ilCertificateTemplateExportAction $exportAction=null, ilCertificateBackgroundImageUpload $upload=null, ilCertificateTemplatePreviewAction $previewAction=null, \ILIAS\FileUpload\FileUpload $fileUpload=null, ilSetting $settings=null, ilCertificateBackgroundImageDelete $backgroundImageDelete=null, \ILIAS\Filesystem\Filesystem $fileSystem=null, ilCertificateBackgroundImageFileService $imageFileService=null, \ILIAS\Filesystem\Filesystem $tmp_file_system=null)
const DEFAULT_MARGIN_BODY_RIGHT
certificateDelete()
Deletes the certificate and all its data.
$placeholderDescriptionObject
Class FlySystemFileAccessTest disabled disabled disabled.
Confirmation screen class.