ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjectCustomUserFieldsPlaceholderValues.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
3
8{
12 private $placeholder;
13
18
23
28 public function __construct(
31 ) {
32 $this->placeholder = array();
33
34 if (null === $objectHelper) {
36 }
37 $this->objectHelper = $objectHelper;
38
39 if (null === $ilUtilHelper) {
41 }
42 $this->ilUtilHelper = $ilUtilHelper;
43 }
44
59 public function getPlaceholderValues(int $user_id, int $obj_id) : array
60 {
62 $user = $this->objectHelper->getInstanceByObjId($user_id);
63 if (!$user instanceof ilObjUser) {
64 throw new ilException('The entered id: ' . $user_id . ' is not an user object');
65 }
66
67 $course_defined_fields = ilCourseDefinedFieldDefinition::_getFields($obj_id);
68 $field_values = ilCourseUserData::_getValuesByObjId($obj_id);
69
70 $placeholder = array();
71 foreach ($course_defined_fields as $key => $field) {
72 $field_id = $field->getId();
73
74 $placeholderText = '+' . str_replace(' ', '_', ilStr::strToUpper($field->getName()));
75
76 $placeholder[$placeholderText] = !empty($field_values[$user_id][$field_id]) ? $field_values[$user_id][$field_id] : "";
77 }
78
79 return $placeholder;
80 }
81
93 public function getPlaceholderValuesForPreview(int $user_id, int $obj_id) : array
94 {
95 global $DIC;
96
97 $lng = $DIC->language();
98
99 $course_defined_fields = ilCourseDefinedFieldDefinition::_getFields($obj_id);
100
101 $placeholder = array();
102 foreach ($course_defined_fields as $key => $field) {
103 $placeholderText = '+' . str_replace(' ', '_', ilStr::strToUpper($field->getName()));
104
105 $placeholder[$placeholderText] = $placeholderText . '_' . ilStr::strToUpper($lng->txt('value'));
106 }
107
108 return $placeholder;
109 }
110}
An exception for terminatinating execution or to throw for unit testing.
Just a wrapper class to create Unit Test for other classes.
static _getFields($a_container_id, $a_sort=IL_CDF_SORT_NAME)
Get all fields of a container.
static _getValuesByObjId($a_obj_id)
Get values by obj_id (for all users)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getPlaceholderValuesForPreview(int $user_id, int $obj_id)
This method is different then the 'getPlaceholderValues' method, this method is used to create a plac...
__construct(ilCertificateObjectHelper $objectHelper=null, ilCertificateUtilHelper $ilUtilHelper=null)
static strToUpper($a_string)
Definition: class.ilStr.php:96
global $DIC
Definition: goto.php:24
getPlaceholderValues(int $userId, int $objId)
This method MUST return an array that contains the actual data for the given user of the given object...
$lng