ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilDefaultPlaceholderDescription.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
28{
29 private array $placeholder;
30 private readonly ilLanguage $language;
31
32 public function __construct(
34 Profile $profile,
35 ?ilUserDefinedFieldsPlaceholderDescription $userDefinedFieldPlaceHolderDescriptionObject = null
36 ) {
37 if (null === $userDefinedFieldPlaceHolderDescriptionObject) {
38 $userDefinedFieldPlaceHolderDescriptionObject = new ilUserDefinedFieldsPlaceholderDescription(
40 $profile
41 );
42 }
43 $userDefinedPlaceholderHtmlDescription = $userDefinedFieldPlaceHolderDescriptionObject->getPlaceholderDescriptions();
44
45 $language->loadLanguageModule('certificate');
46 $this->language = $language;
47
48 $this->placeholder = [
49 'CERTIFICATE_ID' => $language->txt('certificate_ph_cert_id'),
50 'USER_LOGIN' => $language->txt('certificate_ph_login'),
51 'USER_FULLNAME' => $language->txt('certificate_ph_fullname'),
52 'USER_FIRSTNAME' => $language->txt('certificate_ph_firstname'),
53 'USER_LASTNAME' => $language->txt('certificate_ph_lastname'),
54 'USER_TITLE' => $language->txt('certificate_ph_title'),
55 'USER_SALUTATION' => $language->txt('certificate_ph_salutation'),
56 'USER_BIRTHDAY' => $language->txt('certificate_ph_birthday'),
57 'USER_INSTITUTION' => $language->txt('certificate_ph_institution'),
58 'USER_DEPARTMENT' => $language->txt('certificate_ph_department'),
59 'USER_STREET' => $language->txt('certificate_ph_street'),
60 'USER_CITY' => $language->txt('certificate_ph_city'),
61 'USER_ZIPCODE' => $language->txt('certificate_ph_zipcode'),
62 'USER_COUNTRY' => $language->txt('certificate_ph_country'),
63 'USER_MATRICULATION' => $language->txt('certificate_ph_matriculation'),
64 'DATE' => $language->txt("certificate_ph_date"),
65 'DATETIME' => $language->txt("certificate_ph_datetime"),
66 ];
67
68 $this->placeholder = array_merge($this->placeholder, $userDefinedPlaceholderHtmlDescription);
69 }
70
76 public function createPlaceholderHtmlDescription(?ilTemplate $template = null): string
77 {
78 if (null === $template) {
79 $template = new ilTemplate('tpl.default_description.html', true, true, 'components/ILIAS/Certificate');
80 }
81
82 $template->setVariable('PLACEHOLDER_INTRODUCTION', $this->language->txt('certificate_ph_introduction'));
83
84 $template->setCurrentBlock('items');
85 foreach ($this->placeholder as $id => $caption) {
86 $template->setVariable('ID', $id);
87 $template->setVariable('TXT', $caption);
88 $template->parseCurrentBlock();
89 }
90
91 return $template->get();
92 }
93
99 public function getPlaceholderDescriptions(): array
100 {
101 return $this->placeholder;
102 }
103}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Collection of basic placeholder values that can be used.
createPlaceholderHtmlDescription(?ilTemplate $template=null)
This method is different then the 'getPlaceholderValues' method, this method is used to create a plac...
getPlaceholderDescriptions()
This method MUST return an array containing an array with the the description as array value.
__construct(ilLanguage $language, Profile $profile, ?ilUserDefinedFieldsPlaceholderDescription $userDefinedFieldPlaceHolderDescriptionObject=null)
language handling
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
special template class to simplify handling of ITX/PEAR