199 if (!self::$frontend_initialized) {
200 $clientSettings =
new ilSetting(
'chatroom');
202 if (!self::isOnScreenChatAccessible($clientSettings)) {
203 self::$frontend_initialized =
true;
209 $DIC->language()->loadLanguageModule(
'chatroom');
210 $DIC->language()->loadLanguageModule(
'user');
212 $renderer = $DIC->ui()->renderer();
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')
219 $chatWindowTemplate->setVariable(
'ADD_ACTION', $renderer->render(
220 $factory->symbol()->glyph()->add(
'addUser')
222 $chatWindowTemplate->setVariable(
'MINIMIZE_ACTION', $renderer->render(
227 $subscriberRepo =
new Subscriber($DIC->database(), $DIC->user());
230 'chatWindowTemplate' => $chatWindowTemplate->get(),
232 'tpl.chat-message.html',
235 'Services/OnScreenChat' 238 'tpl.chat-add-user.html',
241 'Services/OnScreenChat' 243 'userId' => $DIC->user()->getId(),
244 'username' => $DIC->user()->getLogin(),
245 'userListURL' => $DIC->ctrl()->getLinkTargetByClass(
252 'userProfileDataURL' => $DIC->ctrl()->getLinkTargetByClass(
254 'getUserProfileData',
259 'verifyLoginURL' => $DIC->ctrl()->getLinkTargetByClass(
266 'renderConversationItemsURL' => $DIC->ctrl()->getLinkTargetByClass(
268 'getRenderedConversationItems',
274 'emoticons' => self::getEmoticons(
$settings),
275 'locale' => $DIC->language()->getLangKey(),
276 'initialUserData' => $subscriberRepo->getInitialUserProfileData(),
277 'enabledBrowserNotifications' => (
278 $clientSettings->get(
'enable_browser_notifications',
'0') &&
279 ilUtil::yn2tf((
string) $DIC->user()->getPref(
'chat_osc_browser_notifications'))
281 'broadcast_typing' => (
282 ilUtil::yn2tf((
string) $DIC->user()->getPref(
'chat_broadcast_typing'))
289 'subDirectory' =>
$settings->getSubDirectory() .
'/socket.io',
290 'userId' => $DIC->user()->getId(),
291 'username' => $DIC->user()->getLogin(),
294 $DIC->language()->toJS([
295 'chat_osc_no_usr_found',
296 'chat_osc_emoticons',
297 'chat_osc_write_a_msg',
300 'chat_osc_invite_to_conversation',
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',
309 'chat_osc_conversations',
310 'chat_osc_sure_to_leave_grp_conv',
311 'chat_osc_user_left_grp_conv',
314 'chat_osc_leave_grp_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',
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(
345 (
int) $clientSettings->get(
'conversation_idle_state_in_minutes',
'1')
347 'logLevel' => $DIC[
'ilLoggerFactory']->
getSettings()->getLevelByComponent(
'osch'),
348 ], JSON_THROW_ON_ERROR) .
');');
350 self::$frontend_initialized =
true;
static initLinkify(?ilGlobalTemplateInterface $a_tpl=null)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
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.txt for included components)
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.
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
static yn2tf(string $a_yn)