ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilChatroomFormFactory.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
5 
13 {
17  public function __construct()
18  {
19  }
20 
27  public function getCreationForm()
28  {
32  global $lng;
33 
34  $form = new ilPropertyFormGUI();
35  $title = new ilTextInputGUI($lng->txt('title'), 'title');
36  $title->setRequired(true);
37  $form->addItem($title);
38 
39  $description = new ilTextAreaInputGUI($lng->txt('description'), 'desc');
40  $form->addItem($description);
41 
42  return $this->addDefaultBehaviour($form);
43  }
44 
50  public static function applyValues(ilPropertyFormGUI $form, array $values)
51  {
52  foreach($values as $key => $value)
53  {
54  $field = $form->getItemByPostVar($key);
55  if(!$field)
56  {
57  continue;
58  }
59 
60  switch(strtolower(get_class($field)))
61  {
62  case 'ilcheckboxinputgui':
63  if($value)
64  {
65  $field->setChecked(true);
66  }
67  break;
68 
69  default:
70  $field->setValue($value);
71  }
72  }
73  }
74 
79  public function getSettingsForm()
80  {
84  global $lng;
85 
86  $form = new ilPropertyFormGUI();
87  $title = new ilTextInputGUI($lng->txt('title'), 'title');
88  $title->setRequired(true);
89  $form->addItem($title);
90 
91  $description = new ilTextAreaInputGUI($lng->txt('description'), 'desc');
92  $form->addItem($description);
93 
94  $cb = new ilCheckboxInputGUI($lng->txt('allow_anonymous'), 'allow_anonymous');
95  $cb->setInfo($lng->txt('anonymous_hint'));
96  $form->addItem($cb);
97 
98  $txt = new ilTextInputGUI($lng->txt('autogen_usernames'), 'autogen_usernames');
99  $txt->setRequired(true);
100  $txt->setInfo($lng->txt('autogen_usernames_info'));
101  $form->addItem($txt);
102 
103  $cb = new ilCheckboxInputGUI($lng->txt('allow_custom_usernames'), 'allow_custom_usernames');
104  $form->addItem($cb);
105 
106  $cb_history = new ilCheckboxInputGUI($lng->txt('enable_history'), 'enable_history');
107  $form->addItem($cb_history);
108 
109  $num_msg_history = new ilNumberInputGUI($lng->txt('display_past_msgs'), 'display_past_msgs');
110  $num_msg_history->setInfo($lng->txt('hint_display_past_msgs'));
111  $num_msg_history->setMinValue(0);
112  $num_msg_history->setMaxValue(100);
113  $form->addItem($num_msg_history);
114 
115  $cb = new ilCheckboxInputGUI($lng->txt('private_rooms_enabled'), 'private_rooms_enabled');
116  $cb->setInfo($lng->txt('private_rooms_enabled_info'));
117  $form->addItem($cb);
118 
119  return $form;
120  }
121 
126  public function getFileUploadForm()
127  {
131  global $lng;
132 
133  $form = new ilPropertyFormGUI();
134  $file_input = new ilFileInputGUI();
135 
136  $file_input->setPostVar('file_to_upload');
137  $file_input->setTitle($lng->txt('upload'));
138  $form->addItem($file_input);
139  $form->addCommandButton('UploadFile-uploadFile', $lng->txt('submit'));
140 
141  $form->setTarget('_blank');
142 
143  return $form;
144  }
145 
151  private function addDefaultBehaviour(ilPropertyFormGUI $form)
152  {
156  global $lng;
157 
158  $form->addCommandButton('create-save', $lng->txt('create'));
159  $form->addCommandButton('cancel', $lng->txt('cancel'));
160 
161  return $form;
162  }
163 
168  public function getPeriodForm()
169  {
173  global $lng;
174 
175  $form = new ilPropertyFormGUI();
176  $form->setPreventDoubleSubmission(false);
177 
178  require_once 'Services/Form/classes/class.ilDateDurationInputGUI.php';
179  $duration = new ilDateDurationInputGUI($lng->txt('period'), 'timeperiod');
180 
181  $duration->setStartText($lng->txt('duration_from'));
182  $duration->setEndText($lng->txt('duration_to'));
183  $duration->setShowTime(true);
184  $form->addItem($duration);
185 
186  return $form;
187  }
188 
194  public function getUserChatNameSelectionForm(array $name_options)
195  {
200  global $lng, $ilUser;
201 
202  $form = new ilPropertyFormGUI();
203 
204  $radio = new ilRadioGroupInputGUI($lng->txt('select_custom_username'), 'custom_username_radio');
205 
206  foreach($name_options as $key => $option)
207  {
208  $opt = new ilRadioOption($option, $key);
209  $radio->addOption($opt);
210  }
211 
212  $custom_opt = new ilRadioOption($lng->txt('custom_username'), 'custom_username');
213  $radio->addOption($custom_opt);
214 
215  $txt = new ilTextInputGUI($lng->txt('custom_username'), 'custom_username_text');
216  $custom_opt->addSubItem($txt);
217  $form->addItem($radio);
218 
219  if($ilUser->isAnonymous())
220  {
221  $radio->setValue('anonymousName');
222  }
223  else
224  {
225  $radio->setValue('fullname');
226  }
227 
228  return $form;
229  }
230 
236  public function getSessionForm(array $sessions)
237  {
241  global $lng;
242 
243  $form = new ilPropertyFormGUI();
244  $form->setPreventDoubleSubmission(false);
245  $list = new ilSelectInputGUI($lng->txt('session'), 'session');
246 
247  $options = array();
248 
249  foreach($sessions as $session)
250  {
251  $start = new ilDateTime($session['connected'], IL_CAL_UNIX);
252  $end = new ilDateTime($session['disconnected'], IL_CAL_UNIX);
253 
254  $options[$session['connected'] . ',' .
255  $session['disconnected']] = ilDatePresentation::formatPeriod($start, $end);
256  }
257 
258  $list->setOptions($options);
259  $list->setRequired(true);
260 
261  $form->addItem($list);
262 
263  return $form;
264  }
265 
270  public function getGeneralSettingsForm()
271  {
275  global $lng;
276 
277  $form = new ilPropertyFormGUI();
278 
279  $address = new ilTextInputGUI($lng->txt('chatserver_address'), 'address');
280  $address->setRequired(true);
281  $form->addItem($address);
282 
283  $port = new ilNumberInputGUI($lng->txt('chatserver_port'), 'port');
284  $port->setMinValue(1);
285  $port->setMaxValue(65535);
286  $port->setRequired(true);
287  $port->setInfo($lng->txt('port_info'));
288  $port->setSize(6);
289  $form->addItem($port);
290 
291  $priv_hosts = new ilTextInputGUI($lng->txt('priv_hosts'), 'priv_hosts');
292  $priv_hosts->setRequired(true);
293  $form->addItem($priv_hosts);
294 
295  $keystore = new ilTextInputGUI($lng->txt('keystore'), 'keystore');
296  $keystore->setRequired(true);
297  $keypass = new ilTextInputGUI($lng->txt('keypass'), 'keypass');
298  $keypass->setRequired(true);
299  $storepass = new ilTextInputGUI($lng->txt('storepass'), 'storepass');
300  $storepass->setRequired(true);
301 
302  $protocol = new ilRadioGroupInputGUI($lng->txt('protocol'), 'protocol');
303  $http = new ilRadioOption($lng->txt('http'), 'http');
304  $https = new ilRadioOption($lng->txt('https'), 'https');
305  $https->addSubItem($keystore);
306  $https->addSubItem($keypass);
307  $https->addSubItem($storepass);
308  $protocol->addOption($http);
309  $protocol->addOption($https);
310  $form->addItem($protocol);
311 
312  return $form;
313  }
314 
318  public function getClientSettingsForm()
319  {
323  global $lng;
324 
325  $form = new ilPropertyFormGUI();
326 
327  $cb = new ilCheckboxInputGUI($lng->txt('chat_enabled'), 'chat_enabled');
328  $form->addItem($cb);
329 
330  $cb = new ilCheckboxInputGUI($lng->txt('enable_osd'), 'enable_osd');
331  $cb->setInfo($lng->txt('hint_osd'));
332  $form->addItem($cb);
333 
334  $txt = new ilNumberInputGUI($lng->txt('osd_intervall'), 'osd_intervall');
335  $txt->setMinValue(1);
336  $txt->setRequired(true);
337  $txt->setInfo($lng->txt('hint_osd_interval'));
338  $cb->addSubItem($txt);
339 
340  $cb1 = new ilCheckboxInputGUI($lng->txt('play_invitation_sound'), 'play_invitation_sound');
341  $cb1->setInfo($lng->txt('play_invitation_sound'));
342  $cb->addSubItem($cb1);
343 
344  $cb = new ilCheckboxInputGUI($lng->txt('enable_smilies'), 'enable_smilies');
345  $cb->setInfo($lng->txt('hint_enable_smilies'));
346  $form->addItem($cb);
347 
348  $name = new ilTextInputGUI($lng->txt('instance_name'), 'name');
349  $name->setRequired(true);
350  $name->setValidationRegexp('/^[a-z0-9_-]+$/i');
351  $name->setInfo($lng->txt('hint_unique_name'));
352  $form->addItem($name);
353 
354  $url = new ilTextInputGUI($lng->txt('ilias_url'), 'url');
355  $url->setRequired(true);
356  $form->addItem($url);
357 
358  $user = new ilTextInputGUI($lng->txt('soap_user'), 'user');
359  $user->setInfo($lng->txt('soap_user_hint'));
360  $user->setRequired(true);
361  $form->addItem($user);
362 
363  $password = new ilPasswordInputGUI($lng->txt('soap_user_password'), 'password');
364  $password->setSkipSyntaxCheck(true);
365  $password->setRequired(true);
366  $form->addItem($password);
367 
368  return $form;
369  }
370 }
setPreventDoubleSubmission($a_val)
Set prevent double submission.
This class represents an option in a radio group.
getItemByPostVar($a_post_var)
Get Item by POST variable.
This class represents a selection list property in a property form.
This class represents a property form user interface.
This class represents a file property in a property form.
static formatPeriod(ilDateTime $start, ilDateTime $end)
Format a period of two date Shows: 14.
This class represents a checkbox property in a property form.
addItem($a_item)
Add Item (Property, SectionHeader).
const IL_CAL_UNIX
Class ilChatroomFormFactory.
setInfo($a_info)
Set Information Text.
input GUI for a time span (start and end date)
This class represents a property in a property form.
global $https
Definition: imgupload.php:15
setMinValue($a_minvalue, $a_display_always=false)
Set Minimum Value.
if(!is_array($argv)) $options
addSubItem($a_item)
Add Subitem.
This class represents a number property in a property form.
setSkipSyntaxCheck($a_val)
Set skip syntax check.
This class represents a text property in a property form.
Date and time handling
This class represents a password property in a property form.
addCommandButton($a_cmd, $a_text)
Add Command button.
$txt
Definition: error.php:10
setStartText($a_txt)
Set text, which will be shown before the start date.
global $ilUser
Definition: imgupload.php:15
global $lng
Definition: privfeed.php:40
This class represents a text area property in a property form.
static applyValues(ilPropertyFormGUI $form, array $values)
Applies given values to field in given form.
setRequired($a_required)
Set Required.