ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjectCustomUserFieldsPlaceholderDescription.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
23  private array $placeholder;
24  private int $objectId;
25 
26  public function __construct(int $objectId)
27  {
28  $this->placeholder = [];
29  $this->objectId = $objectId;
30 
31  $this->initPlaceholders();
32  }
33 
34  private function initPlaceholders(): void
35  {
36  $courseDefinedFields = ilCourseDefinedFieldDefinition::_getFields($this->objectId);
37 
38  foreach ($courseDefinedFields as $field) {
39  $name = $field->getName();
40 
41  $placeholderText = '+' . str_replace(' ', '_', ilStr::strToUpper($name));
42 
43  $this->placeholder[$placeholderText] = $name;
44  }
45  }
46 
52  public function getPlaceholderDescriptions(): array
53  {
54  return $this->placeholder;
55  }
56 
57  public function createPlaceholderHtmlDescription(): string
58  {
59  $template = new ilTemplate(
60  'tpl.common_desc.html',
61  true,
62  true,
63  'Services/Certificate'
64  );
65 
66  foreach ($this->getPlaceholderDescriptions() as $key => $field) {
67  $template->setCurrentBlock('cert_field');
68  $template->setVariable('PH', $key);
69  $template->setVariable('PH_TXT', $field);
70  $template->parseCurrentBlock();
71  }
72 
73  return $template->get();
74  }
75 }
static _getFields(int $a_container_id, $a_sort=self::IL_CDF_SORT_NAME)
Get all fields of a container.
if($format !==null) $name
Definition: metadata.php:247
static strToUpper(string $a_string)
Definition: class.ilStr.php:81
string $key
Consumer key/client ID value.
Definition: System.php:193
getPlaceholderDescriptions()
This method MUST return an array containing an array with the the description as array value...