ILIAS  trunk Revision v11.0_alpha-2645-g16283d3b3f8
ILIAS\Chatroom\BuildChat Class Reference
+ Collaboration diagram for ILIAS\Chatroom\BuildChat:

Public Member Functions

 __construct (private readonly ilCtrlInterface $ilCtrl, private readonly ilLanguage $ilLng, private readonly ilChatroomObjectGUI $gui, private readonly ilChatroom $room, private readonly ilChatroomServerSettings $settings, private readonly ilObjUser $user, private readonly UIFactory $ui_factory, private readonly UIRenderer $ui_renderer,)
 
 template (bool $read_only, array $initial, string $input, string $output)
 
 initialData (array $users, bool $show_auto_messages, ?string $redirect_url, array $userinfo, array $messages)
 

Private Member Functions

 renderLanguageVariables (ilTemplate $room_tpl)
 
 timeFormat ()
 

Detailed Description

Definition at line 35 of file BuildChat.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Chatroom\BuildChat::__construct ( private readonly ilCtrlInterface  $ilCtrl,
private readonly ilLanguage  $ilLng,
private readonly ilChatroomObjectGUI  $gui,
private readonly ilChatroom  $room,
private readonly ilChatroomServerSettings  $settings,
private readonly ilObjUser  $user,
private readonly UIFactory  $ui_factory,
private readonly UIRenderer  $ui_renderer 
)

Definition at line 37 of file BuildChat.php.

46  {
47  }

Member Function Documentation

◆ initialData()

ILIAS\Chatroom\BuildChat::initialData ( array  $users,
bool  $show_auto_messages,
?string  $redirect_url,
array  $userinfo,
array  $messages 
)

Definition at line 73 of file BuildChat.php.

References $messages, ilUtil\getImagePath(), and ILIAS\Repository\settings().

73  : array
74  {
75  $initial = [];
76  $initial['users'] = $users;
77  $initial['redirect_url'] = $redirect_url;
78  $initial['profile_image_url'] = $this->ilCtrl->getLinkTarget($this->gui, 'view-getUserProfileImages', '', true);
79  $initial['no_profile_image_url'] = ilUtil::getImagePath('placeholder/no_photo_xxsmall.jpg');
80  $initial['subdirectory'] = $this->settings->getSubDirectory();
81 
82  $initial['userinfo'] = $userinfo;
83  $initial['messages'] = $messages;
84 
85  $initial['state'] = [
86  'scrolling' => true,
87  'show_auto_msg' => $show_auto_messages,
88  'system_message_update_url' => $this->ilCtrl->getFormAction($this->gui, 'view-toggleAutoMessageDisplayState', '', true, false),
89  ];
90 
91  return $initial;
92  }
$messages
Definition: xapiexit.php:21
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
+ Here is the call graph for this function:

◆ renderLanguageVariables()

ILIAS\Chatroom\BuildChat::renderLanguageVariables ( ilTemplate  $room_tpl)
private

Definition at line 94 of file BuildChat.php.

References Vendor\Package\$a, ilUtil\getImagePath(), and HTML_Template_IT\setVariable().

Referenced by ILIAS\Chatroom\BuildChat\template().

94  : void
95  {
96  $set_vars = fn($a) => array_map($room_tpl->setVariable(...), array_keys($a), array_values($a));
97 
98  $js_translations = [
99  'LBL_MAINROOM' => 'chat_mainroom',
100  'LBL_JOIN' => 'chat_join',
101  'LBL_INVITE_TO_PRIVATE_ROOM' => 'invite_to_private_room',
102  'LBL_KICK' => 'chat_kick',
103  'LBL_BAN' => 'chat_ban',
104  'LBL_KICK_QUESTION' => 'kick_question',
105  'LBL_BAN_QUESTION' => 'ban_question',
106  'LBL_ADDRESS' => 'chat_address',
107  'LBL_WHISPER' => 'chat_whisper',
108  'LBL_CONNECT' => 'chat_connection_established',
109  'LBL_DISCONNECT' => 'chat_connection_disconnected',
110  'LBL_TO_MAINROOM' => 'chat_to_mainroom',
111  'LBL_WELCOME_TO_CHAT' => 'welcome_to_chat',
112  'LBL_USER_INVITED' => 'user_invited',
113  'LBL_USER_KICKED' => 'user_kicked',
114  'LBL_USER_BANNED' => 'user_banned',
115  'LBL_USER_INVITED_SELF' => 'user_invited_self',
116  'LBL_PRIVATE_ROOM_CLOSED' => 'private_room_closed',
117  'LBL_PRIVATE_ROOM_ENTERED' => 'private_room_entered',
118  'LBL_PRIVATE_ROOM_LEFT' => 'private_room_left',
119  'LBL_PRIVATE_ROOM_ENTERED_USER' => 'private_room_entered_user',
120  'LBL_KICKED_FROM_PRIVATE_ROOM' => 'kicked_from_private_room',
121  'LBL_OK' => 'ok',
122  'LBL_DELETE' => 'delete',
123  'LBL_INVITE' => 'chat_invite',
124  'LBL_CANCEL' => 'cancel',
125  'LBL_HISTORY_CLEARED' => 'history_cleared',
126  'LBL_CLEAR_ROOM_HISTORY' => 'clear_room_history',
127  'LBL_CLEAR_ROOM_HISTORY_QUESTION' => 'clear_room_history_question',
128  'LBL_END_WHISPER' => 'end_whisper',
129  'LBL_TIMEFORMAT' => 'lang_timeformat_no_sec',
130  'LBL_DATEFORMAT' => 'lang_dateformat',
131  'LBL_START_PRIVATE_CHAT' => 'start_private_chat',
132  ];
133 
134  $set_vars(array_map(
135  fn($v) => json_encode($this->ilLng->txt($v), JSON_THROW_ON_ERROR),
136  $js_translations
137  ));
138 
139  $this->ilLng->toJSMap([
140  'chat_user_x_is_typing' => $this->ilLng->txt('chat_user_x_is_typing'),
141  'chat_users_are_typing' => $this->ilLng->txt('chat_users_are_typing'),
142  ]);
143 
144  $vars = [
145  'LBL_LAYOUT' => 'layout',
146  'LBL_SHOW_SETTINGS' => 'show_settings',
147  'LBL_USER_IN_ROOM' => 'user_in_room',
148  'LOADING_IMAGE' => 'media/loader.svg',
149  ];
150 
151  $set_vars(array_map($this->ilLng->txt(...), $vars));
152  $room_tpl->setVariable('LOADING_IMAGE', ilUtil::getImagePath('media/loader.svg'));
153  }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ template()

ILIAS\Chatroom\BuildChat::template ( bool  $read_only,
array  $initial,
string  $input,
string  $output 
)

Definition at line 49 of file BuildChat.php.

References ILIAS\Chatroom\BuildChat\renderLanguageVariables(), ILIAS\Repository\settings(), ILIAS\Chatroom\BuildChat\timeFormat(), and ILIAS\Repository\user().

49  : ilTemplate
50  {
51  $room_tpl = new ilTemplate('tpl.chatroom.html', true, true, 'components/ILIAS/Chatroom');
52  $set_json_var = fn($var, $value) => $room_tpl->setVariable($var, json_encode($value));
53  $set_json_var('BASEURL', $this->settings->generateClientUrl());
54  $set_json_var('INSTANCE', $this->settings->getInstance());
55  $set_json_var('SCOPE', $this->room->getRoomId());
56  $set_json_var('POSTURL', ILIAS_HTTP_PATH . '/' . $this->ilCtrl->getLinkTarget($this->gui, 'postMessage', '', true));
57  $room_tpl->setVariable('JS_CALL', 'il.Chatroom.' . ($read_only ? 'runReadOnly' : 'run'));
58 
59  $set_json_var('INITIAL_DATA', $initial);
60  $set_json_var('INITIAL_USERS', $this->room->getConnectedUsers());
61  $set_json_var('DATE_FORMAT', (string) $this->user->getDateFormat());
62  $set_json_var('TIME_FORMAT', $this->timeFormat());
63  $set_json_var('NOTHING_FOUND', $this->ui_renderer->render($this->ui_factory->messageBox()->info($this->ilLng->txt('chat_osc_no_usr_found'))));
64 
65  $room_tpl->setVariable('CHAT_OUTPUT', $output);
66  $room_tpl->setVariable('CHAT_INPUT', $input);
67 
68  $this->renderLanguageVariables($room_tpl);
69 
70  return $room_tpl;
71  }
renderLanguageVariables(ilTemplate $room_tpl)
Definition: BuildChat.php:94
+ Here is the call graph for this function:

◆ timeFormat()

ILIAS\Chatroom\BuildChat::timeFormat ( )
private

Definition at line 155 of file BuildChat.php.

References ilCalendarSettings\TIME_FORMAT_12, and ILIAS\Repository\user().

Referenced by ILIAS\Chatroom\BuildChat\template().

155  : string
156  {
157  return match ($this->user->getTimeFormat()) {
158  (string) ilCalendarSettings::TIME_FORMAT_12 => 'h:ia',
159  default => 'H:i',
160  };
161  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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