Use handlebars.php for dialogs' templates

This commit is contained in:
Dmitriy Simushev 2014-02-14 10:51:22 +00:00
parent f4702e5381
commit 9e82414728
22 changed files with 325 additions and 689 deletions

View File

@ -19,7 +19,7 @@ namespace Mibew\Style;
// Import namespaces and classes of the core // Import namespaces and classes of the core
use Mibew\Settings; use Mibew\Settings;
use Mibew\TemplateEngine\ChatTemplateEngine; use Mibew\Handlebars\HelpersSet;
/** /**
* Represents a chat style * Represents a chat style
@ -29,7 +29,7 @@ class ChatStyle extends AbstractStyle implements StyleInterface
/** /**
* Template engine for chat templates. * Template engine for chat templates.
* *
* @var \Mibew\TemplateEngine\ChatTemplateEngine * @var \Handlebars\Handlebars
*/ */
protected $templateEngine; protected $templateEngine;
@ -42,10 +42,19 @@ class ChatStyle extends AbstractStyle implements StyleInterface
{ {
parent::__construct($style_name); parent::__construct($style_name);
$this->templateEngine = new ChatTemplateEngine( $templates_loader = new \Handlebars\Loader\FilesystemLoader(
$this->filesPath(), MIBEW_FS_ROOT . '/' . $this->filesPath() . '/templates_src/server_side/'
$this->name()
); );
$this->templateEngine = new \Handlebars\Handlebars(array(
'loader' => $templates_loader,
'partials_loader' => $templates_loader,
'helpers' => new \Handlebars\Helpers(HelpersSet::getHelpers())
));
// Use custom function to escape strings
$this->templateEngine->setEscape('safe_htmlspecialchars');
$this->templateEngine->setEscapeArgs(array());
} }
/** /**
@ -70,6 +79,15 @@ class ChatStyle extends AbstractStyle implements StyleInterface
public function render($template_name, $data = array()) public function render($template_name, $data = array())
{ {
start_html_output(); start_html_output();
// Pass additional variables to template
$data['mibewRoot'] = MIBEW_WEB_ROOT;
$data['mibewVersion'] = MIBEW_VERSION;
$data['currentLocale'] = CURRENT_LOCALE;
$data['rtl'] = (getlocal("localedirection") == 'rtl');
$data['stylePath'] = MIBEW_WEB_ROOT . '/' . $this->filesPath();
$data['styleName'] = $this->name();
echo($this->templateEngine->render($template_name, $data)); echo($this->templateEngine->render($template_name, $data));
} }

View File

@ -1,262 +0,0 @@
<?php
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace Mibew\TemplateEngine;
/**
* Simple template engine for chat templates
*/
class ChatTemplateEngine
{
/**
* Regular expression for conditional blocks in templates
*/
const IF_REGEXP = "/\\\${(if|ifnot):([\w\.]+)}(.*?)(\\\${else:\\2}.*?)?\\\${endif:\\2}/s";
/**
* Path to teplates relative to MIBEW_FS_ROOT.
* @var string
*/
protected $stylePath;
/**
* Machine name of the templates style.
* @var string
*/
protected $styleName;
/**
* Data for the currently rendering template. Unfortunately there is no
* another place to store these data for used chat templates logic.
* @var array
*/
protected $templateData;
/**
* Flatten data for the currently rendering template.
* @var array
*/
protected $flattenTemplateData;
/**
* Constructs an instance of the template engine.
*
* @param string $style_path Path to the style relative to MIBEW_FS_ROOT.
* @param string $style_name Machine name of the templates style.
*/
public function __construct($style_path, $style_name)
{
$this->stylePath = $style_path;
$this->styleName = $style_name;
}
/**
* Renders template and returns HTML for it.
*
* @param string $template_name Name of a template with neither path nor
* extension.
* @param array $data Data for substitutions.
* @return string Rendered HTML markup.
*/
public function render($template_name, $data)
{
$this->flattenTemplateData = array_flatten_recursive($data);
$this->templateData = $data;
$contents = $this->getTemplateFileContent($template_name);
return $this->expandText($contents);
}
/**
* Check if condition form conditional construction is true.
*
* @param string $condition Condition name. Can be any element name of the
* template data array.
*/
public function checkCondition($condition)
{
if ($condition == 'errors') {
return !empty($this->templateData['errors'])
&& is_array($this->templateData['errors']);
}
return !empty($this->flattenTemplateData[$condition]);
}
/**
* Process conditional construction. This function is a callback for
* "preg_replace_callback" function.
*
* @param array $matches matches passed from "preg_replace_callback"
* function.
* @return string One of conditional blocks depending of conditional value.
*/
public function expandCondition($matches)
{
$value = $this->checkCondition($matches[2]) ^ ($matches[1] != 'if');
if ($value) {
return preg_replace_callback(
self::IF_REGEXP,
array($this, "expandCondition"),
$matches[3]
);
} elseif (isset($matches[4])) {
return preg_replace_callback(
self::IF_REGEXP,
array($this, "expandCondition"),
substr($matches[4], strpos($matches[4], "}") + 1)
);
}
return "";
}
/**
* Replace variables in template with its values. This function is a
* callback for "preg_replace_callback" function.
*
* @param array $matches matches passed from "preg_replace_callback"
* function.
* @return string Value of the variable or empty string if the value was not
* passed in with template data.
*/
public function expandVar($matches)
{
$prefix = $matches[1];
$var = $matches[2];
if (!$prefix) {
if ($var == 'mibewroot') {
return MIBEW_WEB_ROOT;
} elseif ($var == 'tplroot') {
return MIBEW_WEB_ROOT . "/" . $this->stylePath;
} elseif ($var == 'styleid') {
return $this->styleName;
} elseif ($var == 'pagination') {
return generate_pagination(
MIBEW_WEB_ROOT . '/' . $this->stylePath,
$this->templateData['pagination']
);
} elseif ($var == 'errors' || $var == 'harderrors') {
$errors_data_exists = !empty($this->templateData['errors'])
&& is_array($this->templateData['errors']);
if ($errors_data_exists) {
$result = getlocal("$var.header");
foreach ($this->templateData['errors'] as $e) {
$result .= getlocal("errors.prefix")
. $e
. getlocal("errors.suffix");
}
$result .= getlocal("errors.footer");
return $result;
}
}
} elseif ($prefix == 'msg:' || $prefix == 'msgjs:' || $prefix == 'url:') {
$message = '';
if (strpos($var, ",") !== false) {
$pos = strpos($var, ",");
$param = substr($var, $pos + 1);
$var = substr($var, 0, $pos);
$message = getlocal2($var, array($this->flattenTemplateData[$param]));
} else {
$message = getlocal($var);
}
if ($prefix == 'msgjs:') {
return json_encode($message);
}
return $message;
} elseif ($prefix == 'form:') {
return form_value($this->templateData, $var);
} elseif ($prefix == 'page:' || $prefix == 'pagejs:') {
$message = isset($this->flattenTemplateData[$var])
? $this->flattenTemplateData[$var]
: "";
return ($prefix == 'pagejs:') ? json_encode($message) : $message;
} elseif ($prefix == 'if:' || $prefix == 'else:' || $prefix == 'endif:' || $prefix == 'ifnot:') {
return "<!-- wrong $prefix:$var -->";
}
return "";
}
/**
* Process "include" control structure. This function is a callback for
* "preg_replace_callback" function.
*
* @param array $matches matches passed from "preg_replace_callback"
* function.
* @return string Contents of including file
*/
public function expandInclude($matches)
{
$template_name = $matches[1];
return $this->getTemplateFileContent($template_name);
}
/**
* Converts all control structures to markup.
*
* @param string $text Source text
* @return string Markup with no control structures
*/
public function expandText($text)
{
$text = preg_replace_callback(
"/\\\${include:([\w\.]+)}/",
array($this, "expandInclude"),
$text
);
$text = preg_replace_callback(
self::IF_REGEXP,
array($this, "expandCondition"),
$text
);
return preg_replace_callback(
"/\\\${(\w+:)?([\w\.,]+)}/",
array($this, "expandVar"),
$text
);
}
/**
* Loads content of a template file.
*
* @param string $template_name Name of a template file to load.
* @return string Template file's content.
*
* @throws \RuntimeException If there is no such template file or the file
* is not readable.
*/
protected function getTemplateFileContent($template_name)
{
$full_file_path = MIBEW_FS_ROOT . '/' . $this->stylePath
. '/templates/' . $template_name . '.tpl';
if (!is_readable($full_file_path)) {
throw new \RuntimeException(
'Cannot load template file: "' . $full_file_path . '"'
);
}
return file_get_contents($full_file_path);
}
}

View File

@ -104,9 +104,8 @@ img {
text-decoration: none; text-decoration: none;
} }
#page-title { #page-title {
position: absolute; float: right;
right: 14px; margin-top: 5px;
bottom: 5px;
text-align: right; text-align: right;
} }
/* ----------- */ /* ----------- */

View File

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

View File

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

View File

@ -1,119 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>${msg:chat.window.title.agent}</title>
<link rel="shortcut icon" href="${mibewroot}/images/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="${tplroot}/chat.css" media="all" />
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="${tplroot}/chat_ie7.css" media="all" />
<![endif]-->
${page:additional_css}
<!-- External libs -->
<script type="text/javascript" src="${mibewroot}/js/libs/jquery.min.js"></script>
<script type="text/javascript" src="${mibewroot}/js/libs/json2.js"></script>
<script type="text/javascript" src="${mibewroot}/js/libs/underscore-min.js"></script>
<script type="text/javascript" src="${mibewroot}/js/libs/backbone-min.js"></script>
<script type="text/javascript" src="${mibewroot}/js/libs/backbone.marionette.min.js"></script>
<script type="text/javascript" src="${mibewroot}/js/libs/handlebars.js"></script>
<!-- Javascript templates -->
<script type="text/javascript" src="${tplroot}/js/compiled/templates.js"></script>
<!-- Application files -->
<script type="text/javascript" src="${mibewroot}/js/compiled/mibewapi.js"></script>
<script type="text/javascript" src="${mibewroot}/js/compiled/default_app.js"></script>
<script type="text/javascript" src="${mibewroot}/js/compiled/chat_app.js"></script>
<!-- Add style scripts -->
<script type="text/javascript" src="${tplroot}/js/compiled/scripts.js"></script>
${page:additional_js}
<script type="text/javascript"><!--
// Localized strings for the core
Mibew.Localization.set({
'chat.close.confirmation': ${msgjs:chat.close.confirmation},
'typing.remote': ${msgjs:typing.remote},
'chat.window.predefined.select_answer': ${msgjs:chat.window.predefined.select_answer},
'chat.window.send_message': ${msgjs:chat.window.send_message},
'chat.window.send_message_short_and_shortcut': ${msgjs:chat.window.send_message_short,send_shortcut},
'chat.window.close_title': ${msgjs:chat.window.close_title},
'chat.window.toolbar.refresh': ${msgjs:chat.window.toolbar.refresh},
'chat.window.toolbar.mail_history': ${msgjs:chat.window.toolbar.mail_history},
'chat.window.toolbar.redirect_user': ${msgjs:chat.window.toolbar.redirect_user},
'page.analysis.userhistory.title': ${msgjs:page.analysis.userhistory.title},
'chat.client.name': ${msgjs:chat.client.name},
'chat.client.changename': ${msgjs:chat.client.changename},
'chat.window.toolbar.turn_off_sound': ${msgjs:chat.window.toolbar.turn_off_sound},
'chat.window.toolbar.turn_on_sound': ${msgjs:chat.window.toolbar.turn_on_sound},
'chat.window.poweredby': ${msgjs:chat.window.poweredby},
'chat.mailthread.sent.close': ${msgjs:chat.mailthread.sent.close},
'form.field.department': ${msgjs:form.field.department},
'form.field.department.description': ${msgjs:form.field.department.description},
'form.field.email': ${msgjs:form.field.email},
'form.field.name': ${msgjs:form.field.name},
'form.field.message': ${msgjs:form.field.message},
'leavemessage.close': ${msgjs:leavemessage.close},
'leavemessage.descr': ${msgjs:leavemessage.descr},
'leavemessage.sent.message': ${msgjs:leavemessage.sent.message},
'leavemessage.error.email.required': ${pagejs:localized.email.required},
'leavemessage.error.name.required': ${pagejs:localized.name.required},
'leavemessage.error.message.required': ${pagejs:localized.message.required},
'leavemessage.error.wrong.email': ${pagejs:localized.wrong.email},
'errors.captcha': ${msgjs:errors.captcha},
'mailthread.perform': ${msgjs:mailthread.perform},
'presurvey.name': ${msgjs:presurvey.name},
'presurvey.mail': ${msgjs:presurvey.mail},
'presurvey.question': ${msgjs:presurvey.question},
'presurvey.submit': ${msgjs:presurvey.submit},
'presurvey.error.wrong_email': ${msgjs:presurvey.error.wrong_email},
'presurvey.title': ${msgjs:presurvey.title},
'presurvey.intro': ${msgjs:presurvey.intro}
});
// Plugins localization
Mibew.Localization.set(${page:additional_localized_strings});
//--></script>
<!-- Run application -->
<script type="text/javascript"><!--
jQuery(document).ready(function(){
Mibew.Application.start({
server: {
url: "${mibewroot}/thread.php",
requestsFrequency: ${page:frequency}
},
page: {
style: '${styleid}',
mibewRoot: '${mibewroot}',
tplRoot: '${tplroot}',
company: {
name: ${pagejs:company.name},
chatLogoURL: '${page:company.chatLogoURL}'
},
mibewHost: '${page:mibewHost}',
title: ${pagejs:page.title}
},
${if:chatOptions}
chatOptions: ${page:chatOptions},
${endif:chatOptions}
${if:surveyOptions}
surveyOptions: ${page:surveyOptions},
${endif:surveyOptions}
${if:leaveMessageOptions}
leaveMessageOptions: ${page:leaveMessageOptions},
${endif:leaveMessageOptions}
${if:invitationOptions}
invitationOptions: ${page:invitationOptions},
${endif:invitationOptions}
startFrom: "${page:startFrom}",
plugins: ${page:js_plugin_options}
});
});
//--></script>
</head>
<body>
<div id="main-region"></div>
</body>
</html>

View File

@ -1,45 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>${msg:chat.error_page.title}</title>
<link rel="shortcut icon" href="${mibewroot}/images/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" type="text/css" href="${tplroot}/chat.css" />
</head>
<body>
<div id="top2">
<div id="logo">
${if:company.chatLogoURL}
${if:mibewHost}
<a onclick="window.open('${page:mibewHost}');return false;" href="${page:mibewHost}">
<img src="${page:company.chatLogoURL}" alt=""/>
</a>
${else:mibewHost}
<img src="${page:company.chatLogoURL}" alt=""/>
${endif:mibewHost}
${else:company.chatLogoURL}
${if:mibewHost}
<a onclick="window.open('${page:mibewHost}');return false;" href="${page:mibewHost}">
<img src="${tplroot}/images/default-logo.gif" alt=""/>
</a>
${else:mibewHost}
<img src="${tplroot}/images/default-logo.gif" alt=""/>
${endif:mibewHost}
${endif:company.chatLogoURL}
&nbsp;
<div id="page-title">${msg:leavemessage.title}</div>
<div class="clear">&nbsp;</div>
</div>
</div>
<div id="headers">
<div class="wndb"><div class="wndl"><div class="wndr"><div class="wndt"><div class="wndtl"><div class="wndtr"><div class="wndbl"><div class="wndbr">
<div class="buttons">
<a href="javascript:window.close();" title="${msg:chat.error_page.close}"><img class="tpl-image iclosewin" src="${tplroot}/images/free.gif" alt="${msg:chat.error_page.close}" /></a>
</div>
<div class="messagetxt">&nbsp;</div>
</div></div></div></div></div></div></div></div>
</div>
<div id="content-wrapper">
${harderrors}
</div>
</body>
</html>

View File

@ -1,56 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>${msg:chat.window.title.user}</title>
<link rel="shortcut icon" href="${mibewroot}/images/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" type="text/css" href="${tplroot}/chat.css" />
</head>
<body>
<form name="mailThreadForm" method="post" action="${mibewroot}/mail.php"><input type="hidden" name="style" value="${styleid}"/>
<input type="hidden" name="thread" value="${page:chat.thread.id}"/><input type="hidden" name="token" value="${page:chat.thread.token}"/><input type="hidden" name="level" value="${page:level}"/>
<div id="top2">
<div id="logo">
${if:company.chatLogoURL}
${if:mibewHost}
<a onclick="window.open('${page:mibewHost}');return false;" href="${page:mibewHost}">
<img src="${page:company.chatLogoURL}" alt=""/>
</a>
${else:mibewHost}
<img src="${page:company.chatLogoURL}" alt=""/>
${endif:mibewHost}
${else:company.chatLogoURL}
${if:mibewHost}
<a onclick="window.open('${page:mibewHost}');return false;" href="${page:mibewHost}">
<img src="${tplroot}/images/default-logo.gif" alt=""/>
</a>
${else:mibewHost}
<img src="${tplroot}/images/default-logo.gif" alt=""/>
${endif:mibewHost}
${endif:company.chatLogoURL}
&nbsp;<br />&nbsp;
<div id="page-title">${msg:mailthread.title}</div>
<div class="clear">&nbsp;</div>
</div>
</div>
<div id="headers">
<div class="wndb"><div class="wndl"><div class="wndr"><div class="wndt"><div class="wndtl"><div class="wndtr"><div class="wndbl"><div class="wndbr">
<div class="buttons">
<a href="javascript:window.close();" title="${msg:mailthread.close}"><img class="tpl-image iclosewin" src="${tplroot}/images/free.gif" alt="${msg:mailthread.close}" /></a>
</div>
<div class="messagetxt">
<strong>${msg:mailthread.enter_email}</strong>
<input type="text" name="email" size="20" value="${form:email}" class="username" />&nbsp;
<a href="javascript:document.mailThreadForm.submit();">${msg:mailthread.perform}</a>
</div>
</div></div></div></div></div></div></div></div>
</div>
<div id="content-wrapper">
${if:errors}
${errors}
${endif:errors}
</div>
</form>
</body>
</html>

View File

@ -1,45 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>${msg:chat.window.title.user}</title>
<link rel="shortcut icon" href="${mibewroot}/images/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" type="text/css" href="${tplroot}/chat.css" />
</head>
<body>
<div id="top2">
<div id="logo">
${if:company.chatLogoURL}
${if:mibewHost}
<a onclick="window.open('${page:mibewHost}');return false;" href="${page:mibewHost}">
<img src="${page:company.chatLogoURL}" alt=""/>
</a>
${else:mibewHost}
<img src="${page:company.chatLogoURL}" alt=""/>
${endif:mibewHost}
${else:company.chatLogoURL}
${if:mibewHost}
<a onclick="window.open('${page:mibewHost}');return false;" href="${page:mibewHost}">
<img src="${tplroot}/images/default-logo.gif" alt=""/>
</a>
${else:mibewHost}
<img src="${tplroot}/images/default-logo.gif" alt=""/>
${endif:mibewHost}
${endif:company.chatLogoURL}
&nbsp;
<div id="page-title">${msg:chat.mailthread.sent.title}</div>
<div class="clear">&nbsp;</div>
</div>
</div>
<div id="headers">
<div class="wndb"><div class="wndl"><div class="wndr"><div class="wndt"><div class="wndtl"><div class="wndtr"><div class="wndbl"><div class="wndbr">
<div class="buttons">
<a href="javascript:window.close();" title="${msg:chat.mailthread.sent.close}"><img class="tpl-image iclosewin" src="${tplroot}/images/free.gif" alt="${msg:chat.mailthread.sent.close}" /></a>
</div>
<div class="messagetxt">${msg:chat.mailthread.sent.content,email}</div>
</div></div></div></div></div></div></div></div>
</div>
<div id="content-wrapper">
&nbsp;
</div>
</body>
</html>

View File

@ -1,45 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>${msg:chat.window.title.user}</title>
<link rel="shortcut icon" href="${mibewroot}/images/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" type="text/css" href="${tplroot}/chat.css"/>
</head>
<body>
<div id="top2">
<div id="logo">
${if:company.chatLogoURL}
${if:mibewHost}
<a onclick="window.open('${page:mibewHost}');return false;" href="${page:mibewHost}">
<img src="${page:company.chatLogoURL}" alt=""/>
</a>
${else:mibewHost}
<img src="${page:company.chatLogoURL}" alt=""/>
${endif:mibewHost}
${else:company.chatLogoURL}
${if:mibewHost}
<a onclick="window.open('${page:mibewHost}');return false;" href="${page:mibewHost}">
<img src="${tplroot}/images/default-logo.gif" alt=""/>
</a>
${else:mibewHost}
<img src="${tplroot}/images/default-logo.gif" alt=""/>
${endif:mibewHost}
${endif:company.chatLogoURL}
&nbsp;
<div id="page-title">${msg:page.chat.old_browser.title}</div>
<div class="clear">&nbsp;</div>
</div>
</div>
<div id="headers">
<div class="wndb"><div class="wndl"><div class="wndr"><div class="wndt"><div class="wndtl"><div class="wndtr"><div class="wndbl"><div class="wndbr">
<div class="buttons">
<a href="javascript:window.close();" title="${msg:page.chat.old_browser.close}"><img class="tpl-image iclosewin" src="${tplroot}/images/free.gif" alt="${msg:page.chat.old_browser.close}" /></a>
</div>
<div class="messagetxt">${msg:page.chat.old_browser.problem}</div>
</div></div></div></div></div></div></div></div>
</div>
<div id="content-wrapper">
${msg:page.chat.old_browser.list}
</div>
</body>
</html>

View File

@ -1,62 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>${msg:chat.window.title.agent}</title>
<link rel="shortcut icon" href="${mibewroot}/images/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" type="text/css" href="${tplroot}/chat.css" />
</head>
<body>
<div id="top2">
<div id="logo">
${if:company.chatLogoURL}
${if:mibewHost}
<a onclick="window.open('${page:mibewHost}');return false;" href="${page:mibewHost}">
<img src="${page:company.chatLogoURL}" alt=""/>
</a>
${else:mibewHost}
<img src="${page:company.chatLogoURL}" alt=""/>
${endif:mibewHost}
${else:company.chatLogoURL}
${if:mibewHost}
<a onclick="window.open('${page:mibewHost}');return false;" href="${page:mibewHost}">
<img src="${tplroot}/images/default-logo.gif" alt=""/>
</a>
${else:mibewHost}
<img src="${tplroot}/images/default-logo.gif" alt=""/>
${endif:mibewHost}
${endif:company.chatLogoURL}
&nbsp;<br />&nbsp;
<div id="page-title">${msg:chat.redirect.title}</div>
<div class="clear">&nbsp;</div>
</div>
</div>
<div id="headers">
<div class="wndb"><div class="wndl"><div class="wndr"><div class="wndt"><div class="wndtl"><div class="wndtr"><div class="wndbl"><div class="wndbr">
<div class="buttons">
<a href="javascript:window.close();" title="${msg:chat.redirect.back}"><img class="tpl-image iclosewin" src="${tplroot}/images/free.gif" alt="${msg:chat.redirect.back}" /></a>
</div>
<div class="messagetxt">${msg:chat.redirect.choose}</div>
</div></div></div></div></div></div></div></div>
</div>
<div id="content-wrapper">
<div class="left">
${if:redirectToAgent}
<strong>${msg:chat.redirect.operator}</strong>
<ul class="agentlist">
${page:redirectToAgent}
</ul>
${endif:redirectToAgent}
</div>
<div class="right">
${if:redirectToGroup}
<strong>${msg:chat.redirect.group}</strong>
<ul class="agentlist">
${page:redirectToGroup}
</ul>
${endif:redirectToGroup}
</div>
<div class="clear">%nbsp;</div>
<div class="center">${pagination}</div>
</div>
</body>
</html>

View File

@ -1,45 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>${msg:chat.window.title.user}</title>
<link rel="shortcut icon" href="${mibewroot}/images/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" type="text/css" href="${tplroot}/chat.css" />
</head>
<body>
<div id="top2">
<div id="logo">
${if:company.chatLogoURL}
${if:mibewHost}
<a onclick="window.open('${page:mibewHost}');return false;" href="${page:mibewHost}">
<img src="${page:company.chatLogoURL}" alt=""/>
</a>
${else:mibewHost}
<img src="${page:company.chatLogoURL}" alt=""/>
${endif:mibewHost}
${else:company.chatLogoURL}
${if:mibewHost}
<a onclick="window.open('${page:mibewHost}');return false;" href="${page:mibewHost}">
<img src="${tplroot}/images/default-logo.gif" alt=""/>
</a>
${else:mibewHost}
<img src="${tplroot}/images/default-logo.gif" alt=""/>
${endif:mibewHost}
${endif:company.chatLogoURL}
&nbsp;
<div id="page-title">${msg:chat.redirected.title}</div>
<div class="clear">&nbsp;</div>
</div>
</div>
<div id="headers">
<div class="wndb"><div class="wndl"><div class="wndr"><div class="wndt"><div class="wndtl"><div class="wndtr"><div class="wndbl"><div class="wndbr">
<div class="buttons">
<a href="javascript:window.close();" title="${msg:chat.redirected.close}"><img class="tpl-image iclosewin" src="${tplroot}/images/free.gif" alt="${msg:chat.redirected.close}" /></a>
</div>
<div class="messagetxt">${page:message}</div>
</div></div></div></div></div></div></div></div>
</div>
<div id="content-wrapper">
&nbsp;
</div>
</body>
</html>

View File

@ -0,0 +1,56 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>{{#block "windowTitle"}}{{l10n "chat.window.title.user"}}{{/block}}</title>
<link rel="shortcut icon" href="{{mibewRoot}}/images/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="{{stylePath}}/chat.css" media="all" />
{{#block "head"}}{{/block}}
</head>
<body>
{{#block "page"}}
{{! Logo block}}
<div id="top2">
<div id="logo">
{{#if company.chatLogoURL}}
{{#if mibewHost}}
<a onclick="window.open('{{mibewHost}}');return false;" href="{{mibewHost}}">
<img src="{{company.chatLogoURL}}" alt=""/>
</a>
{{else}}
<img src="{{company.chatLogoURL}}" alt=""/>
{{/if}}
{{else}}
{{#if mibewHost}}
<a onclick="window.open('{{mibewHost}}');return false;" href="{{mibewHost}}">
<img src="{{stylePath}}/images/default-logo.gif" alt=""/>
</a>
{{else}}
<img src="{{stylePath}}/images/default-logo.gif" alt=""/>
{{/if}}
{{/if}}
<div id="page-title">{{#block "pageTitle"}}{{l10n "chat.window.title.user"}}{{/block}}</div>
<div class="clear">&nbsp;</div>
</div>
</div>
{{! Header block. Contains page description and buttons}}
<div id="headers">
<div class="wndb"><div class="wndl"><div class="wndr"><div class="wndt"><div class="wndtl"><div class="wndtr"><div class="wndbl"><div class="wndbr">
<div class="buttons">
{{#block "buttons"}}{{/block}}
</div>
<div class="messagetxt">
{{#block "message"}}&nbsp;{{/block}}
</div>
</div></div></div></div></div></div></div></div>
</div>
{{! Main content block}}
<div id="content-wrapper">
{{#block "content"}}&nbsp;{{/block}}
</div>
{{/block}}
</body>
</html>

View File

@ -0,0 +1,116 @@
{{#extends "_layout"}}
{{#override "head"}}
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="{{stylePath}}/chat_ie7.css" media="all" />
<![endif]-->
{{additional_css}}
<!-- External libs -->
<script type="text/javascript" src="{{mibewRoot}}/js/libs/jquery.min.js"></script>
<script type="text/javascript" src="{{mibewRoot}}/js/libs/json2.js"></script>
<script type="text/javascript" src="{{mibewRoot}}/js/libs/underscore-min.js"></script>
<script type="text/javascript" src="{{mibewRoot}}/js/libs/backbone-min.js"></script>
<script type="text/javascript" src="{{mibewRoot}}/js/libs/backbone.marionette.min.js"></script>
<script type="text/javascript" src="{{mibewRoot}}/js/libs/handlebars.js"></script>
<!-- Javascript templates -->
<script type="text/javascript" src="{{stylePath}}/js/compiled/templates.js"></script>
<!-- Application files -->
<script type="text/javascript" src="{{mibewRoot}}/js/compiled/mibewapi.js"></script>
<script type="text/javascript" src="{{mibewRoot}}/js/compiled/default_app.js"></script>
<script type="text/javascript" src="{{mibewRoot}}/js/compiled/chat_app.js"></script>
<!-- Add style scripts -->
<script type="text/javascript" src="{{stylePath}}/js/compiled/scripts.js"></script>
{{additional_js}}
<script type="text/javascript"><!--
// Localized strings for the core
Mibew.Localization.set({
'chat.close.confirmation': '{{#jsString}}{{l10n "chat.close.confirmation"}}{{/jsString}}',
'typing.remote': '{{#jsString}}{{l10n "typing.remote"}}{{/jsString}}',
'chat.window.predefined.select_answer': '{{#jsString}}{{l10n "chat.window.predefined.select_answer"}}{{/jsString}}',
'chat.window.send_message': '{{#jsString}}{{l10n "chat.window.send_message"}}{{/jsString}}',
'chat.window.send_message_short_and_shortcut': '{{#jsString}}{{l10n "chat.window.send_message_short" send_shortcut}}{{/jsString}}',
'chat.window.close_title': '{{#jsString}}{{l10n "chat.window.close_title"}}{{/jsString}}',
'chat.window.toolbar.refresh': '{{#jsString}}{{l10n "chat.window.toolbar.refresh"}}{{/jsString}}',
'chat.window.toolbar.mail_history': '{{#jsString}}{{l10n "chat.window.toolbar.mail_history"}}{{/jsString}}',
'chat.window.toolbar.redirect_user': '{{#jsString}}{{l10n "chat.window.toolbar.redirect_user"}}{{/jsString}}',
'page.analysis.userhistory.title': '{{#jsString}}{{l10n "page.analysis.userhistory.title"}}{{/jsString}}',
'chat.client.name': '{{#jsString}}{{l10n "chat.client.name"}}{{/jsString}}',
'chat.client.changename': '{{#jsString}}{{l10n "chat.client.changename"}}{{/jsString}}',
'chat.window.toolbar.turn_off_sound': '{{#jsString}}{{l10n "chat.window.toolbar.turn_off_sound"}}{{/jsString}}',
'chat.window.toolbar.turn_on_sound': '{{#jsString}}{{l10n "chat.window.toolbar.turn_on_sound"}}{{/jsString}}',
'chat.window.poweredby': '{{#jsString}}{{l10n "chat.window.poweredby"}}{{/jsString}}',
'chat.mailthread.sent.close': '{{#jsString}}{{l10n "chat.mailthread.sent.close"}}{{/jsString}}',
'form.field.department': '{{#jsString}}{{l10n "form.field.department"}}{{/jsString}}',
'form.field.department.description': '{{#jsString}}{{l10n "form.field.department.description"}}{{/jsString}}',
'form.field.email': '{{#jsString}}{{l10n "form.field.email"}}{{/jsString}}',
'form.field.name': '{{#jsString}}{{l10n "form.field.name"}}{{/jsString}}',
'form.field.message': '{{#jsString}}{{l10n "form.field.message"}}{{/jsString}}',
'leavemessage.close': '{{#jsString}}{{l10n "leavemessage.close"}}{{/jsString}}',
'leavemessage.descr': '{{#jsString}}{{l10n "leavemessage.descr"}}{{/jsString}}',
'leavemessage.sent.message': '{{#jsString}}{{l10n "leavemessage.sent.message"}}{{/jsString}}',
'leavemessage.error.email.required': '{{#jsString}}{{localized.[email.required]}}{{/jsString}}',
'leavemessage.error.name.required': '{{#jsString}}{{localized.[name.required]}}{{/jsString}}',
'leavemessage.error.message.required': '{{#jsString}}{{localized.[message.required]}}{{/jsString}}',
'leavemessage.error.wrong.email': '{{#jsString}}{{localized.[wrong.email]}}{{/jsString}}',
'errors.captcha': '{{#jsString}}{{l10n "errors.captcha"}}{{/jsString}}',
'mailthread.perform': '{{#jsString}}{{l10n "mailthread.perform"}}{{/jsString}}',
'presurvey.name': '{{#jsString}}{{l10n "presurvey.name"}}{{/jsString}}',
'presurvey.mail': '{{#jsString}}{{l10n "presurvey.mail"}}{{/jsString}}',
'presurvey.question': '{{#jsString}}{{l10n "presurvey.question"}}{{/jsString}}',
'presurvey.submit': '{{#jsString}}{{l10n "presurvey.submit"}}{{/jsString}}',
'presurvey.error.wrong_email': '{{#jsString}}{{l10n "presurvey.error.wrong_email"}}{{/jsString}}',
'presurvey.title': '{{#jsString}}{{l10n "presurvey.title"}}{{/jsString}}',
'presurvey.intro': '{{#jsString}}{{l10n "presurvey.intro"}}{{/jsString}}'
});
// Plugins localization
Mibew.Localization.set({{additional_localized_strings}});
//--></script>
<!-- Run application -->
<script type="text/javascript"><!--
jQuery(document).ready(function(){
Mibew.Application.start({
server: {
url: '{{mibewRoot}}/thread.php',
requestsFrequency: {{frequency}}
},
page: {
style: '{{styleName}}',
mibewRoot: '{{mibewRoot}}',
tplRoot: '{{stylePath}}',
company: {
name: '{{#jsString}}{{company.name}}{{/jsString}}',
chatLogoURL: '{{company.chatLogoURL}}'
},
mibewHost: '{{mibewHost}}',
title: '{{#jsString}}{{[page.title]}}{{/jsString}}'
},
{{#if chatOptions}}
chatOptions: {{{chatOptions}}},
{{/if}}
{{#if surveyOptions}}
surveyOptions: {{{surveyOptions}}},
{{/if}}
{{#if leaveMessageOptions}}
leaveMessageOptions: {{{leaveMessageOptions}}},
{{/if}}
{{#if invitationOptions}}
invitationOptions: {{{invitationOptions}}},
{{/if}}
startFrom: '{{startFrom}}',
plugins: {{{js_plugin_options}}}
});
});
//--></script>
{{/override}}
{{#override "page"}}
<div id="main-region"></div>
{{/override}}
{{/extends}}

View File

@ -0,0 +1,23 @@
{{#extends "_layout"}}
{{#override "windowTitle"}}{{l10n "chat.error_page.title"}}{{/override}}
{{#override "pageTitle"}}{{l10n "chat.error_page.title"}}{{/override}}
{{#override "buttons"}}
<a href="javascript:window.close();" title="{{l10n 'chat.error_page.close'}}">
<img class="tpl-image iclosewin" src="{{stylePath}}/images/free.gif" alt="{{l10n 'chat.error_page.close'}}" />
</a>
{{/override}}
{{#override "content"}}
{{#if errors}}
{{l10n "harderrors.header"}}
{{#each errors}}
{{l10n "errors.prefix"}}
{{{this}}}
{{l10n "errors.suffix"}}
{{/each}}
{{l10n "errors.footer"}}
{{/if}}
{{/override}}
{{/extends}}

View File

@ -0,0 +1,34 @@
{{#extends "_layout"}}
{{#override "pageTitle"}}{{l10n "mailthread.title"}}{{/override}}
{{#override "buttons"}}
<a href="javascript:window.close();" title="{{l10n 'mailthread.close'}}">
<img class="tpl-image iclosewin" src="{{stylePath}}/images/free.gif" alt="{{l10n 'mailthread.close'}}" />
</a>
{{/override}}
{{#override "message"}}
<form name="mailThreadForm" method="post" action="{{mibewRoot}}/mail.php">
<input type="hidden" name="style" value="{{styleName}}"/>
<input type="hidden" name="thread" value="{{chat.thread.id}}"/>
<input type="hidden" name="token" value="{{chat.thread.token}}"/>
<input type="hidden" name="level" value="{{level}}"/>
<strong>{{l10n "mailthread.enter_email"}}</strong>
<input type="text" name="email" size="20" value="{{formemail}}" class="username" />&nbsp;
<a href="javascript:document.mailThreadForm.submit();">{{l10n "mailthread.perform"}}</a>
</form>
{{/override}}
{{#override "content"}}
{{#if errors}}
{{l10n "errors.header"}}
{{#each errors}}
{{l10n "errors.prefix"}}
{{{this}}}
{{l10n "errors.suffix"}}
{{/each}}
{{l10n "errors.footer"}}
{{/if}}
{{/override}}
{{/extends}}

View File

@ -0,0 +1,11 @@
{{#extends "_layout"}}
{{#override "pageTitle"}}{{l10n "chat.mailthread.sent.title"}}{{/override}}
{{#override "buttons"}}
<a href="javascript:window.close();" title="{{l10n 'chat.mailthread.sent.close'}}">
<img class="tpl-image iclosewin" src="{{stylePath}}/images/free.gif" alt="{{l10n 'chat.mailthread.sent.close'}}" />
</a>
{{/override}}
{{#override "message"}}{{l10n "chat.mailthread.sent.content" email}}{{/override}}
{{/extends}}

View File

@ -0,0 +1,15 @@
{{#extends "_layout"}}
{{#override "pageTitle"}}{{l10n "chat.error_page.title"}}{{/override}}
{{#override "buttons"}}
<a href="javascript:window.close();" title="{{l10n 'page.chat.old_browser.close'}}">
<img class="tpl-image iclosewin" src="{{stylePath}}/images/free.gif" alt="{{l10n 'page.chat.old_browser.close'}}" />
</a>
{{/override}}
{{#override "message"}}{{l10n "page.chat.old_browser.problem"}}{{/override}}
{{#override "content"}}
{{l10n "page.chat.old_browser.list"}}
{{/override}}
{{/extends}}

View File

@ -0,0 +1,32 @@
{{#extends "_layout"}}
{{#override "pageTitle"}}{{l10n "chat.redirect.title"}}{{/override}}
{{#override "buttons"}}
<a href="javascript:window.close();" title="{{l10n 'chat.redirect.back'}}">
<img class="tpl-image iclosewin" src="{{stylePath}}/images/free.gif" alt="{{l10n 'chat.redirect.back'}}" />
</a>
{{/override}}
{{#override "message"}}{{l10n "chat.redirect.choose"}}{{/override}}
{{#override "content"}}
<div class="left">
{{#if redirectToAgent}}
<strong>{{l10n "chat.redirect.operator"}}</strong>
<ul class="agentlist">
{{{redirectToAgent}}}
</ul>
{{/if}}
</div>
<div class="right">
{{#if redirectToGroup}}
<strong>{{l10n "chat.redirect.group"}}</strong>
<ul class="agentlist">
{{{redirectToGroup}}}
</ul>
{{/if}}
</div>
<div class="clear">&nbsp;</div>
<div class="center">{{generatePagination stylePath pagination}}</div>
{{/override}}
{{/extends}}

View File

@ -0,0 +1,11 @@
{{#extends "_layout"}}
{{#override "pageTitle"}}{{l10n "chat.redirected.title"}}{{/override}}
{{#override "buttons"}}
<a href="javascript:window.close();" title="{{l10n 'chat.redirected.close'}}">
<img class="tpl-image iclosewin" src="{{stylePath}}/images/free.gif" alt="{{l10n 'chat.redirected.close'}}" />
</a>
{{/override}}
{{#override "message"}}{{message}}{{/override}}
{{/extends}}