button fix for opera, minor refactoring

git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@45 c66351dc-e62f-0410-b875-e3a5c0b9693f
This commit is contained in:
Evgeny Gryaznov 2008-03-04 22:22:48 +00:00
parent 46f4e47510
commit 03a03cb072
12 changed files with 62 additions and 32 deletions

View File

@ -98,7 +98,7 @@ function message_to_text($msg) {
}
function get_messages($threadid,$meth,$isuser,&$lastid) {
global $kind_for_agent;
global $kind_for_agent, $webim_encoding;
$link = connect();
$query = sprintf(
@ -110,7 +110,13 @@ function get_messages($threadid,$meth,$isuser,&$lastid) {
$result = mysql_query($query,$link) or die(' Query failed: ' .mysql_error().": ".$query);
while ($msg = mysql_fetch_array($result, MYSQL_ASSOC)) {
$message = ($meth == 'text') ? message_to_text($msg) : message_to_html($msg);
$message = "";
if ($meth == 'xml') {
$message = "<message>".myiconv($webim_encoding,"utf-8",escape_with_cdata(message_to_html($msg)))."</message>\n";
} else {
$message = (($meth == 'text') ? message_to_text($msg) : message_to_html($msg));
}
$messages[] = $message;
if( $msg['messageid'] > $lastid ) {
$lastid = $msg['messageid'];
@ -122,18 +128,21 @@ function get_messages($threadid,$meth,$isuser,&$lastid) {
return $messages;
}
function print_thread_mesages($threadid, $token, $lastid, $isuser,$format) {
global $webim_encoding, $webimroot;
$output = get_messages($threadid,"html",$isuser,$lastid);
function print_thread_messages($threadid, $token, $lastid, $isuser,$format) {
global $webim_encoding, $webimroot;
if( $format == "xml" ) {
$output = get_messages($threadid,"xml",$isuser,$lastid);
start_xml_output();
print("<thread lastid=\"$lastid\">");
foreach( $output as $msg ) {
print "<message>".myiconv($webim_encoding,"utf-8",escape_with_cdata($msg))."</message>\n";
print $msg;
}
print("</thread>");
} else if( $format == "html" ) {
$output = get_messages($threadid,"html",$isuser,$lastid);
start_html_output();
$url = "$webimroot/thread.php?act=refresh&thread=$threadid&token=$token&html=on&user=".($isuser?"true":"false");
@ -177,9 +186,11 @@ function setup_chatview_for_user($thread,$level) {
$page['ct.company.name'] = $company_name;
$page['ct.company.chatLogoURL'] = $company_logo_link;
$page['send_shortcut'] = "Ctrl-Enter";
$params = "thread=".$thread['threadid']."&token=".$thread['ltoken'];
$page['selfLink'] = "$webimroot/client.php?".$params."&level=".$level;
}
function setup_chatview_for_operator($thread,$operator) {
@ -194,6 +205,7 @@ function setup_chatview_for_operator($thread,$operator) {
$page['ct.company.name'] = $company_name;
$page['ct.company.chatLogoURL'] = $company_logo_link;
$page['send_shortcut'] = "Ctrl-Enter";
// TODO
$page['namePostfix'] = "";
@ -316,6 +328,7 @@ function rename_user($thread, $newname) {
}
}
function close_thread($thread,$isuser) {
global $state_closed, $kind_events;
@ -420,6 +433,7 @@ function check_for_reassign($thread,$operator) {
( $thread['agentId'] == $operator['operatorid'] )) {
do_take_thread($thread['threadid'], $operator['operatorid'], $operatorName);
$message_to_post = getstring2_("chat.status.operator.changed", array($operatorName,$thread['agentName']), $thread['locale']);
post_message($thread['threadid'],$kind_events,$message_to_post);
}
}

View File

@ -249,12 +249,13 @@ function no_field($key) {
return getstring2("errors.required",array(getstring($key)));
}
function wrong_field($key) {
return getstring2("errors.wrong_field",array(getstring($key)));
}
function get_popup($href,$message,$title,$wndName,$options) {
return "<a href=\"$href\" target=\"_blank\" ".($title?"title=\"$title\" ":"")."onclick=\"this.newWindow = window.open('$href', '$wndName', '$options');this.newWindow.focus();this.newWindow.opener=window;return false;\">$message</a>";
return "<a href=\"$href\" target=\"_blank\" ".($title?"title=\"$title\" ":"")."onclick=\"if(navigator.userAgent.toLowerCase().indexOf('opera') != -1 && window.event.preventDefault) window.event.preventDefault();this.newWindow = window.open('$href', '$wndName', '$options');this.newWindow.focus();this.newWindow.opener=window;return false;\">$message</a>";
}
function get_image($href,$width,$height) {
@ -356,4 +357,6 @@ function set_form_date($time,$prefix) {
$page["form${prefix}month"] = date("m.y", $time);
}
?>

View File

@ -96,5 +96,4 @@ $remote_visitor = 'visitor_from_request';
$online_timeout = 30;
?>

View File

@ -51,7 +51,8 @@ function get_operators() {
function update_operator($operatorid,$login,$password,$localename,$commonname) {
$link = connect();
$query = sprintf(
"update chatoperator set vclogin = '%s',%s vclocalename = '%s',vccommonname = '%s' where operatorid = %s",
"update chatoperator set vclogin = '%s',%s vclocalename = '%s', vccommonname = '%s'".
" where operatorid = %s",
mysql_real_escape_string($login),
($password ? " vcpassword='".md5($password)."'," : ""),
mysql_real_escape_string($localename),
@ -64,11 +65,11 @@ function update_operator($operatorid,$login,$password,$localename,$commonname) {
function create_operator_($login,$password,$localename,$commonname,$link) {
$query = sprintf(
"insert into chatoperator (vclogin,vcpassword,vclocalename,vccommonname) values ('%s','%s','%s','%s')",
"insert into chatoperator (vclogin,vcpassword,vclocalename,vccommonname".") values ('%s','%s','%s','%s'".")",
mysql_real_escape_string($login),
md5($password),
mysql_real_escape_string($localename),
mysql_real_escape_string($commonname) );
mysql_real_escape_string($commonname));
perform_query($query,$link);
$id = mysql_insert_id($link);

View File

@ -18,7 +18,7 @@ chat.window.chatting_with=You chat with:
chat.window.poweredby=Powered by:
chat.window.poweredreftext=webim.ru
chat.window.send_message=Send message
chat.window.send_message_short=Send (Ctrl-Enter)
chat.window.send_message_short=Send ({0})
chat.window.toolbar.mail_history=Send chat history by e-mail
chat.window.toolbar.refresh=Refresh
chat.client.name=Your name:
@ -52,7 +52,7 @@ chat.thread.state_wait_for_another_agent=Waiting for operator
chat.thread.state_chatting_with_agent=In chat
chat.thread.state_closed=Closed
clients.title=List of awaiting visitors
clients.no_clients=The of awaiting visitors is empty
clients.no_clients=The list of awaiting visitors is empty
clients.intro=The page displays list of awaiting visitors.
clients.how_to=To answer the visitor click on his/her name in the list.
clients.queue.prio=Priority visitors queue

View File

@ -18,7 +18,7 @@ chat.window.chatting_with=
chat.window.poweredby=Предоставлено:
chat.window.poweredreftext=webim.ru
chat.window.send_message=Отправить сообщение
chat.window.send_message_short=Îòïðàâèòü (Ctrl-Enter)
chat.window.send_message_short=Îòïðàâèòü ({0})
chat.window.toolbar.mail_history=Отправить историю диалога по электронной почте
chat.window.toolbar.refresh=Обновить содержимое диалога
chat.client.name=Ваше имя:

View File

@ -15,6 +15,8 @@
require('../libs/common.php');
require('../libs/operator.php');
$operator = check_login();
notify_operator_alive($operator['operatorid']);

View File

@ -16,12 +16,16 @@ require('libs/common.php');
require('libs/chat.php');
require('libs/operator.php');
$act = verifyparam( "act", "/^(refresh|post|rename|close|ping)$/");
$act = verifyparam( "act", "/^(refresh|post|rename|close|ping".")$/");
$token = verifyparam( "token", "/^\d{1,9}$/");
$threadid = verifyparam( "thread", "/^\d{1,9}$/");
$isuser = verifyparam( "user", "/^true$/", "false") == 'true';
$outformat = (verifyparam( "html", "/^on$/", "off") == 'on') ? "html" : "xml";
$thread = thread_by_id($threadid);
if( !$thread || !isset($thread['ltoken']) || $token != $thread['ltoken'] ) {
die("wrong thread");
@ -39,7 +43,7 @@ if( !$isuser && $act != "rename" ) {
if( $act == "refresh" ) {
$lastid = verifyparam( "lastid", "/^\d{1,9}$/", -1);
print_thread_mesages($threadid, $token, $lastid, $isuser,$outformat);
print_thread_messages($threadid, $token, $lastid, $isuser,$outformat);
exit;
} else if( $act == "post" ) {
@ -48,9 +52,9 @@ if( $act == "refresh" ) {
$kind = $isuser ? $kind_user : $kind_agent;
$from = $isuser ? $thread['userName'] : $thread['agentName'];
post_message($threadid,$kind,$message,$from, $isuser ? null : $operator['operatorid'] );
print_thread_mesages($threadid, $token, $lastid, $isuser, $outformat);
print_thread_messages($threadid, $token, $lastid, $isuser, $outformat);
exit;
} else if( $act == "rename" ) {

View File

@ -93,11 +93,10 @@
<tr><td colspan='3' height='20'></td></tr><tr><td colspan='3' background='<?php echo $webimroot ?>/images/formline.gif'><img src='<?php echo $webimroot ?>/images/formline.gif' width='1' height='2' border='0' alt=''></td></tr><tr><td colspan='3' height='10'></td></tr>
<tr>
<td class="formauth"><input type="hidden" name="agentId" value="<?php echo $page['agentId'] ?>"/>
<td class="formauth" colspan="3">
<input type="hidden" name="agentId" value="<?php echo $page['agentId'] ?>"/>
<input type="image" name="" src='<?php echo $webimroot.getstring("image.button.save") ?>' border="0" alt='<?php echo getstring("button.save") ?>'/>
</td>
<td></td>
<td></td>
</tr>
</table></td><td></td></tr><tr><td><img src='<?php echo $webimroot ?>/images/logincrnlb.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='<?php echo $webimroot ?>/images/logincrnrb.gif' width='16' height='16' border='0' alt=''></td></tr></table></td></tr></table>

View File

@ -42,17 +42,19 @@ var threadParams = { servl:"<?php echo $webimroot ?>/thread.php",wroot:"<?php ec
<td width="50%" valign="top">
<table width="135" cellspacing="0" cellpadding="0" border="0">
<tr>
<td height="25"></td>
<td height="10"></td>
</tr>
<tr>
<td align="center"><?php if( $page['ct.company.chatLogoURL'] ) { ?><img src="<?php echo $page['ct.company.chatLogoURL'] ?>" width="85" height="45" border="0" alt=""><?php } ?></td>
<td align="center"><?php if( $page['ct.company.chatLogoURL'] ) { ?><a onclick="window.open('<?php echo getstring("site.url") ?>');return false;" href="_blank"><img src="<?php echo $page['ct.company.chatLogoURL'] ?>" border="0" alt=""></a><?php } ?></td>
</tr>
<tr>
<td height="5"></td>
</tr>
<?php if( !$page['ct.company.chatLogoURL'] ) { ?>
<tr>
<td align="center" class="text"><?php echo $page['ct.company.name'] ?></td>
</tr>
<?php } ?>
</table>
</td>
<td width="50%" align="right" valign="top">
@ -192,7 +194,7 @@ var threadParams = { servl:"<?php echo $webimroot ?>/thread.php",wroot:"<?php ec
<td>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="33%">
<td align="left">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="20"></td>
@ -201,17 +203,20 @@ var threadParams = { servl:"<?php echo $webimroot ?>/thread.php",wroot:"<?php ec
</tr>
</table>
</td>
<td width="33%" align="center" class="copyr"><?php echo getstring("chat.window.poweredby") ?> <a href="<?php echo getstring("site.url") ?>" title="<?php echo getstring("company.title") ?>" target="_blank"><?php echo getstring("chat.window.poweredreftext") ?></a></td>
<td width="33%" align="right">
<td align="center" class="copyr"><?php echo getstring("chat.window.poweredby") ?> <a href="<?php echo getstring("site.url") ?>" title="<?php echo getstring("company.title") ?>" target="_blank"><?php echo getstring("chat.window.poweredreftext") ?></a></td>
<td align="right">
<?php if( $page['canpost'] ) { ?>
<table cellspacing="0" cellpadding="0" border="0" id="postmessage">
<tr>
<td>
</td>
<td><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.send_message") ?>"><img src='<?php echo $webimroot ?>/images/submit.gif' width="40" height="35" border="0" alt="" /></a></td>
<td background="<?php echo $webimroot ?>/images/submitbg.gif" valign="top" class="submit">
<img src='<?php echo $webimroot ?>/images/free.gif' width="1" height="10" border="0" alt="" /><br>
<a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.send_message") ?>"><?php echo getstring("chat.window.send_message_short") ?></a><br>
<a id="sndmessagelnk" href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.send_message") ?>"><?php echo getstring2("chat.window.send_message_short",array($page['send_shortcut'])) ?></a><br>
</td>
<td width="10"><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.send_message") ?>"><img src='<?php echo $webimroot ?>/images/submitrest.gif' width="10" height="35" border="0" alt="" /></a></td>
</tr>

View File

@ -100,7 +100,7 @@
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="50%">
<td width="33%">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td><a href="javascript:document.leaveMessageForm.submit();" title="<?php echo getstring("leavemessage.perform") ?>"><img src='<?php echo $webimroot ?>/images/submit.gif' width="40" height="35" border="0" alt="" /></a></td>
@ -112,7 +112,10 @@
</tr>
</table>
</td>
<td width="50%" align="right">
<td width="33%" align="center" class="copyr"><?php echo getstring("chat.window.poweredby") ?> <a href="<?php echo getstring("site.url") ?>" title="<?php echo getstring("company.title") ?>" target="_blank"><?php echo getstring("chat.window.poweredreftext") ?></a></td>
<td width="33%" align="right">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td><a href="javascript:window.close();" title="<?php echo getstring("leavemessage.close") ?>"><img src='<?php echo $webimroot ?>/images/buttons/back.gif' width="25" height="25" border="0" alt="" /></a></td>

View File

@ -189,12 +189,12 @@
<table cellspacing="0" cellpadding="0" border="0" id="postmessage">
<tr>
<td><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.send_message") ?>"><img src='<?php echo $webimroot ?>/images/submit.gif' width="40" height="35" border="0" altKey="chat.window.send_message_short"/></a></td>
<td><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.send_message") ?>"><img src='<?php echo $webimroot ?>/images/submit.gif' width="40" height="35" border="0" alt=""/></a></td>
<td background="<?php echo $webimroot ?>/images/submitbg.gif" valign="top" class="submit">
<img src='<?php echo $webimroot ?>/images/free.gif' width="1" height="10" border="0" alt="" /><br>
<a id="msgsend1" href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.send_message") ?>"><?php echo getstring("chat.window.send_message_short") ?></a><br>
<a id="msgsend1" href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.send_message") ?>"><?php echo getstring2("chat.window.send_message_short",array($page['send_shortcut'])) ?></a><br>
</td>
<td width="10"><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.send_message") ?>"><img src='<?php echo $webimroot ?>/images/submitrest.gif' width="10" height="35" border="0" altKey="chat.window.send_message_short"/></a></td>
<td width="10"><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.send_message") ?>"><img src='<?php echo $webimroot ?>/images/submitrest.gif' width="10" height="35" border="0" alt=""/></a></td>
</tr>
</table>
</td>