ILIAS  release_8 Revision v8.24
ilCustomUserFieldsHelper Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilCustomUserFieldsHelper:

Public Member Functions

 __construct ()
 
 getUDFTypes ()
 
 getPluginForType (string $a_type)
 Get plugin for udf type. More...
 
 getActivePlugins ()
 Get plugins for fields. More...
 
 getFormPropertyForDefinition (array $definition, bool $changeable=true, string $a_default_value=null)
 Get form property for definition. More...
 

Static Public Member Functions

static getInstance ()
 

Protected Attributes

ilComponentRepository $component_repository
 
ilComponentFactory $component_factory
 

Private Attributes

ilLanguage $lng
 

Static Private Attributes

static ilCustomUserFieldsHelper $instance = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 25 of file class.ilCustomUserFieldsHelper.php.

Constructor & Destructor Documentation

◆ __construct()

ilCustomUserFieldsHelper::__construct ( )

Definition at line 32 of file class.ilCustomUserFieldsHelper.php.

33 {
34 global $DIC;
35
36 $this->lng = $DIC->language();
37 $this->component_repository = $DIC['component.repository'];
38 $this->component_factory = $DIC['component.factory'];
39 }
global $DIC
Definition: feed.php:28

References $DIC, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ getActivePlugins()

ilCustomUserFieldsHelper::getActivePlugins ( )

Get plugins for fields.

Returns
ilUDFDefinitionPlugin[]

Definition at line 82 of file class.ilCustomUserFieldsHelper.php.

82 : array
83 {
84 return iterator_to_array($this->component_factory->getActivePluginsInSlot(ilUDFDefinitionPlugin::UDF_SLOT_ID));
85 }

References ilUDFDefinitionPlugin\UDF_SLOT_ID.

Referenced by getFormPropertyForDefinition(), getPluginForType(), and getUDFTypes().

+ Here is the caller graph for this function:

◆ getFormPropertyForDefinition()

ilCustomUserFieldsHelper::getFormPropertyForDefinition ( array  $definition,
bool  $changeable = true,
string  $a_default_value = null 
)

Get form property for definition.

Definition at line 90 of file class.ilCustomUserFieldsHelper.php.

95 $fprop = null;
96 $default_value = $a_default_value ?? '';
97
98 switch ($definition['field_type']) {
99 case UDF_TYPE_TEXT:
100 $fprop = new ilTextInputGUI(
101 $definition['field_name'],
102 'udf_' . $definition['field_id']
103 );
104
105 $fprop->setValue($default_value);
106 $fprop->setSize(40);
107 $fprop->setMaxLength(255);
108 $fprop->setRequired((bool) $definition['required']);
109 if (!$changeable && (!$definition['required'] || $default_value !== '')) {
110 $fprop->setDisabled(true);
111 }
112 break;
113
114 case UDF_TYPE_WYSIWYG:
115 $fprop = new ilTextAreaInputGUI(
116 $definition['field_name'],
117 'udf_' . $definition['field_id']
118 );
119
120 $fprop->setValue($default_value);
121 $fprop->setUseRte(true);
122 $fprop->setRequired((bool) $definition['required']);
123 if (!$changeable && (!$definition['required'] || $default_value !== '')) {
124 $fprop->setDisabled(true);
125 }
126 break;
127
128 case UDF_TYPE_SELECT:
129 $fprop = new ilSelectInputGUI(
130 $definition['field_name'],
131 'udf_' . $definition['field_id']
132 );
133
134 $user_defined_fields = ilUserDefinedFields::_getInstance();
135
136 $fprop->setOptions($user_defined_fields->fieldValuesToSelectArray($definition['field_values']));
137 $fprop->setValue($default_value);
138 $fprop->setRequired((bool) $definition['required']);
139 if (!$changeable && (!$definition['required'] || $default_value !== '')) {
140 $fprop->setDisabled(true);
141 }
142 break;
143
144 default:
145 // should be a plugin
146 foreach ($this->getActivePlugins() as $plugin) {
147 if ($plugin->getDefinitionType() == $definition['field_type']) {
148 $fprop = $plugin->getFormPropertyForDefinition(
149 $definition,
150 $changeable,
151 $a_default_value
152 );
153 break;
154 }
155 }
156 break;
157 }
158
159 return $fprop;
160 }
const UDF_TYPE_SELECT
const UDF_TYPE_WYSIWYG
const UDF_TYPE_TEXT
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getActivePlugins()
Get plugins for fields.
This class represents a property in a property form.
This class represents a selection list property in a property form.
This class represents a text area property in a property form.
This class represents a text property in a property form.

References XapiProxy\$plugin, ilUserDefinedFields\_getInstance(), getActivePlugins(), UDF_TYPE_SELECT, UDF_TYPE_TEXT, and UDF_TYPE_WYSIWYG.

+ Here is the call graph for this function:

◆ getInstance()

static ilCustomUserFieldsHelper::getInstance ( )
static

Definition at line 41 of file class.ilCustomUserFieldsHelper.php.

42 {
43 if (self::$instance) {
44 return self::$instance;
45 }
46 return self::$instance = new self();
47 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static ilCustomUserFieldsHelper $instance

References $instance.

Referenced by ilCustomUserFieldsGUI\create(), ilAccountRegistrationGUI\initForm(), ilObjUserGUI\initForm(), ilCustomUserFieldsGUI\initForm(), ilPersonalProfileGUI\initPersonalDataForm(), ilUserDefinedData\lookupData(), and ilCustomUserFieldsGUI\update().

+ Here is the caller graph for this function:

◆ getPluginForType()

ilCustomUserFieldsHelper::getPluginForType ( string  $a_type)

Get plugin for udf type.

Definition at line 68 of file class.ilCustomUserFieldsHelper.php.

69 {
70 foreach ($this->getActivePlugins() as $plugin) {
71 if ($plugin->getDefinitionType() == $a_type) {
72 return $plugin;
73 }
74 }
75 return null;
76 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References XapiProxy\$plugin, and getActivePlugins().

+ Here is the call graph for this function:

◆ getUDFTypes()

ilCustomUserFieldsHelper::getUDFTypes ( )
Returns
array<int,string>

Definition at line 52 of file class.ilCustomUserFieldsHelper.php.

52 : array
53 {
54 $types = array(
55 UDF_TYPE_TEXT => $this->lng->txt('udf_type_text'),
56 UDF_TYPE_SELECT => $this->lng->txt('udf_type_select'),
57 UDF_TYPE_WYSIWYG => $this->lng->txt('udf_type_wysiwyg')
58 );
59 foreach ($this->getActivePlugins() as $plugin) {
60 $types[$plugin->getDefinitionType()] = $plugin->getDefinitionTypeName();
61 }
62 return $types;
63 }

References XapiProxy\$plugin, getActivePlugins(), ILIAS\Repository\lng(), UDF_TYPE_SELECT, UDF_TYPE_TEXT, and UDF_TYPE_WYSIWYG.

+ Here is the call graph for this function:

Field Documentation

◆ $component_factory

ilComponentFactory ilCustomUserFieldsHelper::$component_factory
protected

Definition at line 30 of file class.ilCustomUserFieldsHelper.php.

◆ $component_repository

ilComponentRepository ilCustomUserFieldsHelper::$component_repository
protected

Definition at line 29 of file class.ilCustomUserFieldsHelper.php.

◆ $instance

ilCustomUserFieldsHelper ilCustomUserFieldsHelper::$instance = null
staticprivate

Definition at line 27 of file class.ilCustomUserFieldsHelper.php.

Referenced by getInstance().

◆ $lng

ilLanguage ilCustomUserFieldsHelper::$lng
private

Definition at line 28 of file class.ilCustomUserFieldsHelper.php.


The documentation for this class was generated from the following file: