ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilCertificateTemplatePreviewAction Class Reference
+ Collaboration diagram for ilCertificateTemplatePreviewAction:

Public Member Functions

 __construct (private readonly ilCertificateTemplateRepository $templateRepository, private readonly ilCertificatePlaceholderValues $placeholderValuesObject, private readonly string $rootDirectory=CLIENT_WEB_DIR, ?ilObjUser $user=null, ?ilCertificateUtilHelper $utilHelper=null, ?ilCertificateMathJaxHelper $mathJaxHelper=null, ?ilCertificateUserDefinedFieldsHelper $userDefinedFieldsHelper=null, ?ilCertificateRpcClientFactoryHelper $rpcClientFactoryHelper=null, ?ilCertificatePdfFileNameFactory $pdfFileNameFactory=null)
 
 createPreviewPdf (int $objectId)
 

Private Member Functions

 exchangeCertificateVariables (string $certificate_text, ilCertificateTemplate $template, int $objectId)
 Exchanges the variables in the certificate text with given values. More...
 
 getCustomCertificateFields ()
 

Private Attributes

readonly ilObjUser $user
 
readonly ilCertificateUtilHelper $utilHelper
 
readonly ilCertificateMathJaxHelper $mathJaxHelper
 
readonly ilCertificateUserDefinedFieldsHelper $userDefinedFieldsHelper
 
readonly ilCertificateRpcClientFactoryHelper $rpcClientFactoryHelper
 
readonly ilCertificatePdfFileNameFactory $pdfFileNameFactory
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCertificateTemplatePreviewAction::__construct ( private readonly ilCertificateTemplateRepository  $templateRepository,
private readonly ilCertificatePlaceholderValues  $placeholderValuesObject,
private readonly string  $rootDirectory = CLIENT_WEB_DIR,
?ilObjUser  $user = null,
?ilCertificateUtilHelper  $utilHelper = null,
?ilCertificateMathJaxHelper  $mathJaxHelper = null,
?ilCertificateUserDefinedFieldsHelper  $userDefinedFieldsHelper = null,
?ilCertificateRpcClientFactoryHelper  $rpcClientFactoryHelper = null,
?ilCertificatePdfFileNameFactory  $pdfFileNameFactory = null 
)

Definition at line 33 of file ilCertificateTemplatePreviewAction.php.

References $DIC, $mathJaxHelper, $pdfFileNameFactory, $rpcClientFactoryHelper, $user, $userDefinedFieldsHelper, $utilHelper, and ILIAS\Repository\user().

43  {
44  global $DIC;
45 
46  if (null === $user) {
47  $user = $DIC->user();
48  }
49  $this->user = $user;
50 
51  if (null === $utilHelper) {
53  }
54  $this->utilHelper = $utilHelper;
55 
56  if (null === $mathJaxHelper) {
58  }
59  $this->mathJaxHelper = $mathJaxHelper;
60 
61  if (null === $userDefinedFieldsHelper) {
63  }
64  $this->userDefinedFieldsHelper = $userDefinedFieldsHelper;
65 
66  if (null === $rpcClientFactoryHelper) {
68  }
69  $this->rpcClientFactoryHelper = $rpcClientFactoryHelper;
70 
71  if (null === $pdfFileNameFactory) {
73  }
74  $this->pdfFileNameFactory = $pdfFileNameFactory;
75  }
readonly ilCertificateRpcClientFactoryHelper $rpcClientFactoryHelper
readonly ilCertificateUserDefinedFieldsHelper $userDefinedFieldsHelper
global $DIC
Definition: feed.php:28
readonly ilCertificatePdfFileNameFactory $pdfFileNameFactory
Just a wrapper class to create Unit Test for other classes.
readonly ilCertificateMathJaxHelper $mathJaxHelper
+ Here is the call graph for this function:

Member Function Documentation

◆ createPreviewPdf()

ilCertificateTemplatePreviewAction::createPreviewPdf ( int  $objectId)
Exceptions
Exception

Definition at line 80 of file ilCertificateTemplatePreviewAction.php.

References exchangeCertificateVariables().

80  : void
81  {
82  $template = $this->templateRepository->fetchCurrentlyUsedCertificate($objectId);
83 
84  $xslfo = $template->getCertificateContent();
85 
86  $xslfo = $this->exchangeCertificateVariables($xslfo, $template, $objectId);
87 
88  // render tex as fo graphics
89  $xlsfo = $this->mathJaxHelper->fillXlsFoContent($xslfo);
90 
91  $pdf_base64 = $this->rpcClientFactoryHelper
92  ->ilFO2PDF('RPCTransformationHandler', $xlsfo);
93 
94  $pdfPresentation = new ilUserCertificatePresentation(
95  $template->getObjId(),
96  $template->getObjType(),
97  null,
98  '',
99  ''
100  );
101 
102  $this->utilHelper->deliverData(
103  $pdf_base64->scalar,
104  $this->pdfFileNameFactory->create($pdfPresentation),
105  'application/pdf'
106  );
107  }
exchangeCertificateVariables(string $certificate_text, ilCertificateTemplate $template, int $objectId)
Exchanges the variables in the certificate text with given values.
+ Here is the call graph for this function:

◆ exchangeCertificateVariables()

ilCertificateTemplatePreviewAction::exchangeCertificateVariables ( string  $certificate_text,
ilCertificateTemplate  $template,
int  $objectId 
)
private

Exchanges the variables in the certificate text with given values.

Parameters
string$certificate_textThe XSL-FO certificate text
Returns
string XSL-FO code

Definition at line 114 of file ilCertificateTemplatePreviewAction.php.

References ilCertificateTemplate\getBackgroundImagePath(), getCustomCertificateFields(), and ILIAS\Repository\user().

Referenced by createPreviewPdf().

118  : string {
119  $insert_tags = $this->placeholderValuesObject->getPlaceholderValuesForPreview($this->user->getId(), $objectId);
120 
121  foreach ($this->getCustomCertificateFields() as $value) {
122  $insert_tags[$value['ph']] = $this->utilHelper->prepareFormOutput($value['name']);
123  }
124 
125  foreach ($insert_tags as $placeholderVariable => $value) {
126  $certificate_text = str_replace('[' . $placeholderVariable . ']', $value, $certificate_text);
127  }
128 
129  $certificate_text = str_replace(
130  '[CLIENT_WEB_DIR]',
131  'file://' . $this->rootDirectory,
132  $certificate_text
133  );
134 
135  $backgroundImagePath = $template->getBackgroundImagePath();
136 
137  return str_replace(
138  '[BACKGROUND_IMAGE]',
139  'file://' . $this->rootDirectory . $backgroundImagePath,
140  $certificate_text
141  );
142  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCustomCertificateFields()

ilCertificateTemplatePreviewAction::getCustomCertificateFields ( )
private
Returns
array<int, array{name: string, ph: string}>

Definition at line 147 of file ilCertificateTemplatePreviewAction.php.

References Vendor\Package\$f.

Referenced by exchangeCertificateVariables().

147  : array
148  {
149  $user_field_definitions = $this->userDefinedFieldsHelper->createInstance();
150  $fds = $user_field_definitions->getDefinitions();
151 
152  $fields = [];
153  foreach ($fds as $f) {
154  if ($f['certificate']) {
155  $fields[$f['field_id']] = [
156  'name' => $f['field_name'],
157  'ph' => '[#' . str_replace(' ', '_', strtoupper($f['field_name'])) . ']'
158  ];
159  }
160  }
161 
162  return $fields;
163  }
+ Here is the caller graph for this function:

Field Documentation

◆ $mathJaxHelper

readonly ilCertificateMathJaxHelper ilCertificateTemplatePreviewAction::$mathJaxHelper
private

Definition at line 28 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().

◆ $pdfFileNameFactory

readonly ilCertificatePdfFileNameFactory ilCertificateTemplatePreviewAction::$pdfFileNameFactory
private

Definition at line 31 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().

◆ $rpcClientFactoryHelper

readonly ilCertificateRpcClientFactoryHelper ilCertificateTemplatePreviewAction::$rpcClientFactoryHelper
private

Definition at line 30 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().

◆ $user

readonly ilObjUser ilCertificateTemplatePreviewAction::$user
private

Definition at line 26 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().

◆ $userDefinedFieldsHelper

readonly ilCertificateUserDefinedFieldsHelper ilCertificateTemplatePreviewAction::$userDefinedFieldsHelper
private

Definition at line 29 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().

◆ $utilHelper

readonly ilCertificateUtilHelper ilCertificateTemplatePreviewAction::$utilHelper
private

Definition at line 27 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().


The documentation for this class was generated from the following file: