ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
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 ()
 

Private Attributes

ilCertificateTemplateRepository $templateRepository
 
ilCertificatePlaceholderValues $placeholderValuesObject
 
ilLogger $logger
 
ilObjUser $user
 
ilCertificateUtilHelper $utilHelper
 
ilCertificateMathJaxHelper $mathJaxHelper
 
ilCertificateUserDefinedFieldsHelper $userDefinedFieldsHelper
 
ilCertificateRpcClientFactoryHelper $rpcClientFactoryHelper
 
string $rootDirectory
 
ilCertificatePdfFileNameFactory $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 
)

Definition at line 37 of file ilCertificateTemplatePreviewAction.php.

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

48  {
49  global $DIC;
50 
51  $this->templateRepository = $templateRepository;
52  $this->placeholderValuesObject = $placeholderValuesObject;
53 
54  if (null === $logger) {
55  $logger = $DIC->logger()->cert();
56  }
57  $this->logger = $logger;
58 
59  if (null === $user) {
60  $user = $DIC->user();
61  }
62  $this->user = $user;
63 
64  if (null === $utilHelper) {
66  }
67  $this->utilHelper = $utilHelper;
68 
69  if (null === $mathJaxHelper) {
71  }
72  $this->mathJaxHelper = $mathJaxHelper;
73 
74  if (null === $userDefinedFieldsHelper) {
76  }
77  $this->userDefinedFieldsHelper = $userDefinedFieldsHelper;
78 
79  if (null === $rpcClientFactoryHelper) {
81  }
82  $this->rpcClientFactoryHelper = $rpcClientFactoryHelper;
83 
84  if (null === $pdfFileNameFactory) {
86  }
87  $this->pdfFileNameFactory = $pdfFileNameFactory;
88 
89  $this->rootDirectory = $rootDirectory;
90  }
ilCertificatePlaceholderValues $placeholderValuesObject
global $DIC
Definition: feed.php:28
ilCertificateRpcClientFactoryHelper $rpcClientFactoryHelper
Just a wrapper class to create Unit Test for other classes.
ilCertificateUserDefinedFieldsHelper $userDefinedFieldsHelper
+ Here is the call graph for this function:

Member Function Documentation

◆ createPreviewPdf()

ilCertificateTemplatePreviewAction::createPreviewPdf ( int  $objectId)
Parameters
int$objectId
Exceptions
Exception

Definition at line 96 of file ilCertificateTemplatePreviewAction.php.

References exchangeCertificateVariables().

96  : void
97  {
98  $template = $this->templateRepository->fetchCurrentlyUsedCertificate($objectId);
99 
100  $xslfo = $template->getCertificateContent();
101 
102  $xslfo = $this->exchangeCertificateVariables($xslfo, $template, $objectId);
103 
104  // render tex as fo graphics
105  $xlsfo = $this->mathJaxHelper->fillXlsFoContent($xslfo);
106 
107  $pdf_base64 = $this->rpcClientFactoryHelper
108  ->ilFO2PDF('RPCTransformationHandler', $xlsfo);
109 
110  $pdfPresentation = new ilUserCertificatePresentation(
111  $template->getObjId(),
112  $template->getObjType(),
113  null,
114  '',
115  ''
116  );
117 
118  $this->utilHelper->deliverData(
119  $pdf_base64->scalar,
120  $this->pdfFileNameFactory->create($pdfPresentation),
121  'application/pdf'
122  );
123  }
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
ilCertificateTemplate$template
int$objectId
Returns
string XSL-FO code

Definition at line 132 of file ilCertificateTemplatePreviewAction.php.

References ILIAS\LTI\ToolProvider\$key, ilCertificateTemplate\getBackgroundImagePath(), getCustomCertificateFields(), and ILIAS\Repository\user().

Referenced by createPreviewPdf().

136  : string {
137  $insert_tags = $this->placeholderValuesObject->getPlaceholderValuesForPreview($this->user->getId(), $objectId);
138 
139  foreach ($this->getCustomCertificateFields() as $key => $value) {
140  $insert_tags[$value['ph']] = $this->utilHelper->prepareFormOutput($value['name']);
141  }
142 
143  foreach ($insert_tags as $placeholderVariable => $value) {
144  $certificate_text = str_replace('[' . $placeholderVariable . ']', $value, $certificate_text);
145  }
146 
147  $certificate_text = str_replace(
148  '[CLIENT_WEB_DIR]',
149  'file://' . $this->rootDirectory,
150  $certificate_text
151  );
152 
153  $backgroundImagePath = $template->getBackgroundImagePath();
154 
155  return str_replace(
156  '[BACKGROUND_IMAGE]',
157  'file://' . $this->rootDirectory . $backgroundImagePath,
158  $certificate_text
159  );
160  }
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCustomCertificateFields()

ilCertificateTemplatePreviewAction::getCustomCertificateFields ( )
private

Definition at line 162 of file ilCertificateTemplatePreviewAction.php.

References Vendor\Package\$f.

Referenced by exchangeCertificateVariables().

162  : array
163  {
164  $user_field_definitions = $this->userDefinedFieldsHelper->createInstance();
165  $fds = $user_field_definitions->getDefinitions();
166 
167  $fields = [];
168  foreach ($fds as $f) {
169  if ($f['certificate']) {
170  $fields[$f['field_id']] = [
171  'name' => $f['field_name'],
172  'ph' => '[#' . str_replace(' ', '_', strtoupper($f['field_name'])) . ']'
173  ];
174  }
175  }
176 
177  return $fields;
178  }
+ Here is the caller graph for this function:

Field Documentation

◆ $logger

ilLogger ilCertificateTemplatePreviewAction::$logger
private

Definition at line 28 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().

◆ $mathJaxHelper

ilCertificateMathJaxHelper ilCertificateTemplatePreviewAction::$mathJaxHelper
private

Definition at line 31 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().

◆ $pdfFileNameFactory

ilCertificatePdfFileNameFactory ilCertificateTemplatePreviewAction::$pdfFileNameFactory
private

Definition at line 35 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().

◆ $placeholderValuesObject

ilCertificatePlaceholderValues ilCertificateTemplatePreviewAction::$placeholderValuesObject
private

Definition at line 27 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().

◆ $rootDirectory

string ilCertificateTemplatePreviewAction::$rootDirectory
private

Definition at line 34 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().

◆ $rpcClientFactoryHelper

ilCertificateRpcClientFactoryHelper ilCertificateTemplatePreviewAction::$rpcClientFactoryHelper
private

Definition at line 33 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().

◆ $templateRepository

ilCertificateTemplateRepository ilCertificateTemplatePreviewAction::$templateRepository
private

Definition at line 26 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().

◆ $user

ilObjUser ilCertificateTemplatePreviewAction::$user
private

Definition at line 29 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().

◆ $userDefinedFieldsHelper

ilCertificateUserDefinedFieldsHelper ilCertificateTemplatePreviewAction::$userDefinedFieldsHelper
private

Definition at line 32 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().

◆ $utilHelper

ilCertificateUtilHelper ilCertificateTemplatePreviewAction::$utilHelper
private

Definition at line 30 of file ilCertificateTemplatePreviewAction.php.

Referenced by __construct().


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