Port text button from legacy (see Issue #35)

This commit is contained in:
Fedor A. Fetisov 2014-05-15 00:53:48 +04:00
parent e76ded074c
commit 88694193b4
4 changed files with 31 additions and 13 deletions

View File

@ -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

View File

@ -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.

View File

@ -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";

View File

@ -52,7 +52,7 @@
</div>
<br clear="all"/>
{{#unless operator_code}}
{{#if generateButton}}
<div class="fieldinrow">
<label for="i" class="flabel">{{l10n "page.gen_button.choose_image"}}</label>
<div class="fvaluenodesc">
@ -78,7 +78,7 @@
{{/if}}
<br clear="all"/>
{{/unless}}
{{/if}}
<div class="fieldinrow">
<label for="group" class="flabel">{{l10n "page.gen_button.choose_group"}}</label>