ILIAS  release_7 Revision v7.30-3-g800a261c036
ilCertificateTemplatePreviewAction Class Reference
+ Collaboration diagram for ilCertificateTemplatePreviewAction:

Public Member Functions

 __construct (ilCertificateTemplateRepository $templateRepository, ilCertificatePlaceholderValues $placeholderValuesObject, ilLogger $logger=null, ilObjUser $user=null, ilCertificateUtilHelper $utilHelper=null, ilCertificateMathJaxHelper $mathJaxHelper=null, ilCertificateUserDefinedFieldsHelper $userDefinedFieldsHelper=null, ilCertificateRpcClientFactoryHelper $rpcClientFactoryHelper=null, string $rootDirectory=CLIENT_WEB_DIR, 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 ()
 Get custom certificate fields. More...
 

Private Attributes

 $templateRepository
 
 $placeholderValuesObject
 
 $logger
 
 $user
 
 $utilHelper
 
 $mathJaxHelper
 
 $userDefinedFieldsHelper
 
 $rpcClientFactoryHelper
 
 $rootDirectory
 
 $pdfFileNameFactory
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 71 of file ilCertificateTemplatePreviewAction.php.

82 {
83 global $DIC;
84
85 $this->templateRepository = $templateRepository;
86 $this->placeholderValuesObject = $placeholderValuesObject;
87
88 if (null === $logger) {
89 $logger = $DIC->logger()->cert();
90 }
91 $this->logger = $logger;
92
93 if (null === $user) {
94 $user = $DIC->user();
95 }
96 $this->user = $user;
97
98 if (null === $utilHelper) {
100 }
101 $this->utilHelper = $utilHelper;
102
103 if (null === $mathJaxHelper) {
105 }
106 $this->mathJaxHelper = $mathJaxHelper;
107
108 if (null === $userDefinedFieldsHelper) {
110 }
111 $this->userDefinedFieldsHelper = $userDefinedFieldsHelper;
112
113 if (null === $rpcClientFactoryHelper) {
115 }
116 $this->rpcClientFactoryHelper = $rpcClientFactoryHelper;
117
118 if (null === $pdfFileNameFactory) {
120 }
121 $this->pdfFileNameFactory = $pdfFileNameFactory;
122
123 $this->rootDirectory = $rootDirectory;
124 }
user()
Definition: user.php:4
Just a wrapper class to create Unit Test for other classes.
global $DIC
Definition: goto.php:24

References $DIC, $logger, $mathJaxHelper, $pdfFileNameFactory, $placeholderValuesObject, $rootDirectory, $rpcClientFactoryHelper, $templateRepository, $user, $userDefinedFieldsHelper, $utilHelper, and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ createPreviewPdf()

ilCertificateTemplatePreviewAction::createPreviewPdf ( int  $objectId)
Parameters
int$objectId
Returns
bool
Exceptions
ilException
Exception

Definition at line 132 of file ilCertificateTemplatePreviewAction.php.

133 {
134 $template = $this->templateRepository->fetchCurrentlyUsedCertificate($objectId);
135
136 $xslfo = $template->getCertificateContent();
137
138 $xslfo = $this->exchangeCertificateVariables($xslfo, $template, $objectId);
139
140 try {
141 // render tex as fo graphics
142 $xlsfo = $this->mathJaxHelper->fillXlsFoContent($xslfo);
143
144 $pdf_base64 = $this->rpcClientFactoryHelper
145 ->ilFO2PDF('RPCTransformationHandler', $xlsfo);
146
147 $pdfPresentation = new ilUserCertificatePresentation(
148 $template->getObjId(),
149 $template->getObjType(),
150 null,
151 '',
152 ''
153 );
154
155 $this->utilHelper->deliverData(
156 $pdf_base64->scalar,
157 $this->pdfFileNameFactory->create($pdfPresentation),
158 'application/pdf'
159 );
160 } catch (Exception $e) {
161 throw $e;
162 }
163 }
exchangeCertificateVariables(string $certificate_text, ilCertificateTemplate $template, int $objectId)
Exchanges the variables in the certificate text with given values.

References Vendor\Package\$e, and exchangeCertificateVariables().

+ 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
ilCertificateTemplate$template
int$objectId
Returns
string XSL-FO code

Definition at line 173 of file ilCertificateTemplatePreviewAction.php.

177 {
178 $insert_tags = $this->placeholderValuesObject->getPlaceholderValuesForPreview($this->user->getId(), $objectId);
179
180 foreach ($this->getCustomCertificateFields() as $key => $value) {
181 $insert_tags[$value['ph']] = $this->utilHelper->prepareFormOutput($value['name']);
182 }
183
184 foreach ($insert_tags as $placeholderVariable => $value) {
185 $certificate_text = str_replace('[' . $placeholderVariable . ']', $value, $certificate_text);
186 }
187
188 $certificate_text = str_replace(
189 '[CLIENT_WEB_DIR]',
190 'file://' . $this->rootDirectory,
191 $certificate_text
192 );
193
194 $backgroundImagePath = $template->getBackgroundImagePath();
195
196 $certificate_text = str_replace(
197 '[BACKGROUND_IMAGE]',
198 'file://' . $this->rootDirectory . $backgroundImagePath,
199 $certificate_text
200 );
201
202 return $certificate_text;
203 }
getCustomCertificateFields()
Get custom certificate fields.

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

Referenced by createPreviewPdf().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCustomCertificateFields()

ilCertificateTemplatePreviewAction::getCustomCertificateFields ( )
private

Get custom certificate fields.

Returns
array

Definition at line 210 of file ilCertificateTemplatePreviewAction.php.

211 {
212 $user_field_definitions = $this->userDefinedFieldsHelper->createInstance();
213 $fds = $user_field_definitions->getDefinitions();
214
215 $fields = array();
216 foreach ($fds as $f) {
217 if ($f['certificate']) {
218 $fields[$f['field_id']] = array(
219 'name' => $f['field_name'],
220 'ph' => '[#' . str_replace(' ', '_', strtoupper($f['field_name'])) . ']');
221 }
222 }
223
224 return $fields;
225 }

References Vendor\Package\$f.

Referenced by exchangeCertificateVariables().

+ Here is the caller graph for this function:

Field Documentation

◆ $logger

ilCertificateTemplatePreviewAction::$logger
private

Definition at line 22 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().

◆ $mathJaxHelper

ilCertificateTemplatePreviewAction::$mathJaxHelper
private

Definition at line 37 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().

◆ $pdfFileNameFactory

ilCertificateTemplatePreviewAction::$pdfFileNameFactory
private

Definition at line 57 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().

◆ $placeholderValuesObject

ilCertificateTemplatePreviewAction::$placeholderValuesObject
private

Definition at line 17 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().

◆ $rootDirectory

ilCertificateTemplatePreviewAction::$rootDirectory
private

Definition at line 52 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().

◆ $rpcClientFactoryHelper

ilCertificateTemplatePreviewAction::$rpcClientFactoryHelper
private

Definition at line 47 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().

◆ $templateRepository

ilCertificateTemplatePreviewAction::$templateRepository
private

Definition at line 12 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().

◆ $user

ilCertificateTemplatePreviewAction::$user
private

Definition at line 27 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().

◆ $userDefinedFieldsHelper

ilCertificateTemplatePreviewAction::$userDefinedFieldsHelper
private

Definition at line 42 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().

◆ $utilHelper

ilCertificateTemplatePreviewAction::$utilHelper
private

Definition at line 32 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().


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