ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjectCustomUserFieldsPlaceholderDescription.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 private array $placeholder;
24
25 public function __construct(private readonly int $objectId)
26 {
27 $this->placeholder = [];
28
29 $this->initPlaceholders();
30 }
31
32 private function initPlaceholders(): void
33 {
34 $courseDefinedFields = ilCourseDefinedFieldDefinition::_getFields($this->objectId);
35
36 foreach ($courseDefinedFields as $field) {
37 $name = $field->getName();
38
39 $placeholderText = '+' . str_replace(' ', '_', ilStr::strToUpper($name));
40
41 $this->placeholder[$placeholderText] = $name;
42 }
43 }
44
50 public function getPlaceholderDescriptions(): array
51 {
52 return $this->placeholder;
53 }
54
55 public function createPlaceholderHtmlDescription(): string
56 {
57 $template = new ilTemplate(
58 'tpl.common_desc.html',
59 true,
60 true,
61 'components/ILIAS/Certificate'
62 );
63
64 foreach ($this->getPlaceholderDescriptions() as $key => $field) {
65 $template->setCurrentBlock('cert_field');
66 $template->setVariable('PH', $key);
67 $template->setVariable('PH_TXT', $field);
68 $template->parseCurrentBlock();
69 }
70
71 return $template->get();
72 }
73}
static _getFields(int $a_container_id, $a_sort=self::IL_CDF_SORT_NAME)
Get all fields of a container.
getPlaceholderDescriptions()
This method MUST return an array containing an array with the the description as array value.
static strToUpper(string $a_string)
Definition: class.ilStr.php:78
special template class to simplify handling of ITX/PEAR