@@ -139,7 +139,7 @@ |
||
139 | 139 | $levelPoints = $this->valueStorage->getValue(UNIT_SERVER_FLEET_NOOB_POINTS); |
140 | 140 | !$levelPoints ? $levelPoints = 5000 * $this->valueStorage->getValue(UNIT_SERVER_SPEED_MINING) : false; |
141 | 141 | |
142 | - for($level = 0; $level <= PLAYER_RANK_MAX; $level++) { |
|
142 | + for ($level = 0; $level <= PLAYER_RANK_MAX; $level++) { |
|
143 | 143 | $this->playerLevels[$level] = $levelPoints; |
144 | 144 | $levelPoints *= $multiplier; |
145 | 145 | } |
@@ -24,7 +24,9 @@ |
||
24 | 24 | * DO NOT CHANGE |
25 | 25 | */ |
26 | 26 | |
27 | -if (!defined('INSIDE')) die(); |
|
27 | +if (!defined('INSIDE')) { |
|
28 | + die(); |
|
29 | +} |
|
28 | 30 | |
29 | 31 | $a_lang_array = array( |
30 | 32 | 'built' => 'Построено', |
@@ -26,7 +26,9 @@ |
||
26 | 26 | * DO NOT CHANGE |
27 | 27 | */ |
28 | 28 | |
29 | -if (!defined('INSIDE')) die(); |
|
29 | +if (!defined('INSIDE')) { |
|
30 | + die(); |
|
31 | +} |
|
30 | 32 | |
31 | 33 | |
32 | 34 | $a_lang_array = array( |
@@ -10,11 +10,11 @@ discard block |
||
10 | 10 | $time_server = $time_local - $time_diff |
11 | 11 | */ |
12 | 12 | |
13 | -if($font_size = sys_get_param_str('font_size')) { |
|
14 | - if(strpos($font_size, '%') !== false) { |
|
13 | +if ($font_size = sys_get_param_str('font_size')) { |
|
14 | + if (strpos($font_size, '%') !== false) { |
|
15 | 15 | // Размер шрифта в процентах |
16 | 16 | $font_size = min(max(floatval($font_size), FONT_SIZE_PERCENT_MIN), FONT_SIZE_PERCENT_MAX) . '%'; |
17 | - } elseif(strpos($font_size, 'px') !== false) { |
|
17 | + } elseif (strpos($font_size, 'px') !== false) { |
|
18 | 18 | // Размер шрифта в пикселях |
19 | 19 | $font_size = min(max(floatval($font_size), FONT_SIZE_PIXELS_MIN), FONT_SIZE_PIXELS_MAX) . 'px'; |
20 | 20 | } else { |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | SN::$user_options[PLAYER_OPTION_BASE_FONT_SIZE] = $font_size; |
27 | 27 | } else { |
28 | 28 | $user_time_diff = playerTimeDiff::user_time_diff_get(); |
29 | - if($user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) { |
|
29 | + if ($user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) { |
|
30 | 30 | $time_diff = intval($user_time_diff[PLAYER_OPTION_TIME_DIFF]); |
31 | 31 | } else { |
32 | 32 | $user_time_diff = playerTimeDiff::user_time_diff_probe(); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | require('../includes/init.' . substr(strrchr(__FILE__, '.'), 1)); |
6 | 6 | |
7 | -if($user['authlevel'] < 3) |
|
7 | +if ($user['authlevel'] < 3) |
|
8 | 8 | { |
9 | 9 | messageBox($lang['sys_noalloaw'], $lang['sys_noaccess']); |
10 | 10 | die(); |
@@ -19,9 +19,9 @@ discard block |
||
19 | 19 | |
20 | 20 | // [#] info_best_battles 1b0 |
21 | 21 | $best_reports = array(); |
22 | -if(defined('MODULE_INFO_BEST_BATTLES_QUERY')) { |
|
22 | +if (defined('MODULE_INFO_BEST_BATTLES_QUERY')) { |
|
23 | 23 | $query = doquery(MODULE_INFO_BEST_BATTLES_QUERY); |
24 | - while($row = db_fetch($query)) { |
|
24 | + while ($row = db_fetch($query)) { |
|
25 | 25 | $best_reports[] = $row['ube_report_id']; |
26 | 26 | } |
27 | 27 | } |
@@ -188,16 +188,16 @@ discard block |
||
188 | 188 | |
189 | 189 | function sn_maintenance_pack_user_list($user_list) { |
190 | 190 | $user_list = explode(',', $user_list); |
191 | - foreach($user_list as $key => $user_id) { |
|
192 | - if(!ceil(floatval($user_id))) { |
|
191 | + foreach ($user_list as $key => $user_id) { |
|
192 | + if (!ceil(floatval($user_id))) { |
|
193 | 193 | unset($user_list[$key]); |
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | 197 | $result = array(); |
198 | - if(!empty($user_list)) { |
|
198 | + if (!empty($user_list)) { |
|
199 | 199 | $query = doquery("SELECT `id` FROM {{users}} WHERE `id` in (" . implode(',', $user_list) . ")"); |
200 | - while($row = db_fetch($query)) { |
|
200 | + while ($row = db_fetch($query)) { |
|
201 | 201 | $result[] = $row['id']; |
202 | 202 | } |
203 | 203 | } |
@@ -212,11 +212,11 @@ discard block |
||
212 | 212 | $old_server_status == GAME_DISABLE_NONE ? SN::$config->db_saveItem('game_disable', GAME_DISABLE_MAINTENANCE) : false; |
213 | 213 | sn_db_transaction_commit(); |
214 | 214 | |
215 | -foreach($ques as $que_transaction) { |
|
215 | +foreach ($ques as $que_transaction) { |
|
216 | 216 | sn_db_transaction_start(); |
217 | 217 | |
218 | 218 | !is_array($que_transaction) ? $que_transaction = array($que_transaction) : false; |
219 | - foreach($que_transaction as $que) { |
|
219 | + foreach ($que_transaction as $que) { |
|
220 | 220 | set_time_limit(120); |
221 | 221 | $QryResult = doquery($que); |
222 | 222 | //$msg .= '<hr>' . $que . '<hr>'; |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | |
16 | 16 | $constants = get_defined_constants(true); |
17 | 17 | $rpgConstants = array(); |
18 | -foreach($constants['user'] as $constantName => $constantValue) { |
|
19 | - if(substr($constantName, 0, 4) == 'RPG_') { |
|
18 | +foreach ($constants['user'] as $constantName => $constantValue) { |
|
19 | + if (substr($constantName, 0, 4) == 'RPG_') { |
|
20 | 20 | $rpgConstants[$constantValue] = $constantName; |
21 | 21 | } |
22 | 22 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | GROUP BY log_dark_matter_reason, IF(sign((log_dark_matter_amount)) > 0, 1, -1) ORDER BY sum(log_dark_matter_amount) DESC; |
34 | 34 | "); |
35 | 35 | |
36 | -while($row = SN::$db->db_fetch($result)) { |
|
36 | +while ($row = SN::$db->db_fetch($result)) { |
|
37 | 37 | $row['CONSTANT'] = $rpgConstants[$row['REASON']]; |
38 | 38 | |
39 | 39 | $row['DM_AMOUNT_TEXT'] = HelperString::numberFloorAndFormat($row['DM_AMOUNT']); |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | GROUP BY reason, if(sign((amount)) > 0, 1, -1) ORDER BY sum(amount) DESC; |
56 | 56 | "); |
57 | 57 | |
58 | -while($row = SN::$db->db_fetch($result)) { |
|
59 | - if(empty($spent[$row['BALANCE']])) { |
|
58 | +while ($row = SN::$db->db_fetch($result)) { |
|
59 | + if (empty($spent[$row['BALANCE']])) { |
|
60 | 60 | $spent[$row['BALANCE']] = array(); |
61 | 61 | } |
62 | 62 | |
@@ -66,16 +66,15 @@ discard block |
||
66 | 66 | $spent[$row['BALANCE']] = array_merge_recursive_numeric($spent[$row['BALANCE']], $row); |
67 | 67 | } |
68 | 68 | |
69 | -foreach($spent as &$row) { |
|
69 | +foreach ($spent as &$row) { |
|
70 | 70 | @$row['TOTAL_COUNT'] = $row['MM_COUNT'] + $row['DM_COUNT']; |
71 | 71 | @$row['TOTAL_AMOUNT'] = $row['MM_AMOUNT'] + $row['DM_AMOUNT']; |
72 | 72 | @$row['TOTAL_AMOUNT_TEXT'] = HelperString::numberFloorAndFormat($row['TOTAL_AMOUNT']); |
73 | 73 | @$row['TOTAL_COUNT_TEXT'] = HelperString::numberFloorAndFormat($row['TOTAL_COUNT']); |
74 | 74 | } |
75 | 75 | |
76 | -usort($spent, function ($a, $b) { |
|
77 | - return $a['TOTAL_AMOUNT'] < $b['TOTAL_AMOUNT'] ? -1 : |
|
78 | - ($a['TOTAL_AMOUNT'] > $b['TOTAL_AMOUNT'] ? 1 : 0); |
|
76 | +usort($spent, function($a, $b) { |
|
77 | + return $a['TOTAL_AMOUNT'] < $b['TOTAL_AMOUNT'] ? -1 : ($a['TOTAL_AMOUNT'] > $b['TOTAL_AMOUNT'] ? 1 : 0); |
|
79 | 78 | }); |
80 | 79 | |
81 | 80 |
@@ -419,7 +419,8 @@ discard block |
||
419 | 419 | $location_info = &static::$location_info[$location_type]; |
420 | 420 | $id_field = $location_info[P_ID]; |
421 | 421 | $table_name = $location_info[P_TABLE_NAME]; |
422 | - if ($result = static::db_query_update("UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ? |
|
422 | + if ($result = static::db_query_update("UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) { |
|
423 | + // TODO Как-то вернуть может быть LIMIT 1 ? |
|
423 | 424 | { |
424 | 425 | if (static::$db->db_affected_rows()) { |
425 | 426 | // Обновляем данные только если ряд был затронут |
@@ -427,6 +428,7 @@ discard block |
||
427 | 428 | |
428 | 429 | // Тут именно так, а не cache_unset - что бы в кэшах автоматически обновилась запись. Будет нужно на будущее |
429 | 430 | _SnCacheInternal::$data[$location_type][$record_id] = null; |
431 | + } |
|
430 | 432 | // Вытаскиваем обновленную запись |
431 | 433 | static::db_get_record_by_id($location_type, $record_id); |
432 | 434 | _SnCacheInternal::cache_clear($location_type, false); // Мягкий сброс - только $queries |
@@ -460,9 +462,11 @@ discard block |
||
460 | 462 | $set = trim($set); |
461 | 463 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
462 | 464 | if ($result = static::db_query_insert("INSERT INTO `{{{$table_name}}}` SET {$set}")) { |
463 | - if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
465 | + if (static::$db->db_affected_rows()) { |
|
466 | + // Обновляем данные только если ряд был затронут |
|
464 | 467 | { |
465 | 468 | $record_id = db_insert_id(); |
469 | + } |
|
466 | 470 | // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию" |
467 | 471 | $result = static::db_get_record_by_id($location_type, $record_id); |
468 | 472 | // Очищаем второстепенные кэши - потому что вставленная запись могла повлиять на результаты запросов или локация или еще чего |
@@ -483,10 +487,12 @@ discard block |
||
483 | 487 | $id_field = $location_info[P_ID]; |
484 | 488 | $table_name = $location_info[P_TABLE_NAME]; |
485 | 489 | if ($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}")) { |
486 | - if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
490 | + if (static::$db->db_affected_rows()) { |
|
491 | + // Обновляем данные только если ряд был затронут |
|
487 | 492 | { |
488 | 493 | _SnCacheInternal::cache_unset($location_type, $safe_record_id); |
489 | 494 | } |
495 | + } |
|
490 | 496 | } |
491 | 497 | |
492 | 498 | return $result; |
@@ -500,11 +506,13 @@ discard block |
||
500 | 506 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
501 | 507 | |
502 | 508 | if ($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE {$condition}")) { |
503 | - if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
509 | + if (static::$db->db_affected_rows()) { |
|
510 | + // Обновляем данные только если ряд был затронут |
|
504 | 511 | { |
505 | 512 | // Обнуление кэша, потому что непонятно, что поменялось |
506 | 513 | _SnCacheInternal::cache_clear($location_type); |
507 | 514 | } |
515 | + } |
|
508 | 516 | } |
509 | 517 | |
510 | 518 | return $result; |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | protected static $is_init = false; |
20 | 20 | |
21 | 21 | protected static function init() { |
22 | - if(!empty(static::$db)) { |
|
22 | + if (!empty(static::$db)) { |
|
23 | 23 | return; |
24 | 24 | } |
25 | 25 | static::$db = SN::$db; |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | $provider_id_safe = intval($provider_id_unsafe); |
67 | 67 | !is_array($account_list) ? $account_list = array($account_list) : false; |
68 | 68 | |
69 | - foreach($account_list as $provider_account_id_unsafe) { |
|
69 | + foreach ($account_list as $provider_account_id_unsafe) { |
|
70 | 70 | $provider_account_id_safe = intval($provider_account_id_unsafe); |
71 | 71 | |
72 | 72 | // TODO - Здесь могут отсутствовать аккаунты - проверять провайдером |
73 | 73 | $query = static::$db->doquery("SELECT `user_id` FROM {{account_translate}} WHERE `provider_id` = {$provider_id_safe} AND `provider_account_id` = {$provider_account_id_safe} FOR UPDATE"); |
74 | - while($row = static::$db->db_fetch($query)) { |
|
74 | + while ($row = static::$db->db_fetch($query)) { |
|
75 | 75 | $account_translation[$row['user_id']][$provider_id_unsafe][$provider_account_id_unsafe] = true; |
76 | 76 | } |
77 | 77 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | "SELECT * FROM {{account_translate}} WHERE `user_id` = {$user_id_safe} " . |
98 | 98 | ($provider_id_unsafe ? "AND `provider_id` = {$provider_id_safe} " : '') . |
99 | 99 | "ORDER BY `timestamp` FOR UPDATE"); |
100 | - while($row = static::$db->db_fetch($query)) { |
|
100 | + while ($row = static::$db->db_fetch($query)) { |
|
101 | 101 | $account_translation[$row['user_id']][$row['provider_id']][$row['provider_account_id']] = $row; |
102 | 102 | } |
103 | 103 |
@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | |
29 | 29 | $this->container = array(); |
30 | 30 | |
31 | - if(SN::$cache->getMode() != classCache::CACHER_NO_CACHE && !SN::$config->locale_cache_disable) { |
|
31 | + if (SN::$cache->getMode() != classCache::CACHER_NO_CACHE && !SN::$config->locale_cache_disable) { |
|
32 | 32 | $this->cache = SN::$cache; |
33 | 33 | SN::log_file('locale.__constructor: Cache is present'); |
34 | 34 | //$this->cache->unset_by_prefix($this->cache_prefix); // TODO - remove? 'cause debug! |
35 | 35 | } |
36 | 36 | |
37 | - if($enable_stat_usage && empty($this->stat_usage)) { |
|
37 | + if ($enable_stat_usage && empty($this->stat_usage)) { |
|
38 | 38 | $this->enable_stat_usage = $enable_stat_usage; |
39 | 39 | $this->usage_stat_load(); |
40 | 40 | // TODO shutdown function |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | unset($fallback[$this->active]); |
61 | 61 | |
62 | 62 | // Проходим по оставшимся локалям |
63 | - foreach($fallback as $try_language) { |
|
63 | + foreach ($fallback as $try_language) { |
|
64 | 64 | // Если нет такой строки - пытаемся вытащить из кэша |
65 | - if(!isset($this->container[$try_language][$offset]) && $this->cache) { |
|
65 | + if (!isset($this->container[$try_language][$offset]) && $this->cache) { |
|
66 | 66 | $this->container[$try_language][$offset] = $this->cache->__get($this->cache_prefix . $try_language . '_' . $offset); |
67 | 67 | // Записываем результат работы кэша |
68 | 68 | $locale_cache_statistic['queries']++; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | // Если мы как-то где-то нашли строку... |
74 | - if(isset($this->container[$try_language][$offset])) { |
|
74 | + if (isset($this->container[$try_language][$offset])) { |
|
75 | 75 | // ...значит она получена в результате фоллбэка и записываем её в кэш и контейнер |
76 | 76 | $this[$offset] = $this->container[$try_language][$offset]; |
77 | 77 | $locale_cache_statistic['fallbacks']++; |
@@ -85,15 +85,15 @@ discard block |
||
85 | 85 | $this->container[$this->active][] = $value; |
86 | 86 | } else { |
87 | 87 | $this->container[$this->active][$offset] = $value; |
88 | - if($this->cache) { |
|
88 | + if ($this->cache) { |
|
89 | 89 | $this->cache->__set($this->cache_prefix_lang . $offset, $value); |
90 | 90 | } |
91 | 91 | } |
92 | 92 | } |
93 | 93 | public function offsetExists($offset) { |
94 | 94 | // Шорткат если у нас уже есть строка в памяти PHP |
95 | - if(!isset($this->container[$this->active][$offset])) { |
|
96 | - if(!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang . $offset))) { |
|
95 | + if (!isset($this->container[$this->active][$offset])) { |
|
96 | + if (!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang . $offset))) { |
|
97 | 97 | // Если нету такой строки - делаем фоллбэк |
98 | 98 | $this->locale_string_fallback($offset); |
99 | 99 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | public function offsetGet($offset) { |
109 | 109 | $value = $this->offsetExists($offset) ? $this->container[$this->active][$offset] : null; |
110 | - if($this->enable_stat_usage) { |
|
110 | + if ($this->enable_stat_usage) { |
|
111 | 111 | $this->usage_stat_log($offset, $value); |
112 | 112 | } |
113 | 113 | return $value; |
@@ -124,24 +124,24 @@ discard block |
||
124 | 124 | public function usage_stat_load() { |
125 | 125 | global $sn_cache; |
126 | 126 | |
127 | - $this->stat_usage = $sn_cache->lng_stat_usage = array(); // TODO for debug |
|
128 | - if(empty($this->stat_usage)) { |
|
127 | + $this->stat_usage = $sn_cache->lng_stat_usage = array(); // TODO for debug |
|
128 | + if (empty($this->stat_usage)) { |
|
129 | 129 | $query = doquery("SELECT * FROM {{lng_usage_stat}}"); |
130 | - while($row = db_fetch($query)) { |
|
130 | + while ($row = db_fetch($query)) { |
|
131 | 131 | $this->stat_usage[$row['lang_code'] . ':' . $row['string_id'] . ':' . $row['file'] . ':' . $row['line']] = $row['is_empty']; |
132 | 132 | } |
133 | 133 | } |
134 | 134 | } |
135 | 135 | public function usage_stat_save() { |
136 | - if(!empty($this->stat_usage_new)) { |
|
136 | + if (!empty($this->stat_usage_new)) { |
|
137 | 137 | global $sn_cache; |
138 | 138 | $sn_cache->lng_stat_usage = $this->stat_usage; |
139 | 139 | doquery("SELECT 1 FROM {{lng_usage_stat}} LIMIT 1"); |
140 | - foreach($this->stat_usage_new as &$value) { |
|
141 | - foreach($value as &$value2) { |
|
140 | + foreach ($this->stat_usage_new as &$value) { |
|
141 | + foreach ($value as &$value2) { |
|
142 | 142 | $value2 = '"' . db_escape($value2) . '"'; |
143 | 143 | } |
144 | - $value = '(' . implode(',', $value) .')'; |
|
144 | + $value = '(' . implode(',', $value) . ')'; |
|
145 | 145 | } |
146 | 146 | doquery("REPLACE INTO {{lng_usage_stat}} (lang_code,string_id,`file`,line,is_empty,locale) VALUES " . implode(',', $this->stat_usage_new)); |
147 | 147 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $file = str_replace('\\', '/', substr($trace[1]['file'], strlen(SN_ROOT_PHYSICAL) - 1)); |
155 | 155 | |
156 | 156 | $string_id = $this->active . ':' . $offset . ':' . $file . ':' . $trace[1]['line']; |
157 | - if(!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != $empty) { |
|
157 | + if (!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != $empty) { |
|
158 | 158 | $this->stat_usage[$string_id] = empty($value); |
159 | 159 | $this->stat_usage_new[] = array( |
160 | 160 | 'lang_code' => $this->active, |
@@ -194,11 +194,11 @@ discard block |
||
194 | 194 | $cache_file_key = $this->cache_prefix_lang . '__' . $filename; |
195 | 195 | |
196 | 196 | // Подключен ли внешний кэш? |
197 | - if($this->cache) { |
|
197 | + if ($this->cache) { |
|
198 | 198 | // Загружен ли уже данный файл? |
199 | 199 | $cache_file_status = $this->cache->__get($cache_file_key); |
200 | 200 | SN::log_file("locale.include: Cache - '{$filename}' has key '{$cache_file_key}' and is " . ($cache_file_status ? 'already loaded - EXIT' : 'EMPTY'), $cache_file_status ? -1 : 0); |
201 | - if($cache_file_status) { |
|
201 | + if ($cache_file_status) { |
|
202 | 202 | // Если да - повторять загрузку нет смысла |
203 | 203 | return null; |
204 | 204 | } |
@@ -212,35 +212,35 @@ discard block |
||
212 | 212 | $this->make_fallback($language); |
213 | 213 | |
214 | 214 | $file_path = ''; |
215 | - foreach($this->fallback as $lang_try) { |
|
216 | - if(!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
215 | + foreach ($this->fallback as $lang_try) { |
|
216 | + if (!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
217 | 217 | continue; |
218 | 218 | } |
219 | 219 | |
220 | - if($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
220 | + if ($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
221 | 221 | break; |
222 | 222 | } |
223 | 223 | |
224 | - if($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
224 | + if ($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
225 | 225 | break; |
226 | 226 | } |
227 | 227 | |
228 | 228 | $file_path = ''; |
229 | 229 | } |
230 | 230 | |
231 | - if($file_path) { |
|
231 | + if ($file_path) { |
|
232 | 232 | include($file_path); |
233 | 233 | |
234 | - if(!empty($a_lang_array)) { |
|
234 | + if (!empty($a_lang_array)) { |
|
235 | 235 | $this->merge($a_lang_array); |
236 | 236 | |
237 | 237 | // Загрузка данных из файла в кэш |
238 | - if($this->cache) { |
|
238 | + if ($this->cache) { |
|
239 | 239 | SN::log_file("Locale: loading '{$filename}' into cache"); |
240 | - foreach($a_lang_array as $key => $value) { |
|
240 | + foreach ($a_lang_array as $key => $value) { |
|
241 | 241 | $value_cache_key = $this->cache_prefix_lang . $key; |
242 | - if($this->cache->__isset($value_cache_key)) { |
|
243 | - if(is_array($value)) { |
|
242 | + if ($this->cache->__isset($value_cache_key)) { |
|
243 | + if (is_array($value)) { |
|
244 | 244 | $alt_value = $this->cache->__get($value_cache_key); |
245 | 245 | $value = array_replace_recursive($alt_value, $value); |
246 | 246 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | - if($this->cache) { |
|
253 | + if ($this->cache) { |
|
254 | 254 | $this->cache->__set($cache_file_key, true); |
255 | 255 | } |
256 | 256 | |
@@ -263,14 +263,14 @@ discard block |
||
263 | 263 | } |
264 | 264 | |
265 | 265 | public function lng_load_i18n($i18n) { |
266 | - if(!isset($i18n)) { |
|
266 | + if (!isset($i18n)) { |
|
267 | 267 | return; |
268 | 268 | } |
269 | 269 | |
270 | - foreach($i18n as $i18n_data) { |
|
271 | - if(is_string($i18n_data)) { |
|
270 | + foreach ($i18n as $i18n_data) { |
|
271 | + if (is_string($i18n_data)) { |
|
272 | 272 | $this->lng_include($i18n_data); |
273 | - } elseif(is_array($i18n_data)) { |
|
273 | + } elseif (is_array($i18n_data)) { |
|
274 | 274 | $this->lng_include($i18n_data['file'], $i18n_data['path']); |
275 | 275 | } |
276 | 276 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | |
289 | 289 | SN::log_file("locale.switch: Trying to switch language to '{$language_new}'"); |
290 | 290 | |
291 | - if($language_new == $this->active) { |
|
291 | + if ($language_new == $this->active) { |
|
292 | 292 | SN::log_file("locale.switch: New language '{$language_new}' is equal to current language '{$this->active}' - EXIT", -1); |
293 | 293 | return false; |
294 | 294 | } |
@@ -299,10 +299,10 @@ discard block |
||
299 | 299 | $this['LANG_INFO'] = $this->lng_get_info($this->active); |
300 | 300 | $this->make_fallback($this->active); |
301 | 301 | |
302 | - if($this->cache) { |
|
302 | + if ($this->cache) { |
|
303 | 303 | $cache_lang_init_status = $this->cache->__get($this->cache_prefix_lang . '__INIT'); |
304 | 304 | SN::log_file("locale.switch: Cache for '{$this->active}' prefixed '{$this->cache_prefix_lang}' is " . ($cache_lang_init_status ? 'already loaded. Doing nothing - EXIT' : 'EMPTY'), $cache_lang_init_status ? -1 : 0); |
305 | - if($cache_lang_init_status) { |
|
305 | + if ($cache_lang_init_status) { |
|
306 | 306 | return false; |
307 | 307 | } |
308 | 308 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | // Loading global language files |
319 | 319 | $this->lng_load_i18n($sn_mvc['i18n']['']); |
320 | 320 | |
321 | - if($this->cache) { |
|
321 | + if ($this->cache) { |
|
322 | 322 | SN::log_file("locale.switch: Cache - setting flag " . $this->cache_prefix_lang . '__INIT'); |
323 | 323 | $this->cache->__set($this->cache_prefix_lang . '__INIT', true); |
324 | 324 | } |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | public function lng_get_info($entry) { |
333 | 333 | $file_name = SN_ROOT_PHYSICAL . 'language/' . $entry . '/language.mo.php'; |
334 | 334 | $lang_info = array(); |
335 | - if(file_exists($file_name)) { |
|
335 | + if (file_exists($file_name)) { |
|
336 | 336 | include($file_name); |
337 | 337 | } |
338 | 338 | |
@@ -340,15 +340,15 @@ discard block |
||
340 | 340 | } |
341 | 341 | |
342 | 342 | public function lng_get_list() { |
343 | - if(empty($this->lang_list)) { |
|
343 | + if (empty($this->lang_list)) { |
|
344 | 344 | $this->lang_list = array(); |
345 | 345 | |
346 | 346 | $path = SN_ROOT_PHYSICAL . 'language/'; |
347 | 347 | $dir = dir($path); |
348 | - while(false !== ($entry = $dir->read())) { |
|
349 | - if(is_dir($path . $entry) && $entry[0] != '.') { |
|
348 | + while (false !== ($entry = $dir->read())) { |
|
349 | + if (is_dir($path . $entry) && $entry[0] != '.') { |
|
350 | 350 | $lang_info = $this->lng_get_info($entry); |
351 | - if($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
351 | + if ($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
352 | 352 | $this->lang_list[$lang_info['LANG_NAME_ISO2']] = $lang_info; |
353 | 353 | } |
354 | 354 | } |