@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | public static function _init($group_name = '') { |
27 | 27 | parent::_init($group_name); |
28 | 28 | |
29 | - foreach(static::$_group_unit_id_list as $resource_id) { |
|
29 | + foreach (static::$_group_unit_id_list as $resource_id) { |
|
30 | 30 | static::$_group_pnames[$resource_id] = pname_resource_name($resource_id); |
31 | 31 | } |
32 | 32 | |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | |
49 | 49 | !is_array($resource_array) ? $resource_array = array() : false; |
50 | 50 | |
51 | - foreach($resource_array as $resource_id => $resource_actual_delta) { |
|
52 | - if(!$resource_actual_delta) { |
|
51 | + foreach ($resource_array as $resource_id => $resource_actual_delta) { |
|
52 | + if (!$resource_actual_delta) { |
|
53 | 53 | // No delta - no changes |
54 | 54 | continue; |
55 | 55 | } |
@@ -119,7 +119,7 @@ |
||
119 | 119 | if ($this->contains($object)) { |
120 | 120 | $this->indexUnset($object); |
121 | 121 | } |
122 | - if($this->indexSet($object, $data)) { |
|
122 | + if ($this->indexSet($object, $data)) { |
|
123 | 123 | // Attaches object only if index sets successfully |
124 | 124 | parent::attach($object, $data); |
125 | 125 | } |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | // $method = new \ReflectionMethod($callable[0], $callable[1]); |
71 | 71 | // $callable = $method->getClosure($callable[0]); |
72 | 72 | // } |
73 | - if(is_array($callable) && ($invoker = Invoker::build($callable))) { |
|
73 | + if (is_array($callable) && ($invoker = Invoker::build($callable))) { |
|
74 | 74 | $callable = $invoker; |
75 | 75 | } |
76 | 76 | |
77 | 77 | $functionName = $accessor . $varName; |
78 | 78 | $this->accessors[$functionName] = $callable; |
79 | - if($shared == ACCESSOR_SHARED) { |
|
79 | + if ($shared == ACCESSOR_SHARED) { |
|
80 | 80 | $this->shared[$functionName] = true; |
81 | 81 | } |
82 | 82 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | } |
109 | 109 | |
110 | 110 | $functionName = $accessor . $varName; |
111 | - if(!isset($this->shared[$functionName]) || !array_key_exists($functionName, $this->executed)) { |
|
111 | + if (!isset($this->shared[$functionName]) || !array_key_exists($functionName, $this->executed)) { |
|
112 | 112 | $this->executed[$functionName] = call_user_func_array($this->accessors[$functionName], $params); |
113 | 113 | } |
114 | 114 |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | // TODO - rewrite |
232 | 232 | public function getParamsFromStaticClass($className) { |
233 | 233 | if (is_string($className) && $className && class_exists($className)) { |
234 | - if(method_exists($className, 'getDb')) { |
|
234 | + if (method_exists($className, 'getDb')) { |
|
235 | 235 | $this->setDb($className::getDb()); |
236 | 236 | } |
237 | 237 | $this->from($className::$_table); |
@@ -398,14 +398,14 @@ discard block |
||
398 | 398 | */ |
399 | 399 | protected function processField($fieldName) { |
400 | 400 | if (is_bool($fieldName)) { |
401 | - $result = (string)intval($fieldName); |
|
401 | + $result = (string) intval($fieldName); |
|
402 | 402 | } elseif (is_numeric($fieldName)) { |
403 | 403 | $result = $fieldName; |
404 | 404 | } elseif (is_null($fieldName)) { |
405 | 405 | $result = 'NULL'; |
406 | 406 | } else { |
407 | 407 | // Field has other type - string or should be convertible to string |
408 | - $result = (string)$fieldName; |
|
408 | + $result = (string) $fieldName; |
|
409 | 409 | if (!$fieldName instanceof DbSqlLiteral) { |
410 | 410 | $result = $this->quoteField($fieldName); |
411 | 411 | } |
@@ -248,7 +248,7 @@ |
||
248 | 248 | */ |
249 | 249 | public function unitsCostInMetal($shipCostInMetalPerPiece) { |
250 | 250 | $shipsCostInMetal = array(); |
251 | - foreach($this->mapUnitIdToDb as $ship_id => $ship) { |
|
251 | + foreach ($this->mapUnitIdToDb as $ship_id => $ship) { |
|
252 | 252 | $shipsCostInMetal[$ship_id] = $ship->count * $shipCostInMetalPerPiece[$ship_id]; |
253 | 253 | } |
254 | 254 |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * @return string |
278 | 278 | */ |
279 | 279 | protected function adjustPropertyString($name, $diff) { |
280 | - return (string)$this->$name . (string)$diff; |
|
280 | + return (string) $this->$name . (string) $diff; |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
@@ -287,8 +287,8 @@ discard block |
||
287 | 287 | * @return array |
288 | 288 | */ |
289 | 289 | protected function adjustPropertyArray($name, $diff) { |
290 | - $copy = (array)$this->$name; |
|
291 | - HelperArray::merge($copy, (array)$diff, HelperArray::MERGE_PHP); |
|
290 | + $copy = (array) $this->$name; |
|
291 | + HelperArray::merge($copy, (array) $diff, HelperArray::MERGE_PHP); |
|
292 | 292 | |
293 | 293 | return $copy; |
294 | 294 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @return int |
301 | 301 | */ |
302 | 302 | protected function deltaInteger($name, $diff) { |
303 | - return (int)HelperArray::keyExistsOr($this->propertiesAdjusted, $name, 0) + (int)$diff; |
|
303 | + return (int) HelperArray::keyExistsOr($this->propertiesAdjusted, $name, 0) + (int) $diff; |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | /** |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * @return float |
311 | 311 | */ |
312 | 312 | protected function deltaDouble($name, $diff) { |
313 | - return (float)HelperArray::keyExistsOr($this->propertiesAdjusted, $name, 0.0) + (float)$diff; |
|
313 | + return (float) HelperArray::keyExistsOr($this->propertiesAdjusted, $name, 0.0) + (float) $diff; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * @return string |
321 | 321 | */ |
322 | 322 | protected function deltaString($name, $diff) { |
323 | - return (string)HelperArray::keyExistsOr($this->propertiesAdjusted, $name, '') . (string)$diff; |
|
323 | + return (string) HelperArray::keyExistsOr($this->propertiesAdjusted, $name, '') . (string) $diff; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * @return array |
331 | 331 | */ |
332 | 332 | protected function deltaArray($name, $diff) { |
333 | - $copy = (array)HelperArray::keyExistsOr($this->propertiesAdjusted, $name, array()); |
|
333 | + $copy = (array) HelperArray::keyExistsOr($this->propertiesAdjusted, $name, array()); |
|
334 | 334 | HelperArray::merge($copy, $diff, HelperArray::MERGE_PHP); |
335 | 335 | |
336 | 336 | return $copy; |
@@ -59,7 +59,7 @@ |
||
59 | 59 | */ |
60 | 60 | protected function quoteFieldSimpleByRef(&$string) { |
61 | 61 | $string = $this->escapeString($string); |
62 | - if ((string)$string && '*' != $string) { |
|
62 | + if ((string) $string && '*' != $string) { |
|
63 | 63 | $string = '`' . $string . '`'; |
64 | 64 | } |
65 | 65 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | require SN_ROOT_PHYSICAL . 'config.php'; |
76 | 76 | |
77 | 77 | $module_config_array = get_class($this) . '_config'; |
78 | - if(!empty($$module_config_array) && is_array($$module_config_array)) { |
|
78 | + if (!empty($$module_config_array) && is_array($$module_config_array)) { |
|
79 | 79 | $this->config = $$module_config_array; |
80 | 80 | |
81 | 81 | return true; |
@@ -93,15 +93,15 @@ discard block |
||
93 | 93 | |
94 | 94 | // TODO: Load configuration from DB. Manifest setting |
95 | 95 | // Trying to load configuration from file |
96 | - if(!$config_exists = $this->loadModuleRootConfig()) { |
|
96 | + if (!$config_exists = $this->loadModuleRootConfig()) { |
|
97 | 97 | // Конфигурация может лежать в config_path в манифеста или в корне модуля |
98 | - if(isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'] . '/config.php')) { |
|
98 | + if (isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'] . '/config.php')) { |
|
99 | 99 | $config_exists = true; |
100 | - } elseif(file_exists($config_filename = dirname($filename) . '/config.php')) { |
|
100 | + } elseif (file_exists($config_filename = dirname($filename) . '/config.php')) { |
|
101 | 101 | $config_exists = true; |
102 | 102 | } |
103 | 103 | |
104 | - if($config_exists) { |
|
104 | + if ($config_exists) { |
|
105 | 105 | include($config_filename); |
106 | 106 | $module_config_array = $class_module_name . '_config'; |
107 | 107 | $this->config = $$module_config_array; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | // Checking module status - is it installed and active |
120 | 120 | $this->check_status(); |
121 | - if(!$this->manifest['active']) { |
|
121 | + if (!$this->manifest['active']) { |
|
122 | 122 | return; |
123 | 123 | } |
124 | 124 | |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | |
139 | 139 | protected function setSystemConstants() { |
140 | 140 | // Setting constants - if any |
141 | - if(empty($this->manifest['constants']) || !is_array($this->manifest['constants'])) { |
|
141 | + if (empty($this->manifest['constants']) || !is_array($this->manifest['constants'])) { |
|
142 | 142 | return; |
143 | 143 | } |
144 | 144 | |
145 | - foreach($this->manifest['constants'] as $constant_name => $constant_value) { |
|
145 | + foreach ($this->manifest['constants'] as $constant_name => $constant_value) { |
|
146 | 146 | !defined($constant_name) ? define($constant_name, $constant_value) : false; |
147 | 147 | } |
148 | 148 | } |
@@ -154,48 +154,48 @@ discard block |
||
154 | 154 | // New values from module variables will overwrite previous values (for root variables) and array elements with corresponding indexes (for arrays) |
155 | 155 | // Constants as array indexes are honored - it's make valid such declarations as 'sn_data[ques][QUE_STRUCTURES]' |
156 | 156 | $this->manifest['vars'] = $this->__assign_vars(); |
157 | - if(empty($this->manifest['vars']) || !is_array($this->manifest['vars'])) { |
|
157 | + if (empty($this->manifest['vars']) || !is_array($this->manifest['vars'])) { |
|
158 | 158 | return; |
159 | 159 | } |
160 | 160 | |
161 | 161 | $vars_assigned = array(); |
162 | - foreach($this->manifest['vars'] as $var_name => $var_value) { |
|
162 | + foreach ($this->manifest['vars'] as $var_name => $var_value) { |
|
163 | 163 | $sub_vars = explode('[', str_replace(']', '', $var_name)); |
164 | 164 | $var_name = $sub_vars[0]; |
165 | 165 | |
166 | - if(!isset($vars_assigned[$var_name])) { |
|
166 | + if (!isset($vars_assigned[$var_name])) { |
|
167 | 167 | $vars_assigned[$var_name] = true; |
168 | 168 | global $$var_name; |
169 | 169 | } |
170 | 170 | |
171 | 171 | $pointer = &$$var_name; |
172 | - if(($n = count($sub_vars)) > 1) { |
|
173 | - for($i = 1; $i < $n; $i++) { |
|
174 | - if(defined($sub_vars[$i])) { |
|
172 | + if (($n = count($sub_vars)) > 1) { |
|
173 | + for ($i = 1; $i < $n; $i++) { |
|
174 | + if (defined($sub_vars[$i])) { |
|
175 | 175 | $sub_vars[$i] = constant($sub_vars[$i]); |
176 | 176 | } |
177 | 177 | |
178 | - if(!isset($pointer[$sub_vars[$i]]) && $i != $n) { |
|
178 | + if (!isset($pointer[$sub_vars[$i]]) && $i != $n) { |
|
179 | 179 | $pointer[$sub_vars[$i]] = array(); |
180 | 180 | } |
181 | 181 | $pointer = &$pointer[$sub_vars[$i]]; |
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
185 | - if(!isset($pointer) || !is_array($pointer)) { |
|
185 | + if (!isset($pointer) || !is_array($pointer)) { |
|
186 | 186 | $pointer = $var_value; |
187 | - } elseif(is_array($$var_name)) { |
|
187 | + } elseif (is_array($$var_name)) { |
|
188 | 188 | $pointer = array_merge_recursive_numeric($pointer, $var_value); |
189 | 189 | } |
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
193 | 193 | protected function mergeMenu(&$sn_menu_extra, &$menu_patch) { |
194 | - if(!is_array($menu_patch)) { |
|
194 | + if (!is_array($menu_patch)) { |
|
195 | 195 | return; |
196 | 196 | } |
197 | 197 | |
198 | - foreach($menu_patch as $menu_item_name => $menu_item_data) { |
|
198 | + foreach ($menu_patch as $menu_item_name => $menu_item_data) { |
|
199 | 199 | $sn_menu_extra[$menu_item_name] = $menu_item_data; |
200 | 200 | } |
201 | 201 | } |
@@ -204,34 +204,34 @@ discard block |
||
204 | 204 | // Overriding function if any |
205 | 205 | sn_sys_handler_add(classSupernova::$functions, $this->manifest['functions'], $this); |
206 | 206 | |
207 | - foreach(classSupernova::$sn_mvc as $handler_type => &$handler_data) { |
|
207 | + foreach (classSupernova::$sn_mvc as $handler_type => &$handler_data) { |
|
208 | 208 | sn_sys_handler_add($handler_data, $this->manifest['mvc'][$handler_type], $this, $handler_type); |
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
212 | 212 | protected function mergeNavbarButton() { |
213 | - if(empty($this->manifest['navbar_prefix_button']) || !is_array($this->manifest['navbar_prefix_button'])) { |
|
213 | + if (empty($this->manifest['navbar_prefix_button']) || !is_array($this->manifest['navbar_prefix_button'])) { |
|
214 | 214 | return; |
215 | 215 | } |
216 | 216 | |
217 | - foreach($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) { |
|
217 | + foreach ($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) { |
|
218 | 218 | classSupernova::$sn_mvc['navbar_prefix_button'][$button_image] = $button_url_relative; |
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | 222 | protected function mergeI18N() { |
223 | 223 | $arrayName = 'i18n'; |
224 | - if(empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
224 | + if (empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
225 | 225 | return; |
226 | 226 | } |
227 | 227 | |
228 | - foreach($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
229 | - foreach($contentList as &$i18n_file_data) { |
|
230 | - if(is_array($i18n_file_data) && !$i18n_file_data['path']) { |
|
228 | + foreach ($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
229 | + foreach ($contentList as &$i18n_file_data) { |
|
230 | + if (is_array($i18n_file_data) && !$i18n_file_data['path']) { |
|
231 | 231 | $i18n_file_data['path'] = $this->manifest['root_relative']; |
232 | 232 | } |
233 | 233 | } |
234 | - if(!isset(classSupernova::$sn_mvc[$arrayName][$pageName])) { |
|
234 | + if (!isset(classSupernova::$sn_mvc[$arrayName][$pageName])) { |
|
235 | 235 | classSupernova::$sn_mvc[$arrayName][$pageName] = array(); |
236 | 236 | } |
237 | 237 | classSupernova::$sn_mvc[$arrayName][$pageName] += $contentList; |
@@ -239,13 +239,13 @@ discard block |
||
239 | 239 | } |
240 | 240 | |
241 | 241 | protected function mergeArraySpecial($arrayName) { |
242 | - if(empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
242 | + if (empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
243 | 243 | return; |
244 | 244 | } |
245 | 245 | |
246 | - foreach($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
246 | + foreach ($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
247 | 247 | !isset(classSupernova::$sn_mvc[$arrayName][$pageName]) ? classSupernova::$sn_mvc[$arrayName][$pageName] = array() : false; |
248 | - foreach($contentList as $contentName => &$content) { |
|
248 | + foreach ($contentList as $contentName => &$content) { |
|
249 | 249 | classSupernova::$sn_mvc[$arrayName][$pageName][$contentName] = $content; |
250 | 250 | } |
251 | 251 | } |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | $load_order[$loaded_module_name] = $level; |
300 | 300 | } |
301 | 301 | } |
302 | - } while($prev_order != $load_order); |
|
302 | + } while ($prev_order != $load_order); |
|
303 | 303 | |
304 | 304 | asort($load_order); |
305 | 305 |
@@ -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 = classSupernova::$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 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | "SELECT * FROM {{account_translate}} WHERE `user_id` = {$user_id_safe} " . |
92 | 92 | ($provider_id_unsafe ? "AND `provider_id` = {$provider_id_safe} " : '') . |
93 | 93 | "ORDER BY `timestamp` FOR UPDATE"); |
94 | - while($row = static::$db->db_fetch($query)) { |
|
94 | + while ($row = static::$db->db_fetch($query)) { |
|
95 | 95 | $account_translation[$row['user_id']][$row['provider_id']][$row['provider_account_id']] = $row; |
96 | 96 | } |
97 | 97 |