zmodel = Mage::getModel('livechat/livechat')->load(1); $zoptions = $this->zmodel->_data; $greetings = Zend_JSON::Decode($zoptions['greetings']); if ($zoptions["code"] == "") { $zoptions["code"] = "zopim"; } $html = ""; if ($this->getRequest()->getParam('zopimColor')!="" || $this->getRequest()->getParam('zopimTheme')!="") { $this->zmodel->setGetvisitorinfo($this->checkbox_helper("zopimGetVisitorInfo")); $this->zmodel->setHideonoffline($this->checkbox_helper("zopimHideOnOffline")); $this->zmodel->setBubbleenable($this->checkbox_helper("zopimBubbleEnable")); $this->zmodel->setLang($this->getRequest()->getParam('zopimLang')); $this->zmodel->setPosition($this->getRequest()->getParam('zopimPosition')); $this->zmodel->setTheme($this->getRequest()->getParam('zopimTheme')); $this->zmodel->setBubbletitle($this->getRequest()->getParam('zopimBubbleTitle')); $this->zmodel->setBubbletext($this->getRequest()->getParam('zopimBubbleText')); $this->zmodel->setColor($this->getRequest()->getParam('zopimColor')); $greetings["online"]["window"] = stripslashes($this->getRequest()->getParam("zopimOnlineLong")); $greetings["away"]["window"] = stripslashes($this->getRequest()->getParam("zopimAwayLong")); $greetings["offline"]["window"] = stripslashes($this->getRequest()->getParam("zopimOfflineLong")); $greetings["online"]["bar"] = stripslashes($this->getRequest()->getParam("zopimOnlineShort")); $greetings["away"]["bar"] = stripslashes($this->getRequest()->getParam("zopimAwayShort")); $greetings["offline"]["bar"] = stripslashes($this->getRequest()->getParam("zopimOfflineShort")); $this->zmodel->setGreetings(Zend_JSON::Encode($greetings)); $this->zmodel->save(); $zoptions = $this->zmodel->_data; $html = '

'; } // print_r(Mage::app()->getLocale()); $html .= " "; $html .= << function updateWidget() { var lang = document.getElementById('zopimLang').options[ document.getElementById('zopimLang').options.selectedIndex ].value; if (lang == 'md') { lang = thisLocale; } \$zopim.livechat.setLanguage(lang); if (document.getElementById("zopimHideOnOffline").checked) { \$zopim.livechat.button.setHideWhenOffline(true); } else { \$zopim.livechat.button.setHideWhenOffline(false); } \$zopim.livechat.window.setColor(document.getElementById("zopimColor").value); \$zopim.livechat.window.setTheme(document.getElementById("zopimTheme").value); \$zopim.livechat.bubble.setTitle(document.getElementById("zopimBubbleTitle").value); \$zopim.livechat.bubble.setText(document.getElementById("zopimBubbleText").value); \$zopim.livechat.setGreetings({ 'online': [document.getElementById("zopimOnlineShort").value, document.getElementById("zopimOnlineLong").value], 'offline': [document.getElementById("zopimOfflineShort").value, document.getElementById("zopimOfflineLong").value], 'away': [document.getElementById("zopimAwayShort").value, document.getElementById("zopimAwayLong").value] }); } function updatePosition() { var position = document.getElementById('zopimPosition').options[ document.getElementById('zopimPosition').options.selectedIndex ].value; \$zopim.livechat.button.setPosition(position); } function updateBubbleStatus() { if (document.getElementById("zopimBubbleEnable").checked) { \$zopim.livechat.bubble.show(); \$zopim.livechat.bubble.reset(); } else { \$zopim.livechat.bubble.hide(); } } var timer; function updateSoon() { clearTimeout(timer); timer = setTimeout("updateWidget()", 300); } EOT; if ($zoptions['hideonoffline'] && $zoptions['hideonoffline']!="disabled") { $hideonoffline = "checked='checked'"; } else { $hideonoffline = ''; } $html .= '

Customize your widget

General Settings

Language
Position
Hide chat bar when offline This prevents visitors from sending you offline messages
'; $colorpick = "
"; $colors = $this->curl_get_url(ZOPIM_COLORS_LIST); $colors = explode("\n", $colors); $i=0; foreach ($colors as $color) { $colorpick .= "
 
"; if (++$i%40==0) { $colorpick .= "
"; } } $colorpick .= "
Restore default color
"; $themeselect = ' View the Chat Panel for changes"; $html .= '

Color & Theme Settings

Color '.$colorpick.'
Theme '.$themeselect.'
'; $bubbleCheck = ""; if ($zoptions["bubbleenable"]!="disabled") { $bubbleCheck = "checked='checked'"; } $html .= '

Help Bubble Settings

Display Help Bubble Use this pretty chat bubble to grab attention!
Help Bubble Title Refresh
Help Bubble Message
'; $html .= '

Greeting Message Settings

Message Shown on Chat Bar
Online
Away
Offline
Message Shown on Chat Panel
Online
Away
Offline
'; $html .= '

'; return $html; } private function curPageURL() { $pageURL = 'http'; if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } $pageURL = preg_replace("/\?.*$/", "", $pageURL); return $pageURL; } private function generate_options($options, $current) { $out = ""; foreach ($options as $key => $value) { if ($value != "") { $isselected = ""; if ($current == $key) { $isselected = "selected"; } $out .= ''; } } return $out; } private function get_languages() { $langjson = '{"--":" - Auto Detect - ","md":" - Magento Locale Detection - ","ar":"Arabic","bg":"Bulgarian","cs":"Czech","da":"Danish","de":"German","en":"English","es":"Spanish; Castilian","fa":"Persian","fo":"Faroese","fr":"French","he":"Hebrew","hr":"Croatian","id":"Indonesian","it":"Italian","ja":"Japanese","ko":"Korean","ms":"Malay","nb":"Norwegian Bokmal","nl":"Dutch; Flemish","pl":"Polish","pt":"Portuguese","ru":"Russian","sk":"Slovak","sl":"Slovenian","sv":"Swedish","th":"Thai","tr":"Turkish","ur":"Urdu","vi":"Vietnamese","zh_CN":"Chinese (China)"}'; return Zend_Json::decode($langjson); } private function curl_get_url($filename) { $ch = curl_init(); $timeout = 5; // set to zero for no timeout curl_setopt ($ch, CURLOPT_URL, $filename); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $file_contents = curl_exec($ch); curl_close($ch); return $file_contents; } private function valuekeys($array) { $newarray = array(); foreach ($array as $s) { $newarray[$s] = $s; } return $newarray; } private function checkbox_helper($fieldname) { $val = $this->getRequest()->getParam($fieldname); if (isset($val) && $val != "") { return $this->getRequest()->getParam($fieldname); } else { return "disabled"; } } }