19 declare(strict_types=1);
49 public function template(
bool $read_only, array $initial,
string $input,
string $output):
ilTemplate 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'));
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'))));
65 $room_tpl->setVariable(
'CHAT_OUTPUT', $output);
66 $room_tpl->setVariable(
'CHAT_INPUT', $input);
73 public function initialData(array $users,
bool $show_auto_messages, ?
string $redirect_url, array $userinfo, array
$messages): array
76 $initial[
'users'] = $users;
77 $initial[
'redirect_url'] = $redirect_url;
78 $initial[
'profile_image_url'] = $this->
ilCtrl->getLinkTarget($this->gui,
'view-getUserProfileImages',
'',
true);
80 $initial[
'subdirectory'] = $this->
settings->getSubDirectory();
82 $initial[
'userinfo'] = $userinfo;
87 'show_auto_msg' => $show_auto_messages,
88 'system_message_update_url' => $this->
ilCtrl->getFormAction($this->gui,
'view-toggleAutoMessageDisplayState',
'',
true,
false),
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',
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',
135 fn($v) => json_encode($this->ilLng->txt($v), JSON_THROW_ON_ERROR),
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'),
145 'LBL_LAYOUT' =>
'layout',
146 'LBL_SHOW_SETTINGS' =>
'show_settings',
147 'LBL_USER_IN_ROOM' =>
'user_in_room',
148 'LOADING_IMAGE' =>
'media/loader.svg',
151 $set_vars(
array_map($this->ilLng->txt(...), $vars));
157 return match ($this->
user->getTimeFormat()) {
__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,)
renderLanguageVariables(ilTemplate $room_tpl)
setVariable($variable, $value='')
Sets a variable value.
initialData(array $users, bool $show_auto_messages, ?string $redirect_url, array $userinfo, array $messages)
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