diff --git a/src/messenger/webim/libs/expand.php b/src/messenger/webim/libs/expand.php
index 377e77e7..07f93e94 100644
--- a/src/messenger/webim/libs/expand.php
+++ b/src/messenger/webim/libs/expand.php
@@ -13,6 +13,7 @@
*/
$ifregexp = "/\\\${(if|ifnot):([\w\.]+)}(.*?)(\\\${else:\\2}.*?)?\\\${endif:\\2}/s";
+$expand_include_path = "";
function check_condition($condition) {
global $errors, $page;
@@ -74,20 +75,31 @@ function expand_var($matches) {
return "";
}
+function expand_include($matches) {
+ global $expand_include_path;
+ $name = $matches[1];
+ $contents = @file_get_contents($expand_include_path.$name) or die("cannot load template");
+ return $contents;
+}
+
function expandtext($text) {
global $ifregexp;
+ $text = preg_replace_callback("/\\\${include:([\w\.]+)}/", "expand_include", $text);
$text = preg_replace_callback($ifregexp, "expand_condition", $text);
return preg_replace_callback("/\\\${(\w+:)?([\w\.,]+)}/", "expand_var", $text);
}
function expand($basedir,$style,$filename) {
+ global $expand_include_path;
start_html_output();
if(!is_dir("$basedir/$style")) {
$style = "default";
}
- $contents = @file_get_contents("$basedir/$style/$filename");
+ $expand_include_path = "$basedir/$style/";
+ $contents = @file_get_contents($expand_include_path.$filename);
if($contents === false) {
- $contents = @file_get_contents("$basedir/default/$filename") or die("cannot load template");
+ $expand_include_path = "$basedir/default/";
+ $contents = @file_get_contents($expand_include_path.$filename) or die("cannot load template");
}
echo expandtext($contents);
}
diff --git a/src/messenger/webim/libs/operator.php b/src/messenger/webim/libs/operator.php
index babf1bd6..1eae52d1 100644
--- a/src/messenger/webim/libs/operator.php
+++ b/src/messenger/webim/libs/operator.php
@@ -161,4 +161,19 @@ function logout_operator() {
}
}
+function get_redirect_links($threadid,$token) {
+ global $page, $webimroot;
+ $found = get_operators();
+ setup_pagination($found);
+
+ $agent_list = "";
+ $params = array('thread' => $threadid, 'token' => $token);
+ for( $indagent = 0; $indagent < count($page['pagination.items']); $indagent += 1 ) {
+ $agent = $page['pagination.items'][$indagent];
+ $params['nextAgent'] = $agent['operatorid'];
+ $agent_list .= "
".topage($agent['vclocalename'])."";
+ }
+ return $agent_list;
+}
+
?>
diff --git a/src/messenger/webim/locales/en/properties b/src/messenger/webim/locales/en/properties
index 56e12e11..5c0b5366 100644
--- a/src/messenger/webim/locales/en/properties
+++ b/src/messenger/webim/locales/en/properties
@@ -231,6 +231,8 @@ page.gen_button.choose_image=Choose image
page.gen_button.choose_locale=Target locale
page.gen_button.include_site_name=Include host name into code
page.gen_button.secure_links=Use secure links (https)
+page.preview.agentchat=Chat window (agent-mode)
+page.preview.agentrochat=View Chat window (agent in readonly mode)
page.preview.chatsimple=Simple chat window, refresh to post messages (IE 5, Opera 7)
page.preview.choose=Choose style
page.preview.choosetpl=Choose template
@@ -240,6 +242,8 @@ page.preview.leavemessagesent=Leave message sent window
page.preview.mail=Mail thread window
page.preview.mailsent=Mail is sent window
page.preview.nochat=List of supported browsers window
+page.preview.redirect=Redirect visitor to another operator window
+page.preview.redirected=Visitor is redirected window
page.preview.title=Site style
page.preview.userchat=Chat window (user-mode)
page_agent.create_new=Here you can create new operator
diff --git a/src/messenger/webim/locales/ru/properties b/src/messenger/webim/locales/ru/properties
index f48778d5..3d618b14 100644
--- a/src/messenger/webim/locales/ru/properties
+++ b/src/messenger/webim/locales/ru/properties
@@ -231,6 +231,8 @@ page.gen_button.choose_image=
page.gen_button.choose_locale=Для какой локали создавать кнопку
page.gen_button.include_site_name=Включать имя сайта в код
page.gen_button.secure_links=Использовать защищенное соединение (https)
+page.preview.agentchat=Chat window (agent-mode)
+page.preview.agentrochat=View Chat window (agent in readonly mode)
page.preview.chatsimple=Simple chat window, refresh to post messages (IE 5, Opera 7)
page.preview.choose=Выберите стиль
page.preview.choosetpl=Выберите шаблон
@@ -240,6 +242,8 @@ page.preview.leavemessagesent=Leave message sent window
page.preview.mail=Mail thread window
page.preview.mailsent=Mail is sent window
page.preview.nochat=List of supported browsers window
+page.preview.redirect=Redirect visitor to another operator window
+page.preview.redirected=Visitor is redirected window
page.preview.title=Стиль мессенджера
page.preview.userchat=Chat window (user-mode)
page_agent.create_new=Создание нового оператора
diff --git a/src/messenger/webim/operator/agent.php b/src/messenger/webim/operator/agent.php
index eefda164..4b97b104 100644
--- a/src/messenger/webim/operator/agent.php
+++ b/src/messenger/webim/operator/agent.php
@@ -67,18 +67,7 @@ start_html_output();
$pparam = verifyparam( "act", "/^(redirect)$/", "default");
if( $pparam == "redirect" ) {
- $found = get_operators();
- setup_pagination($found);
-
- $agent_list = "";
- $params = array('thread' => $threadid, 'token' => $token);
- for( $indagent = 0; $indagent < count($page['pagination.items']); $indagent += 1 ) {
- $agent = $page['pagination.items'][$indagent];
- $params['nextAgent'] = $agent['operatorid'];
- $agent_list .= "".topage($agent['vclocalename'])."";
- }
- $page['pagination_list'] = $agent_list;
-
+ $page['pagination_list'] = get_redirect_links($threadid,$token);
expand("../styles", getchatstyle(), "redirect.tpl");
} else {
expand("../styles", getchatstyle(), "chat.tpl");
diff --git a/src/messenger/webim/operator/preview.php b/src/messenger/webim/operator/preview.php
index adced951..da4fa7e1 100644
--- a/src/messenger/webim/operator/preview.php
+++ b/src/messenger/webim/operator/preview.php
@@ -14,6 +14,7 @@
require_once('../libs/common.php');
require_once('../libs/chat.php');
+require_once('../libs/pagination.php');
require_once('../libs/operator.php');
require_once('../libs/expand.php');
@@ -35,7 +36,7 @@ if(!in_array($preview, $stylelist)) {
$preview = $stylelist[0];
}
-$show = verifyparam("show", "/^(chat|chatsimple|nochat|mail|mailsent|leavemessage|leavemessagesent)$/", "");
+$show = verifyparam("show", "/^(chat|chatsimple|nochat|mail|mailsent|leavemessage|leavemessagesent|redirect|redirected|agentchat|agentrochat)$/", "");
if($show == 'chat' || $show == 'mail' || $show == 'leavemessage' || $show == 'leavemessagesent' || $show == 'chatsimple' || $show == 'nochat') {
setup_chatview_for_user(array('threadid' => 0,'userName' => getstring("chat.default.username"), 'ltoken' => 123), "ajaxed");
@@ -48,6 +49,28 @@ if($show == 'mailsent') {
expand("../styles", "$preview", "$show.tpl");
exit;
}
+if($show == 'redirect' || $show == 'redirected' || $show == 'agentchat' || $show == 'agentrochat' ) {
+ setup_chatview_for_operator(
+ array(
+ 'threadid' => 0,
+ 'userName' => getstring("chat.default.username"),
+ 'remote' => "1.2.3.4",
+ 'agentId' => 1,
+ 'userid' => 'visitor1',
+ 'locale' => $current_locale,
+ 'ltoken' => $show=='agentrochat' ? 124 : 123),
+ array(
+ 'operatorid' => ($show=='agentrochat' ? 2 : 1),
+ ));
+ if($show=='redirect') {
+ $page['pagination_list'] = get_redirect_links( 0,$show=='agentrochat' ? 124 : 123);
+ } elseif($show=='redirected') {
+ $page['nextAgent'] = "Administrator";
+ }
+ $page['redirectLink'] = "$webimroot/operator/preview.php?preview=$preview&show=redirect";
+ expand("../styles", "$preview", "$show.tpl");
+ exit;
+}
$templateList = array(
array('label' => getlocal("page.preview.userchat"), 'id' => 'chat', 'h' => 420, 'w' => 600),
@@ -57,6 +80,10 @@ $templateList = array(
array('label' => getlocal("page.preview.leavemessagesent"), 'id' => 'leavemessagesent', 'h' => 420, 'w' => 600),
array('label' => getlocal("page.preview.mail"), 'id' => 'mail', 'h' => 254, 'w' => 603),
array('label' => getlocal("page.preview.mailsent"), 'id' => 'mailsent', 'h' => 254, 'w' => 603),
+ array('label' => getlocal("page.preview.redirect"), 'id' => 'redirect', 'h' => 420, 'w' => 600),
+ array('label' => getlocal("page.preview.redirected"), 'id' => 'redirected', 'h' => 420, 'w' => 600),
+ array('label' => getlocal("page.preview.agentchat"), 'id' => 'agentchat', 'h' => 420, 'w' => 600),
+ array('label' => getlocal("page.preview.agentrochat"), 'id' => 'agentrochat', 'h' => 420, 'w' => 600),
);
$template = verifyparam("template", "/^\w+$/", "chat");
@@ -64,7 +91,14 @@ $template = verifyparam("template", "/^\w+$/", "chat");
$page['formpreview'] = $preview;
$page['formtemplate'] = $template;
$page['availablePreviews'] = $stylelist;
-$page['availableTemplates'] = array("chat", "chatsimple", "nochat", "leavemessage", "leavemessagesent", "mail", "mailsent", "all");
+$page['availableTemplates'] = array(
+ "chat", "chatsimple", "nochat",
+ "leavemessage", "leavemessagesent",
+ "mail", "mailsent",
+ "redirect", "redirected",
+ "agentchat", "agentrochat",
+ "all");
+
$page['operator'] = topage(get_operator_name($operator));
$page['showlink'] = "$webimroot/operator/preview.php?preview=$preview&show=";
diff --git a/src/messenger/webim/styles/default/agentchat.tpl b/src/messenger/webim/styles/default/agentchat.tpl
new file mode 100644
index 00000000..9b720b3f
--- /dev/null
+++ b/src/messenger/webim/styles/default/agentchat.tpl
@@ -0,0 +1 @@
+${include:chat.tpl}
\ No newline at end of file
diff --git a/src/messenger/webim/styles/default/agentrochat.tpl b/src/messenger/webim/styles/default/agentrochat.tpl
new file mode 100644
index 00000000..9b720b3f
--- /dev/null
+++ b/src/messenger/webim/styles/default/agentrochat.tpl
@@ -0,0 +1 @@
+${include:chat.tpl}
\ No newline at end of file