Completed
Push — trunk ( f009e4...c8f413 )
by SuperNova.WS
06:07
created
includes/functions/tpl_helpers.php 1 patch
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){$result = null;return sn_function_call('tpl_parse_fleet_db', [$fleet, $index, $user_data, &$result]);}
109
+function tpl_parse_fleet_db($fleet, $index, $user_data = false) {$result = null; return sn_function_call('tpl_parse_fleet_db', [$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.
classes/template_compile.php 3 patches
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
   }
56 56
 
57 57
   /**
58
-  * Load template source from file
59
-  * @access private
60
-  */
58
+   * Load template source from file
59
+   * @access private
60
+   */
61 61
   function _tpl_load_file($handle, $store_in_db = false)
62 62
   {
63 63
     // Try and open template for read
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
   }
101 101
 
102 102
   /**
103
-  * Remove any PHP tags that do not belong, these regular expressions are derived from
104
-  * the ones that exist in zend_language_scanner.l
105
-  * @access private
106
-  */
103
+   * Remove any PHP tags that do not belong, these regular expressions are derived from
104
+   * the ones that exist in zend_language_scanner.l
105
+   * @access private
106
+   */
107 107
   function remove_php_tags(&$code)
108 108
   {
109 109
     // This matches the information gathered from the internal PHP lexer
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
   }
118 118
 
119 119
   /**
120
-  * The all seeing all doing compile method. Parts are inspired by or directly from Smarty
121
-  * @access private
122
-  */
120
+   * The all seeing all doing compile method. Parts are inspired by or directly from Smarty
121
+   * @access private
122
+   */
123 123
   function compile($code, $no_echo = false, $echo_var = '')
124 124
   {
125 125
     global $config;
@@ -290,9 +290,9 @@  discard block
 block discarded – undo
290 290
   }
291 291
 
292 292
   /**
293
-  * Compile variables
294
-  * @access private
295
-  */
293
+   * Compile variables
294
+   * @access private
295
+   */
296 296
   function compile_var_tags(&$text_blocks)
297 297
   {
298 298
     // including $lang variable
@@ -365,9 +365,9 @@  discard block
 block discarded – undo
365 365
   }
366 366
 
367 367
   /**
368
-  * Compile blocks
369
-  * @access private
370
-  */
368
+   * Compile blocks
369
+   * @access private
370
+   */
371 371
   function compile_tag_block($tag_args)
372 372
   {
373 373
     $no_nesting = false;
@@ -453,14 +453,14 @@  discard block
 block discarded – undo
453 453
     $tag_template_php .= 'if ($_' . $tag_args . '_count) {';
454 454
 
455 455
     /**
456
-    * The following uses foreach for iteration instead of a for loop, foreach is faster but requires PHP to make a copy of the contents of the array which uses more memory
457
-    * <code>
458
-    * if (!$offset)
459
-    * {
460
-    *   $tag_template_php .= 'foreach (' . $varref . ' as $_' . $tag_args . '_i => $_' . $tag_args . '_val){';
461
-    * }
462
-    * </code>
463
-    */
456
+     * The following uses foreach for iteration instead of a for loop, foreach is faster but requires PHP to make a copy of the contents of the array which uses more memory
457
+     * <code>
458
+     * if (!$offset)
459
+     * {
460
+     *   $tag_template_php .= 'foreach (' . $varref . ' as $_' . $tag_args . '_i => $_' . $tag_args . '_val){';
461
+     * }
462
+     * </code>
463
+     */
464 464
 
465 465
     $tag_template_php .= 'for ($_' . $tag_args . '_i = ' . $loop_start . '; $_' . $tag_args . '_i < ' . $loop_end . '; ++$_' . $tag_args . '_i){';
466 466
 //    $tag_template_php .= '$this->_block_counter["'. $tag_args . '"] = $_' . $tag_args . '_i;';
@@ -471,10 +471,10 @@  discard block
 block discarded – undo
471 471
   }
472 472
 
473 473
   /**
474
-  * Compile IF tags - much of this is from Smarty with
475
-  * some adaptions for our block level methods
476
-  * @access private
477
-  */
474
+   * Compile IF tags - much of this is from Smarty with
475
+   * some adaptions for our block level methods
476
+   * @access private
477
+   */
478 478
   function compile_tag_if($tag_args, $elseif)
479 479
   {
480 480
     // Tokenize args for 'if' tag.
@@ -629,9 +629,9 @@  discard block
 block discarded – undo
629 629
   }
630 630
 
631 631
   /**
632
-  * Compile DEFINE tags
633
-  * @access private
634
-  */
632
+   * Compile DEFINE tags
633
+   * @access private
634
+   */
635 635
   function compile_tag_define($tag_args, $op)
636 636
   {
637 637
     preg_match('#^((?:[a-z0-9\-_]+\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (\'?)([^\']*)(\'?))?$#', $tag_args, $match);
@@ -682,9 +682,9 @@  discard block
 block discarded – undo
682 682
   }
683 683
 
684 684
   /**
685
-  * Compile INCLUDE tag
686
-  * @access private
687
-  */
685
+   * Compile INCLUDE tag
686
+   * @access private
687
+   */
688 688
   function compile_tag_include($tag_args)
689 689
   {
690 690
     // Process dynamic includes
@@ -697,19 +697,19 @@  discard block
 block discarded – undo
697 697
   }
698 698
 
699 699
   /**
700
-  * Compile INCLUDE_PHP tag
701
-  * @access private
702
-  */
700
+   * Compile INCLUDE_PHP tag
701
+   * @access private
702
+   */
703 703
   function compile_tag_include_php($tag_args)
704 704
   {
705 705
     return "\$this->_php_include('$tag_args');";
706 706
   }
707 707
 
708 708
   /**
709
-  * parse expression
710
-  * This is from Smarty
711
-  * @access private
712
-  */
709
+   * parse expression
710
+   * This is from Smarty
711
+   * @access private
712
+   */
713 713
   function _parse_is_expr($is_arg, $tokens)
714 714
   {
715 715
     $expr_end = 0;
@@ -802,14 +802,14 @@  discard block
 block discarded – undo
802 802
   }
803 803
 
804 804
   /**
805
-  * Generates a reference to the array of data values for the given
806
-  * (possibly nested) block namespace. This is a string of the form:
807
-  * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN']
808
-  *
809
-  * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above.
810
-  * NOTE: does not expect a trailing "." on the blockname.
811
-  * @access private
812
-  */
805
+   * Generates a reference to the array of data values for the given
806
+   * (possibly nested) block namespace. This is a string of the form:
807
+   * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN']
808
+   *
809
+   * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above.
810
+   * NOTE: does not expect a trailing "." on the blockname.
811
+   * @access private
812
+   */
813 813
   function generate_block_data_ref($blockname, $include_last_iterator, $defop = false)
814 814
   {
815 815
     // Get an array of the blocks involved.
@@ -845,9 +845,9 @@  discard block
 block discarded – undo
845 845
   }
846 846
 
847 847
   /**
848
-  * Write compiled file to cache directory
849
-  * @access private
850
-  */
848
+   * Write compiled file to cache directory
849
+   * @access private
850
+   */
851 851
   function compile_write($handle, $data)
852 852
   {
853 853
     $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX;
@@ -870,9 +870,9 @@  discard block
 block discarded – undo
870 870
 
871 871
   // Gorlum's minifier BOF
872 872
   /**
873
-  * Minifies template w/i PHP code by removing extra spaces
874
-  * @access private
875
-  */
873
+   * Minifies template w/i PHP code by removing extra spaces
874
+   * @access private
875
+   */
876 876
   function minify($html)
877 877
   {
878 878
     global $config;
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
 
144 144
     preg_match_all('#<!-- INCLUDE (\{\$?[A-Z0-9\-_]+\}|[a-zA-Z0-9\_\-\+\./]+) -->#', $code, $matches);
145 145
     $include_blocks = $matches[1];
146
-    if($include_blocks)
146
+    if ($include_blocks)
147 147
     {
148
-      foreach($include_blocks as &$included_file)
148
+      foreach ($include_blocks as &$included_file)
149 149
       {
150 150
         $included_file .= '.tpl.html';
151 151
       }
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
       $varname = $var_val[3];
311 311
       $new = $this->generate_block_varref($namespace, $varname, $var_val[2]);
312 312
 
313
-      if(!empty($var_val[4])) {
313
+      if (!empty($var_val[4])) {
314 314
         $new = \Ptl\PtlVariableDecorator::decorate($var_val[0], $new, $this->template);
315 315
       }
316 316
 
@@ -464,8 +464,8 @@  discard block
 block discarded – undo
464 464
 
465 465
     $tag_template_php .= 'for ($_' . $tag_args . '_i = ' . $loop_start . '; $_' . $tag_args . '_i < ' . $loop_end . '; ++$_' . $tag_args . '_i){';
466 466
 //    $tag_template_php .= '$this->_block_counter["'. $tag_args . '"] = $_' . $tag_args . '_i;';
467
-    $tag_template_php .= '$_'. $tag_args . '_val = &' . $varref . '[$_'. $tag_args. '_i];';
468
-    $tag_template_php .= '$this->_block_value["'. $tag_args . '"] = &' . $varref . '[$_'. $tag_args. '_i];';
467
+    $tag_template_php .= '$_' . $tag_args . '_val = &' . $varref . '[$_' . $tag_args . '_i];';
468
+    $tag_template_php .= '$this->_block_value["' . $tag_args . '"] = &' . $varref . '[$_' . $tag_args . '_i];';
469 469
 
470 470
     return $tag_template_php;
471 471
   }
@@ -569,10 +569,10 @@  discard block
 block discarded – undo
569 569
         break;
570 570
 
571 571
         case 'is':
572
-          $is_arg_start = ($tokens[$i-1] == ')') ? array_pop($is_arg_stack) : $i-1;
572
+          $is_arg_start = ($tokens[$i - 1] == ')') ? array_pop($is_arg_stack) : $i - 1;
573 573
           $is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start));
574 574
 
575
-          $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1));
575
+          $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i + 1));
576 576
 
577 577
           array_splice($tokens, $is_arg_start, sizeof($tokens), $new_tokens);
578 578
 
@@ -836,11 +836,11 @@  discard block
 block discarded – undo
836 836
     }
837 837
     else if ($include_last_iterator)
838 838
     {
839
-      return '$_'. $blocks[$blockcount] . '_val';
839
+      return '$_' . $blocks[$blockcount] . '_val';
840 840
     }
841 841
     else
842 842
     {
843
-      return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']';
843
+      return '$_' . $blocks[$blockcount - 1] . '_val[\'' . $blocks[$blockcount] . '\']';
844 844
     }
845 845
   }
846 846
 
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
     if ($fp = @fopen($filename, 'wb'))
858 858
     {
859 859
       @flock($fp, LOCK_EX);
860
-      @fwrite ($fp, $data);
860
+      @fwrite($fp, $data);
861 861
       @flock($fp, LOCK_UN);
862 862
       @fclose($fp);
863 863
 
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
   {
878 878
     global $config;
879 879
 
880
-    if(!$config->tpl_minifier)
880
+    if (!$config->tpl_minifier)
881 881
     {
882 882
       return $html;
883 883
     }
@@ -889,14 +889,14 @@  discard block
 block discarded – undo
889 889
     //$html = preg_replace('/[\r\n\t]+/', ' ', $html);
890 890
     $html = preg_replace('/>[\s]*</', '><', $html); // Strip spacechars between tags
891 891
     $html = preg_replace('/[\s]+/', ' ', $html); // Replace several spacechars with one space
892
-    if(!empty($pre[0]))
892
+    if (!empty($pre[0]))
893 893
     {
894
-      foreach($pre[0] as $tag)
894
+      foreach ($pre[0] as $tag)
895 895
       {
896 896
         $tag = preg_replace('/^\ *\/\/[^\<]*?$/m', ' ', $tag); // Strips comments - except those that contains HTML comment inside
897 897
         $tag = preg_replace('/[\ \t]{2,}/', ' ', $tag); // Replace several spaces by one
898 898
         $tag = preg_replace('/\s{2,}/', "\r\n", $tag); // Replace several linefeeds by one
899
-        $html = preg_replace('/#pre#/', $tag, $html,1);
899
+        $html = preg_replace('/#pre#/', $tag, $html, 1);
900 900
       }
901 901
     }
902 902
 
Please login to merge, or discard this patch.
Braces   +33 added lines, -66 removed lines patch added patch discarded remove patch
@@ -37,8 +37,7 @@  discard block
 block discarded – undo
37 37
 *
38 38
 * @package phpBB3
39 39
 */
40
-class template_compile
41
-{
40
+class template_compile {
42 41
   var $template;
43 42
 
44 43
   // Various storage arrays
@@ -58,8 +57,7 @@  discard block
 block discarded – undo
58 57
   * Load template source from file
59 58
   * @access private
60 59
   */
61
-  function _tpl_load_file($handle, $store_in_db = false)
62
-  {
60
+  function _tpl_load_file($handle, $store_in_db = false) {
63 61
     // Try and open template for read
64 62
     if (!file_exists($this->template->files[$handle]))
65 63
     {
@@ -67,8 +65,7 @@  discard block
 block discarded – undo
67 65
       {
68 66
         return;
69 67
         trigger_error("template->_tpl_load_file(): File {$this->template->files[$handle]} does not exist or is empty", E_USER_ERROR);
70
-      }
71
-      else
68
+      } else
72 69
       {
73 70
         $this->template->files[$handle] = $this->template->files_inherit[$handle];
74 71
       }
@@ -104,8 +101,7 @@  discard block
 block discarded – undo
104 101
   * the ones that exist in zend_language_scanner.l
105 102
   * @access private
106 103
   */
107
-  function remove_php_tags(&$code)
108
-  {
104
+  function remove_php_tags(&$code) {
109 105
     // This matches the information gathered from the internal PHP lexer
110 106
     $match = array(
111 107
       '#<([\?%])=?.*?\1>#s',
@@ -120,8 +116,7 @@  discard block
 block discarded – undo
120 116
   * The all seeing all doing compile method. Parts are inspired by or directly from Smarty
121 117
   * @access private
122 118
   */
123
-  function compile($code, $no_echo = false, $echo_var = '')
124
-  {
119
+  function compile($code, $no_echo = false, $echo_var = '') {
125 120
     global $config;
126 121
 
127 122
     if ($echo_var)
@@ -226,15 +221,13 @@  discard block
 block discarded – undo
226 221
               $var = substr($temp, 2, -1);
227 222
               //$file = $this->template->_tpldata['DEFINE']['.'][$var];
228 223
               $temp = "\$this->_tpldata['DEFINE']['.']['$var']";
229
-            }
230
-            else
224
+            } else
231 225
             {
232 226
               $var = substr($temp, 1, -1);
233 227
               //$file = $this->template->_rootref[$var];
234 228
               $temp = "\$this->_rootref['$var']";
235 229
             }
236
-          }
237
-          else
230
+          } else
238 231
           {
239 232
             $file = $temp;
240 233
           }
@@ -293,8 +286,7 @@  discard block
 block discarded – undo
293 286
   * Compile variables
294 287
   * @access private
295 288
   */
296
-  function compile_var_tags(&$text_blocks)
297
-  {
289
+  function compile_var_tags(&$text_blocks) {
298 290
     // including $lang variable
299 291
     global $lang, $config;
300 292
 
@@ -368,8 +360,7 @@  discard block
 block discarded – undo
368 360
   * Compile blocks
369 361
   * @access private
370 362
   */
371
-  function compile_tag_block($tag_args)
372
-  {
363
+  function compile_tag_block($tag_args) {
373 364
     $no_nesting = false;
374 365
 
375 366
     // Is the designer wanting to call another loop in a loop?
@@ -392,8 +383,7 @@  discard block
 block discarded – undo
392 383
       if ($match[2] < 0)
393 384
       {
394 385
         $loop_start = '($_' . $tag_args . '_count ' . $match[2] . ' < 0 ? 0 : $_' . $tag_args . '_count ' . $match[2] . ')';
395
-      }
396
-      else
386
+      } else
397 387
       {
398 388
         $loop_start = '($_' . $tag_args . '_count < ' . $match[2] . ' ? $_' . $tag_args . '_count : ' . $match[2] . ')';
399 389
       }
@@ -401,17 +391,14 @@  discard block
 block discarded – undo
401 391
       if (strlen($match[3]) < 1 || $match[3] == -1)
402 392
       {
403 393
         $loop_end = '$_' . $tag_args . '_count';
404
-      }
405
-      else if ($match[3] >= 0)
394
+      } else if ($match[3] >= 0)
406 395
       {
407 396
         $loop_end = '(' . ($match[3] + 1) . ' > $_' . $tag_args . '_count ? $_' . $tag_args . '_count : ' . ($match[3] + 1) . ')';
408
-      }
409
-      else //if ($match[3] < -1)
397
+      } else //if ($match[3] < -1)
410 398
       {
411 399
         $loop_end = '$_' . $tag_args . '_count' . ($match[3] + 1);
412 400
       }
413
-    }
414
-    else
401
+    } else
415 402
     {
416 403
       $loop_start = 0;
417 404
       $loop_end = '$_' . $tag_args . '_count';
@@ -424,8 +411,7 @@  discard block
 block discarded – undo
424 411
     {
425 412
       // We need to implode $no_nesting times from the end...
426 413
       $block = array_slice($this->block_names, -$no_nesting);
427
-    }
428
-    else
414
+    } else
429 415
     {
430 416
       $block = $this->block_names;
431 417
     }
@@ -435,8 +421,7 @@  discard block
 block discarded – undo
435 421
       // Block is not nested.
436 422
       $tag_template_php = '$_' . $tag_args . "_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;";
437 423
       $varref = "\$this->_tpldata['$tag_args']";
438
-    }
439
-    else
424
+    } else
440 425
     {
441 426
       // This block is nested.
442 427
       // Generate a namespace string for this block.
@@ -475,8 +460,7 @@  discard block
 block discarded – undo
475 460
   * some adaptions for our block level methods
476 461
   * @access private
477 462
   */
478
-  function compile_tag_if($tag_args, $elseif)
479
-  {
463
+  function compile_tag_if($tag_args, $elseif) {
480 464
     // Tokenize args for 'if' tag.
481 465
     preg_match_all('/(?:
482 466
       "[^"\\\\]*(?:\\\\.[^"\\\\]*)*"         |
@@ -584,8 +568,7 @@  discard block
 block discarded – undo
584 568
           if (preg_match('#^((?:[a-z0-9\-_]+\.)+)?(\$)?(?=[A-Za-z])([A-Za-z0-9\-_]+)#s', $token, $varrefs))
585 569
           {
586 570
             $token = (!empty($varrefs[1])) ? $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[2]) . '[\'' . $varrefs[3] . '\']' : (($varrefs[2]) ? '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $varrefs[3] . '\']' : '$this->_rootref[\'' . $varrefs[3] . '\']');
587
-          }
588
-          else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs))
571
+          } else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs))
589 572
           {
590 573
             // Allow checking if loops are set with .loopname
591 574
             // It is also possible to check the loop count by doing <!-- IF .loopname > 1 --> for example
@@ -601,8 +584,7 @@  discard block
 block discarded – undo
601 584
 
602 585
               // Add the block reference for the last child.
603 586
               $varref .= "['" . $block . "']";
604
-            }
605
-            else
587
+            } else
606 588
             {
607 589
               $varref = '$this->_tpldata';
608 590
 
@@ -610,8 +592,7 @@  discard block
 block discarded – undo
610 592
               $varref .= "['" . $blocks[0] . "']";
611 593
             }
612 594
             $token = "sizeof($varref)";
613
-          }
614
-          else if (!empty($token))
595
+          } else if (!empty($token))
615 596
           {
616 597
             $token = '(' . $token . ')';
617 598
           }
@@ -632,8 +613,7 @@  discard block
 block discarded – undo
632 613
   * Compile DEFINE tags
633 614
   * @access private
634 615
   */
635
-  function compile_tag_define($tag_args, $op)
636
-  {
616
+  function compile_tag_define($tag_args, $op) {
637 617
     preg_match('#^((?:[a-z0-9\-_]+\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (\'?)([^\']*)(\'?))?$#', $tag_args, $match);
638 618
 
639 619
     if (empty($match[2]) || (!isset($match[4]) && $op))
@@ -656,8 +636,7 @@  discard block
 block discarded – undo
656 636
 
657 637
       // Now replace the php code
658 638
       $match[4] = "'" . str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4]) . "'";
659
-    }
660
-    else
639
+    } else
661 640
     {
662 641
       preg_match('#true|false|\.#i', $match[4], $type);
663 642
 
@@ -685,8 +664,7 @@  discard block
 block discarded – undo
685 664
   * Compile INCLUDE tag
686 665
   * @access private
687 666
   */
688
-  function compile_tag_include($tag_args)
689
-  {
667
+  function compile_tag_include($tag_args) {
690 668
     // Process dynamic includes
691 669
     if ($tag_args[0] == '$')
692 670
     {
@@ -700,8 +678,7 @@  discard block
 block discarded – undo
700 678
   * Compile INCLUDE_PHP tag
701 679
   * @access private
702 680
   */
703
-  function compile_tag_include_php($tag_args)
704
-  {
681
+  function compile_tag_include_php($tag_args) {
705 682
     return "\$this->_php_include('$tag_args');";
706 683
   }
707 684
 
@@ -710,8 +687,7 @@  discard block
 block discarded – undo
710 687
   * This is from Smarty
711 688
   * @access private
712 689
   */
713
-  function _parse_is_expr($is_arg, $tokens)
714
-  {
690
+  function _parse_is_expr($is_arg, $tokens) {
715 691
     $expr_end = 0;
716 692
     $negate_expr = false;
717 693
 
@@ -719,8 +695,7 @@  discard block
 block discarded – undo
719 695
     {
720 696
       $negate_expr = true;
721 697
       $expr_type = array_shift($tokens);
722
-    }
723
-    else
698
+    } else
724 699
     {
725 700
       $expr_type = $first_token;
726 701
     }
@@ -733,8 +708,7 @@  discard block
 block discarded – undo
733 708
           $expr_end++;
734 709
           $expr_arg = $tokens[$expr_end++];
735 710
           $expr = "!(($is_arg / $expr_arg) % $expr_arg)";
736
-        }
737
-        else
711
+        } else
738 712
         {
739 713
           $expr = "!($is_arg & 1)";
740 714
         }
@@ -746,8 +720,7 @@  discard block
 block discarded – undo
746 720
           $expr_end++;
747 721
           $expr_arg = $tokens[$expr_end++];
748 722
           $expr = "(($is_arg / $expr_arg) % $expr_arg)";
749
-        }
750
-        else
723
+        } else
751 724
         {
752 725
           $expr = "($is_arg & 1)";
753 726
         }
@@ -786,8 +759,7 @@  discard block
 block discarded – undo
786 759
    *
787 760
    * @return string
788 761
    */
789
-  private function generate_block_varref($namespace, $varname, $defop = false)
790
-  {
762
+  private function generate_block_varref($namespace, $varname, $defop = false) {
791 763
     // Strip the trailing period.
792 764
     $namespace = substr($namespace, 0, -1);
793 765
 
@@ -810,8 +782,7 @@  discard block
 block discarded – undo
810 782
   * NOTE: does not expect a trailing "." on the blockname.
811 783
   * @access private
812 784
   */
813
-  function generate_block_data_ref($blockname, $include_last_iterator, $defop = false)
814
-  {
785
+  function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) {
815 786
     // Get an array of the blocks involved.
816 787
     $blocks = explode('.', $blockname);
817 788
     $blockcount = sizeof($blocks) - 1;
@@ -833,12 +804,10 @@  discard block
 block discarded – undo
833 804
         $varref .= '[$_' . $blocks[$blockcount] . '_i]';
834 805
       }
835 806
       return $varref;
836
-    }
837
-    else if ($include_last_iterator)
807
+    } else if ($include_last_iterator)
838 808
     {
839 809
       return '$_'. $blocks[$blockcount] . '_val';
840
-    }
841
-    else
810
+    } else
842 811
     {
843 812
       return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']';
844 813
     }
@@ -848,8 +817,7 @@  discard block
 block discarded – undo
848 817
   * Write compiled file to cache directory
849 818
   * @access private
850 819
   */
851
-  function compile_write($handle, $data)
852
-  {
820
+  function compile_write($handle, $data) {
853 821
     $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX;
854 822
 
855 823
     $data = "<?php if (!defined('INSIDE')) exit;" . ((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>' . $data);
@@ -873,8 +841,7 @@  discard block
 block discarded – undo
873 841
   * Minifies template w/i PHP code by removing extra spaces
874 842
   * @access private
875 843
   */
876
-  function minify($html)
877
-  {
844
+  function minify($html) {
878 845
     global $config;
879 846
 
880 847
     if(!$config->tpl_minifier)
Please login to merge, or discard this patch.
classes/Ptl/PtlVariableDecorator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@
 block discarded – undo
74 74
 
75 75
     if (array_key_exists(self::PARAM_NUMERIC, $ptlTag->params)) {
76 76
       // Just dump other params
77
-      foreach(static::$allowedParams as $paramName => $limitTag) {
77
+      foreach (static::$allowedParams as $paramName => $limitTag) {
78 78
         if ($limitTag != self::PARAM_NUMERIC || !array_key_exists($paramName, $ptlTag->params)) {
79 79
           continue;
80 80
         }
Please login to merge, or discard this patch.
resources.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
   ]);
51 51
 };
52 52
 
53
-$ValidList['percent'] = array (  0,  10,  20,  30,  40,  50,  60,  70,  80,  90, 100 );
53
+$ValidList['percent'] = array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100);
54 54
 $template = gettemplate('resources', true);
55 55
 
56 56
 $planet = new \Planet\Planet($planetrow['id']);
57
-if(!empty($transmutation_result = $planet->sn_sys_planet_core_transmute($user))) {
57
+if (!empty($transmutation_result = $planet->sn_sys_planet_core_transmute($user))) {
58 58
   $template->assign_block_vars('result', $transmutation_result);
59 59
   $planet = new \Planet\Planet($planetrow['id']);
60 60
 }
@@ -63,20 +63,20 @@  discard block
 block discarded – undo
63 63
 $production = $_POST['production'];
64 64
 //$SubQry     = '';
65 65
 $SubQry     = array();
66
-if(is_array($production)) {
67
-  foreach($production as $prod_id => $percent) {
68
-    if($percent > 100 || $percent < 0) {
66
+if (is_array($production)) {
67
+  foreach ($production as $prod_id => $percent) {
68
+    if ($percent > 100 || $percent < 0) {
69 69
       $debug->warning('Supplying wrong production percent (less then 0 or greater then 100)', 'Hack attempt', 302, array('base_dump' => true));
70 70
       die();
71 71
     }
72 72
 
73 73
     $prod_id = intval($prod_id);
74
-    if(in_array($prod_id, $sn_group_factories) && get_unit_param($prod_id, P_MINING_IS_MANAGED)) {
74
+    if (in_array($prod_id, $sn_group_factories) && get_unit_param($prod_id, P_MINING_IS_MANAGED)) {
75 75
       $field_name              = pname_factory_production_field_name($prod_id);
76 76
       $percent                 = floor($percent / 10);
77 77
       $planetrow[$field_name]  = $percent;
78 78
       //$SubQry                 .= "`{$field_name}` = '{$percent}',";
79
-      $SubQry[]                 = "`{$field_name}` = '{$percent}'";
79
+      $SubQry[] = "`{$field_name}` = '{$percent}'";
80 80
     } else {
81 81
       $debug->warning('Supplying wrong ID in production array - attempt to change some field - ID' . $prod_id, 'Resource Page', 301);
82 82
       continue;
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
   'ENERGY_TYPE'    => $capsObj->productionCurrentMatrix[RES_ENERGY][0],
114 114
 ));
115 115
 
116
-foreach($sn_group_factories as $unit_id)
116
+foreach ($sn_group_factories as $unit_id)
117 117
 {
118
-  if(mrc_get_level($user, $planetrow, $unit_id) > 0 && get_unit_param($unit_id))
118
+  if (mrc_get_level($user, $planetrow, $unit_id) > 0 && get_unit_param($unit_id))
119 119
   {
120 120
     $level_plain = mrc_get_level($user, $planetrow, $unit_id, false, true);
121 121
     $template->assign_block_vars('production', array(
Please login to merge, or discard this patch.