Initialize frontend and delivers required javascript files and configuration to the global template.
218 if (!self::$frontend_initialized) {
219 $clientSettings =
new ilSetting(
'chatroom');
221 if (!self::isOnScreenChatAccessible($clientSettings)) {
222 self::$frontend_initialized =
true;
228 $DIC->language()->loadLanguageModule(
'chatroom');
229 $DIC->language()->loadLanguageModule(
'user');
231 $renderer = $DIC->ui()->renderer();
234 $chatWindowTemplate =
new ilTemplate(
'tpl.chat-window.html',
false,
false,
'Services/OnScreenChat');
235 $chatWindowTemplate->setVariable(
'SUBMIT_ACTION', $renderer->render(
236 $factory->button()->standard($DIC->language()->txt(
'chat_osc_send'),
'onscreenchat-submit')
238 $chatWindowTemplate->setVariable(
'ADD_ACTION', $renderer->render(
239 $factory->symbol()->glyph()->add(
'addUser')
241 $chatWindowTemplate->setVariable(
'CLOSE_ACTION', $renderer->render(
246 $subscriberRepo =
new Subscriber($DIC->database(), $DIC->user());
249 'chatWindowTemplate' => $chatWindowTemplate->get(),
251 'tpl.chat-message.html',
254 'Services/OnScreenChat' 257 'tpl.chat-add-user.html',
260 'Services/OnScreenChat' 262 'userId' => $DIC->user()->getId(),
263 'username' => $DIC->user()->getLogin(),
264 'userListURL' => $DIC->ctrl()->getLinkTargetByClass(
271 'userProfileDataURL' => $DIC->ctrl()->getLinkTargetByClass(
273 'getUserProfileData',
278 'verifyLoginURL' => $DIC->ctrl()->getLinkTargetByClass(
285 'renderNotificationItemsURL' => $DIC->ctrl()->getLinkTargetByClass(
287 'getRenderedNotificationItems',
293 'emoticons' => self::getEmoticons($settings),
294 'locale' => $DIC->language()->getLangKey(),
295 'initialUserData' => $subscriberRepo->getInitialUserProfileData(),
296 'enabledBrowserNotifications' => (
297 $clientSettings->get(
'enable_browser_notifications',
false) &&
298 (bool)
ilUtil::yn2tf($DIC->user()->getPref(
'chat_osc_browser_notifications'))
304 'url' => $settings->generateClientUrl() .
'/' . $settings->getInstance() .
'-im',
305 'subDirectory' => $settings->getSubDirectory() .
'/socket.io',
306 'userId' => $DIC->user()->getId(),
307 'username' => $DIC->user()->getLogin(),
310 $DIC->language()->toJS([
311 'chat_osc_no_usr_found',
312 'chat_osc_emoticons',
313 'chat_osc_write_a_msg',
316 'chat_osc_invite_to_conversation',
319 'chat_osc_subs_rej_msgs',
320 'chat_osc_subs_rej_msgs_p',
321 'chat_osc_self_rej_msgs',
322 'chat_osc_search_modal_info',
323 'chat_osc_head_grp_x_persons',
325 'chat_osc_conversations',
326 'chat_osc_sure_to_leave_grp_conv',
327 'chat_osc_user_left_grp_conv',
330 'chat_osc_leave_grp_conv',
332 'chat_osc_nc_conv_x_p',
333 'chat_osc_nc_conv_x_s',
334 'chat_osc_nc_no_conv',
343 $page->
addJavaScript(
'./libs/bower/bower_components/jquery-outside-events/jquery.ba-outside-events.min.js');
344 $page->
addJavaScript(
'./libs/bower/bower_components/jqueryui-touch-punch/jquery.ui.touch-punch.min.js');
345 $page->addJavascript(
'./Services/UIComponent/Modal/js/Modal.js');
346 $page->addJavascript(
'./libs/bower/bower_components/moment/min/moment-with-locales.min.js');
347 $page->addJavascript(
'./Services/Notifications/js/browser_notifications.js');
348 $page->addJavascript(
'./Services/OnScreenChat/js/onscreenchat-notifications.js');
349 $page->addJavascript(
'./Services/OnScreenChat/js/moment.js');
350 $page->addJavascript(
'./Modules/Chatroom/chat/node_modules/socket.io-client/dist/socket.io.js');
351 $page->addJavascript(
'./Services/OnScreenChat/js/chat.js');
352 $page->addJavascript(
'./Services/OnScreenChat/js/onscreenchat.js');
353 $page->
addOnLoadCode(
"il.Chat.setConfig(" . json_encode($chatConfig) .
");");
354 $page->
addOnLoadCode(
"il.OnScreenChat.setConfig(" . json_encode($guiConfig) .
");");
356 $page->
addOnLoadCode(
'il.OnScreenChatNotifications.init(' . json_encode([
357 'conversationIdleTimeThreshold' => max(
359 (
int) $clientSettings->get(
'conversation_idle_state_in_minutes', 1)
361 'logLevel' => $DIC[
'ilLoggerFactory']->getSettings()->getLevelByComponent(
'osch'),
364 self::$frontend_initialized =
true;
addOnLoadCode($a_code, $a_batch=2)
Add on load code.
addJavaScript($a_js_file, $a_add_version_parameter=true, $a_batch=2)
Add a javascript file that should be included in the header.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static initjQueryUI($a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components.txt for included components)
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
static yn2tf($a_yn)
convert "y"/"n" to true/false
static initLinkify($a_tpl=null)
Init Linkify.