24include_once(
"./Services/Certificate/classes/class.ilCertificate.php");
229 $this->lng =
$DIC[
'lng'];
230 $this->tpl =
$DIC[
'tpl'];
231 $this->ctrl =
$DIC[
'ilCtrl'];
232 $this->
ilias = $DIC[
'ilias'];
233 $this->tree =
$DIC[
'tree'];
234 $this->tree =
$DIC[
'tree'];
235 $this->access =
$DIC[
'ilAccess'];
236 $this->toolbar =
$DIC[
'ilToolbar'];
238 $this->lng->loadLanguageModule(
'certificate');
239 $this->lng->loadLanguageModule(
'cert');
240 $this->lng->loadLanguageModule(
"trac");
242 $this->ref_id = (int)
$_GET[
'ref_id'];
250 $logger =
$DIC->logger()->cert();
291 if (
null === $upload) {
299 $this->backgroundImageUpload = $upload;
305 $this->templateRepository,
306 $DIC->filesystem()->web()
340 $cmd = $this->ctrl->getCmd();
341 $next_class = $this->ctrl->getNextClass($this);
344 switch ($next_class) {
345 case 'ilpropertyformgui':
347 $this->ctrl->forwardCommand(
$form);
351 $ret = $this->$cmd();
370 $this->certificateEditor();
379 $this->previewAction->createPreviewPdf($this->objectId);
380 }
catch (Exception $exception) {
382 $this->certificateEditor();
391 $this->exportAction->export();
399 $this->certifcateObject->deleteBackgroundImage();
400 $this->certificateEditor();
410 $cgui->setFormAction($this->ctrl->getFormAction($this,
"certificateEditor"));
411 $cgui->setHeaderText($this->lng->txt(
"certificate_confirm_deletion_text"));
412 $cgui->setCancel($this->lng->txt(
"no"),
"certificateEditor");
413 $cgui->setConfirm($this->lng->txt(
"yes"),
"certificateDeleteConfirm");
415 $this->tpl->setContent($cgui->getHTML());
423 $template = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
426 $this->deleteAction->delete($templateId, $this->objectId);
427 $this->ctrl->redirect($this,
"certificateEditor");
437 $form = $this->settingsFormFactory->createForm(
439 $this->certifcateObject
442 $form->setValuesByPost();
446 $formFields =
$request->getParsedBody();
448 $this->tpl->setVariable(
'ADM_CONTENT',
$form->getHTML());
450 $this->saveCertificate(
$form, $formFields, $this->objectId);
458 $this->certificateEditor();
472 $certificateTemplate = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
474 $form = $this->settingsFormFactory->createForm(
476 $this->certifcateObject
481 $formFields[
'active'] = $certificateTemplate->isCurrentlyActive();
483 $form->setValuesByArray($formFields);
491 public function certificateEditor()
496 $messageBoxHtml =
'';
497 if ($enabledGlobalLearningProgress) {
498 $objectLearningProgressSettings =
new ilLPObjSettings($this->objectId);
499 $mode = $objectLearningProgressSettings->getMode();
506 $renderer =
$DIC->ui()->renderer();
507 $messageBox =
$DIC->ui()
510 ->info($this->lng->txt(
'learning_progress_deactivated'));
512 $messageBoxHtml = $renderer->render($messageBox);
513 $form->clearCommandButtons();
517 $formHtml =
$form->getHTML();
519 $this->tpl->setVariable(
"ADM_CONTENT", $messageBoxHtml . $formHtml);
529 $previousCertificateTemplate = $this->templateRepository->fetchPreviousCertificate($objId);
530 $currentVersion = $previousCertificateTemplate->getVersion();
531 $nextVersion = $currentVersion + 1;
533 if (
$_POST[
"background_delete"]) {
534 $this->certifcateObject->deleteBackgroundImage($currentVersion);
537 if (
$form->checkInput()) {
539 $this->settingsFormFactory->save($form_fields);
541 $templateValues = $this->placeholderDescriptionObject->getPlaceholderDescriptions();
544 $backgroundImagePath =
'';
545 $temporaryFileName = $_FILES[
'background'][
'tmp_name'];
546 if (strlen($temporaryFileName)) {
548 $backgroundImagePath = $this->backgroundImageUpload->uploadBackgroundImage($temporaryFileName, $nextVersion);
550 $form->getItemByPostVar(
'background')->setAlert($this->lng->txt(
"certificate_error_upload_bgimage"));
552 if (
false === $this->fileSystem->has($backgroundImagePath)) {
553 $form->getItemByPostVar(
'background')->setAlert($this->lng->txt(
"certificate_error_upload_bgimage"));
554 $backgroundImagePath =
'';
557 if ($backgroundImagePath ===
'') {
558 if (
$_POST[
'background_delete'] || $previousCertificateTemplate->getBackgroundImagePath() ===
'') {
560 $backgroundImagePath = str_replace(
'[CLIENT_WEB_DIR]',
'', $globalBackgroundImagePath);
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 $result = $uploadResults[$temporaryFileName];
578 if (
$result->getStatus() == \
ILIAS\FileUpload\DTO\ProcessingStatus::OK) {
579 $cardThumbnailFileName =
'card_thumbnail_image_' . $nextVersion .
'.svg';
581 $this->fileUpload->moveOneFileTo(
583 $this->certificatePath,
584 \
ILIAS\FileUpload\Location::WEB,
585 $cardThumbnailFileName,
589 $cardThumbnailImagePath = $this->certificatePath . $cardThumbnailFileName;
592 $form->getItemByPostVar(
'certificate_card_thumbnail_image')->setAlert($this->lng->txt(
"certificate_error_upload_ctimage"));
594 if (
false === $this->fileSystem->has($cardThumbnailImagePath)) {
595 $form->getItemByPostVar(
'certificate_card_thumbnail_image')->setAlert($this->lng->txt(
"certificate_error_upload_ctimage"));
596 $cardThumbnailImagePath =
'';
599 if ($cardThumbnailImagePath ===
'' && !
$_POST[
'certificate_card_thumbnail_image_delete']) {
600 $cardThumbnailImagePath = $previousCertificateTemplate->getThumbnailImagePath();
603 $jsonEncodedTemplateValues = json_encode($templateValues);
605 $xslfo = $this->xlsFoParser->parse($form_fields);
607 $newHashValue =
hash(
611 $backgroundImagePath,
612 $jsonEncodedTemplateValues,
613 $cardThumbnailImagePath
617 $active = (bool) $form_fields[
'active'];
619 if ($newHashValue !== $previousCertificateTemplate->getCertificateHash()) {
625 $jsonEncodedTemplateValues,
630 $backgroundImagePath,
631 $cardThumbnailImagePath
634 $this->templateRepository->save($certificateTemplate);
635 ilUtil::sendSuccess($this->lng->txt(
"saved_successfully"),
true);
636 $this->ctrl->redirect($this,
"certificateEditor");
639 if ($previousCertificateTemplate->getId() !==
null && $previousCertificateTemplate->isCurrentlyActive() !== $active) {
640 $this->templateRepository->updateActivity($previousCertificateTemplate, $active);
641 ilUtil::sendInfo($this->lng->txt(
'certificate_change_active_status'),
true);
642 $this->ctrl->redirect($this,
"certificateEditor");
646 $this->ctrl->redirect($this,
"certificateEditor");
647 }
catch (Exception $e) {
652 $form->setValuesByPost();
654 $this->tpl->setVariable(
"ADM_CONTENT",
$form->getHTML());
664 $form_fields = $this->settingsFormFactory->fetchFormFieldData(
$certificate->getCertificateContent());
665 $form_fields[
'active'] =
$certificate->isCurrentlyActive();
667 $form->setValuesByArray($form_fields);
669 $this->tpl->setVariable(
"ADM_CONTENT",
$form->getHTML());
680 $formats = $this->pageFormats->fetchPageFormats();
682 $formFieldArray = array(
693 return $formFieldArray;
695 return $this->settingsFormFactory->fetchFormFieldData($certificateTemplate->
getCertificateContent());
foreach($paths as $path) $request
An exception for terminatinating execution or to throw for unit testing.
Adapter class to provide certificate data for the certificate generator.
GUI class to create PDF certificates.
certificateExportFO()
Exports the certificate.
createFormatArray(ilCertificateTemplate $certificateTemplate)
certificatePreview()
Creates a certificate preview.
certificateImport()
Import a certificate from a ZIP archive.
setTemplateContent(ilCertificateTemplate $certificate, ilPropertyFormGUI $form)
certificateDelete()
Deletes the certificate and all its data.
getCommand($cmd)
Retrieves the ilCtrl command.
executeCommand()
execute command
certificateUpload()
Uploads the certificate.
certificateSave()
Saves the certificate.
__construct(ilCertificateAdapter $adapter, 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, \ILIAS\Filesystem\Filesystem $fileSystem=null)
ilCertificateGUI constructor
$placeholderDescriptionObject
certificateDeleteConfirm()
Deletes the certificate and all its data.
certificateRemoveBackground()
Removes the background image of a certificate.
Confirmation screen class.
Base class for ILIAS Exception handling.
const LP_MODE_DEACTIVATED
static getBackgroundImagePath($asRelative=false)
Returns the filesystem path of the background image.
static _enabledLearningProgress()
check wether learing progress is enabled or not
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
const DEFAULT_MARGIN_BODY_RIGHT
const DEFAULT_MARGIN_BODY_LEFT
const DEFAULT_MARGIN_BODY_TOP
const DEFAULT_MARGIN_BODY_BOTTOM
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
if(@file_exists(dirname(__FILE__).'/lang/eng.php')) $certificate
const ILIAS_VERSION_NUMERIC
Class FlySystemFileAccessTest.
hash(StreamInterface $stream, $algo, $rawOutput=false)
Calculate a hash of a Stream.
redirection script todo: (a better solution should control the processing via a xml file)
if(isset($_POST['submit'])) $form