From 4f3c9af3c484457ddd6daeab2a11b288b5ebacca Mon Sep 17 00:00:00 2001 From: "Fedor A. Fetisov" Date: Thu, 15 May 2014 01:06:12 +0400 Subject: [PATCH] Generate non-graphical buttons for locales with missed images --- src/mibew/operator/getcode.php | 35 ++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/mibew/operator/getcode.php b/src/mibew/operator/getcode.php index 1ecf92d0..ff668017 100644 --- a/src/mibew/operator/getcode.php +++ b/src/mibew/operator/getcode.php @@ -54,6 +54,8 @@ if ($invitation_style && !in_array($invitation_style, $invitation_style_list)) { $invitation_style = ""; } +$locales_list = get_available_locales(); + $group_id = verifyparam_groupid("group", $page['errors']); $show_host = verify_param("hostname", "/^on$/", "") == "on"; $force_secure = verify_param("secure", "/^on$/", "") == "on"; @@ -61,21 +63,16 @@ $mod_security = verify_param("modsecurity", "/^on$/", "") == "on"; $code_type = verify_param("codetype", "/^(button|operator_code|text_link)$/", "button"); $operator_code = ($code_type == "operator_code"); +$generate_button = ($code_type == "button"); -$lang = verify_param("lang", "/^[\w-]{2,5}$/", ""); -if (!$lang || !in_array($lang, $image_locales)) { - $lang = in_array(CURRENT_LOCALE, $image_locales) ? CURRENT_LOCALE : $image_locales[0]; -} - -if ($code_type == "text_link") { - $disable_invitation = true; - - $message = getlocal('page.gen_button.text_link_text'); - -} -else { +if ($generate_button) { $disable_invitation = false; + $lang = verify_param("lang", "/^[\w-]{2,5}$/", ""); + 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); @@ -85,6 +82,16 @@ else { } $message = get_image($image_href, $size[0], $size[1]); } +else { + $disable_invitation = true; + + $lang = verify_param("lang", "/^[\w-]{2,5}$/", ""); + if (!$lang || !in_array($lang, $locales_list)) { + $lang = in_array(CURRENT_LOCALE, $locales_list) ? CURRENT_LOCALE : $locales_list[0]; + } + + $message = getlocal('page.gen_button.text_link_text'); +} $page['buttonCode'] = generate_button( "", @@ -100,7 +107,7 @@ $page['buttonCode'] = generate_button( $disable_invitation ); $page['availableImages'] = array_keys($image_locales_map); -$page['availableLocales'] = $image_locales; +$page['availableLocales'] = $generate_button ? $image_locales : $locales_list; $page['availableChatStyles'] = $style_list; $page['availableInvitationStyles'] = $invitation_style_list; $page['groups'] = get_groups_list(); @@ -123,7 +130,7 @@ $page['formcodetype'] = $code_type; $page['enabletracking'] = Settings::get('enabletracking'); $page['operator_code'] = $operator_code; -$page['generateButton'] = ($code_type == "button"); +$page['generateButton'] = $generate_button; $page['title'] = getlocal("page.gen_button.title"); $page['menuid'] = "getcode";