ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilChatroomFormFactory Class Reference
+ Collaboration diagram for ilChatroomFormFactory:

Public Member Functions

 __construct ()
 
 getCreationForm ()
 Instantiates and returns ilPropertyFormGUI containing ilTextInputGUI and ilTextAreaInputGUI. More...
 
 getSettingsForm (ilChatroomObjectGUI $gui, ilCtrlInterface $ctrl, ?array $values=null)
 
 getPeriodForm ()
 
 getUserChatNameSelectionForm (array $name_options)
 Returns chatname selection form. More...
 
 getSessionForm (array $sessions)
 Returns session form with period set by given $sessions. More...
 
 getClientSettingsForm ()
 

Static Public Member Functions

static applyValues (ilPropertyFormGUI $form, array $values)
 Applies given values to field in given form. More...
 

Data Fields

const PROP_TITLE_AND_DESC = 'title_and_desc'
 
const PROP_ONLINE_STATUS = 'online_status'
 
const PROP_TILE_IMAGE = 'tile_image'
 
const PROP_DISPLAY_PAST_MSG = 'display_past_msgs'
 
const PROP_ENABLE_HISTORY = 'enable_history'
 
const PROP_ALLOW_ANONYMOUS = 'allow_anonymous'
 
const PROP_ALLOW_CUSTOM_NAMES = 'allow_custom_usernames'
 
const PROP_AUTOGEN_USERNAMES = 'autogen_usernames'
 

Protected Attributes

ilLanguage $lng
 
ilObjUser $user
 
ILIAS HTTP Services $http
 
ILIAS UI Factory $ui_factory
 
ILIAS Refinery Factory $refinery
 

Private Member Functions

 addDefaultBehaviour (ilPropertyFormGUI $form)
 Adds 'create-save' and 'cancel' button to given $form and returns it. More...
 
 mergeValuesTrafo ()
 
 saniziteArrayElementsTrafo ()
 

Detailed Description

Definition at line 21 of file class.ilChatroomFormFactory.php.

Constructor & Destructor Documentation

◆ __construct()

ilChatroomFormFactory::__construct ( )

Definition at line 38 of file class.ilChatroomFormFactory.php.

References $DIC, ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\user().

39  {
40  global $DIC;
41 
42  $this->lng = $DIC->language();
43  $this->user = $DIC->user();
44  $this->http = $DIC->http();
45  $this->ui_factory = $DIC->ui()->factory();
46  $this->refinery = $DIC->refinery();
47  }
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

Member Function Documentation

◆ addDefaultBehaviour()

ilChatroomFormFactory::addDefaultBehaviour ( ilPropertyFormGUI  $form)
private

Adds 'create-save' and 'cancel' button to given $form and returns it.

Definition at line 83 of file class.ilChatroomFormFactory.php.

References ilPropertyFormGUI\addCommandButton(), and ILIAS\Repository\lng().

Referenced by getCreationForm().

84  {
85  $form->addCommandButton('create-save', $this->lng->txt('create'));
86  $form->addCommandButton('cancel', $this->lng->txt('cancel'));
87 
88  return $form;
89  }
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyValues()

static ilChatroomFormFactory::applyValues ( ilPropertyFormGUI  $form,
array  $values 
)
static

Applies given values to field in given form.

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

References ilPropertyFormGUI\setValuesByArray().

52  : void
53  {
54  $form->setValuesByArray(
55  array_map(
56  static fn($value) => is_int($value) ? (string) $value : $value,
57  $values
58  )
59  );
60  }
setValuesByArray(array $a_values, bool $a_restrict_to_value_keys=false)
+ Here is the call graph for this function:

◆ getClientSettingsForm()

ilChatroomFormFactory::getClientSettingsForm ( )

Definition at line 293 of file class.ilChatroomFormFactory.php.

References $http, ILIAS\Repository\lng(), and ilFormPropertyGUI\setInfo().

294  {
295  $form = new ilPropertyFormGUI();
296 
297  $enable_chat = new ilCheckboxInputGUI($this->lng->txt('chat_enabled'), 'chat_enabled');
298  $form->addItem($enable_chat);
299 
300  $enable_osc = new ilCheckboxInputGUI($this->lng->txt('chatroom_enable_osc'), 'enable_osc');
301  $enable_osc->setInfo($this->lng->txt('chatroom_enable_osc_info'));
302  $enable_chat->addSubItem($enable_osc);
303 
304  $oscBrowserNotificationStatus = new ilCheckboxInputGUI(
305  $this->lng->txt('osc_adm_browser_noti_label'),
306  'enable_browser_notifications'
307  );
308  $oscBrowserNotificationStatus->setInfo($this->lng->txt('osc_adm_browser_noti_info'));
309  $oscBrowserNotificationStatus->setValue('1');
310  $enable_osc->addSubItem($oscBrowserNotificationStatus);
311 
312  $oscBrowserNotificationIdleTime = new ilNumberInputGUI(
313  $this->lng->txt('osc_adm_conv_idle_state_threshold_label'),
314  'conversation_idle_state_in_minutes'
315  );
316  $oscBrowserNotificationIdleTime->allowDecimals(false);
317  $oscBrowserNotificationIdleTime->setSuffix($this->lng->txt('minutes'));
318  $oscBrowserNotificationIdleTime->setMinValue(1);
319  $oscBrowserNotificationIdleTime->setSize(5);
320  $oscBrowserNotificationIdleTime->setInfo($this->lng->txt('osc_adm_conv_idle_state_threshold_info'));
321  $enable_osc->addSubItem($oscBrowserNotificationIdleTime);
322 
323  $name = new ilTextInputGUI($this->lng->txt('chatroom_client_name'), 'client_name');
324  $name->setInfo($this->lng->txt('chatroom_client_name_info'));
325  $name->setRequired(true);
326  $name->setMaxLength(100);
327  $enable_chat->addSubItem($name);
328 
329  $auth = new ilChatroomAuthInputGUI(
330  $this->lng->txt('chatroom_auth'),
331  'auth',
333  );
334  $auth->setInfo($this->lng->txt('chat_auth_token_info'));
335  $auth->setCtrlPath(
336  [
337  ilAdministrationGUI::class,
338  ilObjChatroomGUI::class,
339  ilPropertyFormGUI::class,
340  ilFormPropertyDispatchGUI::class,
341  ilChatroomAuthInputGUI::class,
342  ]
343  );
344  $auth->setRequired(true);
345  $enable_chat->addSubItem($auth);
346 
347  return $form;
348  }
Class ilChatroomAuthInputGUI.
+ Here is the call graph for this function:

◆ getCreationForm()

ilChatroomFormFactory::getCreationForm ( )

Instantiates and returns ilPropertyFormGUI containing ilTextInputGUI and ilTextAreaInputGUI.

Deprecated:
replaced by default creation screens

Definition at line 67 of file class.ilChatroomFormFactory.php.

References addDefaultBehaviour(), and ILIAS\Repository\lng().

68  {
69  $form = new ilPropertyFormGUI();
70  $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
71  $title->setRequired(true);
72  $form->addItem($title);
73 
74  $description = new ilTextAreaInputGUI($this->lng->txt('description'), 'desc');
75  $form->addItem($description);
76 
77  return $this->addDefaultBehaviour($form);
78  }
This class represents a text area property in a property form.
addDefaultBehaviour(ilPropertyFormGUI $form)
Adds 'create-save' and 'cancel' button to given $form and returns it.
+ Here is the call graph for this function:

◆ getPeriodForm()

ilChatroomFormFactory::getPeriodForm ( )

Definition at line 219 of file class.ilChatroomFormFactory.php.

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

220  {
221  $form = new ilPropertyFormGUI();
222  $form->setPreventDoubleSubmission(false);
223 
224  $duration = new ilDateDurationInputGUI($this->lng->txt('period'), 'timeperiod');
225 
226  $duration->setStartText($this->lng->txt('duration_from'));
227  $duration->setEndText($this->lng->txt('duration_to'));
228  $duration->setShowTime(true);
229  $duration->setRequired(true);
230  $form->addItem($duration);
231 
232  return $form;
233  }
$duration
+ Here is the call graph for this function:

◆ getSessionForm()

ilChatroomFormFactory::getSessionForm ( array  $sessions)

Returns session form with period set by given $sessions.

Definition at line 269 of file class.ilChatroomFormFactory.php.

References ilDatePresentation\formatPeriod(), IL_CAL_UNIX, and ILIAS\Repository\lng().

270  {
271  $form = new ilPropertyFormGUI();
272  $form->setPreventDoubleSubmission(false);
273  $list = new ilSelectInputGUI($this->lng->txt('session'), 'session');
274 
275  $options = [];
276 
277  foreach ($sessions as $session) {
278  $start = new ilDateTime($session['connected'], IL_CAL_UNIX);
279  $end = new ilDateTime($session['disconnected'], IL_CAL_UNIX);
280 
281  $options[$session['connected'] . ',' .
282  $session['disconnected']] = ilDatePresentation::formatPeriod($start, $end);
283  }
284 
285  $list->setOptions($options);
286  $list->setRequired(true);
287 
288  $form->addItem($list);
289 
290  return $form;
291  }
This class represents a selection list property in a property form.
const IL_CAL_UNIX
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false)
Format a period of two dates Shows: 14.
+ Here is the call graph for this function:

◆ getSettingsForm()

ilChatroomFormFactory::getSettingsForm ( ilChatroomObjectGUI  $gui,
ilCtrlInterface  $ctrl,
?array  $values = null 
)

Definition at line 113 of file class.ilChatroomFormFactory.php.

References ilCtrlInterface\getFormAction(), ilObjectGUI\getObject(), ILIAS\Repository\lng(), mergeValuesTrafo(), ILIAS\Repository\refinery(), saniziteArrayElementsTrafo(), ILIAS\UI\Implementation\Component\Input\ViewControl\withAdditionalTransformation(), and ILIAS\UI\Implementation\Component\Input\withValue().

118  $this->lng->loadLanguageModule('obj');
119  $this->lng->loadLanguageModule('rep');
120 
121  $field_factory = $this->ui_factory->input()->field();
122 
123  $title_and_description = $gui->getObject()->getObjectProperties()->getPropertyTitleAndDescription();
124  $general_settings_fields = [
125  self::PROP_TITLE_AND_DESC => $title_and_description->toForm(
126  $this->lng,
127  $field_factory,
128  $this->refinery
129  )
130  ];
131 
132  $online_status = $gui->getObject()->getObjectProperties()->getPropertyIsOnline();
133  $availability_fields = [
134  self::PROP_ONLINE_STATUS => $online_status->toForm(
135  $this->lng,
136  $field_factory,
137  $this->refinery
138  )->withByline($this->lng->txt('chtr_activation_online_info')),
139  ];
140 
141  $tile_image = $gui->getObject()->getObjectProperties()->getPropertyTileImage();
142  $presentation_fields = [
143  self::PROP_TILE_IMAGE => $tile_image->toForm(
144  $this->lng,
145  $field_factory,
146  $this->refinery
147  ),
148  self::PROP_DISPLAY_PAST_MSG => $field_factory->numeric(
149  $this->lng->txt('display_past_msgs'),
150  $this->lng->txt('hint_display_past_msgs')
151  )->withRequired(
152  true
153  )->withAdditionalTransformation(
154  $this->refinery->logical()->parallel([
155  $this->refinery->int()->isGreaterThanOrEqual(0),
156  $this->refinery->int()->isLessThanOrEqual(100)
157  ])
158  )->withValue(
159  $values['display_past_msgs'] ?? 0
160  ),
161  self::PROP_ENABLE_HISTORY => $field_factory->checkbox(
162  $this->lng->txt('chat_enable_history'),
163  $this->lng->txt('chat_enable_history_info')
164  )->withValue((bool) ($values['enable_history'] ?? false)),
165  ];
166 
167  $function_fields = [
168  self::PROP_ALLOW_ANONYMOUS => $field_factory->checkbox(
169  $this->lng->txt('allow_anonymous'),
170  $this->lng->txt('anonymous_hint')
171  )->withValue((bool) ($values['allow_anonymous'] ?? false)),
172  self::PROP_ALLOW_CUSTOM_NAMES => $field_factory->optionalGroup(
173  [
174  self::PROP_AUTOGEN_USERNAMES => $field_factory->text(
175  $this->lng->txt('autogen_usernames'),
176  $this->lng->txt('autogen_usernames_info')
177  )->withRequired(true),
178  ],
179  $this->lng->txt('allow_custom_usernames')
180  )->withValue(
181  ($values['allow_custom_usernames'] ?? false) ? [self::PROP_AUTOGEN_USERNAMES => $values['autogen_usernames'] ?? ''] : null
182  ),
183  ];
184 
185  $sections = [
186  $field_factory->section(
187  $general_settings_fields,
188  $this->lng->txt('settings_title'),
189  ''
190  ),
191  $field_factory->section(
192  $availability_fields,
193  $this->lng->txt('rep_activation_availability'),
194  ''
195  ),
196  $field_factory->section(
197  $presentation_fields,
198  $this->lng->txt('settings_presentation_header'),
199  ''
200  ),
201  $field_factory->section(
202  $function_fields,
203  $this->lng->txt('chat_settings_functions_header'),
204  ''
205  ),
206  ];
207 
208  return $this->ui_factory->input()
209  ->container()
210  ->form()
211  ->standard(
212  $ctrl->getFormAction($gui, 'settings-saveGeneral'),
213  $sections
214  )
217  }
This describes commonalities between all forms.
Definition: Form.php:32
getFormAction(object $a_gui_obj, string $a_fallback_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
Returns a form action link for the given information.
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:58
+ Here is the call graph for this function:

◆ getUserChatNameSelectionForm()

ilChatroomFormFactory::getUserChatNameSelectionForm ( array  $name_options)

Returns chatname selection form.

Parameters
array<string,string>$name_options

Definition at line 239 of file class.ilChatroomFormFactory.php.

References ILIAS\LTI\ToolProvider\$key, $txt, ILIAS\Repository\lng(), and ILIAS\Repository\user().

240  {
241  $form = new ilPropertyFormGUI();
242 
243  $radio = new ilRadioGroupInputGUI($this->lng->txt('select_custom_username'), 'custom_username_radio');
244 
245  foreach ($name_options as $key => $option) {
246  $opt = new ilRadioOption($option, $key);
247  $radio->addOption($opt);
248  }
249 
250  $custom_opt = new ilRadioOption($this->lng->txt('custom_username'), 'custom_username');
251  $radio->addOption($custom_opt);
252 
253  $txt = new ilTextInputGUI($this->lng->txt('preferred_chatname'), 'custom_username_text');
254  $custom_opt->addSubItem($txt);
255  $form->addItem($radio);
256 
257  if ($this->user->isAnonymous()) {
258  $radio->setValue('anonymousName');
259  } else {
260  $radio->setValue('fullname');
261  }
262 
263  return $form;
264  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property in a property form.
string $key
Consumer key/client ID value.
Definition: System.php:193
$txt
Definition: error.php:14
+ Here is the call graph for this function:

◆ mergeValuesTrafo()

ilChatroomFormFactory::mergeValuesTrafo ( )
private

Definition at line 91 of file class.ilChatroomFormFactory.php.

References ILIAS\Repository\refinery().

Referenced by getSettingsForm().

92  {
93  return $this->refinery->custom()->transformation(static fn(array $values): array => array_merge(...$values));
94  }
A transformation is a function from one datatype to another.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saniziteArrayElementsTrafo()

ilChatroomFormFactory::saniziteArrayElementsTrafo ( )
private

Definition at line 96 of file class.ilChatroomFormFactory.php.

References $data, ILIAS\LTI\ToolProvider\$key, ILIAS\Repository\refinery(), and ilUtil\stripSlashes().

Referenced by getSettingsForm().

97  {
98  $sanitize = static function (array $data) use (&$sanitize): array {
99  foreach ($data as $key => $value) {
100  if (is_array($value)) {
101  $data[$key] = $sanitize($value);
102  } elseif (is_string($value)) {
103  $data[$key] = ilUtil::stripSlashes($value);
104  }
105  }
106 
107  return $data;
108  };
109 
110  return $this->refinery->custom()->transformation($sanitize);
111  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
string $key
Consumer key/client ID value.
Definition: System.php:193
A transformation is a function from one datatype to another.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $http

ILIAS HTTP Services ilChatroomFormFactory::$http
protected

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

Referenced by getClientSettingsForm().

◆ $lng

ilLanguage ilChatroomFormFactory::$lng
protected

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

◆ $refinery

ILIAS Refinery Factory ilChatroomFormFactory::$refinery
protected

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

◆ $ui_factory

ILIAS UI Factory ilChatroomFormFactory::$ui_factory
protected

Definition at line 35 of file class.ilChatroomFormFactory.php.

◆ $user

ilObjUser ilChatroomFormFactory::$user
protected

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

◆ PROP_ALLOW_ANONYMOUS

const ilChatroomFormFactory::PROP_ALLOW_ANONYMOUS = 'allow_anonymous'

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

◆ PROP_ALLOW_CUSTOM_NAMES

const ilChatroomFormFactory::PROP_ALLOW_CUSTOM_NAMES = 'allow_custom_usernames'

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

Referenced by ilChatroomSettingsGUI\saveGeneral().

◆ PROP_AUTOGEN_USERNAMES

const ilChatroomFormFactory::PROP_AUTOGEN_USERNAMES = 'autogen_usernames'

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

Referenced by ilChatroomSettingsGUI\saveGeneral().

◆ PROP_DISPLAY_PAST_MSG

const ilChatroomFormFactory::PROP_DISPLAY_PAST_MSG = 'display_past_msgs'

Definition at line 26 of file class.ilChatroomFormFactory.php.

◆ PROP_ENABLE_HISTORY

const ilChatroomFormFactory::PROP_ENABLE_HISTORY = 'enable_history'

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

◆ PROP_ONLINE_STATUS

const ilChatroomFormFactory::PROP_ONLINE_STATUS = 'online_status'

Definition at line 24 of file class.ilChatroomFormFactory.php.

Referenced by ilChatroomSettingsGUI\saveGeneral().

◆ PROP_TILE_IMAGE

const ilChatroomFormFactory::PROP_TILE_IMAGE = 'tile_image'

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

Referenced by ilChatroomSettingsGUI\saveGeneral().

◆ PROP_TITLE_AND_DESC

const ilChatroomFormFactory::PROP_TITLE_AND_DESC = 'title_and_desc'

Definition at line 23 of file class.ilChatroomFormFactory.php.

Referenced by ilChatroomSettingsGUI\saveGeneral().


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