ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
TestPlaceholderDescription.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24
29{
30 private readonly \ilLanguage $language;
31 private array $placeholder;
32
33 public function __construct(
34 ?\ilDefaultPlaceholderDescription $defaultPlaceholderDescriptionObject = null,
35 ?\ilLanguage $language = null,
36 ?Profile $profile = null,
37 ?\ilUserDefinedFieldsPlaceholderDescription $userDefinedFieldPlaceHolderDescriptionObject = null
38 ) {
39 global $DIC;
40
41 if (null === $language) {
42 $language = $DIC->language();
43 $language->loadLanguageModule('certificate');
44 }
45 $this->language = $language;
46 $profile ??= $DIC['user']->getProfile();
47
48 if (null === $defaultPlaceholderDescriptionObject) {
49 $defaultPlaceholderDescriptionObject = new \ilDefaultPlaceholderDescription(
51 $profile,
52 $userDefinedFieldPlaceHolderDescriptionObject
53 );
54 }
55 $this->placeholder = $defaultPlaceholderDescriptionObject->getPlaceholderDescriptions();
56
57 $this->placeholder['RESULT_PASSED'] = \ilLegacyFormElementsUtil::prepareFormOutput(
58 $this->language->txt('certificate_var_result_passed')
59 );
60 $this->placeholder['RESULT_POINTS'] = \ilLegacyFormElementsUtil::prepareFormOutput(
61 $this->language->txt('certificate_var_result_points')
62 );
63 $this->placeholder['RESULT_PERCENT'] = \ilLegacyFormElementsUtil::prepareFormOutput(
64 $this->language->txt('certificate_var_result_percent')
65 );
66 $this->placeholder['MAX_POINTS'] = \ilLegacyFormElementsUtil::prepareFormOutput(
67 $this->language->txt('certificate_var_max_points')
68 );
69 $this->placeholder['RESULT_MARK_SHORT'] = \ilLegacyFormElementsUtil::prepareFormOutput(
70 $this->language->txt('certificate_var_result_mark_short')
71 );
72 $this->placeholder['RESULT_MARK_LONG'] = \ilLegacyFormElementsUtil::prepareFormOutput(
73 $this->language->txt('certificate_var_result_mark_long')
74 );
75 $this->placeholder['TEST_TITLE'] = \ilLegacyFormElementsUtil::prepareFormOutput(
76 $this->language->txt('certificate_ph_testtitle')
77 );
78 $this->placeholder['DATE_COMPLETED'] = \ilLegacyFormElementsUtil::prepareFormOutput(
79 $language->txt('certificate_ph_date_completed')
80 );
81 $this->placeholder['DATETIME_COMPLETED'] = \ilLegacyFormElementsUtil::prepareFormOutput(
82 $language->txt('certificate_ph_datetime_completed')
83 );
84 }
85
90 public function createPlaceholderHtmlDescription(?\ilTemplate $template = null): string
91 {
92 if (null === $template) {
93 $template = new \ilTemplate('tpl.default_description.html', true, true, 'components/ILIAS/Certificate');
94 }
95
96 $template->setVariable('PLACEHOLDER_INTRODUCTION', $this->language->txt('certificate_ph_introduction'));
97
98 $template->setCurrentBlock('items');
99 foreach ($this->placeholder as $id => $caption) {
100 $template->setVariable('ID', $id);
101 $template->setVariable('TXT', $caption);
102 $template->parseCurrentBlock();
103 }
104
105 return $template->get();
106 }
107
113 public function getPlaceholderDescriptions(): array
114 {
115 return $this->placeholder;
116 }
117}
$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, ?Profile $profile=null, ?\ilUserDefinedFieldsPlaceholderDescription $userDefinedFieldPlaceHolderDescriptionObject=null)
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...
static prepareFormOutput($a_str, bool $a_strip=false)
special template class to simplify handling of ITX/PEAR
global $DIC
Definition: shib_login.php:26