19 declare(strict_types=1);
21 require_once
'Services/Calendar/classes/class.ilDateTime.php';
41 ?
int $dateFormat = null,
45 private readonly
int $birthdayDateFormat =
IL_CAL_DATE 47 if (null === $objectHelper) {
52 if (null === $dateHelper) {
57 if (null === $dateFormat) {
62 if (null === $language) {
64 $language = $DIC->language();
65 $language->loadLanguageModule(
'certificate');
69 if (null === $utilHelper) {
74 if (null === $userDefinedFieldsPlaceholderValues) {
79 $this->placeholder = [
81 'USER_FULLNAME' =>
'',
82 'USER_FIRSTNAME' =>
'',
83 'USER_LASTNAME' =>
'',
85 'USER_SALUTATION' =>
'',
86 'USER_BIRTHDAY' =>
'',
87 'USER_INSTITUTION' =>
'',
88 'USER_DEPARTMENT' =>
'',
93 'USER_MATRICULATION' =>
'',
96 'DATE_COMPLETED' =>
'',
97 'DATETIME_COMPLETED' =>
'',
111 $user = $this->objectHelper->getInstanceByObjId($userId);
113 throw new ilException(
'The entered id: ' . $userId .
' is not an user object');
118 $placeholder[
'USER_LOGIN'] = $this->utilHelper->prepareFormOutput((trim($user->getLogin())));
119 $placeholder[
'USER_FULLNAME'] = $this->utilHelper->prepareFormOutput((trim($user->getFullname())));
120 $placeholder[
'USER_FIRSTNAME'] = $this->utilHelper->prepareFormOutput((trim($user->getFirstname())));
121 $placeholder[
'USER_LASTNAME'] = $this->utilHelper->prepareFormOutput((trim($user->getLastname())));
122 $placeholder[
'USER_TITLE'] = $this->utilHelper->prepareFormOutput((trim($user->getUTitle())));
125 $gender = $user->getGender();
126 if (trim($gender) !==
'' && strtolower($gender) !==
'n') {
127 $salutation = $this->utilHelper->prepareFormOutput($user_lng->txt(
"salutation_" . trim($gender)));
130 $placeholder[
'USER_SALUTATION'] = $salutation;
133 $dateObject = $user->getBirthday();
134 if (null !== $dateObject) {
135 $birthday = $this->dateHelper->formatDate($dateObject, $this->birthdayDateFormat);
138 $placeholder[
'USER_BIRTHDAY'] = $this->utilHelper->prepareFormOutput((trim($birthday)));
139 $placeholder[
'USER_INSTITUTION'] = $this->utilHelper->prepareFormOutput((trim($user->getInstitution())));
140 $placeholder[
'USER_DEPARTMENT'] = $this->utilHelper->prepareFormOutput((trim($user->getDepartment())));
141 $placeholder[
'USER_STREET'] = $this->utilHelper->prepareFormOutput((trim($user->getStreet())));
142 $placeholder[
'USER_CITY'] = $this->utilHelper->prepareFormOutput((trim($user->getCity())));
143 $placeholder[
'USER_ZIPCODE'] = $this->utilHelper->prepareFormOutput((trim($user->getZipcode())));
144 $placeholder[
'USER_COUNTRY'] = $this->utilHelper->prepareFormOutput((trim($user->getCountry())));
145 $placeholder[
'USER_MATRICULATION'] = $this->utilHelper->prepareFormOutput((trim($user->getMatriculation())));
146 $placeholder[
'DATE'] = $this->utilHelper->prepareFormOutput((trim($this->dateHelper->formatDate(
150 $placeholder[
'DATETIME'] = $this->utilHelper->prepareFormOutput((trim($this->dateHelper->formatDateTime(
157 $this->userDefinedFieldsPlaceholderValues->getPlaceholderValues($userId, $objId)
172 $previewPlacholderValues = [
173 "USER_LOGIN" => $this->utilHelper->prepareFormOutput($this->
language->txt(
"certificate_var_user_login")),
174 "USER_FULLNAME" => $this->utilHelper->prepareFormOutput($this->language->txt(
"certificate_var_user_fullname")),
175 "USER_FIRSTNAME" => $this->utilHelper->prepareFormOutput($this->language->txt(
"certificate_var_user_firstname")),
176 "USER_LASTNAME" => $this->utilHelper->prepareFormOutput($this->language->txt(
"certificate_var_user_lastname")),
177 "USER_TITLE" => $this->utilHelper->prepareFormOutput($this->language->txt(
"certificate_var_user_title")),
178 "USER_SALUTATION" => $this->utilHelper->prepareFormOutput($this->language->txt(
"certificate_var_user_salutation")),
179 "USER_BIRTHDAY" => $this->utilHelper->prepareFormOutput((trim($this->dateHelper->formatDate(
183 "USER_INSTITUTION" => $this->utilHelper->prepareFormOutput($this->language->txt(
"certificate_var_user_institution")),
184 "USER_DEPARTMENT" => $this->utilHelper->prepareFormOutput($this->language->txt(
"certificate_var_user_department")),
185 "USER_STREET" => $this->utilHelper->prepareFormOutput($this->language->txt(
"certificate_var_user_street")),
186 "USER_CITY" => $this->utilHelper->prepareFormOutput($this->language->txt(
"certificate_var_user_city")),
187 "USER_ZIPCODE" => $this->utilHelper->prepareFormOutput($this->language->txt(
"certificate_var_user_zipcode")),
188 "USER_COUNTRY" => $this->utilHelper->prepareFormOutput($this->language->txt(
"certificate_var_user_country")),
189 "USER_MATRICULATION" => $this->utilHelper->prepareFormOutput($this->language->txt(
"certificate_var_user_matriculation")),
190 'DATE' => $this->utilHelper->prepareFormOutput((trim($this->dateHelper->formatDate(
194 'DATETIME' => $this->utilHelper->prepareFormOutput((trim($this->dateHelper->formatDateTime(
198 'DATE_COMPLETED' => $this->utilHelper->prepareFormOutput((trim($this->dateHelper->formatDate(
202 'DATETIME_COMPLETED' => $this->utilHelper->prepareFormOutput((trim($this->dateHelper->formatDateTime(
209 $previewPlacholderValues,
210 $this->userDefinedFieldsPlaceholderValues->getPlaceholderValuesForPreview($userId, $objId)
216 if ($this->user_language instanceof
ilLanguage) {
Collection of basic placeholder values that can be used.
readonly ilUserDefinedFieldsPlaceholderValues $userDefinedFieldsPlaceholderValues
loadLanguageModule(string $a_module)
Load language module.
readonly ilCertificateUtilHelper $utilHelper
__construct(?ilCertificateObjectHelper $objectHelper=null, ?ilCertificateDateHelper $dateHelper=null, ?int $dateFormat=null, ?ilLanguage $language=null, ?ilCertificateUtilHelper $utilHelper=null, ?ilUserDefinedFieldsPlaceholderValues $userDefinedFieldsPlaceholderValues=null, private readonly int $birthdayDateFormat=IL_CAL_DATE)
getPlaceholderValuesForPreview(int $userId, int $objId)
This method is different then the 'getPlaceholderValues' method, this method is used to create a plac...
readonly array $placeholder
readonly ilLanguage $language
ilLanguage $user_language
Just a wrapper class to create Unit Test for other classes.
readonly ilCertificateDateHelper $dateHelper
getUserLanguage(ilObjUser $user)
getPlaceholderValues(int $userId, int $objId)
This method MUST return an array that contains the actual data for the given user of the given object...
readonly ilCertificateObjectHelper $objectHelper
setUserLanguage(ilLanguage $language)