From f90a934457321cbedf78028d892c93f7074b334e Mon Sep 17 00:00:00 2001 From: Evgeny Gryaznov Date: Sun, 12 Oct 2008 23:05:47 +0000 Subject: [PATCH] preview for simplechat, nochat git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@181 c66351dc-e62f-0410-b875-e3a5c0b9693f --- src/messenger/webim/libs/demothread.php | 52 ++++++++++++++++------- src/messenger/webim/libs/expand.php | 2 +- src/messenger/webim/locales/en/properties | 2 + src/messenger/webim/locales/ru/properties | 2 + src/messenger/webim/operator/preview.php | 8 ++-- src/messenger/webim/thread.php | 2 +- 6 files changed, 48 insertions(+), 20 deletions(-) diff --git a/src/messenger/webim/libs/demothread.php b/src/messenger/webim/libs/demothread.php index c5df7565..28d3b584 100644 --- a/src/messenger/webim/libs/demothread.php +++ b/src/messenger/webim/libs/demothread.php @@ -12,45 +12,67 @@ * Evgeny Gryaznov - initial API and implementation */ -function demo_print_message($msg) { +function demo_print_message($msg,$format) { global $webim_encoding; - print "".myiconv($webim_encoding,"utf-8",escape_with_cdata(message_to_html($msg)))."\n"; + if($format == "xml") { + print "".myiconv($webim_encoding,"utf-8",escape_with_cdata(message_to_html($msg)))."\n"; + } else { + print topage(message_to_html($msg)); + } } -function demo_process_thread($act,$lastid,$isuser,$canpost,$istyping,$postmessage) { - global $kind_for_agent, $kind_info, $kind_events, $kind_user, $kind_agent; +function demo_process_thread($act,$outformat,$lastid,$isuser,$canpost,$istyping,$postmessage) { + global $kind_for_agent, $kind_info, $kind_events, $kind_user, $kind_agent, $webimroot; if( $act == "refresh" || $act == "post" ) { $lastid++; - start_xml_output(); - print(""); + if($outformat == "xml") { + start_xml_output(); + print(""); + } else { + start_html_output(); + $url = "$webimroot/thread.php?act=refresh&thread=0&token=123&html=on&user=".($isuser?"true":"false"); + print("\n". + "\n". + "\n". + "\n". + "". + "". + "
" ); + } if($lastid == 1) { demo_print_message( array('ikind'=>$kind_for_agent,'created'=>time()-15,'tname'=>'', - 'tmessage'=>getstring2('chat.came.from',array("http://google.com")))); + 'tmessage'=>getstring2('chat.came.from',array("http://google.com"))), $outformat); demo_print_message( array('ikind'=>$kind_info,'created'=>time()-15,'tname'=>'', - 'tmessage'=>getstring('chat.wait'))); + 'tmessage'=>getstring('chat.wait')), $outformat); demo_print_message( array('ikind'=>$kind_events,'created'=>time()-10,'tname'=>'', - 'tmessage'=>getstring2("chat.status.operator.joined", array("Administrator")))); + 'tmessage'=>getstring2("chat.status.operator.joined", array("Administrator"))), $outformat); demo_print_message( array('ikind'=>$kind_agent,'created'=>time()-9,'tname'=>'Administrator', - 'tmessage'=>getstring("demo.chat.welcome"))); + 'tmessage'=>getstring("demo.chat.welcome")), $outformat); demo_print_message( array('ikind'=>$kind_user,'created'=>time()-5,'tname'=>getstring("chat.default.username"), - 'tmessage'=>getstring("demo.chat.question"))); - if($canpost) { + 'tmessage'=>getstring("demo.chat.question")), $outformat); + if($canpost && $outformat == 'xml') { demo_print_message( array('ikind'=>$kind_info,'created'=>time()-5,'tname'=>'', - 'tmessage'=>'Hint: type something in message field to see typing notification')); + 'tmessage'=>'Hint: type something in message field to see typing notification'), $outformat); } } if($act == 'post') { demo_print_message( array('ikind'=>$isuser?$kind_user:$kind_agent,'created'=>time(),'tmessage'=>$postmessage, - 'tname'=>$isuser?getstring("chat.default.username"):"Administrator")); + 'tname'=>$isuser?getstring("chat.default.username"):"Administrator"), $outformat); + } + if($outformat == "xml") { + print(""); + } else { + print( + "
". + "" ); } - print("
"); } } diff --git a/src/messenger/webim/libs/expand.php b/src/messenger/webim/libs/expand.php index aef55a9f..84a25054 100644 --- a/src/messenger/webim/libs/expand.php +++ b/src/messenger/webim/libs/expand.php @@ -82,7 +82,7 @@ function expandtext($text) { function expand($filename) { start_html_output(); - $contents = file_get_contents($filename) or die("illegal template"); + $contents = @file_get_contents($filename) or die("illegal template"); echo expandtext($contents); } diff --git a/src/messenger/webim/locales/en/properties b/src/messenger/webim/locales/en/properties index 1b16f7cf..56e12e11 100644 --- a/src/messenger/webim/locales/en/properties +++ b/src/messenger/webim/locales/en/properties @@ -231,6 +231,7 @@ 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.chatsimple=Simple chat window, refresh to post messages (IE 5, Opera 7) page.preview.choose=Choose style page.preview.choosetpl=Choose template page.preview.intro=You can preview styles for your site @@ -238,6 +239,7 @@ page.preview.leavemessage=Leave message window 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.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 66460d7c..f48778d5 100644 --- a/src/messenger/webim/locales/ru/properties +++ b/src/messenger/webim/locales/ru/properties @@ -231,6 +231,7 @@ page.gen_button.choose_image= page.gen_button.choose_locale=Для какой локали создавать кнопку page.gen_button.include_site_name=Включать имя сайта в код page.gen_button.secure_links=Использовать защищенное соединение (https) +page.preview.chatsimple=Simple chat window, refresh to post messages (IE 5, Opera 7) page.preview.choose=Выберите стиль page.preview.choosetpl=Выберите шаблон page.preview.intro=Здесь вы можете посмотреть на стиль вашего сайта @@ -238,6 +239,7 @@ page.preview.leavemessage=Leave message window 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.title=Стиль мессенджера page.preview.userchat=Chat window (user-mode) page_agent.create_new=Создание нового оператора diff --git a/src/messenger/webim/operator/preview.php b/src/messenger/webim/operator/preview.php index 84adef8f..b852e876 100644 --- a/src/messenger/webim/operator/preview.php +++ b/src/messenger/webim/operator/preview.php @@ -35,9 +35,9 @@ if(!in_array($preview, $designlist)) { $preview = $designlist[0]; } -$show = verifyparam("show", "/^(chat|mail|mailsent|leavemessage|leavemessagesent)$/", ""); +$show = verifyparam("show", "/^(chat|chatsimple|nochat|mail|mailsent|leavemessage|leavemessagesent)$/", ""); -if($show == 'chat' || $show == 'mail' || $show == 'leavemessage' || $show == 'leavemessagesent') { +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"); $page['mailLink'] = "$webimroot/operator/preview.php?preview=$preview&show=mail"; expand("../design/$preview/$show.tpl"); @@ -51,6 +51,8 @@ if($show == 'mailsent') { $templateList = array( array('label' => getlocal("page.preview.userchat"), 'id' => 'chat', 'h' => 420, 'w' => 600), + array('label' => getlocal("page.preview.chatsimple"), 'id' => 'chatsimple', 'h' => 420, 'w' => 600), + array('label' => getlocal("page.preview.nochat"), 'id' => 'nochat', 'h' => 420, 'w' => 600), array('label' => getlocal("page.preview.leavemessage"), 'id' => 'leavemessage', 'h' => 420, 'w' => 600), array('label' => getlocal("page.preview.leavemessagesent"), 'id' => 'leavemessagesent', 'h' => 420, 'w' => 600), array('label' => getlocal("page.preview.mail"), 'id' => 'mail', 'h' => 254, 'w' => 603), @@ -62,7 +64,7 @@ $template = verifyparam("template", "/^\w+$/", "chat"); $page['formpreview'] = $preview; $page['formtemplate'] = $template; $page['availablePreviews'] = $designlist; -$page['availableTemplates'] = array("chat", "leavemessage", "leavemessagesent", "mail", "mailsent", "all"); +$page['availableTemplates'] = array("chat", "chatsimple", "nochat", "leavemessage", "leavemessagesent", "mail", "mailsent", "all"); $page['operator'] = topage(get_operator_name($operator)); $page['showlink'] = "$webimroot/operator/preview.php?preview=$preview&show="; diff --git a/src/messenger/webim/thread.php b/src/messenger/webim/thread.php index d90ac9a3..0705ebbe 100644 --- a/src/messenger/webim/thread.php +++ b/src/messenger/webim/thread.php @@ -26,7 +26,7 @@ $istyping = verifyparam( "typed", "/^1$/", "") == '1'; if($threadid == 0 && ($token == 123 || $token == 124)) { require_once('libs/demothread.php'); $lastid = verifyparam( "lastid", "/^\d{1,9}$/", 0); - demo_process_thread($act,$lastid,$isuser,$token == 123,$istyping,$act=="post"?getrawparam('message') : ""); + demo_process_thread($act,$outformat,$lastid,$isuser,$token == 123,$istyping,$act=="post"?getrawparam('message') : ""); exit; }