@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @return $this |
32 | 32 | */ |
33 | 33 | public function literal($value) { |
34 | - $this->literal = (string)$value; |
|
34 | + $this->literal = (string) $value; |
|
35 | 35 | |
36 | 36 | return $this; |
37 | 37 | } |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | $alias = $this->aliasFromField($functionName, $field); |
65 | 65 | } |
66 | 66 | |
67 | - $this->literal = strtoupper($functionName) . '(' . $this->quoteField($field) . ')'; |
|
67 | + $this->literal = strtoupper($functionName).'('.$this->quoteField($field).')'; |
|
68 | 68 | |
69 | 69 | if (self::SQL_LITERAL_ALIAS_NONE !== $alias && !empty($alias)) { |
70 | - $this->literal .= ' AS `' . $alias . '`'; |
|
70 | + $this->literal .= ' AS `'.$alias.'`'; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | return $this; |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | $alias = $this->aliasFromField($functionName, $field); |
125 | 125 | } |
126 | 126 | |
127 | - $this->literal = $this->quoteField($field) . ' IS NULL'; |
|
127 | + $this->literal = $this->quoteField($field).' IS NULL'; |
|
128 | 128 | |
129 | 129 | if (!empty($alias)) { |
130 | - $this->literal .= ' AS `' . $alias . '`'; |
|
130 | + $this->literal .= ' AS `'.$alias.'`'; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | return $this; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @param db_mysql|null $db |
87 | 87 | */ |
88 | 88 | public static function setDb($db = null) { |
89 | - if(empty($db) || !($db instanceof db_mysql)) { |
|
89 | + if (empty($db) || !($db instanceof db_mysql)) { |
|
90 | 90 | $db = null; |
91 | 91 | } |
92 | 92 | static::$db = !empty($db) || !class_exists('classSupernova', false) ? $db : classSupernova::$db; |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | public function dbLoad($dbId, $lockSkip = false) { |
150 | 150 | $dbId = idval($dbId); |
151 | 151 | if ($dbId <= 0) { |
152 | - classSupernova::$debug->error(get_called_class() . '::' . __METHOD__ . ' $dbId not positive = ' . $dbId); |
|
152 | + classSupernova::$debug->error(get_called_class().'::'.__METHOD__.' $dbId not positive = '.$dbId); |
|
153 | 153 | |
154 | 154 | return; |
155 | 155 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $this->dbGetLockById($this->_dbId); |
162 | 162 | } |
163 | 163 | |
164 | - $db_row = classSupernova::$db->doSelectFetch("SELECT * FROM `{{" . static::$_table . "}}` WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId . " LIMIT 1 FOR UPDATE;"); |
|
164 | + $db_row = classSupernova::$db->doSelectFetch("SELECT * FROM `{{".static::$_table."}}` WHERE `".static::$_dbIdFieldName."` = ".$this->_dbId." LIMIT 1 FOR UPDATE;"); |
|
165 | 165 | if (empty($db_row)) { |
166 | 166 | return; |
167 | 167 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | if ($this->isNew()) { |
194 | 194 | // No DB_ID - new unit |
195 | 195 | if ($this->isEmpty()) { |
196 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - object is empty on ' . get_called_class() . '::dbSave'); |
|
196 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - object is empty on '.get_called_class().'::dbSave'); |
|
197 | 197 | } |
198 | 198 | $this->dbInsert(); |
199 | 199 | } else { |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $this->dbDelete(); |
203 | 203 | } else { |
204 | 204 | if (!sn_db_transaction_check(false)) { |
205 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - transaction should always be started on ' . get_called_class() . '::dbUpdate'); |
|
205 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - transaction should always be started on '.get_called_class().'::dbUpdate'); |
|
206 | 206 | } |
207 | 207 | $this->dbUpdate(); |
208 | 208 | } |
@@ -230,13 +230,13 @@ discard block |
||
230 | 230 | // TODO - protected |
231 | 231 | public function dbInsert() { |
232 | 232 | if (!$this->isNew()) { |
233 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - record db_id is not empty on ' . get_called_class() . '::dbInsert'); |
|
233 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - record db_id is not empty on '.get_called_class().'::dbInsert'); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | $fieldSet = $this->dbMakeFieldSet(false); |
237 | 237 | |
238 | 238 | if (!static::$db->doInsertSet(static::$_table, $fieldSet)) { |
239 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - error saving record ' . get_called_class() . '::dbInsert'); |
|
239 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - error saving record '.get_called_class().'::dbInsert'); |
|
240 | 240 | } |
241 | 241 | $this->_dbId = static::$db->db_insert_id(); |
242 | 242 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | public function dbUpdate() { |
251 | 251 | // TODO - Update |
252 | 252 | if ($this->isNew()) { |
253 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbUpdate'); |
|
253 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - unit db_id is empty on dbUpdate'); |
|
254 | 254 | } |
255 | 255 | $this->db_field_update($this->dbMakeFieldUpdate()); |
256 | 256 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | // TODO - protected |
262 | 262 | public function dbDelete() { |
263 | 263 | if ($this->isNew()) { |
264 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbDelete'); |
|
264 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - unit db_id is empty on dbDelete'); |
|
265 | 265 | } |
266 | 266 | classSupernova::$gc->db->doDeleteRowWhere(static::$_table, array(static::$_dbIdFieldName => $this->_dbId)); |
267 | 267 | $this->_dbId = 0; |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | } |
448 | 448 | } |
449 | 449 | |
450 | - if(empty($set)) { |
|
450 | + if (empty($set)) { |
|
451 | 451 | $theResult = true; |
452 | 452 | } else { |
453 | 453 | $theResult = classSupernova::$db->doUpdateRowAdjust( |
@@ -34,7 +34,7 @@ |
||
34 | 34 | * @throws ExceptionFleetInvalid |
35 | 35 | */ |
36 | 36 | public static function build($missionType, $fleet) { |
37 | - if (!empty(self::$missions[$missionType]) && class_exists($className = __NAMESPACE__ . '\\' . self::$missions[$missionType])) { |
|
37 | + if (!empty(self::$missions[$missionType]) && class_exists($className = __NAMESPACE__.'\\'.self::$missions[$missionType])) { |
|
38 | 38 | $result = new $className($fleet); |
39 | 39 | } else { |
40 | 40 | throw new ExceptionFleetInvalid("Mission type {$missionType} unknown", FLIGHT_MISSION_UNKNOWN); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | // Проверить наличие такого имени в истории имён |
223 | 223 | do { |
224 | 224 | sn_db_transaction_rollback(); |
225 | - $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000); |
|
225 | + $this->player_suggested_name = 'Emperor '.mt_rand($max_user_id + 1, $max_user_id + 1000); |
|
226 | 226 | sn_db_transaction_start(); |
227 | 227 | } while (db_player_name_exists($this->player_suggested_name)); |
228 | 228 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | if ($player_name_submitted) { |
232 | 232 | $this->register_player_db_create($this->player_suggested_name); // OK 4.5 |
233 | 233 | if ($this->register_status == LOGIN_SUCCESS) { |
234 | - sys_redirect(SN_ROOT_VIRTUAL . 'overview.php'); |
|
234 | + sys_redirect(SN_ROOT_VIRTUAL.'overview.php'); |
|
235 | 235 | } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) { |
236 | 236 | // self::$player_suggested_name .= ' ' . $this->account->account_id; |
237 | 237 | } |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | ); |
258 | 258 | |
259 | 259 | if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
260 | - $prohibited_characters = array_map(function ($value) { |
|
261 | - return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'"; |
|
260 | + $prohibited_characters = array_map(function($value) { |
|
261 | + return "'".htmlentities($value, ENT_QUOTES, 'UTF-8')."'"; |
|
262 | 262 | }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED)); |
263 | 263 | $template_result[F_PLAYER_REGISTER_MESSAGE] .= implode(', ', $prohibited_characters); |
264 | 264 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | |
306 | 306 | foreach ($this->providers as $provider_id => $provider) { |
307 | 307 | $login_status = $provider->login(); // OK v4.5 |
308 | - self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? classLocale::$lang['sys_login_messages'][$provider->account_login_status] : dump($provider))); |
|
308 | + self::flog(($provider->manifest['name'].'->'.'login_try - ').(empty($provider->account->account_id) ? classLocale::$lang['sys_login_messages'][$provider->account_login_status] : dump($provider))); |
|
309 | 309 | if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) { |
310 | 310 | $this->providers_authorised[$provider_id] = &$this->providers[$provider_id]; |
311 | 311 | |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | if (!$this->is_player_register) { |
346 | 346 | // Нет - отправляем на процесс регистрации |
347 | 347 | $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id')); |
348 | - sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : '')); |
|
348 | + sys_redirect(SN_ROOT_VIRTUAL.'index.php?page=player_register&player_register=1'.($partner_id ? '&id_ref='.$partner_id : '')); |
|
349 | 349 | } |
350 | 350 | } else { |
351 | 351 | // Да, есть доступные игроки, которые так же прописаны в базе |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | } |
406 | 406 | |
407 | 407 | if ($redirect === true) { |
408 | - sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php')); |
|
408 | + sys_redirect(SN_ROOT_RELATIVE.(empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php')); |
|
409 | 409 | } elseif ($redirect !== false) { |
410 | 410 | sys_redirect($redirect); |
411 | 411 | } |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | */ |
802 | 802 | // OK v4 |
803 | 803 | public static function password_encode($password, $salt) { |
804 | - return md5($password . $salt); |
|
804 | + return md5($password.$salt); |
|
805 | 805 | } |
806 | 806 | /** |
807 | 807 | * Генерирует соль |
@@ -827,10 +827,10 @@ discard block |
||
827 | 827 | } |
828 | 828 | list($called, $caller) = debug_backtrace(false); |
829 | 829 | $caller_name = |
830 | - (!empty($caller['class']) ? $caller['class'] : '') . |
|
831 | - (!empty($caller['type']) ? $caller['type'] : '') . |
|
832 | - (!empty($caller['function']) ? $caller['function'] : '') . |
|
833 | - (!empty($called['line']) ? ':' . $called['line'] : ''); |
|
830 | + (!empty($caller['class']) ? $caller['class'] : ''). |
|
831 | + (!empty($caller['type']) ? $caller['type'] : ''). |
|
832 | + (!empty($caller['function']) ? $caller['function'] : ''). |
|
833 | + (!empty($called['line']) ? ':'.$called['line'] : ''); |
|
834 | 834 | |
835 | 835 | $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false; |
836 | 836 | |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | if ($die) { |
839 | 839 | // pdump($caller); |
840 | 840 | // pdump(debug_backtrace(false)); |
841 | - $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
|
841 | + $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в ".get_called_class()." (располагается в ".get_class()."). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
|
842 | 842 | } |
843 | 843 | } |
844 | 844 |
@@ -20,7 +20,7 @@ |
||
20 | 20 | * |
21 | 21 | * @package Buddy |
22 | 22 | */ |
23 | -class BuddyModel extends \Entity\KeyedModel{ |
|
23 | +class BuddyModel extends \Entity\KeyedModel { |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Name of table for this entity |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @property string $playerName |
22 | 22 | * @property string $playerNameAndCoordinates |
23 | 23 | */ |
24 | -class BuddyParams extends ContainerPlus { |
|
24 | +class BuddyParams extends ContainerPlus { |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * BuddyParams constructor. |
@@ -39,14 +39,14 @@ discard block |
||
39 | 39 | |
40 | 40 | // $this->playerArray = $user; |
41 | 41 | |
42 | - $this->playerId = function (BuddyParams $cBuddy) { |
|
42 | + $this->playerId = function(BuddyParams $cBuddy) { |
|
43 | 43 | return $cBuddy->playerArray['id']; |
44 | 44 | }; |
45 | - $this->playerName = function (BuddyParams $cBuddy) { |
|
45 | + $this->playerName = function(BuddyParams $cBuddy) { |
|
46 | 46 | return $cBuddy->playerArray['username']; |
47 | 47 | }; |
48 | - $this->playerNameAndCoordinates = function (BuddyParams $cBuddy) { |
|
49 | - return "{$cBuddy->playerArray['username']} " . uni_render_coordinates($cBuddy->playerArray); |
|
48 | + $this->playerNameAndCoordinates = function(BuddyParams $cBuddy) { |
|
49 | + return "{$cBuddy->playerArray['username']} ".uni_render_coordinates($cBuddy->playerArray); |
|
50 | 50 | }; |
51 | 51 | } |
52 | 52 |
@@ -52,7 +52,7 @@ |
||
52 | 52 | !mysql_select_db($settings['name']) |
53 | 53 | ? classSupernova::$debug->error_fatal('DB error - cannot find DB on server', $this->mysql_error()) |
54 | 54 | : false; |
55 | - !$this->mysql_query('SET SESSION TRANSACTION ISOLATION LEVEL ' . self::DB_MYSQL_TRANSACTION_REPEATABLE_READ . ';') |
|
55 | + !$this->mysql_query('SET SESSION TRANSACTION ISOLATION LEVEL '.self::DB_MYSQL_TRANSACTION_REPEATABLE_READ.';') |
|
56 | 56 | ? classSupernova::$debug->error_fatal('DB error - cannot set desired isolation level', $this->mysql_error()) |
57 | 57 | : false; |
58 | 58 |
@@ -122,10 +122,10 @@ discard block |
||
122 | 122 | |
123 | 123 | $update_cache = false; |
124 | 124 | |
125 | - if(!empty($this->to_write)) { |
|
126 | - foreach($this->to_write as $key => $cork) { |
|
125 | + if (!empty($this->to_write)) { |
|
126 | + foreach ($this->to_write as $key => $cork) { |
|
127 | 127 | $value = is_array($this->data[$key]) ? serialize($this->data[$key]) : $this->data[$key]; // Сериализация для массивов при сохранении в БД |
128 | - $this->to_write[$key] = "({$this->user_id}, '" . db_escape($key) . "', '" . db_escape($value) . "')"; |
|
128 | + $this->to_write[$key] = "({$this->user_id}, '".db_escape($key)."', '".db_escape($value)."')"; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | classSupernova::$gc->db->doReplaceValuesDeprecated( |
@@ -143,9 +143,9 @@ discard block |
||
143 | 143 | $update_cache = true; |
144 | 144 | } |
145 | 145 | |
146 | - if(!empty($this->to_delete)) { |
|
147 | - foreach($this->to_delete as $key => &$value) { |
|
148 | - $value = is_string($key) ? "'". db_escape($key) . "'" : $key; |
|
146 | + if (!empty($this->to_delete)) { |
|
147 | + foreach ($this->to_delete as $key => &$value) { |
|
148 | + $value = is_string($key) ? "'".db_escape($key)."'" : $key; |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | classSupernova::$db->doDeleteDanger( |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | 'player_id' => $this->user_id, |
155 | 155 | ), |
156 | 156 | array( |
157 | - "`option_id` IN (" . implode(',', $this->to_delete) . ")", |
|
157 | + "`option_id` IN (".implode(',', $this->to_delete).")", |
|
158 | 158 | ) |
159 | 159 | ); |
160 | 160 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $update_cache = true; |
163 | 163 | } |
164 | 164 | |
165 | - if($update_cache) { |
|
165 | + if ($update_cache) { |
|
166 | 166 | $field_name = $this->cached_name(); |
167 | 167 | classSupernova::$cache->$field_name = $this->data; |
168 | 168 | } |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | $this->load(); |
182 | 182 | } |
183 | 183 | protected function cached_name() { |
184 | - return 'options_' . $this->user_id; |
|
184 | + return 'options_'.$this->user_id; |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | protected function load() { |
188 | - if($this->loaded) { |
|
188 | + if ($this->loaded) { |
|
189 | 189 | return; |
190 | 190 | } |
191 | 191 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | $this->to_write = array(); |
194 | 194 | $this->to_delete = array(); |
195 | 195 | |
196 | - if(!$this->user_id) { |
|
196 | + if (!$this->user_id) { |
|
197 | 197 | $this->loaded = true; |
198 | 198 | return; |
199 | 199 | } |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | $field_name = $this->cached_name(); |
202 | 202 | $a_data = classSupernova::$cache->$field_name; |
203 | 203 | |
204 | - if(!empty($a_data)) { |
|
204 | + if (!empty($a_data)) { |
|
205 | 205 | $this->data = array_replace_recursive($this->data, $a_data); |
206 | 206 | return; |
207 | 207 | } |
208 | 208 | |
209 | 209 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE"); |
210 | - while($row = db_fetch($query)) { |
|
210 | + while ($row = db_fetch($query)) { |
|
211 | 211 | // $this->data[$row['option_id']] = $row['value']; |
212 | 212 | $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация |
213 | 213 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | } |
285 | 285 | |
286 | 286 | protected function cached_name() { |
287 | - return 'options_' . $this->user_id; |
|
287 | + return 'options_'.$this->user_id; |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | // TODO - serialize/unserialize options |
@@ -292,14 +292,14 @@ discard block |
||
292 | 292 | // Если в массиве индекса только один элемент - значит это просто индекс |
293 | 293 | is_array($option_id) && count($option_id) == 1 ? $option_id = reset($option_id) : false; |
294 | 294 | |
295 | - if(!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) { |
|
295 | + if (!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) { |
|
296 | 296 | $this->load(); |
297 | 297 | } |
298 | 298 | |
299 | - if(is_array($option_id)) { |
|
299 | + if (is_array($option_id)) { |
|
300 | 300 | $result = $this->data; |
301 | - foreach($option_id as $sub_key) { |
|
302 | - if(!isset($result) || !isset($result[$sub_key])) { |
|
301 | + foreach ($option_id as $sub_key) { |
|
302 | + if (!isset($result) || !isset($result[$sub_key])) { |
|
303 | 303 | $result = null; |
304 | 304 | break; |
305 | 305 | } |
@@ -317,12 +317,12 @@ discard block |
||
317 | 317 | * @param null|mixed $value |
318 | 318 | */ |
319 | 319 | public function __set($option, $value = null) { |
320 | - if(empty($option) || !$this->user_id) { |
|
320 | + if (empty($option) || !$this->user_id) { |
|
321 | 321 | return; |
322 | 322 | } |
323 | 323 | |
324 | 324 | // Если в массиве индекса только один элемент - значит это просто индекс |
325 | - if(is_array($option) && count($option) == 1) { |
|
325 | + if (is_array($option) && count($option) == 1) { |
|
326 | 326 | // Разворачиваем его в индекс |
327 | 327 | $option = array(reset($option) => $value); |
328 | 328 | unset($value); |
@@ -331,13 +331,13 @@ discard block |
||
331 | 331 | |
332 | 332 | $to_write = array(); |
333 | 333 | // Адресация многомерного массива через массив индексов в $option |
334 | - if(is_array($option) && isset($value)) { |
|
334 | + if (is_array($option) && isset($value)) { |
|
335 | 335 | $a_data = &$this->data; |
336 | - foreach($option as $option_id) { |
|
336 | + foreach ($option as $option_id) { |
|
337 | 337 | !is_array($a_data[$option_id]) ? $a_data[$option_id] = array() : false; |
338 | 338 | $a_data = &$a_data[$option_id]; |
339 | 339 | } |
340 | - if($a_data != $value) { |
|
340 | + if ($a_data != $value) { |
|
341 | 341 | $a_data = $value; |
342 | 342 | $to_write[reset($option)] = null; |
343 | 343 | } |
@@ -345,11 +345,11 @@ discard block |
||
345 | 345 | // Пакетная запись из массива ключ -> значение |
346 | 346 | !is_array($option) ? $option = array($option => $value) : false; |
347 | 347 | |
348 | - foreach($option as $option_id => $option_value) { |
|
349 | - if($this->data[$option_id] !== $option_value) { |
|
348 | + foreach ($option as $option_id => $option_value) { |
|
349 | + if ($this->data[$option_id] !== $option_value) { |
|
350 | 350 | // TODO - вынести отдельно в обработчик |
351 | - if($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON && $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) { |
|
352 | - sn_setcookie(SN_COOKIE . '_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE); |
|
351 | + if ($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON && $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) { |
|
352 | + sn_setcookie(SN_COOKIE.'_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | $this->data[$option_id] = $option_value; |
@@ -358,13 +358,13 @@ discard block |
||
358 | 358 | } |
359 | 359 | } |
360 | 360 | |
361 | - if(!empty($to_write)) { |
|
361 | + if (!empty($to_write)) { |
|
362 | 362 | $field_name = $this->cached_name(); |
363 | 363 | classSupernova::$cache->$field_name = $this->data; |
364 | 364 | |
365 | - foreach($to_write as $option_id => &$option_value) { |
|
365 | + foreach ($to_write as $option_id => &$option_value) { |
|
366 | 366 | $option_value = is_array($this->data[$option_id]) ? serialize($this->data[$option_id]) : $this->data[$option_id]; // Сериализация для массивов при сохранении в БД |
367 | - $to_write[$option_id] = "({$this->user_id}, '" . db_escape($option_id) . "', '" . db_escape($option_value) . "')"; |
|
367 | + $to_write[$option_id] = "({$this->user_id}, '".db_escape($option_id)."', '".db_escape($option_value)."')"; |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | classSupernova::$gc->db->doReplaceValuesDeprecated( |
@@ -380,26 +380,26 @@ discard block |
||
380 | 380 | } |
381 | 381 | |
382 | 382 | protected function load() { |
383 | - if($this->loaded) { |
|
383 | + if ($this->loaded) { |
|
384 | 384 | return; |
385 | 385 | } |
386 | 386 | |
387 | 387 | $this->data = $this->defaults; |
388 | 388 | |
389 | - if(!$this->user_id) { |
|
389 | + if (!$this->user_id) { |
|
390 | 390 | return; |
391 | 391 | } |
392 | 392 | |
393 | 393 | $field_name = $this->cached_name(); |
394 | 394 | $a_data = classSupernova::$cache->$field_name; |
395 | 395 | |
396 | - if(!empty($a_data)) { |
|
396 | + if (!empty($a_data)) { |
|
397 | 397 | $this->data = array_replace($this->data, $a_data); |
398 | 398 | return; |
399 | 399 | } |
400 | 400 | |
401 | 401 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE"); |
402 | - while($row = db_fetch($query)) { |
|
402 | + while ($row = db_fetch($query)) { |
|
403 | 403 | // $this->data[$row['option_id']] = $row['value']; |
404 | 404 | $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация |
405 | 405 | } |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | return $this->__get($offset); |
416 | 416 | } |
417 | 417 | public function offsetSet($offset, $value) { |
418 | - if(!is_null($offset)) { |
|
418 | + if (!is_null($offset)) { |
|
419 | 419 | // $this->data[$offset] = $value; |
420 | 420 | $this->__set($offset, $value); |
421 | 421 | } else { |
@@ -125,7 +125,7 @@ |
||
125 | 125 | * @since 5.1.0 |
126 | 126 | */ |
127 | 127 | public function count() { |
128 | - throw new Exception('You should implement ' . get_called_class() . '::count()'); |
|
128 | + throw new Exception('You should implement '.get_called_class().'::count()'); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | } |