ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 if (null === $language) {
47 $language = $DIC->language();
48 $language->loadLanguageModule('certificate');
49 }
50 $this->language = $language;
51
52 if (null === $defaultPlaceholderDescriptionObject) {
53 $defaultPlaceholderDescriptionObject = new ilDefaultPlaceholderDescription(
55 $profile ?? $DIC['user']->getProfile(),
56 $userDefinedFieldPlaceHolderDescriptionObject
57 );
58 }
59 $this->placeholder = $defaultPlaceholderDescriptionObject->getPlaceholderDescriptions();
60
61 $this->placeholder['RESULT_PASSED'] = ilLegacyFormElementsUtil::prepareFormOutput(
62 $language->txt('certificate_var_result_passed')
63 );
64 $this->placeholder['RESULT_MARK'] = ilLegacyFormElementsUtil::prepareFormOutput(
65 $language->txt('certificate_var_result_mark_short')
66 );
67 $this->placeholder['EXERCISE_TITLE'] = ilLegacyFormElementsUtil::prepareFormOutput(
68 $language->txt('certificate_ph_exercisetitle')
69 );
70 $this->placeholder['DATE_COMPLETED'] = ilLegacyFormElementsUtil::prepareFormOutput(
71 $language->txt('certificate_ph_datetime_completed')
72 );
73 $this->placeholder['DATETIME_COMPLETED'] = ilLegacyFormElementsUtil::prepareFormOutput(
74 $language->txt('certificate_ph_datetime_completed')
75 );
76 }
77
83 public function createPlaceholderHtmlDescription(?ilTemplate $template = null): string
84 {
85 if (null === $template) {
86 $template = new ilTemplate('tpl.default_description.html', true, true, 'components/ILIAS/Certificate');
87 }
88
89 $template->setVariable('PLACEHOLDER_INTRODUCTION', $this->language->txt('certificate_ph_introduction'));
90
91 $template->setCurrentBlock('items');
92 foreach ($this->placeholder as $id => $caption) {
93 $template->setVariable('ID', $id);
94 $template->setVariable('TXT', $caption);
95 $template->parseCurrentBlock();
96 }
97
98 return $template->get();
99 }
100
106 public function getPlaceholderDescriptions(): array
107 {
108 return $this->placeholder;
109 }
110}
$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