From a4d12d7b6578029a56b55002d8a63c3673e14e15 Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Tue, 26 Feb 2013 11:31:24 +0000 Subject: [PATCH] Add 'msgjs:' and 'pagejs:' prefixies to template engine --- src/messenger/webim/libs/expand.php | 17 ++-- .../styles/dialogs/default/templates/chat.tpl | 78 +++++++++---------- 2 files changed, 51 insertions(+), 44 deletions(-) diff --git a/src/messenger/webim/libs/expand.php b/src/messenger/webim/libs/expand.php index 7cdfcdff..53d76df3 100644 --- a/src/messenger/webim/libs/expand.php +++ b/src/messenger/webim/libs/expand.php @@ -65,18 +65,25 @@ function expand_var($matches) } } - } else if ($prefix == 'msg:' || $prefix == 'url:') { + } else if ($prefix == 'msg:' || $prefix == 'msgjs:' || $prefix == 'url:') { + $message = ''; if (strpos($var, ",") !== false) { $pos = strpos($var, ","); $param = substr($var, $pos + 1); $var = substr($var, 0, $pos); - return getlocal2($var, array($page[$param])); + $message = getlocal2($var, array($page[$param])); + } else { + $message = getlocal($var); } - return getlocal($var); + if ($prefix == 'msgjs:') { + return json_encode($message); + } + return $message; } else if ($prefix == 'form:') { return form_value($var); - } else if ($prefix == 'page:') { - return isset($page[$var]) ? $page[$var] : ""; + } else if ($prefix == 'page:' || $prefix == 'pagejs:') { + $message = isset($page[$var]) ? $page[$var] : ""; + return ($prefix == 'pagejs:') ? json_encode($message) : $message; } else if ($prefix == 'if:' || $prefix == 'else:' || $prefix == 'endif:' || $prefix == 'ifnot:') { return ""; } diff --git a/src/messenger/webim/styles/dialogs/default/templates/chat.tpl b/src/messenger/webim/styles/dialogs/default/templates/chat.tpl index ca3fe308..0918e87d 100644 --- a/src/messenger/webim/styles/dialogs/default/templates/chat.tpl +++ b/src/messenger/webim/styles/dialogs/default/templates/chat.tpl @@ -32,43 +32,43 @@ ${page:additional_js} @@ -85,11 +85,11 @@ webimRoot: '${webimroot}', tplRoot: '${tplroot}', company: { - name: '${page:company.name}', + name: ${pagejs:company.name}, chatLogoURL: '${page:company.chatLogoURL}' }, webimHost: '${page:webimHost}', - title: '${page:page.title}' + title: ${pagejs:page.title} }, ${if:chatOptions} chatOptions: ${page:chatOptions},