ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilCustomUserFieldsHelper Class Reference
+ Collaboration diagram for ilCustomUserFieldsHelper:

Public Member Functions

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

Static Public Member Functions

static getInstance ()
 

Protected Attributes

ilComponentRepository $component_repository
 
ilComponentFactory $component_factory
 

Private Attributes

Language $lng
 

Static Private Attributes

static ilCustomUserFieldsHelper $instance = null
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCustomUserFieldsHelper::__construct ( )

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

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

37  {
38  global $DIC;
39 
40  $this->lng = $DIC->language();
41  $this->component_repository = $DIC['component.repository'];
42  $this->component_factory = $DIC['component.factory'];
43  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ getActivePlugins()

ilCustomUserFieldsHelper::getActivePlugins ( )

Get plugins for fields.

Returns
ilUDFDefinitionPlugin[]

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

References ilUDFDefinitionPlugin\UDF_SLOT_ID.

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

86  : array
87  {
88  return iterator_to_array($this->component_factory->getActivePluginsInSlot(ilUDFDefinitionPlugin::UDF_SLOT_ID));
89  }
+ Here is the caller graph for this function:

◆ getFormPropertyForDefinition()

ilCustomUserFieldsHelper::getFormPropertyForDefinition ( array  $definition,
bool  $changeable = true,
string  $default_value = '' 
)

Get form property for definition.

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

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

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

◆ getInstance()

static ilCustomUserFieldsHelper::getInstance ( )
static

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

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

46  {
47  if (self::$instance) {
48  return self::$instance;
49  }
50  return self::$instance = new self();
51  }
+ Here is the caller graph for this function:

◆ getPluginForType()

ilCustomUserFieldsHelper::getPluginForType ( int  $type)

Get plugin for udf type.

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

References XapiProxy\$plugin, getActivePlugins(), and null.

73  {
74  foreach ($this->getActivePlugins() as $plugin) {
75  if ($plugin->getDefinitionType() === $type) {
76  return $plugin;
77  }
78  }
79  return null;
80  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getActivePlugins()
Get plugins for fields.
+ Here is the call graph for this function:

◆ getUDFTypes()

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

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

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

56  : array
57  {
58  $types = [
59  UDF_TYPE_TEXT => $this->lng->txt('udf_type_text'),
60  UDF_TYPE_SELECT => $this->lng->txt('udf_type_select'),
61  UDF_TYPE_WYSIWYG => $this->lng->txt('udf_type_wysiwyg')
62  ];
63  foreach ($this->getActivePlugins() as $plugin) {
64  $types[$plugin->getDefinitionType()] = $plugin->getDefinitionTypeName();
65  }
66  return $types;
67  }
const UDF_TYPE_SELECT
getActivePlugins()
Get plugins for fields.
const UDF_TYPE_TEXT
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const UDF_TYPE_WYSIWYG
+ Here is the call graph for this function:

Field Documentation

◆ $component_factory

ilComponentFactory ilCustomUserFieldsHelper::$component_factory
protected

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

◆ $component_repository

ilComponentRepository ilCustomUserFieldsHelper::$component_repository
protected

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

◆ $instance

ilCustomUserFieldsHelper ilCustomUserFieldsHelper::$instance = null
staticprivate

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

◆ $lng

Language ilCustomUserFieldsHelper::$lng
private

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


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