Completed
Push — work-fleets ( 23812c...abbbcf )
by SuperNova.WS
05:51
created
includes/classes/Fleet.php 2 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -534,6 +534,9 @@  discard block
 block discarded – undo
534 534
     $this->mission_type = $mission_id;
535 535
   }
536 536
 
537
+  /**
538
+   * @param integer $ship_id
539
+   */
537 540
   public function shipCountById($ship_id) {
538 541
     return $this->unitList->unitCountById($ship_id);
539 542
   }
@@ -884,7 +887,7 @@  discard block
 block discarded – undo
884 887
   /**
885 888
    * Set current resource list from array of units
886 889
    *
887
-   * @param array $resource_list
890
+   * @param integer[] $resource_list
888 891
    */
889 892
   public function unitSetResourceList($resource_list) {
890 893
     if(!empty($this->propertiesAdjusted['resource_list'])) {
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
    */
337 337
   public function db_delete_this_fleet() {
338 338
     $fleet_id_safe = idval($this->_dbId);
339
-    if(!empty($fleet_id_safe)) {
339
+    if (!empty($fleet_id_safe)) {
340 340
       $result = doquery("DELETE FROM {{fleets}} WHERE `fleet_id` = {$fleet_id_safe} LIMIT 1;");
341 341
     } else {
342 342
       $result = false;
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
     // Записываем изменения в БД
380 380
     $this->dbSave();
381 381
 
382
-    if($this->_group_id) {
382
+    if ($this->_group_id) {
383 383
       // TODO: Make here to delete only one AKS - by adding aks_fleet_count to AKS table
384 384
       db_fleet_aks_purge();
385 385
     }
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
     sn_db_transaction_check(true);
447 447
 
448 448
     // Если флот уже обработан - не существует или возращается - тогда ничего не делаем
449
-    if(!$this->_dbId || ($this->_is_returning == 1 && $only_resources)) {
449
+    if (!$this->_dbId || ($this->_is_returning == 1 && $only_resources)) {
450 450
       return $result;
451 451
     }
452 452
 
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 
467 467
     // TODO - Проверка, что планета всё еще существует на указанных координатах, а не телепортировалась, не удалена хозяином, не уничтожена врагом
468 468
     // Флот, который возвращается на захваченную планету, пропадает
469
-    if($start && $this->_is_returning == 1 && $planet_arrival['id_owner'] != $this->_playerOwnerId) {
469
+    if ($start && $this->_is_returning == 1 && $planet_arrival['id_owner'] != $this->_playerOwnerId) {
470 470
       $result = RestoreFleetToPlanet($this, $start, $only_resources, $result);
471 471
 
472 472
       $this->db_delete_this_fleet();
@@ -475,20 +475,20 @@  discard block
 block discarded – undo
475 475
     }
476 476
 
477 477
 //pdump($planet_arrival);
478
-    if(!$only_resources) {
478
+    if (!$only_resources) {
479 479
       // Landing ships
480 480
       $db_changeset = array();
481 481
 
482
-      if($this->_playerOwnerId == $planet_arrival['id_owner']) {
482
+      if ($this->_playerOwnerId == $planet_arrival['id_owner']) {
483 483
         $fleet_array = $this->get_unit_list();
484
-        foreach($fleet_array as $ship_id => $ship_count) {
485
-          if($ship_count) {
484
+        foreach ($fleet_array as $ship_id => $ship_count) {
485
+          if ($ship_count) {
486 486
             $db_changeset['unit'][] = sn_db_unit_changeset_prepare($ship_id, $ship_count, $user, $planet_arrival['id']);
487 487
           }
488 488
         }
489 489
 
490 490
         // Adjusting ship amount on planet
491
-        if(!empty($db_changeset)) {
491
+        if (!empty($db_changeset)) {
492 492
           db_changeset_apply($db_changeset);
493 493
         }
494 494
       }
@@ -499,13 +499,13 @@  discard block
 block discarded – undo
499 499
     }
500 500
 
501 501
     // Restoring resources to planet
502
-    if($this->get_resources_amount() != 0) {
502
+    if ($this->get_resources_amount() != 0) {
503 503
       $fleet_resources = $this->get_resource_list();
504 504
       db_planet_set_by_id($planet_arrival['id'],
505 505
         "`metal` = `metal` + '{$fleet_resources[RES_METAL]}', `crystal` = `crystal` + '{$fleet_resources[RES_CRYSTAL]}', `deuterium` = `deuterium` + '{$fleet_resources[RES_DEUTERIUM]}'");
506 506
     }
507 507
 
508
-    if(!$only_resources) {
508
+    if (!$only_resources) {
509 509
       $this->db_delete_this_fleet();
510 510
     }
511 511
 
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
     pdie('Replace_ships should be rewritten! Deletes ships by setting their count to 0, adding ship with UnitList standard procedure');
557 557
     !is_array($unit_list) ? $unit_list = array() : false;
558 558
 
559
-    foreach($unit_list as $unit_id => $unit_count) {
559
+    foreach ($unit_list as $unit_id => $unit_count) {
560 560
       // TODO - проверка на допустимые корабли
561 561
 //      if(!UnitShip::is_in_group($unit_id) || !($unit_count = floor($unit_count))) {
562 562
 //        // Not a ship - continuing
@@ -583,15 +583,15 @@  discard block
 block discarded – undo
583 583
    * @param $unit_array
584 584
    */
585 585
   public function unitsSetFromArray($unit_array) {
586
-    foreach($unit_array as $unit_id => $unit_count) {
586
+    foreach ($unit_array as $unit_id => $unit_count) {
587 587
       $unit_count = floatval($unit_count);
588
-      if(!$unit_count) {
588
+      if (!$unit_count) {
589 589
         continue;
590 590
       }
591 591
 
592
-      if($this->isUnit($unit_id)) {
592
+      if ($this->isUnit($unit_id)) {
593 593
         $this->unitList->unitSetCount($unit_id, $unit_count);
594
-      } elseif($this->isResource($unit_id)) {
594
+      } elseif ($this->isResource($unit_id)) {
595 595
         $this->resource_list[$unit_id] = $unit_count;
596 596
       } else {
597 597
         throw new Exception('Trying to pass to fleet non-resource and non-ship ' . var_export($unit_array, true), ERR_ERROR);
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
   public function dbInsert() {
631 631
     // WARNING! MISSION TIMES MUST BE SET WITH set_times() method!
632 632
     // TODO - more checks!
633
-    if(empty($this->_time_launch)) {
633
+    if (empty($this->_time_launch)) {
634 634
       die('Fleet time not set!');
635 635
     }
636 636
 
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
   public function parse_missile_db_row($missile_db_row) {
709 709
 //    $this->_reset();
710 710
 
711
-    if(empty($missile_db_row) || !is_array($missile_db_row)) {
711
+    if (empty($missile_db_row) || !is_array($missile_db_row)) {
712 712
       return;
713 713
     }
714 714
 
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
   public function fleet_recyclers_capacity(array $recycler_info) {
758 758
     $recyclers_incoming_capacity = 0;
759 759
     $fleet_data = $this->get_unit_list();
760
-    foreach($recycler_info as $recycler_id => $recycler_data) {
760
+    foreach ($recycler_info as $recycler_id => $recycler_data) {
761 761
       $recyclers_incoming_capacity += $fleet_data[$recycler_id] * $recycler_data['capacity'];
762 762
     }
763 763
 
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
    * @param array $resource_list
888 888
    */
889 889
   public function unitSetResourceList($resource_list) {
890
-    if(!empty($this->propertiesAdjusted['resource_list'])) {
890
+    if (!empty($this->propertiesAdjusted['resource_list'])) {
891 891
       throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::unitSetResourceList', ERR_ERROR);
892 892
     }
893 893
     $this->unitAdjustResourceList($resource_list, true);
@@ -901,13 +901,13 @@  discard block
 block discarded – undo
901 901
   public function unitAdjustResourceList($resource_delta_list, $replace_value = false) {
902 902
     !is_array($resource_delta_list) ? $resource_delta_list = array() : false;
903 903
 
904
-    foreach($resource_delta_list as $resource_id => $unit_delta) {
905
-      if(!UnitResourceLoot::is_in_group($resource_id) || !($unit_delta = floor($unit_delta))) {
904
+    foreach ($resource_delta_list as $resource_id => $unit_delta) {
905
+      if (!UnitResourceLoot::is_in_group($resource_id) || !($unit_delta = floor($unit_delta))) {
906 906
         // Not a resource or no resources - continuing
907 907
         continue;
908 908
       }
909 909
 
910
-      if($replace_value) {
910
+      if ($replace_value) {
911 911
         $this->resource_list[$resource_id] = $unit_delta;
912 912
       } else {
913 913
         $this->resource_list[$resource_id] += $unit_delta;
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
       }
917 917
 
918 918
       // Check for negative unit value
919
-      if($this->resource_list[$resource_id] < 0) {
919
+      if ($this->resource_list[$resource_id] < 0) {
920 920
         // TODO
921 921
         throw new Exception('Resource ' . $resource_id . ' will become negative in ' . get_called_class() . '::unitAdjustResourceList', ERR_ERROR);
922 922
       }
Please login to merge, or discard this patch.
includes/init_secondary.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if($config->server_updater_check_auto && $config->server_updater_check_last + $config->server_updater_check_period <= SN_TIME_NOW) {
3
+if ($config->server_updater_check_auto && $config->server_updater_check_last + $config->server_updater_check_period <= SN_TIME_NOW) {
4 4
   include(SN_ROOT_PHYSICAL . 'ajax_version_check' . DOT_PHP_EX);
5 5
 }
6 6
 
7
-if($config->user_birthday_gift && SN_TIME_NOW - $config->user_birthday_celebrate > PERIOD_DAY) {
7
+if ($config->user_birthday_gift && SN_TIME_NOW - $config->user_birthday_celebrate > PERIOD_DAY) {
8 8
   require_once(SN_ROOT_PHYSICAL . "includes/includes/user_birthday_celebrate" . DOT_PHP_EX);
9 9
   sn_user_birthday_celebrate();
10 10
 }
11 11
 
12
-if(!$config->var_online_user_count || $config->var_online_user_time + 30 < SN_TIME_NOW) {
12
+if (!$config->var_online_user_count || $config->var_online_user_time + 30 < SN_TIME_NOW) {
13 13
   $config->db_saveItem('var_online_user_count', db_user_count(true));
14 14
   $config->db_saveItem('var_online_user_time', SN_TIME_NOW);
15
-  if($config->server_log_online) {
15
+  if ($config->server_log_online) {
16 16
     db_log_online_insert();
17 17
   }
18 18
 }
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 $template_result[F_ACCOUNT_IS_AUTHORIZED] = $sys_user_logged_in = !empty($user) && isset($user['id']) && $user['id'];
43 43
 //pdump($template_result[F_ACCOUNT_IS_AUTHORIZED]);die();
44 44
 
45
-if(!empty($user['id'])) {
45
+if (!empty($user['id'])) {
46 46
   classSupernova::$user_options->user_change($user['id']);
47 47
 }
48 48
 
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
     : false
56 56
   );
57 57
 
58
-if($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
59
-  $prohibited_characters = array_map(function ($value) {
58
+if ($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
59
+  $prohibited_characters = array_map(function($value) {
60 60
     return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'";
61 61
   }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED));
62 62
   $template_result[F_LOGIN_MESSAGE] .= implode(', ', $prohibited_characters);
63 63
 }
64 64
 
65 65
 
66
-if(defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) {
66
+if (defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) {
67 67
   pdump("Отключи отладку перед продакшном!");
68 68
 }
69 69
 
@@ -77,17 +77,17 @@  discard block
 block discarded – undo
77 77
   ? define('INSTALL_MODE', GAME_DISABLE_INSTALL)
78 78
   : false;
79 79
 
80
-if($template_result[F_GAME_DISABLE] = $config->game_disable) {
80
+if ($template_result[F_GAME_DISABLE] = $config->game_disable) {
81 81
   $template_result[F_GAME_DISABLE_REASON] = sys_bbcodeParse(
82 82
     $config->game_disable == GAME_DISABLE_REASON
83 83
       ? $config->game_disable_reason
84 84
       : $lang['sys_game_disable_reason'][$config->game_disable]
85 85
   );
86
-  if(defined('IN_API')) {
86
+  if (defined('IN_API')) {
87 87
     return;
88 88
   }
89 89
 
90
-  if(
90
+  if (
91 91
     ($user['authlevel'] < 1 || !(defined('IN_ADMIN') && IN_ADMIN))
92 92
     &&
93 93
     !(defined('INSTALL_MODE') && defined('LOGIN_LOGOUT'))
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 
101 101
 // TODO ban
102 102
 // TODO $skip_ban_check
103
-if($template_result[F_BANNED_STATUS] && !$skip_ban_check) {
104
-  if(defined('IN_API')) {
103
+if ($template_result[F_BANNED_STATUS] && !$skip_ban_check) {
104
+  if (defined('IN_API')) {
105 105
     return;
106 106
   }
107 107
 
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
 // pdump($allow_anonymous, '$allow_anonymous');
120 120
 // pdump($sys_user_logged_in, '$sys_user_logged_in');
121 121
 
122
-if($sys_user_logged_in && INITIAL_PAGE == 'login') {
122
+if ($sys_user_logged_in && INITIAL_PAGE == 'login') {
123 123
   sys_redirect(SN_ROOT_VIRTUAL . 'overview.php');
124
-} elseif($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id'])
124
+} elseif ($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id'])
125 125
 //  pdump($sn_page_name);
126 126
 //  pdump(INITIAL_PAGE);
127 127
 //  die('{Тут должна быть ваша реклама. Точнее - ввод имени игрока}');
128
-} elseif(!$allow_anonymous && !$sys_user_logged_in) {
128
+} elseif (!$allow_anonymous && !$sys_user_logged_in) {
129 129
   // sn_setcookie(SN_COOKIE, '', time() - PERIOD_WEEK, SN_ROOT_RELATIVE);
130 130
   sys_redirect(SN_ROOT_VIRTUAL . 'login.php');
131 131
 }
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
 global $skip_fleet_update;
148 148
 $skip_fleet_update = $skip_fleet_update || $supernova->options['fleet_update_skip'] || defined('IN_ADMIN');
149
-if(
149
+if (
150 150
   !$skip_fleet_update
151 151
   && !(defined('IN_AJAX') && IN_AJAX === true)
152 152
   && SN_TIME_NOW - strtotime($config->fleet_update_last) > $config->fleet_update_interval
Please login to merge, or discard this patch.
includes/classes/Unit.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -154,15 +154,15 @@  discard block
 block discarded – undo
154 154
    * @param string $group_name
155 155
    */
156 156
   public static function _init($group_name = '') {
157
-    if(static::$_is_static_init) {
157
+    if (static::$_is_static_init) {
158 158
       return;
159 159
     }
160 160
 
161
-    if($group_name) {
161
+    if ($group_name) {
162 162
       static::$_sn_group_name = $group_name;
163 163
     }
164 164
 
165
-    if(static::$_sn_group_name) {
165
+    if (static::$_sn_group_name) {
166 166
       static::$_group_unit_id_list = sn_get_groups(static::$_sn_group_name);
167 167
       empty(static::$_group_unit_id_list) ? static::$_group_unit_id_list = array() : false;
168 168
     }
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
     // TODO - Reset combat stats??
188 188
     $this->_unitId = $unitId;
189 189
 
190
-    if($this->_unitId) {
190
+    if ($this->_unitId) {
191 191
       $this->info = get_unit_param($this->_unitId);
192 192
       $this->_type = $this->info[P_UNIT_TYPE];
193 193
     } else {
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 
199 199
   protected function setCount($value) {
200 200
     // TODO - Reset combat stats??
201
-    if($value < 0) {
201
+    if ($value < 0) {
202 202
       classSupernova::$debug->error('Can not set Unit::$count to negative value');
203 203
     }
204 204
     $this->_count = $value;
Please login to merge, or discard this patch.
includes/classes/DBRow.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
 
132 132
     // If method is not getter or setter OR property name not exists in $_properties - raising exception
133 133
     // Descendants can catch this Exception to make own __call magic
134
-    if(($left3 != 'get' && $left3 != 'set') || empty(static::$_properties[$propertyName])) {
134
+    if (($left3 != 'get' && $left3 != 'set') || empty(static::$_properties[$propertyName])) {
135 135
       throw new ExceptionPropertyNotExists('Property ' . $propertyName . ' not exists when calling getter/setter ' . get_called_class() . '::' . $name, ERR_ERROR);
136 136
     }
137 137
 
138 138
     // TODO check for read-only
139 139
 
140
-    if($left3 == 'set') {
141
-      if(!empty($this->propertiesAdjusted[$propertyName])) {
140
+    if ($left3 == 'set') {
141
+      if (!empty($this->propertiesAdjusted[$propertyName])) {
142 142
         throw new PropertyAccessException('Property ' . $propertyName . ' already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::' . $name, ERR_ERROR);
143 143
       }
144 144
       $this->propertiesChanged[$propertyName] = 1;
@@ -147,13 +147,13 @@  discard block
 block discarded – undo
147 147
     // Now deciding - will we call a protected setter or will we work with protected property
148 148
 
149 149
     // If method exists - just calling it
150
-    if(method_exists($this, $name)) {
150
+    if (method_exists($this, $name)) {
151 151
       return call_user_func_array(array($this, $name), $arguments);
152 152
     }
153 153
     // No getter/setter exists - works directly with protected property
154 154
 
155 155
     // Is it getter?
156
-    if($left3 === 'get') {
156
+    if ($left3 === 'get') {
157 157
       return $this->{'_' . $propertyName};
158 158
     }
159 159
 
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 //    $this->_reset();
175 175
 
176 176
     $dbId = idval($dbId);
177
-    if($dbId <= 0) {
177
+    if ($dbId <= 0) {
178 178
       classSupernova::$debug->error(get_called_class() . '::dbLoad $dbId not positive = ' . $dbId);
179 179
 
180 180
       return;
181 181
     }
182 182
 
183 183
     $db_row = doquery("SELECT * FROM `{{" . static::$_table . "}}` WHERE `" . static::$_dbIdFieldName . "` = " . $dbId . " LIMIT 1 FOR UPDATE;", true);
184
-    if(empty($db_row)) {
184
+    if (empty($db_row)) {
185 185
       return;
186 186
     }
187 187
 
@@ -197,26 +197,26 @@  discard block
 block discarded – undo
197 197
    */
198 198
   // TODO - perform operations only if properties was changed
199 199
   public function dbSave() {
200
-    if($this->isNew()) {
200
+    if ($this->isNew()) {
201 201
       // No DB_ID - new unit
202
-      if($this->isEmpty()) {
202
+      if ($this->isEmpty()) {
203 203
         classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - object is empty on ' . get_called_class() . '::dbSave');
204 204
       }
205 205
       $this->dbInsert();
206 206
     } else {
207 207
       // DB_ID is present
208
-      if($this->isEmpty()) {
208
+      if ($this->isEmpty()) {
209 209
         $this->dbDelete();
210 210
       } else {
211
-        if(!sn_db_transaction_check(false)) {
211
+        if (!sn_db_transaction_check(false)) {
212 212
           classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - transaction should always be started on ' . get_called_class() . '::dbUpdate');
213 213
         }
214 214
         $this->dbUpdate();
215 215
       }
216 216
     }
217 217
 
218
-    if(!empty($this->triggerDbOperationOn)) {
219
-      foreach($this->triggerDbOperationOn as $item) {
218
+    if (!empty($this->triggerDbOperationOn)) {
219
+      foreach ($this->triggerDbOperationOn as $item) {
220 220
         $item->dbSave();
221 221
       }
222 222
     }
@@ -235,12 +235,12 @@  discard block
 block discarded – undo
235 235
    * @return int|string
236 236
    */
237 237
   public function dbInsert() {
238
-    if(!$this->isNew()) {
238
+    if (!$this->isNew()) {
239 239
       classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - record db_id is not empty on ' . get_called_class() . '::dbInsert');
240 240
     }
241 241
     $this->_dbId = $this->db_field_set_create($this->dbMakeFieldSet());
242 242
 
243
-    if(empty($this->_dbId)) {
243
+    if (empty($this->_dbId)) {
244 244
       classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - error saving record ' . get_called_class() . '::dbInsert');
245 245
     }
246 246
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
    */
253 253
   public function dbUpdate() {
254 254
     // TODO - Update
255
-    if($this->isNew()) {
255
+    if ($this->isNew()) {
256 256
       classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbUpdate');
257 257
     }
258 258
     $this->db_field_update($this->dbMakeFieldSet(true));
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
    * Deletes record from DB
263 263
    */
264 264
   public function dbDelete() {
265
-    if($this->isNew()) {
265
+    if ($this->isNew()) {
266 266
       classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbDelete');
267 267
     }
268 268
     doquery("DELETE FROM {{" . static::$_table . "}} WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId);
@@ -304,18 +304,18 @@  discard block
 block discarded – undo
304 304
    * @param array $db_row
305 305
    */
306 306
   public function dbRowParse(array $db_row) {
307
-    foreach(static::$_properties as $property_name => &$property_data) {
307
+    foreach (static::$_properties as $property_name => &$property_data) {
308 308
       // Advanced values extraction procedure. Should be used when at least one of following rules is matched:
309 309
       // - one field should translate to several properties;
310 310
       // - one property should be filled according to several fields;
311 311
       // - property filling requires some lookup in object values;
312
-      if(!empty($property_data[P_METHOD_EXTRACT]) && is_callable(array($this, $property_data[P_METHOD_EXTRACT]))) {
312
+      if (!empty($property_data[P_METHOD_EXTRACT]) && is_callable(array($this, $property_data[P_METHOD_EXTRACT]))) {
313 313
         call_user_func_array(array($this, $property_data[P_METHOD_EXTRACT]), array(&$db_row));
314 314
         continue;
315 315
       }
316 316
 
317 317
       // If property is read-only - doing nothing
318
-      if(!empty($property_data[P_READ_ONLY])) {
318
+      if (!empty($property_data[P_READ_ONLY])) {
319 319
         continue;
320 320
       }
321 321
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
       !empty($property_data[P_FUNC_INPUT]) && is_callable($property_data[P_FUNC_INPUT]) ? $value = call_user_func($property_data[P_FUNC_INPUT], $value) : false;
327 327
 
328 328
       // If there is setter for this field - using it. Setters is always a methods of $THIS
329
-      if(!empty($property_data[P_METHOD_SET]) && is_callable(array($this, $property_data[P_METHOD_SET]))) {
329
+      if (!empty($property_data[P_METHOD_SET]) && is_callable(array($this, $property_data[P_METHOD_SET]))) {
330 330
         call_user_func(array($this, $property_data[P_METHOD_SET]), $value);
331 331
       } else {
332 332
         $this->{$property_name} = $value;
@@ -342,21 +342,21 @@  discard block
 block discarded – undo
342 342
   protected function dbMakeFieldSet($isUpdate = false) {
343 343
     $array = array();
344 344
 
345
-    foreach(static::$_properties as $property_name => &$property_data) {
345
+    foreach (static::$_properties as $property_name => &$property_data) {
346 346
       // TODO - on isUpdate add only changed/adjusted properties
347 347
 
348
-      if(!empty($property_data[P_METHOD_INJECT]) && is_callable(array($this, $property_data[P_METHOD_INJECT]))) {
348
+      if (!empty($property_data[P_METHOD_INJECT]) && is_callable(array($this, $property_data[P_METHOD_INJECT]))) {
349 349
         call_user_func_array(array($this, $property_data[P_METHOD_INJECT]), array(&$array));
350 350
         continue;
351 351
       }
352 352
 
353 353
       // Skipping properties which have no corresponding field in DB
354
-      if(empty($property_data[P_DB_FIELD])) {
354
+      if (empty($property_data[P_DB_FIELD])) {
355 355
         continue;
356 356
       }
357 357
 
358 358
       // Checking - is property was adjusted or changed
359
-      if($isUpdate && array_key_exists($property_name, $this->propertiesAdjusted)) {
359
+      if ($isUpdate && array_key_exists($property_name, $this->propertiesAdjusted)) {
360 360
         // For adjusted property - take value from propertiesAdjusted array
361 361
         // TODO - differ how treated conversion to string for changed and adjusted properties
362 362
         $value = $this->propertiesAdjusted[$property_name];
@@ -386,17 +386,17 @@  discard block
 block discarded – undo
386 386
    */
387 387
   protected function isFieldChanged($fieldName) {
388 388
     $isFieldChanged = false;
389
-    foreach($this->propertiesChanged as $propertyName => $cork) {
389
+    foreach ($this->propertiesChanged as $propertyName => $cork) {
390 390
       $propertyScheme = static::$_properties[$propertyName];
391
-      if(!empty($propertyScheme[P_DB_FIELDS_LINKED])) {
392
-        foreach($propertyScheme[P_DB_FIELDS_LINKED] as $linkedFieldName) {
393
-          if($linkedFieldName == $fieldName) {
391
+      if (!empty($propertyScheme[P_DB_FIELDS_LINKED])) {
392
+        foreach ($propertyScheme[P_DB_FIELDS_LINKED] as $linkedFieldName) {
393
+          if ($linkedFieldName == $fieldName) {
394 394
             $isFieldChanged = $propertyName;
395 395
             break 2;
396 396
           }
397 397
         }
398 398
       }
399
-      if(!empty($propertyScheme[P_DB_FIELD]) && $propertyScheme[P_DB_FIELD] == $fieldName) {
399
+      if (!empty($propertyScheme[P_DB_FIELD]) && $propertyScheme[P_DB_FIELD] == $fieldName) {
400 400
         $isFieldChanged = $propertyName;
401 401
         break;
402 402
       }
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
     $fields = implode(',', array_keys($field_set));
419 419
 
420 420
     $result = 0;
421
-    if(classSupernova::db_query("INSERT INTO `{{" . static::$_table . "}}` ({$fields}) VALUES ({$values});")) {
421
+    if (classSupernova::db_query("INSERT INTO `{{" . static::$_table . "}}` ({$fields}) VALUES ({$values});")) {
422 422
       $result = db_insert_id();
423 423
     }
424 424
 
@@ -436,13 +436,13 @@  discard block
 block discarded – undo
436 436
     sn_db_field_set_safe_flag_clear($field_set);
437 437
 
438 438
     $set = array();
439
-    foreach($field_set as $fieldName => $value) {
440
-      if(!($changedProperty = $this->isFieldChanged($fieldName))) {
439
+    foreach ($field_set as $fieldName => $value) {
440
+      if (!($changedProperty = $this->isFieldChanged($fieldName))) {
441 441
         continue;
442 442
       }
443 443
 
444 444
       // TODO - separate sets from adjusts
445
-      if(array_key_exists($changedProperty, $this->propertiesAdjusted)) {
445
+      if (array_key_exists($changedProperty, $this->propertiesAdjusted)) {
446 446
         $value = "`{$fieldName}` + ($value)"; // braces for negative values
447 447
       }
448 448
 
Please login to merge, or discard this patch.
includes/init.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Защита от двойного инита
4
-if(defined('INIT')) {
4
+if (defined('INIT')) {
5 5
   return;
6 6
 }
7 7
 
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 version_compare(PHP_VERSION, '5.3.2') < 0 ? die('FATAL ERROR: SuperNova REQUIRE PHP version > 5.3.2') : false;
21 21
 
22 22
 // Бенчмарк
23
-register_shutdown_function(function () {
24
-  if(defined('IN_AJAX')) {
23
+register_shutdown_function(function() {
24
+  if (defined('IN_AJAX')) {
25 25
     return;
26 26
   }
27 27
 
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
     (!empty($locale_cache_statistic['misses']) ? ', LOCALE MISSED' : '') .
32 32
     (class_exists('classSupernova') && is_object(classSupernova::$db) ? ', DB time: ' . classSupernova::$db->time_mysql_total . 'ms' : '') .
33 33
     '</div>');
34
-  if($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL . 'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL . 'badqrys.txt') > 0) {
34
+  if ($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL . 'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL . 'badqrys.txt') > 0) {
35 35
     echo '<a href="badqrys.txt" target="_blank" style="color:red">', 'HACK ALERT!', '</a>';
36 36
   }
37 37
 
38
-  if(!empty($locale_cache_statistic['misses'])) {
38
+  if (!empty($locale_cache_statistic['misses'])) {
39 39
     print('<!--');
40 40
     pdump($locale_cache_statistic);
41 41
     print('-->');
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
 define('SN_TIME_NOW_GMT_STRING', gmdate(DATE_ATOM, SN_TIME_NOW));
57 57
 
58
-if(strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) {
58
+if (strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) {
59 59
   define('SN_GOOGLE', true);
60 60
 }
61 61
 
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
 $debug = new debug();
106 106
 classSupernova::debug_set_handler($debug);
107 107
 
108
-spl_autoload_register(function ($class) {
109
-  if(file_exists(SN_ROOT_PHYSICAL . 'includes/classes/' . $class . '.php')) {
108
+spl_autoload_register(function($class) {
109
+  if (file_exists(SN_ROOT_PHYSICAL . 'includes/classes/' . $class . '.php')) {
110 110
     require_once SN_ROOT_PHYSICAL . 'includes/classes/' . $class . '.php';
111 111
   }
112 112
 });
113 113
 
114
-spl_autoload_register(function ($class) {
115
-  if(file_exists(SN_ROOT_PHYSICAL . 'includes/classes/UBE/' . $class . '.php')) {
114
+spl_autoload_register(function($class) {
115
+  if (file_exists(SN_ROOT_PHYSICAL . 'includes/classes/UBE/' . $class . '.php')) {
116 116
     require_once SN_ROOT_PHYSICAL . 'includes/classes/UBE/' . $class . '.php';
117 117
   }
118 118
 });
@@ -190,10 +190,10 @@  discard block
 block discarded – undo
190 190
 
191 191
 sn_sys_load_php_files(SN_ROOT_PHYSICAL . "includes/functions/", PHP_EX);
192 192
 
193
-spl_autoload_register(function ($class) {
194
-  if(file_exists('includes/classes/' . $class . '.php')) {
193
+spl_autoload_register(function($class) {
194
+  if (file_exists('includes/classes/' . $class . '.php')) {
195 195
     require_once 'includes/classes/' . $class . '.php';
196
-  } elseif(file_exists('includes/classes/UBE/' . $class . '.php')) {
196
+  } elseif (file_exists('includes/classes/UBE/' . $class . '.php')) {
197 197
     require_once 'includes/classes/UBE/' . $class . '.php';
198 198
   } else {
199 199
 //    die("Can't find {$class} class");
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
 // Но нужно, пока у нас есть не MVC-страницы
231 231
 $sn_page_data = $sn_data['pages'][$sn_page_name];
232 232
 $sn_page_name_file = 'includes/pages/' . $sn_page_data['filename'] . DOT_PHP_EX;
233
-if($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) {
233
+if ($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) {
234 234
   require_once($sn_page_name_file);
235
-  if(is_array($sn_page_data['options'])) {
235
+  if (is_array($sn_page_data['options'])) {
236 236
     $supernova->options = array_merge($supernova->options, $sn_page_data['options']);
237 237
   }
238 238
 //  $sn_page_data
@@ -254,10 +254,10 @@  discard block
 block discarded – undo
254 254
 $load_order = array();
255 255
 $sn_req = array();
256 256
 
257
-foreach($sn_module as $loaded_module_name => $module_data) {
257
+foreach ($sn_module as $loaded_module_name => $module_data) {
258 258
   $load_order[$loaded_module_name] = isset($module_data->manifest['load_order']) && !empty($module_data->manifest['load_order']) ? $module_data->manifest['load_order'] : 100000;
259
-  if(isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) {
260
-    foreach($module_data->manifest['require'] as $require_name) {
259
+  if (isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) {
260
+    foreach ($module_data->manifest['require'] as $require_name) {
261 261
       $sn_req[$loaded_module_name][$require_name] = 0;
262 262
     }
263 263
   }
@@ -270,10 +270,10 @@  discard block
 block discarded – undo
270 270
 do {
271 271
   $prev_order = $load_order;
272 272
 
273
-  foreach($sn_req as $loaded_module_name => &$req_data) {
273
+  foreach ($sn_req as $loaded_module_name => &$req_data) {
274 274
     $level = 1;
275
-    foreach($req_data as $req_name => &$req_level) {
276
-      if($load_order[$req_name] == -1 || !isset($load_order[$req_name])) {
275
+    foreach ($req_data as $req_name => &$req_level) {
276
+      if ($load_order[$req_name] == -1 || !isset($load_order[$req_name])) {
277 277
         $level = $req_level = -1;
278 278
         break;
279 279
       } else {
@@ -281,20 +281,20 @@  discard block
 block discarded – undo
281 281
       }
282 282
       $req_level = $load_order[$req_name];
283 283
     }
284
-    if($level > $load_order[$loaded_module_name] || $level == -1) {
284
+    if ($level > $load_order[$loaded_module_name] || $level == -1) {
285 285
       $load_order[$loaded_module_name] = $level;
286 286
     }
287 287
   }
288
-} while($prev_order != $load_order);
288
+} while ($prev_order != $load_order);
289 289
 
290 290
 asort($load_order);
291 291
 
292 292
 // Инициализируем модули
293 293
 // По нормальным делам это должна быть загрузка модулей и лишь затем инициализация - что бы минимизировать размер процесса в памяти
294
-foreach($load_order as $loaded_module_name => $load_order_order) {
295
-  if($load_order_order >= 0) {
294
+foreach ($load_order as $loaded_module_name => $load_order_order) {
295
+  if ($load_order_order >= 0) {
296 296
     $sn_module[$loaded_module_name]->check_status();
297
-    if(!$sn_module[$loaded_module_name]->manifest['active']) {
297
+    if (!$sn_module[$loaded_module_name]->manifest['active']) {
298 298
       unset($sn_module[$loaded_module_name]);
299 299
       continue;
300 300
     }
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 unset($sn_req);
312 312
 
313 313
 // А теперь проверяем - поддерживают ли у нас загруженный код такую страницу
314
-if(!isset($sn_data['pages'][$sn_page_name])) {
314
+if (!isset($sn_data['pages'][$sn_page_name])) {
315 315
   $sn_page_name = '';
316 316
 }
317 317
 
@@ -328,6 +328,6 @@  discard block
 block discarded – undo
328 328
 $lang = new classLocale($config->server_locale_log_usage);
329 329
 $lang->lng_switch(sys_get_param_str('lang'));
330 330
 
331
-if(!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) {
331
+if (!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) {
332 332
   require_once "init_secondary.php";
333 333
 }
Please login to merge, or discard this patch.
includes/debug.class.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Some helpers to sweeten dev's life
4
- */
3
+   * Some helpers to sweeten dev's life
4
+   */
5 5
 
6 6
 /*
7 7
  * debug.class.php ::  Clase Debug, maneja reporte de eventos
Please login to merge, or discard this patch.