Completed
Push — trunk ( cc9b3e...f009e4 )
by SuperNova.WS
04:37
created
includes/functions/tpl_helpers.php 2 patches
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@  discard block
 block discarded – undo
3 3
 // Compare function to sort fleet in time order
4 4
 function tpl_assign_fleet_compare($a, $b)
5 5
 {
6
-  if($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET'])
6
+  if ($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET'])
7 7
   {
8
-    if($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT'])
8
+    if ($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT'])
9 9
     {
10 10
       return 0;
11 11
     }
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
  *
107 107
  * @return mixed
108 108
  */
109
-function tpl_parse_fleet_db($fleet, $index, $user_data = false){return sn_function_call('tpl_parse_fleet_db', array($fleet, $index, $user_data, &$result));}
109
+function tpl_parse_fleet_db($fleet, $index, $user_data = false) {return sn_function_call('tpl_parse_fleet_db', array($fleet, $index, $user_data, &$result)); }
110 110
 /**
111 111
  * @param array      $fleet
112 112
  * @param int        $index
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
 function sn_tpl_parse_fleet_db($fleet, $index, $user_data = false, &$result) {
119 119
   global $lang, $user;
120 120
 
121
-  if(!$user_data) {
121
+  if (!$user_data) {
122 122
     $user_data = $user;
123 123
   }
124 124
 
125
-  if($fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] == MT_AKS) {
125
+  if ($fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] == MT_AKS) {
126 126
     $aks = doquery("SELECT * FROM {{aks}} WHERE id={$fleet['fleet_group']} LIMIT 1;", true);
127 127
   }
128 128
 
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
   $ship_list = explode(';', $fleet['fleet_array']);
174 174
 
175 175
   $ship_id = 0;
176
-  if($spy_level >= 6) {
177
-    foreach($ship_list as $ship_record) {
178
-      if($ship_record) {
176
+  if ($spy_level >= 6) {
177
+    foreach ($ship_list as $ship_record) {
178
+      if ($ship_record) {
179 179
         $ship_data = explode(',', $ship_record);
180
-        if($spy_level >= 10) {
180
+        if ($spy_level >= 10) {
181 181
           $single_ship_data = get_ship_data($ship_data[0], $user_data);
182 182
           $result['ships'][$ship_data[0]] = array(
183 183
             'ID'          => $ship_data[0],
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
 {
212 212
   $hangar_que = array();
213 213
   $que_hangar = $que['ques'][$que_id][$planet['id_owner']][$planet['id']];
214
-  if(!empty($que_hangar))
214
+  if (!empty($que_hangar))
215 215
   {
216
-    foreach($que_hangar as $que_item)
216
+    foreach ($que_hangar as $que_item)
217 217
     {
218 218
       $hangar_que['que'][] = array('id' => $que_item['que_unit_id'], 'count' => $que_item['que_unit_amount']);
219 219
       $hangar_que[$que_item['que_unit_id']] += $que_item['que_unit_amount'];
@@ -317,11 +317,11 @@  discard block
 block discarded – undo
317 317
     'PLANET_GOVERNOR_LEVEL_MAX' => get_unit_param($planet['PLANET_GOVERNOR_ID'], P_MAX_STACK),
318 318
   ];
319 319
 
320
-  if(!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']]))
320
+  if (!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']]))
321 321
   {
322 322
     $result['building_que'] = [];
323 323
     $building_que = &$que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']];
324
-    foreach($building_que as $que_element)
324
+    foreach ($building_que as $que_element)
325 325
     {
326 326
       $result['building_que'][] = que_tpl_parse_element($que_element);
327 327
     }
@@ -332,23 +332,23 @@  discard block
 block discarded – undo
332 332
 
333 333
 function flt_get_fleets_to_planet($planet, $fleet_db_list = 0)
334 334
 {
335
-  if(!($planet && $planet['id']) && !$fleet_db_list)
335
+  if (!($planet && $planet['id']) && !$fleet_db_list)
336 336
   {
337 337
     return $planet;
338 338
   }
339 339
 
340 340
   global $user;
341 341
 
342
-  if($fleet_db_list === 0)
342
+  if ($fleet_db_list === 0)
343 343
   {
344 344
     $fleet_db_list = fleet_and_missiles_list_by_coordinates($planet);
345 345
   }
346 346
 
347
-  foreach($fleet_db_list as $fleet)
347
+  foreach ($fleet_db_list as $fleet)
348 348
   {
349
-    if($fleet['fleet_owner'] == $user['id'])
349
+    if ($fleet['fleet_owner'] == $user['id'])
350 350
     {
351
-      if($fleet['fleet_mission'] == MT_MISSILE)
351
+      if ($fleet['fleet_mission'] == MT_MISSILE)
352 352
       {
353 353
         continue;
354 354
       }
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
     }
357 357
     else
358 358
     {
359
-      switch($fleet['fleet_mission'])
359
+      switch ($fleet['fleet_mission'])
360 360
       {
361 361
         case MT_ATTACK:
362 362
         case MT_AKS:
@@ -374,13 +374,13 @@  discard block
 block discarded – undo
374 374
 
375 375
     $fleet_list[$fleet_ownage]['fleets'][$fleet['fleet_id']] = $fleet;
376 376
 
377
-    if($fleet['fleet_mess'] == 1 || ($fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] == MT_RELOCATE) || ($fleet['fleet_target_owner'] != $user['id']))
377
+    if ($fleet['fleet_mess'] == 1 || ($fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] == MT_RELOCATE) || ($fleet['fleet_target_owner'] != $user['id']))
378 378
     {
379 379
 //      $fleet_sn = flt_expand($fleet);
380 380
       $fleet_sn = sys_unit_str2arr($fleet['fleet_array']);
381
-      foreach($fleet_sn as $ship_id => $ship_amount)
381
+      foreach ($fleet_sn as $ship_id => $ship_amount)
382 382
       {
383
-        if(in_array($ship_id, sn_get_groups('fleet')))
383
+        if (in_array($ship_id, sn_get_groups('fleet')))
384 384
         {
385 385
           $fleet_list[$fleet_ownage]['total'][$ship_id] += $ship_amount;
386 386
         }
@@ -414,14 +414,14 @@  discard block
 block discarded – undo
414 414
     'ENERGY_MAX_NUMBER_TEXT_NO_COLOR' => HelperString::numberFloorAndFormat($planetrow['energy_max']),
415 415
     'ENERGY_MAX_NUMBER_TEXT' => Tools::numberPercentSpan($planetrow['energy_max'], $planetrow['energy_used']),
416 416
     'ENERGY_MAX' => prettyNumberStyledCompare($planetrow['energy_max'], -$planetrow['energy_used']),
417
-    'ENERGY_FILL' => round(($planetrow["energy_used"]/($planetrow["energy_max"]+1))*100,0),
417
+    'ENERGY_FILL' => round(($planetrow["energy_used"] / ($planetrow["energy_max"] + 1)) * 100, 0),
418 418
 
419 419
     'PLANET_METAL' => floor($planetrow["metal"]),
420 420
     'PLANET_METAL_TEXT' => prettyNumberStyledCompare($planetrow["metal"], $planetrow["metal_max"]),
421 421
     'PLANET_METAL_MAX' => floor($planetrow["metal_max"]),
422 422
     'PLANET_METAL_MAX_TEXT' => Tools::numberPercentSpan($planetrow["metal_max"], $planetrow["metal"]),
423 423
     'PLANET_METAL_MAX_NO_COLOR' => HelperString::numberFloorAndFormat($planetrow["metal_max"]),
424
-    'PLANET_METAL_FILL' => round(($planetrow["metal"]/($planetrow["metal_max"]+1))*100,0),
424
+    'PLANET_METAL_FILL' => round(($planetrow["metal"] / ($planetrow["metal_max"] + 1)) * 100, 0),
425 425
     'PLANET_METAL_PERHOUR' => round($planetrow["metal_perhour"], 5),
426 426
     'PLANET_METAL_FLEET_TEXT' => prettyNumberStyledDefault($fleets_to_planet[$planetrow['id']]['fleet']['METAL']),
427 427
 
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
     'PLANET_CRYSTAL_MAX' => floor($planetrow["crystal_max"]),
431 431
     'PLANET_CRYSTAL_MAX_TEXT' => Tools::numberPercentSpan($planetrow["crystal_max"], $planetrow["crystal"]),
432 432
     'PLANET_CRYSTAL_MAX_NO_COLOR' => HelperString::numberFloorAndFormat($planetrow["crystal_max"]),
433
-    'PLANET_CRYSTAL_FILL' => round(($planetrow["crystal"]/($planetrow["crystal_max"]+1))*100,0),
433
+    'PLANET_CRYSTAL_FILL' => round(($planetrow["crystal"] / ($planetrow["crystal_max"] + 1)) * 100, 0),
434 434
     'PLANET_CRYSTAL_PERHOUR' => round($planetrow["crystal_perhour"], 5),
435 435
     'PLANET_CRYSTAL_FLEET_TEXT' => prettyNumberStyledDefault($fleets_to_planet[$planetrow['id']]['fleet']['CRYSTAL']),
436 436
 
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
     'PLANET_DEUTERIUM_MAX' => floor($planetrow["deuterium_max"]),
440 440
     'PLANET_DEUTERIUM_MAX_TEXT' => Tools::numberPercentSpan($planetrow["deuterium_max"], $planetrow["deuterium"]),
441 441
     'PLANET_DEUTERIUM_MAX_NO_COLOR' => HelperString::numberFloorAndFormat($planetrow["deuterium_max"]),
442
-    'PLANET_DEUTERIUM_FILL' => round(($planetrow["deuterium"]/($planetrow["deuterium_max"]+1))*100,0),
442
+    'PLANET_DEUTERIUM_FILL' => round(($planetrow["deuterium"] / ($planetrow["deuterium_max"] + 1)) * 100, 0),
443 443
     'PLANET_DEUTERIUM_PERHOUR' => round($planetrow["deuterium_perhour"], 5),
444 444
     'PLANET_DEUTERIUM_FLEET_TEXT' => prettyNumberStyledDefault($fleets_to_planet[$planetrow['id']]['fleet']['DEUTERIUM']),
445 445
   ));
Please login to merge, or discard this patch.
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,8 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Compare function to sort fleet in time order
4
-function tpl_assign_fleet_compare($a, $b)
5
-{
4
+function tpl_assign_fleet_compare($a, $b) {
6 5
   if($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET'])
7 6
   {
8 7
     if($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT'])
@@ -10,8 +9,7 @@  discard block
 block discarded – undo
10 9
       return 0;
11 10
     }
12 11
     return ($a['fleet']['OV_LEFT'] < $b['fleet']['OV_LEFT']) ? -1 : 1;
13
-  }
14
-  else
12
+  } else
15 13
   {
16 14
     return $a['fleet']['OV_THIS_PLANET'] ? -1 : 1;
17 15
   }
@@ -207,8 +205,7 @@  discard block
 block discarded – undo
207 205
   return $result;
208 206
 }
209 207
 
210
-function tpl_parse_planet_que($que, $planet, $que_id)
211
-{
208
+function tpl_parse_planet_que($que, $planet, $que_id) {
212 209
   $hangar_que = array();
213 210
   $que_hangar = $que['ques'][$que_id][$planet['id_owner']][$planet['id']];
214 211
   if(!empty($que_hangar))
@@ -270,8 +267,7 @@  discard block
 block discarded – undo
270 267
  *
271 268
  * @return array
272 269
  */
273
-function tpl_parse_planet($planet)
274
-{
270
+function tpl_parse_planet($planet) {
275 271
   global $lang;
276 272
 
277 273
   $que = que_get($planet['id_owner'], $planet['id'], false);
@@ -330,8 +326,7 @@  discard block
 block discarded – undo
330 326
   return $result;
331 327
 }
332 328
 
333
-function flt_get_fleets_to_planet($planet, $fleet_db_list = 0)
334
-{
329
+function flt_get_fleets_to_planet($planet, $fleet_db_list = 0) {
335 330
   if(!($planet && $planet['id']) && !$fleet_db_list)
336 331
   {
337 332
     return $planet;
@@ -353,8 +348,7 @@  discard block
 block discarded – undo
353 348
         continue;
354 349
       }
355 350
       $fleet_ownage = 'own';
356
-    }
357
-    else
351
+    } else
358 352
     {
359 353
       switch($fleet['fleet_mission'])
360 354
       {
@@ -402,8 +396,7 @@  discard block
 block discarded – undo
402 396
  * @param array    $planetrow
403 397
  * @param array    $fleets_to_planet
404 398
  */
405
-function tpl_set_resource_info(&$template, $planetrow, $fleets_to_planet = array())
406
-{
399
+function tpl_set_resource_info(&$template, $planetrow, $fleets_to_planet = array()) {
407 400
   $template->assign_vars(array(
408 401
     'RESOURCE_ROUNDING' => 0,
409 402
 
Please login to merge, or discard this patch.