195 : void
196 {
198
199 if (!self::$frontend_initialized) {
200 $clientSettings =
new ilSetting(
'chatroom');
201
202 if (!self::isOnScreenChatAccessible($clientSettings)) {
203 self::$frontend_initialized = true;
204 return;
205 }
206
208
209 $DIC->language()->loadLanguageModule(
'chatroom');
210 $DIC->language()->loadLanguageModule(
'user');
211
212 $renderer =
$DIC->ui()->renderer();
214
215 $chatWindowTemplate =
new ilTemplate(
'tpl.chat-window.html',
false,
false,
'Services/OnScreenChat');
216 $chatWindowTemplate->setVariable('SUBMIT_ACTION', $renderer->render(
217 $factory->button()->standard(
$DIC->language()->txt(
'chat_osc_send'),
'onscreenchat-submit')
218 ));
219 $chatWindowTemplate->setVariable('ADD_ACTION', $renderer->render(
220 $factory->symbol()->glyph()->add(
'addUser')
221 ));
222 $chatWindowTemplate->setVariable('MINIMIZE_ACTION', $renderer->render(
224 ));
226
228
229 $guiConfig = [
230 'chatWindowTemplate' => $chatWindowTemplate->get(),
232 'tpl.chat-message.html',
233 false,
234 false,
235 'Services/OnScreenChat'
236 ))->get(),
238 'tpl.chat-add-user.html',
239 false,
240 false,
241 'Services/OnScreenChat'
242 ))->get(),
243 'userId' =>
$DIC->user()->getId(),
244 'username' =>
$DIC->user()->getLogin(),
245 'userListURL' =>
$DIC->ctrl()->getLinkTargetByClass(
246 'ilonscreenchatgui',
247 'getUserList',
248 '',
249 true,
250 false
251 ),
252 'userProfileDataURL' =>
$DIC->ctrl()->getLinkTargetByClass(
253 'ilonscreenchatgui',
254 'getUserProfileData',
255 '',
256 true,
257 false
258 ),
259 'verifyLoginURL' =>
$DIC->ctrl()->getLinkTargetByClass(
260 'ilonscreenchatgui',
261 'verifyLogin',
262 '',
263 true,
264 false
265 ),
266 'renderConversationItemsURL' =>
$DIC->ctrl()->getLinkTargetByClass(
267 'ilonscreenchatgui',
268 'getRenderedConversationItems',
269 '',
270 true,
271 false
272 ),
275 'locale' =>
$DIC->language()->getLangKey(),
276 'initialUserData' => $subscriberRepo->getInitialUserProfileData(),
277 'enabledBrowserNotifications' => (
278 $clientSettings->get('enable_browser_notifications', '0') &&
280 ),
281 'broadcast_typing' => (
283 ),
285 ];
286
287 $chatConfig = [
289 'subDirectory' =>
$settings->getSubDirectory() .
'/socket.io',
290 'userId' =>
$DIC->user()->getId(),
291 'username' =>
$DIC->user()->getLogin(),
292 ];
293
294 $DIC->language()->toJS([
295 'chat_osc_no_usr_found',
296 'chat_osc_emoticons',
297 'chat_osc_write_a_msg',
298 'autocomplete_more',
299 'chat_osc_minimize',
300 'chat_osc_invite_to_conversation',
301 'chat_osc_user',
302 'chat_osc_add_user',
303 'chat_osc_subs_rej_msgs',
304 'chat_osc_subs_rej_msgs_p',
305 'chat_osc_self_rej_msgs',
306 'chat_osc_search_modal_info',
307 'chat_osc_head_grp_x_persons',
308 'osc_noti_title',
309 'chat_osc_conversations',
310 'chat_osc_sure_to_leave_grp_conv',
311 'chat_osc_user_left_grp_conv',
312 'confirm',
313 'cancel',
314 'chat_osc_leave_grp_conv',
315 'chat_osc_no_conv',
316 'chat_osc_nc_conv_x_p',
317 'chat_osc_nc_conv_x_s',
318 'chat_osc_nc_no_conv',
319 'chat_user_x_is_typing',
320 'chat_users_are_typing',
321 'today',
322 'yesterday',
323 ], $page);
324
328
329 $page->
addJavaScript(
'./node_modules/jquery-outside-events/jquery.ba-outside-events.js');
330 $page->
addJavaScript(
'./node_modules/@andxor/jquery-ui-touch-punch-fix/jquery.ui.touch-punch.js');
331 $page->addJavascript('./Services/UIComponent/Modal/js/Modal.js');
332 $page->addJavascript('./node_modules/moment/min/moment-with-locales.min.js');
333 $page->addJavascript('./Services/Notifications/js/browser_notifications.js');
334 $page->addJavascript('./Services/OnScreenChat/js/onscreenchat-notifications.js');
335 $page->addJavascript('./Services/OnScreenChat/js/moment.js');
336 $page->addJavascript('./Modules/Chatroom/chat/node_modules/socket.io-client/dist/socket.io.js');
337 $page->addJavascript('./Services/OnScreenChat/js/chat.js');
338 $page->addJavascript('./Services/OnScreenChat/js/onscreenchat.js');
339 $page->
addOnLoadCode(
"il.Chat.setConfig(" . json_encode($chatConfig, JSON_THROW_ON_ERROR) .
");");
340 $page->
addOnLoadCode(
"il.OnScreenChat.setConfig(" . json_encode($guiConfig, JSON_THROW_ON_ERROR) .
");");
342 $page->
addOnLoadCode(
'il.OnScreenChatNotifications.init(' . json_encode([
343 'conversationIdleTimeThreshold' => max(
344 1,
345 (int) $clientSettings->get('conversation_idle_state_in_minutes', '1')
346 ),
347 'logLevel' =>
$DIC[
'ilLoggerFactory']->getSettings()->getLevelByComponent(
'osch'),
348 ], JSON_THROW_ON_ERROR) . ');');
349
350 self::$frontend_initialized = true;
351 }
352 }
static initLinkify(?ilGlobalTemplateInterface $a_tpl=null)
static getEmoticons(ilChatroomServerSettings $chatSettings)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
special template class to simplify handling of ITX/PEAR
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static yn2tf(string $a_yn)
static img(string $a_src, ?string $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static initjQueryUI(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components....
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
addJavaScript(string $a_js_file, bool $a_add_version_parameter=true, int $a_batch=2)
Add a javascript file that should be included in the header.
addOnLoadCode(string $a_code, int $a_batch=2)
Add on load code.