163 if (!self::$frontend_initialized) {
164 $clientSettings =
new ilSetting(
'chatroom');
166 if (!self::isOnScreenChatAccessible($clientSettings)) {
167 self::$frontend_initialized =
true;
173 $DIC->language()->loadLanguageModule(
'chatroom');
174 $DIC->language()->loadLanguageModule(
'user');
176 $renderer = $DIC->ui()->renderer();
177 $factory = $DIC->ui()->factory();
179 $chatWindowTemplate =
new ilTemplate(
'tpl.chat-window.html',
false,
false,
'Services/OnScreenChat');
180 $chatWindowTemplate->setVariable(
'SUBMIT_ACTION', $renderer->render(
181 $factory->button()->standard($DIC->language()->txt(
'chat_osc_send'),
'onscreenchat-submit')
183 $chatWindowTemplate->setVariable(
'ADD_ACTION', $renderer->render(
184 $factory->symbol()->glyph()->add(
'addUser')
186 $chatWindowTemplate->setVariable(
'MINIMIZE_ACTION', $renderer->render(
187 $factory->button()->minimize()
191 $subscriberRepo =
new Subscriber($DIC->database(), $DIC->user());
194 'chatWindowTemplate' => $chatWindowTemplate->get(),
196 'tpl.chat-message.html',
199 'Services/OnScreenChat' 202 'tpl.chat-add-user.html',
205 'Services/OnScreenChat' 207 'userId' => $DIC->user()->getId(),
208 'username' => $DIC->user()->getLogin(),
209 'userListURL' => $DIC->ctrl()->getLinkTargetByClass(
216 'userProfileDataURL' => $DIC->ctrl()->getLinkTargetByClass(
218 'getUserProfileData',
223 'verifyLoginURL' => $DIC->ctrl()->getLinkTargetByClass(
230 'renderConversationItemsURL' => $DIC->ctrl()->getLinkTargetByClass(
232 'getRenderedConversationItems',
238 'locale' => $DIC->language()->getLangKey(),
239 'initialUserData' => $subscriberRepo->getInitialUserProfileData(),
240 'enabledBrowserNotifications' => (
241 $clientSettings->get(
'enable_browser_notifications',
'0') &&
242 ilUtil::yn2tf((
string) $DIC->user()->getPref(
'chat_osc_browser_notifications'))
244 'broadcast_typing' => (
245 ilUtil::yn2tf((
string) $DIC->user()->getPref(
'chat_broadcast_typing'))
252 'subDirectory' =>
$settings->getSubDirectory() .
'/socket.io',
253 'userId' => $DIC->user()->getId(),
254 'username' => $DIC->user()->getLogin(),
257 $DIC->language()->toJS([
258 'chat_osc_no_usr_found',
259 'chat_osc_write_a_msg',
262 'chat_osc_invite_to_conversation',
265 'chat_osc_subs_rej_msgs',
266 'chat_osc_subs_rej_msgs_p',
267 'chat_osc_self_rej_msgs',
268 'chat_osc_search_modal_info',
269 'chat_osc_head_grp_x_persons',
271 'chat_osc_conversations',
272 'chat_osc_sure_to_leave_grp_conv',
273 'chat_osc_user_left_grp_conv',
276 'chat_osc_leave_grp_conv',
278 'chat_osc_nc_conv_x_p',
279 'chat_osc_nc_conv_x_s',
280 'chat_osc_nc_no_conv',
281 'chat_user_x_is_typing',
282 'chat_users_are_typing',
291 $page->
addJavaScript(
'./node_modules/jquery-outside-events/jquery.ba-outside-events.js');
292 $page->
addJavaScript(
'./node_modules/@andxor/jquery-ui-touch-punch-fix/jquery.ui.touch-punch.js');
293 $page->addJavascript(
'./Services/UIComponent/Modal/js/Modal.js');
294 $page->addJavascript(
'./node_modules/moment/min/moment-with-locales.min.js');
295 $page->addJavascript(
'./Services/Notifications/js/browser_notifications.js');
296 $page->addJavascript(
'./Services/OnScreenChat/js/onscreenchat-notifications.js');
297 $page->addJavascript(
'./Services/OnScreenChat/js/moment.js');
298 $page->addJavascript(
'./Modules/Chatroom/chat/node_modules/socket.io-client/dist/socket.io.js');
299 $page->addJavascript(
'./Services/OnScreenChat/js/chat.js');
300 $page->addJavascript(
'./Services/OnScreenChat/js/onscreenchat.js');
301 $page->
addOnLoadCode(
"il.Chat.setConfig(" . json_encode($chatConfig, JSON_THROW_ON_ERROR) .
");");
302 $page->
addOnLoadCode(
"il.OnScreenChat.setConfig(" . json_encode($guiConfig, JSON_THROW_ON_ERROR) .
");");
304 $page->
addOnLoadCode(
'il.OnScreenChatNotifications.init(' . json_encode([
305 'conversationIdleTimeThreshold' => max(
307 (
int) $clientSettings->get(
'conversation_idle_state_in_minutes',
'1')
309 'logLevel' => $DIC[
'ilLoggerFactory']->
getSettings()->getLevelByComponent(
'osch'),
310 ], JSON_THROW_ON_ERROR) .
');');
312 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)