ILIAS  release_8 Revision v8.24
class.ilUserDefinedFieldsPlaceholderDescription.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
26 private array $placeholder;
27
28 public function __construct(?ilUserDefinedFields $userDefinedFieldsObject = null)
29 {
30 $this->placeholder = [];
31
32 if (null === $userDefinedFieldsObject) {
33 $userDefinedFieldsObject = ilUserDefinedFields::_getInstance();
34 }
35 $userDefinedFields = $userDefinedFieldsObject->getDefinitions();
36
37 foreach ($userDefinedFields as $field) {
38 if ($field['certificate']) {
39 $placeholderText = '#' . str_replace(' ', '_', ilStr::strToUpper($field['field_name']));
40
41 $this->placeholder[$placeholderText] = $field['field_name'];
42 }
43 }
44 }
45
51 public function getPlaceholderDescriptions(): array
52 {
53 return $this->placeholder;
54 }
55
59 public function createPlaceholderHtmlDescription(): string
60 {
61 $template = new ilTemplate(
62 'tpl.common_desc.html',
63 true,
64 true,
65 'Services/Certificate'
66 );
67
68 foreach ($this->getPlaceholderDescriptions() as $key => $field) {
69 $template->setCurrentBlock('cert_field');
70 $template->setVariable('PH', $key);
71 $template->setVariable('PH_TXT', $field);
72 $template->parseCurrentBlock();
73 }
74
75 return $template->get();
76 }
77}
static strToUpper(string $a_string)
Definition: class.ilStr.php:81
special template class to simplify handling of ITX/PEAR
getPlaceholderDescriptions()
This method MUST return an array containing an array with the the description as array value.
__construct(?ilUserDefinedFields $userDefinedFieldsObject=null)
Additional user data fields definition.
string $key
Consumer key/client ID value.
Definition: System.php:193