ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
CoursePlaceholderDescription.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ilLanguage;
24use ilTemplate;
31
36{
39 private readonly ilLanguage $language;
40 private array $placeholder;
41
42 public function __construct(
43 int $objectId,
44 ?ilDefaultPlaceholderDescription $defaultPlaceholderDescriptionObject = null,
45 ?ilLanguage $language = null,
46 ?ilUserDefinedFieldsPlaceholderDescription $userDefinedFieldPlaceHolderDescriptionObject = null,
48 ?Profile $profile = null
49 ) {
50 global $DIC;
51
52 if (null === $language) {
53 $language = $DIC->language();
54 $language->loadLanguageModule('certificate');
55 }
56 $this->language = $language;
57
58 if (null === $defaultPlaceholderDescriptionObject) {
59 $defaultPlaceholderDescriptionObject = new ilDefaultPlaceholderDescription(
61 $profile ?? $DIC['user']->getProfile(),
62 $userDefinedFieldPlaceHolderDescriptionObject
63 );
64 }
65 $this->defaultPlaceHolderDescriptionObject = $defaultPlaceholderDescriptionObject;
66
69 }
70 $this->customUserFieldsPlaceholderDescriptionObject = $customUserFieldsPlaceholderDescriptionObject;
71
72 $customUserFieldsPlaceholderHtmlDescription = $this->customUserFieldsPlaceholderDescriptionObject->getPlaceholderDescriptions();
73 $defaultPlaceholderDescription = $this->defaultPlaceHolderDescriptionObject->getPlaceholderDescriptions();
74
75 $this->placeholder = array_merge($defaultPlaceholderDescription, $customUserFieldsPlaceholderHtmlDescription);
76 $this->placeholder['COURSE_TITLE'] = $this->language->txt('crs_title');
77 $this->placeholder['DATE_COMPLETED'] = ilLegacyFormElementsUtil::prepareFormOutput(
78 $language->txt('certificate_ph_date_completed')
79 );
80 $this->placeholder['DATETIME_COMPLETED'] = ilLegacyFormElementsUtil::prepareFormOutput(
81 $language->txt('certificate_ph_datetime_completed')
82 );
83 }
84
85 public function createPlaceholderHtmlDescription(?ilTemplate $template = null): string
86 {
87 if (null === $template) {
88 $template = new ilTemplate('tpl.default_description.html', true, true, 'components/ILIAS/Certificate');
89 }
90
91 $template->setVariable('PLACEHOLDER_INTRODUCTION', $this->language->txt('certificate_ph_introduction'));
92
93 $template->setCurrentBlock('items');
94 foreach ($this->placeholder as $id => $caption) {
95 $template->setVariable('ID', $id);
96 $template->setVariable('TXT', $caption);
97 $template->parseCurrentBlock();
98 }
99
100 return $template->get();
101 }
102
108 public function getPlaceholderDescriptions(): array
109 {
110 return $this->placeholder;
111 }
112}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(int $objectId, ?ilDefaultPlaceholderDescription $defaultPlaceholderDescriptionObject=null, ?ilLanguage $language=null, ?ilUserDefinedFieldsPlaceholderDescription $userDefinedFieldPlaceHolderDescriptionObject=null, ?ilObjectCustomUserFieldsPlaceholderDescription $customUserFieldsPlaceholderDescriptionObject=null, ?Profile $profile=null)
getPlaceholderDescriptions()
This method MUST return an array containing an array with the description as array value.
readonly ilDefaultPlaceholderDescription $defaultPlaceHolderDescriptionObject
readonly ilObjectCustomUserFieldsPlaceholderDescription $customUserFieldsPlaceholderDescriptionObject
Collection of basic placeholder values that can be used.
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static prepareFormOutput($a_str, bool $a_strip=false)
getPlaceholderDescriptions()
This method MUST return an array containing an array with the the description as array value.
special template class to simplify handling of ITX/PEAR
global $DIC
Definition: shib_login.php:26