add preview for 4 templates

git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@185 c66351dc-e62f-0410-b875-e3a5c0b9693f
This commit is contained in:
Evgeny Gryaznov 2008-10-14 21:14:49 +00:00
parent 3e4e6802fe
commit 584b9d5fec
8 changed files with 76 additions and 16 deletions

View File

@ -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);
}

View File

@ -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 .= "<li><a href=\"".add_params($webimroot."/operator/redirect.php",$params)."\" title=\"".topage($agent['vclocalename'])."\">".topage($agent['vclocalename'])."</a>";
}
return $agent_list;
}
?>

View File

@ -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

View File

@ -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=Ñîçäàíèå íîâîãî îïåðàòîðà

View File

@ -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 .= "<li><a href=\"".add_params($webimroot."/operator/redirect.php",$params)."\" title=\"".topage($agent['vclocalename'])."\">".topage($agent['vclocalename'])."</a>";
}
$page['pagination_list'] = $agent_list;
$page['pagination_list'] = get_redirect_links($threadid,$token);
expand("../styles", getchatstyle(), "redirect.tpl");
} else {
expand("../styles", getchatstyle(), "chat.tpl");

View File

@ -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&amp;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&amp;show=";

View File

@ -0,0 +1 @@
${include:chat.tpl}

View File

@ -0,0 +1 @@
${include:chat.tpl}