chat.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. define('CHAMILO_LOAD_WYSIWYG', false);
  4. require_once __DIR__.'/../inc/global.inc.php';
  5. api_protect_course_script(true);
  6. Event::event_access_tool(TOOL_CHAT);
  7. $logInfo = [
  8. 'tool' => TOOL_CHAT,
  9. 'tool_id' => 0,
  10. 'tool_id_detail' => 0,
  11. 'action' => 'start',
  12. 'action_details' => 'start-chat',
  13. ];
  14. Event::registerLog($logInfo);
  15. // View
  16. $externalCSS = [
  17. 'jquery-emojiarea/jquery.emojiarea.css',
  18. 'jquery-textcomplete/jquery.textcomplete.css',
  19. 'emojione/css/emojione.min.css',
  20. 'emojione/css/autocomplete.css',
  21. 'highlight/styles/github.css',
  22. ];
  23. foreach ($externalCSS as $css) {
  24. $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_JS_PATH).$css);
  25. }
  26. $htmlHeadXtra[] = api_get_css(api_get_path(WEB_CSS_PATH).'chat.css');
  27. $htmlHeadXtra[] = api_get_css(api_get_path(WEB_CSS_PATH).'markdown.css');
  28. $externalJS = [
  29. 'highlight/highlight.pack.js',
  30. 'jquery-textcomplete/jquery.textcomplete.js',
  31. 'emojione/js/emojione.min.js',
  32. 'jquery-emojiarea/jquery.emojiarea.js',
  33. ];
  34. foreach ($externalJS as $js) {
  35. $htmlHeadXtra[] = api_get_js($js);
  36. }
  37. $iconList = [];
  38. foreach (Emojione\Emojione::$shortcode_replace as $key => $icon) {
  39. if (!in_array($key, CourseChatUtils::getEmojisToInclude())) {
  40. continue;
  41. }
  42. $iconList[$key] = strtoupper($icon).'.png';
  43. }
  44. $view = new Template(get_lang('Chat'), false, false, false, true, false);
  45. $view->assign('icons', $iconList);
  46. $view->assign('emoji_strategy', CourseChatUtils::getEmojiStrategy());
  47. $view->assign('emoji_smile', \Emojione\Emojione::toImage(':smile:'));
  48. $view->assign('restrict_to_coach', api_get_configuration_value('course_chat_restrict_to_coach'));
  49. $template = $view->get_template('chat/chat.tpl');
  50. $content = $view->fetch($template);
  51. $view->assign('content', $content);
  52. $view->display_no_layout_template();