ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilExercisePlaceholderDescription.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 {
27  private readonly ilLanguage $language;
28  private array $placeholder;
29 
30  public function __construct(
31  ?ilDefaultPlaceholderDescription $defaultPlaceholderDescriptionObject = null,
32  ?ilLanguage $language = null,
33  ?ilUserDefinedFieldsPlaceholderDescription $userDefinedFieldPlaceHolderDescriptionObject = null
34  ) {
35  global $DIC;
36 
37  if (null === $language) {
38  $language = $DIC->language();
39  $language->loadLanguageModule('certificate');
40  }
41  $this->language = $language;
42 
43  if (null === $defaultPlaceholderDescriptionObject) {
44  $defaultPlaceholderDescriptionObject = new ilDefaultPlaceholderDescription(
45  $language,
46  $userDefinedFieldPlaceHolderDescriptionObject
47  );
48  }
49  $this->defaultPlaceHolderDescriptionObject = $defaultPlaceholderDescriptionObject;
50 
51  $this->placeholder = $this->defaultPlaceHolderDescriptionObject->getPlaceholderDescriptions();
52 
53  $this->placeholder['RESULT_PASSED'] = ilLegacyFormElementsUtil::prepareFormOutput(
54  $language->txt('certificate_var_result_passed')
55  );
56  $this->placeholder['RESULT_MARK'] = ilLegacyFormElementsUtil::prepareFormOutput(
57  $language->txt('certificate_var_result_mark_short')
58  );
59  $this->placeholder['EXERCISE_TITLE'] = ilLegacyFormElementsUtil::prepareFormOutput(
60  $language->txt('certificate_ph_exercisetitle')
61  );
62  $this->placeholder['DATE_COMPLETED'] = ilLegacyFormElementsUtil::prepareFormOutput(
63  $language->txt('certificate_ph_datetime_completed')
64  );
65  $this->placeholder['DATETIME_COMPLETED'] = ilLegacyFormElementsUtil::prepareFormOutput(
66  $language->txt('certificate_ph_datetime_completed')
67  );
68  }
69 
75  public function createPlaceholderHtmlDescription(?ilTemplate $template = null): string
76  {
77  if (null === $template) {
78  $template = new ilTemplate('tpl.default_description.html', true, true, 'Services/Certificate');
79  }
80 
81  $template->setVariable('PLACEHOLDER_INTRODUCTION', $this->language->txt('certificate_ph_introduction'));
82 
83  $template->setCurrentBlock('items');
84  foreach ($this->placeholder as $id => $caption) {
85  $template->setVariable('ID', $id);
86  $template->setVariable('TXT', $caption);
87  $template->parseCurrentBlock();
88  }
89 
90  return $template->get();
91  }
92 
98  public function getPlaceholderDescriptions(): array
99  {
100  return $this->placeholder;
101  }
102 }
static prepareFormOutput($a_str, bool $a_strip=false)
global $DIC
Definition: feed.php:28
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 the description as array value...
__construct(?ilDefaultPlaceholderDescription $defaultPlaceholderDescriptionObject=null, ?ilLanguage $language=null, ?ilUserDefinedFieldsPlaceholderDescription $userDefinedFieldPlaceHolderDescriptionObject=null)
readonly ilDefaultPlaceholderDescription $defaultPlaceHolderDescriptionObject
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Collection of basic placeholder values that can be used.