Completed
Push — work-fleets ( 8591a1...0fb536 )
by SuperNova.WS
07:12
created
includes/general.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -162,12 +162,12 @@  discard block
 block discarded – undo
162 162
   $suffix = '';
163 163
   if ($limit) {
164 164
     if ($ret > 0) {
165
-      while($ret > $limit) {
165
+      while ($ret > $limit) {
166 166
         $suffix .= 'k';
167 167
         $ret = round($ret / 1000);
168 168
       }
169 169
     } else {
170
-      while($ret < -$limit) {
170
+      while ($ret < -$limit) {
171 171
         $suffix .= 'k';
172 172
         $ret = round($ret / 1000);
173 173
       }
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
     $mercenary = get_unit_param($mercenary_id);
413 413
     $mercenary_bonus = $mercenary['bonus'];
414 414
 
415
-    switch($mercenary['bonus_type']) {
415
+    switch ($mercenary['bonus_type']) {
416 416
       case BONUS_PERCENT_CUMULATIVE:
417 417
         $value *= 1 + $mercenary_level * $mercenary_bonus / 100;
418 418
       break;
@@ -685,10 +685,10 @@  discard block
 block discarded – undo
685 685
     $rexep = "#" . strtr(preg_quote($format), $masks) . "#";
686 686
     if (preg_match($rexep, $date, $out)) {
687 687
       $ret = array(
688
-        "tm_sec"  => (int)$out['S'],
689
-        "tm_min"  => (int)$out['M'],
690
-        "tm_hour" => (int)$out['H'],
691
-        "tm_mday" => (int)$out['d'],
688
+        "tm_sec"  => (int) $out['S'],
689
+        "tm_min"  => (int) $out['M'],
690
+        "tm_hour" => (int) $out['H'],
691
+        "tm_mday" => (int) $out['d'],
692 692
         "tm_mon"  => $out['m'] ? $out['m'] - 1 : 0,
693 693
         "tm_year" => $out['Y'] > 1900 ? $out['Y'] - 1900 : 0,
694 694
       );
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
   }
838 838
 
839 839
   if (isset($nick_array[NICK_AUTH_LEVEL]) || isset($nick_array[NICK_PREMIUM])) {
840
-    switch($nick_array[NICK_AUTH_LEVEL]) {
840
+    switch ($nick_array[NICK_AUTH_LEVEL]) {
841 841
       case 4:
842 842
         $highlight = classSupernova::$config->chat_highlight_developer;
843 843
       break;
@@ -1339,7 +1339,7 @@  discard block
 block discarded – undo
1339 1339
     $time_left = min(floor($time_left / PERIOD_DAY), $term_original);
1340 1340
     $cost_left = $term_original > 0 ? ceil($time_left / $term_original * $original_cost) : 0;
1341 1341
 
1342
-    array_walk_recursive($result, function (&$value) use ($cost_left) {
1342
+    array_walk_recursive($result, function(&$value) use ($cost_left) {
1343 1343
       $value -= $cost_left;
1344 1344
     });
1345 1345
   }
@@ -1479,7 +1479,7 @@  discard block
 block discarded – undo
1479 1479
  */
1480 1480
 function sortUnitRenderedList(&$ListToSort, $sort_option, $sort_option_inverse) {
1481 1481
   if ($sort_option || $sort_option_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) {
1482
-    switch($sort_option) {
1482
+    switch ($sort_option) {
1483 1483
       case PLAYER_OPTION_SORT_NAME:
1484 1484
         $sort_option_field = 'NAME';
1485 1485
       break;
@@ -1500,7 +1500,7 @@  discard block
 block discarded – undo
1500 1500
       break;
1501 1501
     }
1502 1502
     $sort_option_inverse_closure = $sort_option_inverse ? -1 : 1;
1503
-    usort($ListToSort, function ($a, $b) use ($sort_option_field, $sort_option_inverse_closure) {
1503
+    usort($ListToSort, function($a, $b) use ($sort_option_field, $sort_option_inverse_closure) {
1504 1504
       return $a[$sort_option_field] < $b[$sort_option_field] ? -1 * $sort_option_inverse_closure : (
1505 1505
       $a[$sort_option_field] > $b[$sort_option_field] ? 1 * $sort_option_inverse_closure : 0
1506 1506
       );
Please login to merge, or discard this patch.
includes/template.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 function gettemplatename($u_dpath) {
13 13
   static $template_names = array();
14 14
 
15
-  if(!isset($template_names[$u_dpath])) {
15
+  if (!isset($template_names[$u_dpath])) {
16 16
     $template_names[$u_dpath] = file_exists(SN_ROOT_PHYSICAL . $u_dpath . 'tmpl.ini') ? sys_file_read(SN_ROOT_PHYSICAL . $u_dpath . 'tmpl.ini') : TEMPLATE_NAME;
17 17
   }
18 18
 
@@ -54,12 +54,12 @@  discard block
 block discarded – undo
54 54
  * @param $sn_menu_extra
55 55
  */
56 56
 function tpl_menu_merge_extra(&$sn_menu, &$sn_menu_extra) {
57
-  if(empty($sn_menu) || empty($sn_menu_extra)) {
57
+  if (empty($sn_menu) || empty($sn_menu_extra)) {
58 58
     return;
59 59
   }
60 60
 
61
-  foreach($sn_menu_extra as $menu_item_id => $menu_item) {
62
-    if(empty($menu_item['LOCATION'])) {
61
+  foreach ($sn_menu_extra as $menu_item_id => $menu_item) {
62
+    if (empty($menu_item['LOCATION'])) {
63 63
       $sn_menu[$menu_item_id] = $menu_item;
64 64
       continue;
65 65
     }
@@ -68,16 +68,16 @@  discard block
 block discarded – undo
68 68
     unset($menu_item['LOCATION']);
69 69
 
70 70
     $is_positioned = $item_location[0];
71
-    if($is_positioned == '+' || $is_positioned == '-') {
71
+    if ($is_positioned == '+' || $is_positioned == '-') {
72 72
       $item_location = substr($item_location, 1);
73 73
     } else {
74 74
       $is_positioned = '';
75 75
     }
76 76
 
77
-    if($item_location) {
77
+    if ($item_location) {
78 78
       $menu_keys = array_keys($sn_menu);
79 79
       $insert_position = array_search($item_location, $menu_keys);
80
-      if($insert_position === false) {
80
+      if ($insert_position === false) {
81 81
         $insert_position = count($sn_menu) - 1;
82 82
         $is_positioned = '+';
83 83
         $item_location = '';
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     $spliced = array_splice($sn_menu, $insert_position, count($sn_menu) - $insert_position);
91 91
     $sn_menu[$menu_item_id] = $menu_item;
92 92
 
93
-    if(!$is_positioned && $item_location) {
93
+    if (!$is_positioned && $item_location) {
94 94
       unset($spliced[$item_location]);
95 95
     }
96 96
     $sn_menu = array_merge($sn_menu, $spliced);
@@ -104,24 +104,24 @@  discard block
 block discarded – undo
104 104
  * @param template $template
105 105
  */
106 106
 function tpl_menu_assign_to_template(&$sn_menu, &$template) {
107
-  if(empty($sn_menu) || !is_array($sn_menu)) {
107
+  if (empty($sn_menu) || !is_array($sn_menu)) {
108 108
     return;
109 109
   }
110 110
 
111
-  foreach($sn_menu as $menu_item_id => $menu_item) {
112
-    if(!$menu_item) {
111
+  foreach ($sn_menu as $menu_item_id => $menu_item) {
112
+    if (!$menu_item) {
113 113
       continue;
114 114
     }
115 115
 
116
-    if(is_string($menu_item_id)) {
116
+    if (is_string($menu_item_id)) {
117 117
       $menu_item['ID'] = $menu_item_id;
118 118
     }
119 119
 
120
-    if($menu_item['TYPE'] == 'lang') {
120
+    if ($menu_item['TYPE'] == 'lang') {
121 121
       $lang_string = &classLocale::$lang;
122
-      if(preg_match('#(\w+)(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?#', $menu_item['ITEM'], $matches) && count($matches) > 1) {
123
-        for($i = 1; $i < count($matches); $i++) {
124
-          if(defined($matches[$i])) {
122
+      if (preg_match('#(\w+)(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?(?:\[(\w+)\])?#', $menu_item['ITEM'], $matches) && count($matches) > 1) {
123
+        for ($i = 1; $i < count($matches); $i++) {
124
+          if (defined($matches[$i])) {
125 125
             $matches[$i] = constant($matches[$i]);
126 126
           }
127 127
           $lang_string = &$lang_string[$matches[$i]];
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
     $menu_item['ALT'] = htmlentities($menu_item['ALT']);
134 134
     $menu_item['TITLE'] = htmlentities($menu_item['TITLE']);
135 135
 
136
-    if(!empty($menu_item['ICON'])) {
137
-      if(is_string($menu_item['ICON'])) {
136
+    if (!empty($menu_item['ICON'])) {
137
+      if (is_string($menu_item['ICON'])) {
138 138
         $menu_item['ICON_PATH'] = $menu_item['ICON'];
139 139
       } else {
140 140
         $menu_item['ICON'] = $menu_item_id;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
     'MENU_START_HIDE'     => !empty($_COOKIE[SN_COOKIE . '_menu_hidden']) || defined('SN_GOOGLE'),
165 165
   ));
166 166
 
167
-  if(isset($template_result['MENU_CUSTOMIZE'])) {
167
+  if (isset($template_result['MENU_CUSTOMIZE'])) {
168 168
     $template->assign_vars(array(
169 169
       'PLAYER_OPTION_MENU_SHOW_ON_BUTTON'   => classSupernova::$user_options[PLAYER_OPTION_MENU_SHOW_ON_BUTTON],
170 170
       'PLAYER_OPTION_MENU_HIDE_ON_BUTTON'   => classSupernova::$user_options[PLAYER_OPTION_MENU_HIDE_ON_BUTTON],
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
     ));
179 179
   }
180 180
 
181
-  if(defined('IN_ADMIN') && IN_ADMIN === true && !empty($user['authlevel']) && $user['authlevel'] > 0) {
181
+  if (defined('IN_ADMIN') && IN_ADMIN === true && !empty($user['authlevel']) && $user['authlevel'] > 0) {
182 182
     tpl_menu_merge_extra($sn_menu_admin, $sn_menu_admin_extra);
183 183
     tpl_menu_assign_to_template($sn_menu_admin, $template);
184 184
   } else {
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
   $in_admin = defined('IN_ADMIN') && IN_ADMIN === true;
219 219
   $is_login = defined('LOGIN_LOGOUT') && LOGIN_LOGOUT === true;
220 220
 
221
-  if(is_object($page)) {
221
+  if (is_object($page)) {
222 222
     isset($page->_rootref['MENU']) ? $isDisplayMenu = $page->_rootref['MENU'] : false;
223 223
     isset($page->_rootref['NAVBAR']) ? $isDisplayTopNav = $page->_rootref['NAVBAR'] : false;
224 224
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
     !isset($page->_rootref['PAGE_HEADER']) && $title ? $page->assign_var('PAGE_HEADER', $title) : false;
227 227
   }
228 228
 
229
-  if(empty($user['id']) || !is_numeric($user['id'])) {
229
+  if (empty($user['id']) || !is_numeric($user['id'])) {
230 230
     $isDisplayMenu = false;
231 231
     $isDisplayTopNav = false;
232 232
   }
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
   $user_time_measured_unix = intval(isset($user_time_diff[PLAYER_OPTION_TIME_DIFF_MEASURE_TIME]) ? strtotime($user_time_diff[PLAYER_OPTION_TIME_DIFF_MEASURE_TIME]) : 0);
239 239
 
240 240
   $font_size = !empty($_COOKIE[SN_COOKIE_F]) ? $_COOKIE[SN_COOKIE_F] : classSupernova::$user_options[PLAYER_OPTION_BASE_FONT_SIZE];
241
-  if(strpos($font_size, '%') !== false) {
241
+  if (strpos($font_size, '%') !== false) {
242 242
     // Размер шрифта в процентах
243 243
     $font_size = min(max(floatval($font_size), FONT_SIZE_PERCENT_MIN), FONT_SIZE_PERCENT_MAX) . '%';
244
-  } elseif(strpos($font_size, 'px') !== false) {
244
+  } elseif (strpos($font_size, 'px') !== false) {
245 245
     // Размер шрифта в пикселях
246 246
     $font_size = min(max(floatval($font_size), FONT_SIZE_PIXELS_MIN), FONT_SIZE_PIXELS_MAX) . 'px';
247 247
   } else {
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
 
254 254
   $template = gettemplate('_global_header', true);
255 255
 
256
-  if(!empty(classSupernova::$sn_mvc['javascript'])) {
257
-    foreach(classSupernova::$sn_mvc['javascript'] as $page_name => $script_list) {
258
-      if(empty($page_name) || $page_name == $sn_page_name) {
259
-        foreach($script_list as $filename => $content) {
256
+  if (!empty(classSupernova::$sn_mvc['javascript'])) {
257
+    foreach (classSupernova::$sn_mvc['javascript'] as $page_name => $script_list) {
258
+      if (empty($page_name) || $page_name == $sn_page_name) {
259
+        foreach ($script_list as $filename => $content) {
260 260
           $template_result['.']['javascript'][] = array(
261 261
             'FILE'    => $filename,
262 262
             'CONTENT' => $content,
@@ -284,10 +284,10 @@  discard block
 block discarded – undo
284 284
   empty(classSupernova::$css) ? classSupernova::$css = array('' => array()) : false;
285 285
   // Prepending standard CSS files
286 286
   classSupernova::$css[''] = array_merge($standard_css, classSupernova::$css[''], array('design/css/global_override' => ''));
287
-  foreach(classSupernova::$css as $page_name => $script_list) {
288
-    if(empty($page_name) || $page_name == $sn_page_name) {
289
-      foreach($script_list as $filename => $content) {
290
-        if(!($filename = getMinifiedName($filename, '.css'))) {
287
+  foreach (classSupernova::$css as $page_name => $script_list) {
288
+    if (empty($page_name) || $page_name == $sn_page_name) {
289
+      foreach ($script_list as $filename => $content) {
290
+        if (!($filename = getMinifiedName($filename, '.css'))) {
291 291
           continue;
292 292
         }
293 293
         $template_result['.']['css'][] = array(
@@ -336,12 +336,12 @@  discard block
 block discarded – undo
336 336
   $template->assign_recursive($template_result);
337 337
   displayP(parsetemplate($template));
338 338
 
339
-  if(($isDisplayMenu || $in_admin) && !isset($_COOKIE['menu_disable'])) {
339
+  if (($isDisplayMenu || $in_admin) && !isset($_COOKIE['menu_disable'])) {
340 340
     // $AdminPage = $AdminPage ? $user['authlevel'] : 0;
341 341
     displayP(parsetemplate(tpl_render_menu()));
342 342
   }
343 343
 
344
-  if($isDisplayTopNav && !$in_admin) {
344
+  if ($isDisplayTopNav && !$in_admin) {
345 345
     displayP(parsetemplate(tpl_render_topnav($user, $planetrow)));
346 346
   }
347 347
 
@@ -349,8 +349,8 @@  discard block
 block discarded – undo
349 349
 
350 350
   !is_array($page) ? $page = array($page) : false;
351 351
   $result_added = false;
352
-  foreach($page as $page_item) {
353
-    if(!$result_added && is_object($page_item) && isset($page_item->_tpldata['result'])) {
352
+  foreach ($page as $page_item) {
353
+    if (!$result_added && is_object($page_item) && isset($page_item->_tpldata['result'])) {
354 354
       $page_item = gettemplate('_result_message', $page_item);
355 355
       $temp = $page_item->files['_result_message'];
356 356
       unset($page_item->files['_result_message']);
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
   ));
374 374
   displayP(parsetemplate($template));
375 375
 
376
-  $user['authlevel'] >= 3 && classSupernova::$config->debug ? classSupernova::$debug->echo_log() : false;;
376
+  $user['authlevel'] >= 3 && classSupernova::$config->debug ? classSupernova::$debug->echo_log() : false; ;
377 377
 
378 378
   classSupernova::$db->db_disconnect();
379 379
 
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
  * @param string         $type
412 412
  */
413 413
 function tpl_topnav_event_build(&$template, $FleetList, $type = 'fleet') {
414
-  if(empty($FleetList)) {
414
+  if (empty($FleetList)) {
415 415
     return;
416 416
   }
417 417
 
@@ -420,19 +420,19 @@  discard block
 block discarded – undo
420 420
   $fleet_event_count = 0;
421 421
   $fleet_flying_sorter = array();
422 422
   $fleet_flying_events = array();
423
-  foreach($FleetList->_container as $objFleet) {
423
+  foreach ($FleetList->_container as $objFleet) {
424 424
     $will_return = true;
425
-    if(!$objFleet->isReturning()) {
425
+    if (!$objFleet->isReturning()) {
426 426
       // cut fleets on Hold and Expedition
427
-      if($objFleet->time_arrive_to_target >= SN_TIME_NOW) {
427
+      if ($objFleet->time_arrive_to_target >= SN_TIME_NOW) {
428 428
         $objFleet->mission_type == MT_RELOCATE ? $will_return = false : false;
429 429
         tpl_topnav_event_build_helper($objFleet->time_arrive_to_target, EVENT_FLEET_ARRIVE, classLocale::$lang['sys_event_arrive'], $objFleet->target_coordinates_typed(), !$will_return, $objFleet, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count);
430 430
       }
431
-      if($objFleet->time_mission_job_complete) {
431
+      if ($objFleet->time_mission_job_complete) {
432 432
         tpl_topnav_event_build_helper($objFleet->time_mission_job_complete, EVENT_FLEET_STAY, classLocale::$lang['sys_event_stay'], $objFleet->target_coordinates_typed(), false, $objFleet, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count);
433 433
       }
434 434
     }
435
-    if($will_return) {
435
+    if ($will_return) {
436 436
       tpl_topnav_event_build_helper($objFleet->time_return_to_source, EVENT_FLEET_RETURN, classLocale::$lang['sys_event_return'], $objFleet->launch_coordinates_typed(), true, $objFleet, $fleet_flying_sorter, $fleet_flying_events, $fleet_event_count);
437 437
     }
438 438
   }
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
   asort($fleet_flying_sorter);
441 441
 
442 442
   $fleet_flying_count = $FleetList->count();
443
-  foreach($fleet_flying_sorter as $fleet_event_id => $fleet_time) {
443
+  foreach ($fleet_flying_sorter as $fleet_event_id => $fleet_time) {
444 444
     $fleet_event = &$fleet_flying_events[$fleet_event_id];
445 445
     $template->assign_block_vars("flying_{$type}s", array(
446 446
       'TIME' => max(0, $fleet_time - SN_TIME_NOW),
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
   global $template_result;
470 470
   $classLocale = classLocale::$lang;
471 471
 
472
-  if(!is_array($user)) {
472
+  if (!is_array($user)) {
473 473
     return '';
474 474
   }
475 475
 
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
 
491 491
   $ThisUsersPlanets = DBStaticPlanet::db_planet_list_sorted($user);
492 492
   // while ($CurPlanet = db_fetch($ThisUsersPlanets))
493
-  foreach($ThisUsersPlanets as $CurPlanet) {
494
-    if($CurPlanet['destruyed']) {
493
+  foreach ($ThisUsersPlanets as $CurPlanet) {
494
+    if ($CurPlanet['destruyed']) {
495 495
       continue;
496 496
     }
497 497
 
@@ -515,8 +515,8 @@  discard block
 block discarded – undo
515 515
    */
516 516
   $fleet_flying_list = array();
517 517
   $fleet_flying_list[0] = FleetList::dbGetFleetListByOwnerId($user['id']);
518
-  foreach($fleet_flying_list[0]->_container as $fleet_id => $objFleet) {
519
-    if(empty($fleet_flying_list[$objFleet->mission_type])) {
518
+  foreach ($fleet_flying_list[0]->_container as $fleet_id => $objFleet) {
519
+    if (empty($fleet_flying_list[$objFleet->mission_type])) {
520 520
       $fleet_flying_list[$objFleet->mission_type] = new FleetList();
521 521
     }
522 522
     $fleet_flying_list[$objFleet->mission_type][$fleet_id] = $objFleet;
@@ -528,8 +528,8 @@  discard block
 block discarded – undo
528 528
   que_tpl_parse($template, QUE_RESEARCH, $user, array(), null, !classSupernova::$user_options[PLAYER_OPTION_NAVBAR_RESEARCH_WIDE]);
529 529
   que_tpl_parse($template, SUBQUE_FLEET, $user, $planetrow, null, true);
530 530
 
531
-  if(!empty(classSupernova::$sn_mvc['navbar_prefix_button']) && is_array(classSupernova::$sn_mvc['navbar_prefix_button'])) {
532
-    foreach(classSupernova::$sn_mvc['navbar_prefix_button'] as $navbar_button_image => $navbar_button_url) {
531
+  if (!empty(classSupernova::$sn_mvc['navbar_prefix_button']) && is_array(classSupernova::$sn_mvc['navbar_prefix_button'])) {
532
+    foreach (classSupernova::$sn_mvc['navbar_prefix_button'] as $navbar_button_image => $navbar_button_url) {
533 533
       $template->assign_block_vars('navbar_prefix_button', array(
534 534
         'IMAGE'        => $navbar_button_image,
535 535
         'URL_RELATIVE' => $navbar_button_url,
@@ -543,13 +543,13 @@  discard block
 block discarded – undo
543 543
   $time_now_parsed = getdate(SN_TIME_NOW);
544 544
   $time_local_parsed = getdate(defined('SN_CLIENT_TIME_LOCAL') ? SN_CLIENT_TIME_LOCAL : SN_TIME_NOW);
545 545
 
546
-  if(classSupernova::$config->game_news_overview) {
546
+  if (classSupernova::$config->game_news_overview) {
547 547
     $user_last_read_safe = intval($user['news_lastread']);
548 548
     nws_render($template, "WHERE UNIX_TIMESTAMP(`tsTimeStamp`) >= {$user_last_read_safe}", classSupernova::$config->game_news_overview);
549 549
   }
550 550
 
551 551
   $notes_query = DBStaticNote::db_note_list_by_owner($user['id'], true);
552
-  while($note_row = db_fetch($notes_query)) {
552
+  while ($note_row = db_fetch($notes_query)) {
553 553
     note_assign($template, $note_row);
554 554
   }
555 555
 
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
     'QUE_ID'   => QUE_RESEARCH,
564 564
     'QUE_HTML' => 'topnav',
565 565
 
566
-    'RESEARCH_ONGOING' => (boolean)$user['que'],
566
+    'RESEARCH_ONGOING' => (boolean) $user['que'],
567 567
 
568 568
     'TIME_TEXT'       => sprintf($str_date_format, $time_now_parsed['year'], classLocale::$lang['months'][$time_now_parsed['mon']], $time_now_parsed['mday'],
569 569
       $time_now_parsed['hours'], $time_now_parsed['minutes'], $time_now_parsed['seconds']
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
     'QUE_STRUCTURES' => QUE_STRUCTURES,
641 641
   ));
642 642
 
643
-  if((defined('SN_RENDER_NAVBAR_PLANET') && SN_RENDER_NAVBAR_PLANET === true) || ($user['option_list'][OPT_INTERFACE]['opt_int_navbar_resource_force'] && SN_RENDER_NAVBAR_PLANET !== false)) {
643
+  if ((defined('SN_RENDER_NAVBAR_PLANET') && SN_RENDER_NAVBAR_PLANET === true) || ($user['option_list'][OPT_INTERFACE]['opt_int_navbar_resource_force'] && SN_RENDER_NAVBAR_PLANET !== false)) {
644 644
     tpl_set_resource_info($template, $planetrow);
645 645
     $template->assign_vars(array(
646 646
       'SN_RENDER_NAVBAR_PLANET' => true,
@@ -655,12 +655,12 @@  discard block
 block discarded – undo
655 655
  * @param template|string $template
656 656
  */
657 657
 function displayP($template) {
658
-  if(is_object($template)) {
659
-    if(empty($template->parsed)) {
658
+  if (is_object($template)) {
659
+    if (empty($template->parsed)) {
660 660
       parsetemplate($template);
661 661
     }
662 662
 
663
-    foreach($template->files as $section => $filename) {
663
+    foreach ($template->files as $section => $filename) {
664 664
       $template->display($section);
665 665
     }
666 666
   } else {
@@ -675,11 +675,11 @@  discard block
 block discarded – undo
675 675
  * @return mixed
676 676
  */
677 677
 function parsetemplate($template, $array = false) {
678
-  if(is_object($template)) {
678
+  if (is_object($template)) {
679 679
     global $user;
680 680
 
681
-    if(!empty($array) && is_array($array)) {
682
-      foreach($array as $key => $data) {
681
+    if (!empty($array) && is_array($array)) {
682
+      foreach ($array as $key => $data) {
683 683
         $template->assign_var($key, $data);
684 684
       }
685 685
     }
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
 
721 721
   $template_ex = '.tpl.html';
722 722
 
723
-  if($template === false) {
723
+  if ($template === false) {
724 724
     return sys_file_read(TEMPLATE_DIR . '/' . $files . $template_ex);
725 725
   }
726 726
 
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
   !empty(classSupernova::$sn_mvc['i18n']['']) ? lng_load_i18n(classSupernova::$sn_mvc['i18n']['']) : false;
741 741
   $sn_page_name ? lng_load_i18n(classSupernova::$sn_mvc['i18n'][$sn_page_name]) : false;
742 742
 
743
-  foreach($files as &$filename) {
743
+  foreach ($files as &$filename) {
744 744
     $filename = $filename . $template_ex;
745 745
   }
746 746
 
@@ -765,13 +765,13 @@  discard block
 block discarded – undo
765 765
     'LANG'     => $language ? $language : '',
766 766
     'referral' => $id_ref ? '&id_ref=' . $id_ref : '',
767 767
 
768
-    'REQUEST_PARAMS' => !empty($url_params) ? '?' . implode('&', $url_params) : '',// "?lang={$language}" . ($id_ref ? "&id_ref={$id_ref}" : ''),
768
+    'REQUEST_PARAMS' => !empty($url_params) ? '?' . implode('&', $url_params) : '', // "?lang={$language}" . ($id_ref ? "&id_ref={$id_ref}" : ''),
769 769
     'FILENAME'       => basename($_SERVER['PHP_SELF']),
770 770
   ));
771 771
 
772
-  foreach(lng_get_list() as $lng_id => $lng_data) {
773
-    if(isset($lng_data['LANG_VARIANTS']) && is_array($lng_data['LANG_VARIANTS'])) {
774
-      foreach($lng_data['LANG_VARIANTS'] as $lang_variant) {
772
+  foreach (lng_get_list() as $lng_id => $lng_data) {
773
+    if (isset($lng_data['LANG_VARIANTS']) && is_array($lng_data['LANG_VARIANTS'])) {
774
+      foreach ($lng_data['LANG_VARIANTS'] as $lang_variant) {
775 775
         $lng_data1 = $lng_data;
776 776
         $lng_data1 = array_merge($lng_data1, $lang_variant);
777 777
         $template->assign_block_vars('language', $lng_data1);
@@ -794,8 +794,8 @@  discard block
 block discarded – undo
794 794
   $que = $que['ques'][$que_type][$planet['id_owner']][$planet['id']];
795 795
 
796 796
   $que_length = 0;
797
-  if(!empty($que)) {
798
-    foreach($que as $que_item) {
797
+  if (!empty($que)) {
798
+    foreach ($que as $que_item) {
799 799
       $template->assign_block_vars('que', que_tpl_parse_element($que_item));
800 800
     }
801 801
     $que_length = count($que);
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
  * @param int      $user_dark_matter
811 811
  */
812 812
 function tpl_planet_density_info(&$template, &$density_price_chart, $user_dark_matter) {
813
-  foreach($density_price_chart as $density_price_index => &$density_price_data) {
813
+  foreach ($density_price_chart as $density_price_index => &$density_price_data) {
814 814
     $density_cost = $density_price_data;
815 815
     $density_number_style = pretty_number($density_cost, true, $user_dark_matter, false, false);
816 816
 
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 function tpl_assign_select(&$template, $name, $values) {
835 835
   !is_array($values) ? $values = array($values => $values) : false;
836 836
 
837
-  foreach($values as $key => $value) {
837
+  foreach ($values as $key => $value) {
838 838
     $template->assign_block_vars($name, array(
839 839
       'KEY'   => htmlentities($key, ENT_COMPAT, 'UTF-8'),
840 840
       'VALUE' => htmlentities($value, ENT_COMPAT, 'UTF-8'),
Please login to merge, or discard this patch.
classes/sn_module.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
           $load_order[$loaded_module_name] = $level;
311 311
         }
312 312
       }
313
-    } while($prev_order != $load_order);
313
+    } while ($prev_order != $load_order);
314 314
 
315 315
     asort($load_order);
316 316
 
Please login to merge, or discard this patch.