ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ExercisePlaceholderDescription.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ilLanguage;
24use ilTemplate;
30
35{
37 private readonly ilLanguage $language;
38 private array $placeholder;
39
40 public function __construct(
41 ?ilDefaultPlaceholderDescription $defaultPlaceholderDescriptionObject = null,
42 ?ilLanguage $language = null,
43 ?ilUserDefinedFieldsPlaceholderDescription $userDefinedFieldPlaceHolderDescriptionObject = null,
44 ?Profile $profile = null
45 ) {
46 global $DIC;
47 if (null === $language) {
48 $language = $DIC->language();
49 $language->loadLanguageModule('certificate');
50 }
51 $this->language = $language;
52
53 if (null === $defaultPlaceholderDescriptionObject) {
54 $defaultPlaceholderDescriptionObject = new ilDefaultPlaceholderDescription(
56 $profile ?? $DIC['user']->getProfile(),
57 $userDefinedFieldPlaceHolderDescriptionObject
58 );
59 }
60 $this->placeholder = $defaultPlaceholderDescriptionObject->getPlaceholderDescriptions();
61
62 $this->placeholder['RESULT_PASSED'] = ilLegacyFormElementsUtil::prepareFormOutput(
63 $language->txt('certificate_var_result_passed')
64 );
65 $this->placeholder['RESULT_MARK'] = ilLegacyFormElementsUtil::prepareFormOutput(
66 $language->txt('certificate_var_result_mark_short')
67 );
68 $this->placeholder['EXERCISE_TITLE'] = ilLegacyFormElementsUtil::prepareFormOutput(
69 $language->txt('certificate_ph_exercisetitle')
70 );
71 $this->placeholder['DATE_COMPLETED'] = ilLegacyFormElementsUtil::prepareFormOutput(
72 $language->txt('certificate_ph_datetime_completed')
73 );
74 $this->placeholder['DATETIME_COMPLETED'] = ilLegacyFormElementsUtil::prepareFormOutput(
75 $language->txt('certificate_ph_datetime_completed')
76 );
77 }
78
84 public function createPlaceholderHtmlDescription(?ilTemplate $template = null): string
85 {
86 if (null === $template) {
87 $template = new ilTemplate('tpl.default_description.html', true, true, 'components/ILIAS/Certificate');
88 }
89
90 $template->setVariable('PLACEHOLDER_INTRODUCTION', $this->language->txt('certificate_ph_introduction'));
91
92 $template->setCurrentBlock('items');
93 foreach ($this->placeholder as $id => $caption) {
94 $template->setVariable('ID', $id);
95 $template->setVariable('TXT', $caption);
96 $template->parseCurrentBlock();
97 }
98
99 return $template->get();
100 }
101
107 public function getPlaceholderDescriptions(): array
108 {
109 return $this->placeholder;
110 }
111}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
createPlaceholderHtmlDescription(?ilTemplate $template=null)
This methods MUST return an array containing an array with the the description as array value.
getPlaceholderDescriptions()
This method MUST return an array containing an array with the description as array value.
__construct(?ilDefaultPlaceholderDescription $defaultPlaceholderDescriptionObject=null, ?ilLanguage $language=null, ?ilUserDefinedFieldsPlaceholderDescription $userDefinedFieldPlaceHolderDescriptionObject=null, ?Profile $profile=null)
readonly ilDefaultPlaceholderDescription $defaultPlaceHolderDescriptionObject
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)
special template class to simplify handling of ITX/PEAR
global $DIC
Definition: shib_login.php:26