@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | $update_cache = false; |
| 136 | 136 | |
| 137 | - if(!empty($this->to_write)) { |
|
| 138 | - foreach($this->to_write as $key => $cork) { |
|
| 137 | + if (!empty($this->to_write)) { |
|
| 138 | + foreach ($this->to_write as $key => $cork) { |
|
| 139 | 139 | $value = is_array($this->data[$key]) ? serialize($this->data[$key]) : $this->data[$key]; // Сериализация для массивов при сохранении в БД |
| 140 | 140 | $this->to_write[$key] = "({$this->user_id}, '" . db_escape($key) . "', '" . db_escape($value) . "')"; |
| 141 | 141 | } |
@@ -146,18 +146,18 @@ discard block |
||
| 146 | 146 | $update_cache = true; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - if(!empty($this->to_delete)) { |
|
| 150 | - foreach($this->to_delete as $key => &$value) { |
|
| 151 | - $value = is_string($key) ? "'". db_escape($key) . "'" : $key; |
|
| 149 | + if (!empty($this->to_delete)) { |
|
| 150 | + foreach ($this->to_delete as $key => &$value) { |
|
| 151 | + $value = is_string($key) ? "'" . db_escape($key) . "'" : $key; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - doquery("DELETE FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} AND `option_id` IN (". implode(',', $this->to_delete) . ") "); |
|
| 154 | + doquery("DELETE FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} AND `option_id` IN (" . implode(',', $this->to_delete) . ") "); |
|
| 155 | 155 | |
| 156 | 156 | $this->to_delete = array(); |
| 157 | 157 | $update_cache = true; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - if($update_cache) { |
|
| 160 | + if ($update_cache) { |
|
| 161 | 161 | global $sn_cache; |
| 162 | 162 | |
| 163 | 163 | $field_name = $this->cached_name(); |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | protected function load($forceLoad = false) { |
| 185 | 185 | global $sn_cache; |
| 186 | 186 | |
| 187 | - if($this->loaded) { |
|
| 187 | + if ($this->loaded) { |
|
| 188 | 188 | return; |
| 189 | 189 | } |
| 190 | 190 | |
@@ -192,23 +192,23 @@ discard block |
||
| 192 | 192 | $this->to_write = array(); |
| 193 | 193 | $this->to_delete = array(); |
| 194 | 194 | |
| 195 | - if(!$this->user_id) { |
|
| 195 | + if (!$this->user_id) { |
|
| 196 | 196 | $this->loaded = true; |
| 197 | 197 | return; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | $field_name = $this->cached_name(); |
| 201 | - if(!$forceLoad) { |
|
| 201 | + if (!$forceLoad) { |
|
| 202 | 202 | $a_data = $sn_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 | |
| 210 | 210 | $query = doquery("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE"); |
| 211 | - while($row = db_fetch($query)) { |
|
| 211 | + while ($row = db_fetch($query)) { |
|
| 212 | 212 | // $this->data[$row['option_id']] = $row['value']; |
| 213 | 213 | $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация |
| 214 | 214 | } |
@@ -27,17 +27,17 @@ discard block |
||
| 27 | 27 | * @param string $class - Fully-qualified path with namespaces |
| 28 | 28 | */ |
| 29 | 29 | public static function autoloader($class) { |
| 30 | - foreach(static::$folders as $data) { |
|
| 30 | + foreach (static::$folders as $data) { |
|
| 31 | 31 | $theClassFile = $class; |
| 32 | 32 | |
| 33 | - if($data[static::P_PREFIX] && strrpos($class, $data[static::P_PREFIX]) !== false) { |
|
| 33 | + if ($data[static::P_PREFIX] && strrpos($class, $data[static::P_PREFIX]) !== false) { |
|
| 34 | 34 | $theClassFile = substr($class, strlen($data[static::P_PREFIX])); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | $classFullFileName = str_replace('\\', '/', $data[static::P_FOLDER] . $theClassFile) . DOT_PHP_EX; |
| 38 | - if(file_exists($classFullFileName) && is_file($classFullFileName)) { |
|
| 38 | + if (file_exists($classFullFileName) && is_file($classFullFileName)) { |
|
| 39 | 39 | require_once($classFullFileName); |
| 40 | - if(method_exists($class, '_constructorStatic')) { |
|
| 40 | + if (method_exists($class, '_constructorStatic')) { |
|
| 41 | 41 | $class::_constructorStatic(); |
| 42 | 42 | } |
| 43 | 43 | } |
@@ -49,21 +49,21 @@ discard block |
||
| 49 | 49 | * @param string $classPrefix - PHP class prefix to ignore. Can be whole namespace or part of it |
| 50 | 50 | */ |
| 51 | 51 | public static function register($absoluteClassRoot, $classPrefix = '') { |
| 52 | - if(!static::$autoloaderRegistered) { |
|
| 52 | + if (!static::$autoloaderRegistered) { |
|
| 53 | 53 | spl_autoload_register(array(__CLASS__, 'autoloader')); |
| 54 | 54 | static::$autoloaderRegistered = true; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | $absoluteClassRoot = str_replace('\\', '/', $absoluteClassRoot); |
| 58 | 58 | |
| 59 | - if(!($absoluteClassRoot = realpath($absoluteClassRoot))) { |
|
| 59 | + if (!($absoluteClassRoot = realpath($absoluteClassRoot))) { |
|
| 60 | 60 | // TODO - throw exception |
| 61 | 61 | return; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | $absoluteClassRoot = str_replace('\\', '/', $absoluteClassRoot) . '/'; |
| 65 | 65 | |
| 66 | - if($classPrefix && strrpos($classPrefix, 1) != '\\') { |
|
| 66 | + if ($classPrefix && strrpos($classPrefix, 1) != '\\') { |
|
| 67 | 67 | $classPrefix .= '\\'; |
| 68 | 68 | } |
| 69 | 69 | |