/** * Generates JavaScript code that starts client side application. * * @param Request $request Incoming request. * @param array $operator Current operator. * @return string JavaScript code that starts "users" client side * application. */ protected function startJsApplication(Request $request, $operator) { // Load dialogs style options $chat_style = new ChatStyle(ChatStyle::getCurrentStyle()); $chat_style_config = $style_config = $chat_style->getConfigurations(); // Load page style options $page_style_config = $style_config = $this->getStyle()->getConfigurations(); return sprintf('jQuery(document).ready(function() {Mibew.Application.start(%s);});', json_encode(array('server' => array('url' => $this->generateUrl('users_update'), 'requestsFrequency' => Settings::get('updatefrequency_operator')), 'agent' => array('id' => $operator['operatorid']), 'page' => array('mibewBasePath' => $request->getBasePath(), 'mibewBaseUrl' => $request->getBaseUrl(), 'showOnlineOperators' => Settings::get('showonlineoperators') == '1', 'showVisitors' => Settings::get('enabletracking') == '1', 'showPopup' => Settings::get('enablepopupnotification') == '1', 'threadTag' => $page_style_config['users']['thread_tag'], 'visitorTag' => $page_style_config['users']['visitor_tag'], 'agentLink' => $request->getBaseUrl() . '/operator/chat', 'geoLink' => Settings::get('geolink'), 'trackedLink' => $request->getBaseUrl() . '/operator/history/user-track', 'banLink' => $request->getBaseUrl() . '/operator/ban', 'inviteLink' => $request->getBaseUrl() . '/operator/invite', 'chatWindowParams' => $chat_style_config['chat']['window'], 'geoWindowParams' => Settings::get('geolinkparams'), 'trackedUserWindowParams' => $page_style_config['tracked']['user_window'], 'trackedVisitorWindowParams' => $page_style_config['tracked']['visitor_window'], 'banWindowParams' => $page_style_config['ban']['window'], 'inviteWindowParams' => $chat_style_config['chat']['window'])))); }
/** * Generates a JavaScript file with popup CSS file loader. * * @param Request $request * @return JsonResponse */ public function loadPopupStyleAction(Request $request) { $style_name = $request->attributes->get('style'); if (!$style_name) { $style_name = ChatStyle::getDefaultStyle(); } $style = new ChatStyle($style_name); $configs = $style->getConfigurations(); $response = new JsonResponse(); if ($configs['chat']['iframe']['css']) { $generator = $this->getAssetManager()->getUrlGenerator(); $css = $generator->generate($style->getFilesPath() . '/' . $configs['chat']['iframe']['css'], UrlGeneratorInterface::ABSOLUTE_URL); $response->setData($css); $response->setCallback('Mibew.Utils.loadStyleSheet'); } return $response; }
/** * Prepare some data for chat for both user and operator * * @param Thread $thread thread object * @return array Array of chat view data */ function setup_chatview(Thread $thread) { $data = prepare_chat_app_data(); // Get group info if (!empty($thread->groupId)) { $group = group_by_id($thread->groupId); $group = get_top_level_group($group); } else { $group = array(); } // Create some empty arrays $data['chat'] = array('messageForm' => array(), 'links' => array(), 'windowsParams' => array()); // Set thread params $data['chat']['thread'] = array('id' => $thread->id, 'token' => $thread->lastToken, 'agentId' => $thread->agentId, 'userId' => $thread->userId); $data['page.title'] = empty($group['vcchattitle']) ? Settings::get('chattitle') : $group['vcchattitle']; $data['chat']['page'] = array('title' => $data['page.title']); // Setup logo $data = array_merge_recursive($data, setup_logo($group)); // Set enter key shortcut if (Settings::get('sendmessagekey') == 'enter') { $data['chat']['messageForm']['ignoreCtrl'] = true; } else { $data['chat']['messageForm']['ignoreCtrl'] = false; } // Load dialogs style options $chat_style = new ChatStyle(ChatStyle::getCurrentStyle()); $style_config = $chat_style->getConfigurations(); $data['chat']['windowsParams']['mail'] = $style_config['mail']['window']; // Load core style options $page_style = new PageStyle(PageStyle::getCurrentStyle()); $style_config = $page_style->getConfigurations(); $data['chat']['windowsParams']['history'] = $style_config['history']['window']; $data['startFrom'] = 'chat'; return $data; }
/** * Gets the style options string for the chat popup. * * @return array */ protected function getPopupStyle() { $defaults = array('width' => 640, 'height' => 480, 'resizable' => true); $style_name = $this->getOption('chat_style'); if (!$style_name) { return $defaults + array('styleLoader' => $this->generateUrl('chat_user_popup_style')); } $chat_style = new ChatStyle($style_name); $chat_configs = $chat_style->getConfigurations(); // Intersection is used to limit style options to keys from the defaults // array. return array_intersect_key($chat_configs['chat']['window'] + $defaults, $defaults) + array('styleLoader' => $this->generateUrl('chat_user_popup_style', array('style' => $style_name))); }