From 7410a0019b5a257a41ba8ef06473d33fb62aea42 Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Thu, 5 Jun 2014 08:51:14 +0000 Subject: [PATCH] Replace "getlocal2" function with "getlocal" one --- src/mibew/install/index.php | 28 +++++++++---------- src/mibew/libs/chat.php | 10 ++++--- .../Mibew/Controller/BanController.php | 2 +- .../Mibew/Controller/Chat/MailController.php | 6 ++-- .../Controller/Chat/RedirectController.php | 4 +-- .../Controller/PasswordRecoveryController.php | 2 +- .../Mibew/Controller/StatisticsController.php | 2 +- .../classes/Mibew/Handlebars/HelpersSet.php | 6 +--- .../RequestProcessor/ThreadProcessor.php | 8 +++--- src/mibew/libs/common/locale.php | 5 ---- src/mibew/libs/common/response.php | 6 ++-- src/mibew/libs/invitation.php | 3 +- src/mibew/libs/operator.php | 2 +- src/mibew/libs/pagination.php | 4 +-- 14 files changed, 42 insertions(+), 46 deletions(-) diff --git a/src/mibew/install/index.php b/src/mibew/install/index.php index 8957fa02..27e66a55 100644 --- a/src/mibew/install/index.php +++ b/src/mibew/install/index.php @@ -83,7 +83,7 @@ function check_mibewroot() return false; } - $page['done'][] = getlocal2("install.0.app", array(MIBEW_WEB_ROOT)); + $page['done'][] = getlocal("install.0.app", array(MIBEW_WEB_ROOT)); return true; } @@ -129,9 +129,9 @@ function check_files() $packageFile = MIBEW_FS_ROOT . "/install/package"; $fp = @fopen($packageFile, "r"); if ($fp === FALSE) { - $errors[] = getlocal2("install.cannot_read", array(MIBEW_WEB_ROOT . "/install/package")); + $errors[] = getlocal("install.cannot_read", array(MIBEW_WEB_ROOT . "/install/package")); if (file_exists($packageFile)) { - $errors[] = getlocal2("install.check_permissions", array(fpermissions($packageFile))); + $errors[] = getlocal("install.check_permissions", array(fpermissions($packageFile))); } return false; } @@ -150,10 +150,10 @@ function check_files() $relativeName = MIBEW_FS_ROOT . "/$file"; if (!is_readable($relativeName)) { if (file_exists($relativeName)) { - $errors[] = getlocal2("install.cannot_read", array(MIBEW_WEB_ROOT . "/$file")); - $errors[] = getlocal2("install.check_permissions", array(fpermissions($relativeName))); + $errors[] = getlocal("install.cannot_read", array(MIBEW_WEB_ROOT . "/$file")); + $errors[] = getlocal("install.check_permissions", array(fpermissions($relativeName))); } else { - $errors[] = getlocal2("install.no_file", array(MIBEW_WEB_ROOT . "/$file")); + $errors[] = getlocal("install.no_file", array(MIBEW_WEB_ROOT . "/$file")); } return false; } @@ -164,7 +164,7 @@ function check_files() $result = md5(str_replace("\r", "", file_get_contents($relativeName))); } if ($result != $sum) { - $errors[] = getlocal2("install.bad_checksum", array(MIBEW_WEB_ROOT . "/$file")); + $errors[] = getlocal("install.bad_checksum", array(MIBEW_WEB_ROOT . "/$file")); $errors[] = getlocal("install.check_files"); return false; } @@ -182,7 +182,7 @@ function check_connection() if ($link) { $result = mysql_query("SELECT VERSION() as c", $link); if ($result && $ver = mysql_fetch_array($result, MYSQL_ASSOC)) { - $page['done'][] = getlocal2("install.1.connected", array($ver['c'])); + $page['done'][] = getlocal("install.1.connected", array($ver['c'])); mysql_free_result($result); } else { $errors[] = "Version of your SQL server is unknown. Please check. Error: " . mysql_error($link); @@ -191,7 +191,7 @@ function check_connection() } return $link; } else { - $errors[] = getlocal2("install.connection.error", array(mysql_error())); + $errors[] = getlocal("install.connection.error", array(mysql_error())); return null; } } @@ -200,12 +200,12 @@ function check_database($link) { global $mysqldb, $page; if (mysql_select_db($mysqldb, $link)) { - $page['done'][] = getlocal2("install.2.db_exists", array($mysqldb)); + $page['done'][] = getlocal("install.2.db_exists", array($mysqldb)); mysql_query("SET character set utf8", $link); return true; } else { - $page['nextstep'] = getlocal2("install.2.create", array($mysqldb)); + $page['nextstep'] = getlocal("install.2.create", array($mysqldb)); $page['nextnotice'] = getlocal("install.2.notice"); $page['nextstepurl'] = MIBEW_WEB_ROOT . "/install/dbperform.php?act=createdb"; } @@ -281,7 +281,7 @@ function check_sound() global $page; $page['soundcheck'] = true; - $page['done'][] = getlocal2("install.5.text", array( + $page['done'][] = getlocal("install.5.text", array( "" . getlocal("install.5.newvisitor") . "", "" . getlocal("install.5.newmessage") . "" )); @@ -333,7 +333,7 @@ function check_status() { global $page, $mysqlprefix; - $page['done'][] = getlocal2("install.0.php", array(phpversion())); + $page['done'][] = getlocal("install.0.php", array(phpversion())); if (!check_mibewroot()) { return; @@ -371,7 +371,7 @@ function check_status() if (!check_admin($link)) { $page['nextstep'] = getlocal("installed.login_link"); - $page['nextnotice'] = getlocal2("installed.notice", array(MIBEW_WEB_ROOT . "/install/")); + $page['nextnotice'] = getlocal("installed.notice", array(MIBEW_WEB_ROOT . "/install/")); $page['nextstepurl'] = MIBEW_WEB_ROOT . "/operator/login?login=admin"; } diff --git a/src/mibew/libs/chat.php b/src/mibew/libs/chat.php index 1906f935..e780865e 100644 --- a/src/mibew/libs/chat.php +++ b/src/mibew/libs/chat.php @@ -766,9 +766,10 @@ function chat_start_for_user( $operator_name = get_operator_name($operator); $thread->postMessage( Thread::KIND_FOR_AGENT, - getlocal2( + getlocal( 'chat.visitor.invitation.accepted', array($operator_name), + CURRENT_LOCALE, true ) ); @@ -776,15 +777,16 @@ function chat_start_for_user( if ($referrer) { $thread->postMessage( Thread::KIND_FOR_AGENT, - getlocal2('chat.came.from', array($referrer), true) + getlocal('chat.came.from', array($referrer), CURRENT_LOCALE, true) ); } if ($requested_operator && !$requested_operator_online) { $thread->postMessage( Thread::KIND_INFO, - getlocal2( + getlocal( 'chat.requested_operator.offline', array(get_operator_name($requested_operator)), + CURRENT_LOCALE, true ) ); @@ -800,7 +802,7 @@ function chat_start_for_user( if ($info) { $thread->postMessage( Thread::KIND_FOR_AGENT, - getlocal2('chat.visitor.info', array($info), true) + getlocal('chat.visitor.info', array($info), CURRENT_LOCALE, true) ); } diff --git a/src/mibew/libs/classes/Mibew/Controller/BanController.php b/src/mibew/libs/classes/Mibew/Controller/BanController.php index 3a9fd1fe..ceee5a02 100644 --- a/src/mibew/libs/classes/Mibew/Controller/BanController.php +++ b/src/mibew/libs/classes/Mibew/Controller/BanController.php @@ -214,7 +214,7 @@ class BanController extends AbstractController 'ban_edit', array('ban_id' => $existing_ban['banid']) ); - $errors[] = getlocal2('ban.error.duplicate', array($address, $ban_url)); + $errors[] = getlocal('ban.error.duplicate', array($address, $ban_url)); } if (count($errors) != 0) { diff --git a/src/mibew/libs/classes/Mibew/Controller/Chat/MailController.php b/src/mibew/libs/classes/Mibew/Controller/Chat/MailController.php index b6c5cbb0..958dd257 100644 --- a/src/mibew/libs/classes/Mibew/Controller/Chat/MailController.php +++ b/src/mibew/libs/classes/Mibew/Controller/Chat/MailController.php @@ -111,13 +111,15 @@ class MailController extends AbstractController } $subject = getlocal('mail.user.history.subject', null, CURRENT_LOCALE, true); - $body = getlocal2( + $body = getlocal( 'mail.user.history.body', - array($thread->userName, + array( + $thread->userName, $history, Settings::get('title'), Settings::get('hosturl') ), + CURRENT_LOCALE, true ); diff --git a/src/mibew/libs/classes/Mibew/Controller/Chat/RedirectController.php b/src/mibew/libs/classes/Mibew/Controller/Chat/RedirectController.php index 2fabfda5..958a5d7d 100644 --- a/src/mibew/libs/classes/Mibew/Controller/Chat/RedirectController.php +++ b/src/mibew/libs/classes/Mibew/Controller/Chat/RedirectController.php @@ -102,7 +102,7 @@ class RedirectController extends AbstractController $next_group = group_by_id($next_id); if ($next_group) { - $page['message'] = getlocal2( + $page['message'] = getlocal( 'chat.redirected.group.content', array(get_group_name($next_group)) ); @@ -121,7 +121,7 @@ class RedirectController extends AbstractController $next_operator = operator_by_id($next_id); if ($next_operator) { - $page['message'] = getlocal2( + $page['message'] = getlocal( 'chat.redirected.content', array(get_operator_name($next_operator)) ); diff --git a/src/mibew/libs/classes/Mibew/Controller/PasswordRecoveryController.php b/src/mibew/libs/classes/Mibew/Controller/PasswordRecoveryController.php index d03e483c..84f5bcde 100644 --- a/src/mibew/libs/classes/Mibew/Controller/PasswordRecoveryController.php +++ b/src/mibew/libs/classes/Mibew/Controller/PasswordRecoveryController.php @@ -94,7 +94,7 @@ class PasswordRecoveryController extends AbstractController $email, $email, getlocal('restore.mailsubj'), - getlocal2( + getlocal( 'restore.mailtext', array(get_operator_name($to_restore), $href) ) diff --git a/src/mibew/libs/classes/Mibew/Controller/StatisticsController.php b/src/mibew/libs/classes/Mibew/Controller/StatisticsController.php index 0bf3d3f1..7c891498 100644 --- a/src/mibew/libs/classes/Mibew/Controller/StatisticsController.php +++ b/src/mibew/libs/classes/Mibew/Controller/StatisticsController.php @@ -61,7 +61,7 @@ class StatisticsController extends AbstractController array('cron_key' => Settings::get('cron_key')), UrlGeneratorInterface::ABSOLUTE_URL ); - $page['pageDescription'] = getlocal2( + $page['pageDescription'] = getlocal( 'statistics.description.full', array( date_to_text(Settings::get('_last_cron_run')), diff --git a/src/mibew/libs/classes/Mibew/Handlebars/HelpersSet.php b/src/mibew/libs/classes/Mibew/Handlebars/HelpersSet.php index a07ab429..d82ef1ee 100644 --- a/src/mibew/libs/classes/Mibew/Handlebars/HelpersSet.php +++ b/src/mibew/libs/classes/Mibew/Handlebars/HelpersSet.php @@ -98,11 +98,7 @@ class HelpersSet array_shift($escape_args); } - if (empty($local_args)) { - $result = getlocal($text); - } else { - $result = getlocal2($text, $local_args); - } + $result = getlocal($text, $local_args); return new \Handlebars\SafeString($result); } diff --git a/src/mibew/libs/classes/Mibew/RequestProcessor/ThreadProcessor.php b/src/mibew/libs/classes/Mibew/RequestProcessor/ThreadProcessor.php index 1f7314dd..995ddfaf 100644 --- a/src/mibew/libs/classes/Mibew/RequestProcessor/ThreadProcessor.php +++ b/src/mibew/libs/classes/Mibew/RequestProcessor/ThreadProcessor.php @@ -503,7 +503,7 @@ class ThreadProcessor extends ClientSideProcessor if ($email) { $thread->postMessage( Thread::KIND_FOR_AGENT, - getlocal2('chat.visitor.email', array($email), true) + getlocal('chat.visitor.email', array($email), CURRENT_LOCALE, true) ); } @@ -617,19 +617,19 @@ class ThreadProcessor extends ClientSideProcessor if ($referrer) { $thread->postMessage( Thread::KIND_FOR_AGENT, - getlocal2('chat.came.from', array($referrer), true) + getlocal('chat.came.from', array($referrer), CURRENT_LOCALE, true) ); } if ($email) { $thread->postMessage( Thread::KIND_FOR_AGENT, - getlocal2('chat.visitor.email', array($email), true) + getlocal('chat.visitor.email', array($email), CURRENT_LOCALE, true) ); } if ($info) { $thread->postMessage( Thread::KIND_FOR_AGENT, - getlocal2('chat.visitor.info', array($info), true) + getlocal('chat.visitor.info', array($info), CURRENT_LOCALE, true) ); } $thread->postMessage(Thread::KIND_USER, $message, array('name' => $name)); diff --git a/src/mibew/libs/common/locale.php b/src/mibew/libs/common/locale.php index ff998f93..cb6a93f5 100644 --- a/src/mibew/libs/common/locale.php +++ b/src/mibew/libs/common/locale.php @@ -278,11 +278,6 @@ function get_localized_string($string, $locale) return "!" . $string; } -function getlocal2($text, $params, $raw = false) -{ - return getlocal($text, $params, CURRENT_LOCALE, $raw); -} - /* prepares for Javascript string */ function get_local_for_js($text, $params) { diff --git a/src/mibew/libs/common/response.php b/src/mibew/libs/common/response.php index 2c4d7a37..fe4c15df 100644 --- a/src/mibew/libs/common/response.php +++ b/src/mibew/libs/common/response.php @@ -201,17 +201,17 @@ function get_plugins_data($page_name) function no_field($key) { - return getlocal2("errors.required", array(getlocal($key))); + return getlocal('errors.required', array(getlocal($key))); } function failed_uploading_file($filename, $key) { - return getlocal2("errors.failed.uploading.file", array($filename, getlocal($key))); + return getlocal('errors.failed.uploading.file', array($filename, getlocal($key))); } function wrong_field($key) { - return getlocal2("errors.wrong_field", array(getlocal($key))); + return getlocal('errors.wrong_field', array(getlocal($key))); } function add_params($servlet, $params) diff --git a/src/mibew/libs/invitation.php b/src/mibew/libs/invitation.php index 53fc612f..be6e247d 100644 --- a/src/mibew/libs/invitation.php +++ b/src/mibew/libs/invitation.php @@ -119,9 +119,10 @@ function invitation_invite($visitor_id, $operator) // Send some messages $thread->postMessage( Thread::KIND_FOR_AGENT, - getlocal2( + getlocal( 'chat.visitor.invitation.sent', array($operator_name, $last_visited_page), + CURRENT_LOCALE, true ) ); diff --git a/src/mibew/libs/operator.php b/src/mibew/libs/operator.php index da4eb714..4c79f8b9 100644 --- a/src/mibew/libs/operator.php +++ b/src/mibew/libs/operator.php @@ -647,7 +647,7 @@ function prepare_menu($operator, $has_right = true) $result['showMenu'] = true; $result['operator'] = get_operator_name($operator); - $result['goOnlineLink'] = getlocal2( + $result['goOnlineLink'] = getlocal( "menu.goonline", array(MIBEW_WEB_ROOT . "/operator/users?nomenu") ); diff --git a/src/mibew/libs/pagination.php b/src/mibew/libs/pagination.php index 0ab7203c..09e0ba96 100644 --- a/src/mibew/libs/pagination.php +++ b/src/mibew/libs/pagination.php @@ -148,8 +148,8 @@ function setup_pagination($items, $default_items_per_page = 15) */ function generate_pagination($style_path, $pagination, $bottom = true) { - $result = getlocal2( - "tag.pagination.info", + $result = getlocal( + 'tag.pagination.info', array( $pagination['page'], $pagination['total'],