From 88694193b4b8319d41d401ed1f113342f729d107 Mon Sep 17 00:00:00 2001 From: "Fedor A. Fetisov" Date: Thu, 15 May 2014 00:53:48 +0400 Subject: [PATCH] Port text button from legacy (see Issue #35) --- src/mibew/libs/getcode.php | 7 +++-- src/mibew/locales/en/properties | 2 ++ src/mibew/operator/getcode.php | 31 +++++++++++++------ .../server_side/get_code.handlebars | 4 +-- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/mibew/libs/getcode.php b/src/mibew/libs/getcode.php index 9801b4ea..ddabc862 100644 --- a/src/mibew/libs/getcode.php +++ b/src/mibew/libs/getcode.php @@ -35,6 +35,8 @@ use Mibew\Style\InvitationStyle; * @param bool $mod_security add rule to remove protocol from document location * in generated javascript code * @param bool $operator_code add operator code to generated button code or not + * @param bool $disable_invitation forcibly disable invitation regadless of + * tracking settings * * @return string Generate chat button code */ @@ -48,7 +50,8 @@ function generate_button( $show_host, $force_secure, $mod_security, - $operator_code + $operator_code, + $disable_invitation ) { $app_location = get_app_location($show_host, $force_secure); $link = $app_location . "/client.php"; @@ -92,7 +95,7 @@ function generate_button( // Generate button $temp = get_popup($link, "$js_link", $inner, $title, "mibew", $popup_options); - if (Settings::get('enabletracking')) { + if (!$disable_invitation && Settings::get('enabletracking')) { $widget_data = array(); // Get actual invitation style instance diff --git a/src/mibew/locales/en/properties b/src/mibew/locales/en/properties index 90f8c03b..151dbe4e 100644 --- a/src/mibew/locales/en/properties +++ b/src/mibew/locales/en/properties @@ -296,6 +296,8 @@ page.gen_button.modsecurity=Compatibility with mod_security (modsecurity.org), t page.gen_button.operator_code=operator code field page.gen_button.sample=Example page.gen_button.secure_links=Use secure links (https) +page.gen_button.text_link=text link +page.gen_button.text_link_text=Click to chat page.gen_button.title=Button HTML code generation page.group.create_new=Create new group here. page.group.duplicate_name=Please choose another name because a group with that name already exists. diff --git a/src/mibew/operator/getcode.php b/src/mibew/operator/getcode.php index 3aafc1e3..1ecf92d0 100644 --- a/src/mibew/operator/getcode.php +++ b/src/mibew/operator/getcode.php @@ -59,7 +59,7 @@ $show_host = verify_param("hostname", "/^on$/", "") == "on"; $force_secure = verify_param("secure", "/^on$/", "") == "on"; $mod_security = verify_param("modsecurity", "/^on$/", "") == "on"; -$code_type = verify_param("codetype", "/^(button|operator_code)$/", "button"); +$code_type = verify_param("codetype", "/^(button|operator_code|text_link)$/", "button"); $operator_code = ($code_type == "operator_code"); $lang = verify_param("lang", "/^[\w-]{2,5}$/", ""); @@ -67,14 +67,24 @@ if (!$lang || !in_array($lang, $image_locales)) { $lang = in_array(CURRENT_LOCALE, $image_locales) ? CURRENT_LOCALE : $image_locales[0]; } -$file = MIBEW_FS_ROOT . '/locales/${lang}/button/${image}_on.gif'; -$size = get_gifimage_size($file); +if ($code_type == "text_link") { + $disable_invitation = true; + + $message = getlocal('page.gen_button.text_link_text'); -$image_href = get_app_location($show_host, $force_secure) . "/b?i=$image&lang=$lang"; -if ($group_id) { - $image_href .= "&group=$group_id"; } -$message = get_image($image_href, $size[0], $size[1]); +else { + $disable_invitation = false; + + $file = MIBEW_FS_ROOT . '/locales/${lang}/button/${image}_on.gif'; + $size = get_gifimage_size($file); + + $image_href = get_app_location($show_host, $force_secure) . "/b?i=$image&lang=$lang"; + if ($group_id) { + $image_href .= "&group=$group_id"; + } + $message = get_image($image_href, $size[0], $size[1]); +} $page['buttonCode'] = generate_button( "", @@ -86,7 +96,8 @@ $page['buttonCode'] = generate_button( $show_host, $force_secure, $mod_security, - $operator_code + $operator_code, + $disable_invitation ); $page['availableImages'] = array_keys($image_locales_map); $page['availableLocales'] = $image_locales; @@ -96,7 +107,8 @@ $page['groups'] = get_groups_list(); $page['availableCodeTypes'] = array( 'button' => getlocal('page.gen_button.button'), - 'operator_code' => getlocal('page.gen_button.operator_code') + 'operator_code' => getlocal('page.gen_button.operator_code'), + 'text_link' => getlocal('page.gen_button.text_link') ); $page['formgroup'] = $group_id; @@ -111,6 +123,7 @@ $page['formcodetype'] = $code_type; $page['enabletracking'] = Settings::get('enabletracking'); $page['operator_code'] = $operator_code; +$page['generateButton'] = ($code_type == "button"); $page['title'] = getlocal("page.gen_button.title"); $page['menuid'] = "getcode"; diff --git a/src/mibew/styles/pages/default/templates_src/server_side/get_code.handlebars b/src/mibew/styles/pages/default/templates_src/server_side/get_code.handlebars index 936b798f..c3072942 100644 --- a/src/mibew/styles/pages/default/templates_src/server_side/get_code.handlebars +++ b/src/mibew/styles/pages/default/templates_src/server_side/get_code.handlebars @@ -52,7 +52,7 @@
- {{#unless operator_code}} + {{#if generateButton}}
@@ -78,7 +78,7 @@ {{/if}}
- {{/unless}} + {{/if}}