Completed
Push — work-fleets ( 961997...006942 )
by SuperNova.WS
06:22
created
classes/template_compile.php 4 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -47,6 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
   /**
49 49
   * constuctor
50
+  * @param template $template
50 51
   */
51 52
   function template_compile(&$template)
52 53
   {
@@ -463,6 +464,7 @@  discard block
 block discarded – undo
463 464
   * Compile IF tags - much of this is from Smarty with
464 465
   * some adaptions for our block level methods
465 466
   * @access private
467
+  * @param boolean $elseif
466 468
   */
467 469
   function compile_tag_if($tag_args, $elseif)
468 470
   {
@@ -620,6 +622,7 @@  discard block
 block discarded – undo
620 622
   /**
621 623
   * Compile DEFINE tags
622 624
   * @access private
625
+  * @param boolean $op
623 626
   */
624 627
   function compile_tag_define($tag_args, $op)
625 628
   {
@@ -698,6 +701,7 @@  discard block
 block discarded – undo
698 701
   * parse expression
699 702
   * This is from Smarty
700 703
   * @access private
704
+  * @param string $is_arg
701 705
   */
702 706
   function _parse_is_expr($is_arg, $tokens)
703 707
   {
@@ -794,6 +798,8 @@  discard block
 block discarded – undo
794 798
   * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above.
795 799
   * NOTE: does not expect a trailing "." on the blockname.
796 800
   * @access private
801
+  * @param string $blockname
802
+  * @param boolean $include_last_iterator
797 803
   */
798 804
   function generate_block_data_ref($blockname, $include_last_iterator, $defop = false)
799 805
   {
@@ -832,6 +838,7 @@  discard block
 block discarded – undo
832 838
   /**
833 839
   * Write compiled file to cache directory
834 840
   * @access private
841
+  * @param string $data
835 842
   */
836 843
   function compile_write($handle, $data)
837 844
   {
@@ -857,6 +864,7 @@  discard block
 block discarded – undo
857 864
   /**
858 865
   * Minifies template w/i PHP code by removing extra spaces
859 866
   * @access private
867
+  * @return string
860 868
   */
861 869
   function minify($html)
862 870
   {
Please login to merge, or discard this patch.
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -44,17 +44,17 @@  discard block
 block discarded – undo
44 44
   var $block_else_level = array();
45 45
 
46 46
   /**
47
-  * constuctor
48
-  */
47
+   * constuctor
48
+   */
49 49
   function template_compile(&$template)
50 50
   {
51 51
     $this->template = &$template;
52 52
   }
53 53
 
54 54
   /**
55
-  * Load template source from file
56
-  * @access private
57
-  */
55
+   * Load template source from file
56
+   * @access private
57
+   */
58 58
   function _tpl_load_file($handle, $store_in_db = false)
59 59
   {
60 60
     // Try and open template for read
@@ -97,10 +97,10 @@  discard block
 block discarded – undo
97 97
   }
98 98
 
99 99
   /**
100
-  * Remove any PHP tags that do not belong, these regular expressions are derived from
101
-  * the ones that exist in zend_language_scanner.l
102
-  * @access private
103
-  */
100
+   * Remove any PHP tags that do not belong, these regular expressions are derived from
101
+   * the ones that exist in zend_language_scanner.l
102
+   * @access private
103
+   */
104 104
   function remove_php_tags(&$code)
105 105
   {
106 106
     // This matches the information gathered from the internal PHP lexer
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
   }
115 115
 
116 116
   /**
117
-  * The all seeing all doing compile method. Parts are inspired by or directly from Smarty
118
-  * @access private
119
-  */
117
+   * The all seeing all doing compile method. Parts are inspired by or directly from Smarty
118
+   * @access private
119
+   */
120 120
   function compile($code, $no_echo = false, $echo_var = '')
121 121
   {
122 122
     if ($echo_var)
@@ -285,9 +285,9 @@  discard block
 block discarded – undo
285 285
   }
286 286
 
287 287
   /**
288
-  * Compile variables
289
-  * @access private
290
-  */
288
+   * Compile variables
289
+   * @access private
290
+   */
291 291
   function compile_var_tags(&$text_blocks)
292 292
   {
293 293
     // change template varrefs into PHP varrefs
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
   }
348 348
 
349 349
   /**
350
-  * Compile blocks
351
-  * @access private
352
-  */
350
+   * Compile blocks
351
+   * @access private
352
+   */
353 353
   function compile_tag_block($tag_args)
354 354
   {
355 355
     $no_nesting = false;
@@ -435,14 +435,14 @@  discard block
 block discarded – undo
435 435
     $tag_template_php .= 'if ($_' . $tag_args . '_count) {';
436 436
 
437 437
     /**
438
-    * 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
439
-    * <code>
440
-    * if (!$offset)
441
-    * {
442
-    *   $tag_template_php .= 'foreach (' . $varref . ' as $_' . $tag_args . '_i => $_' . $tag_args . '_val){';
443
-    * }
444
-    * </code>
445
-    */
438
+     * 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
439
+     * <code>
440
+     * if (!$offset)
441
+     * {
442
+     *   $tag_template_php .= 'foreach (' . $varref . ' as $_' . $tag_args . '_i => $_' . $tag_args . '_val){';
443
+     * }
444
+     * </code>
445
+     */
446 446
 
447 447
     $tag_template_php .= 'for ($_' . $tag_args . '_i = ' . $loop_start . '; $_' . $tag_args . '_i < ' . $loop_end . '; ++$_' . $tag_args . '_i){';
448 448
 //    $tag_template_php .= '$this->_block_counter["'. $tag_args . '"] = $_' . $tag_args . '_i;';
@@ -453,10 +453,10 @@  discard block
 block discarded – undo
453 453
   }
454 454
 
455 455
   /**
456
-  * Compile IF tags - much of this is from Smarty with
457
-  * some adaptions for our block level methods
458
-  * @access private
459
-  */
456
+   * Compile IF tags - much of this is from Smarty with
457
+   * some adaptions for our block level methods
458
+   * @access private
459
+   */
460 460
   function compile_tag_if($tag_args, $elseif)
461 461
   {
462 462
     // Tokenize args for 'if' tag.
@@ -611,9 +611,9 @@  discard block
 block discarded – undo
611 611
   }
612 612
 
613 613
   /**
614
-  * Compile DEFINE tags
615
-  * @access private
616
-  */
614
+   * Compile DEFINE tags
615
+   * @access private
616
+   */
617 617
   function compile_tag_define($tag_args, $op)
618 618
   {
619 619
     preg_match('#^((?:[a-z0-9\-_]+\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (\'?)([^\']*)(\'?))?$#', $tag_args, $match);
@@ -664,9 +664,9 @@  discard block
 block discarded – undo
664 664
   }
665 665
 
666 666
   /**
667
-  * Compile INCLUDE tag
668
-  * @access private
669
-  */
667
+   * Compile INCLUDE tag
668
+   * @access private
669
+   */
670 670
   function compile_tag_include($tag_args)
671 671
   {
672 672
     // Process dynamic includes
@@ -679,19 +679,19 @@  discard block
 block discarded – undo
679 679
   }
680 680
 
681 681
   /**
682
-  * Compile INCLUDE_PHP tag
683
-  * @access private
684
-  */
682
+   * Compile INCLUDE_PHP tag
683
+   * @access private
684
+   */
685 685
   function compile_tag_include_php($tag_args)
686 686
   {
687 687
     return "\$this->_php_include('$tag_args');";
688 688
   }
689 689
 
690 690
   /**
691
-  * parse expression
692
-  * This is from Smarty
693
-  * @access private
694
-  */
691
+   * parse expression
692
+   * This is from Smarty
693
+   * @access private
694
+   */
695 695
   function _parse_is_expr($is_arg, $tokens)
696 696
   {
697 697
     $expr_end = 0;
@@ -756,13 +756,13 @@  discard block
 block discarded – undo
756 756
   }
757 757
 
758 758
   /**
759
-  * Generates a reference to the given variable inside the given (possibly nested)
760
-  * block namespace. This is a string of the form:
761
-  * ' . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . '
762
-  * It's ready to be inserted into an "echo" line in one of the templates.
763
-  * NOTE: expects a trailing "." on the namespace.
764
-  * @access private
765
-  */
759
+   * Generates a reference to the given variable inside the given (possibly nested)
760
+   * block namespace. This is a string of the form:
761
+   * ' . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . '
762
+   * It's ready to be inserted into an "echo" line in one of the templates.
763
+   * NOTE: expects a trailing "." on the namespace.
764
+   * @access private
765
+   */
766 766
   function generate_block_varref($namespace, $varname, $echo = true, $defop = false)
767 767
   {
768 768
     // Strip the trailing period.
@@ -780,14 +780,14 @@  discard block
 block discarded – undo
780 780
   }
781 781
 
782 782
   /**
783
-  * Generates a reference to the array of data values for the given
784
-  * (possibly nested) block namespace. This is a string of the form:
785
-  * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN']
786
-  *
787
-  * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above.
788
-  * NOTE: does not expect a trailing "." on the blockname.
789
-  * @access private
790
-  */
783
+   * Generates a reference to the array of data values for the given
784
+   * (possibly nested) block namespace. This is a string of the form:
785
+   * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN']
786
+   *
787
+   * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above.
788
+   * NOTE: does not expect a trailing "." on the blockname.
789
+   * @access private
790
+   */
791 791
   function generate_block_data_ref($blockname, $include_last_iterator, $defop = false)
792 792
   {
793 793
     // Get an array of the blocks involved.
@@ -823,9 +823,9 @@  discard block
 block discarded – undo
823 823
   }
824 824
 
825 825
   /**
826
-  * Write compiled file to cache directory
827
-  * @access private
828
-  */
826
+   * Write compiled file to cache directory
827
+   * @access private
828
+   */
829 829
   function compile_write($handle, $data)
830 830
   {
831 831
     $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX;
@@ -848,8 +848,8 @@  discard block
 block discarded – undo
848 848
 
849 849
   // Gorlum's minifier BOF
850 850
   /**
851
-  * Minifies template w/i PHP code by removing extra spaces
852
-  */
851
+   * Minifies template w/i PHP code by removing extra spaces
852
+   */
853 853
   private function minify($html)
854 854
   {
855 855
     if(!classSupernova::$config->tpl_minifier)
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         'template_data'     => trim(@file_get_contents($this->template->files[$handle])),
92 92
       );
93 93
 
94
-      $sql = 'INSERT INTO ' . STYLES_TEMPLATE_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
94
+      $sql = 'INSERT INTO '.STYLES_TEMPLATE_DATA_TABLE.' '.$db->sql_build_array('INSERT', $sql_ary);
95 95
       $db->sql_query($sql);
96 96
     }
97 97
   }
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
 
139 139
     preg_match_all('#<!-- INCLUDE (\{\$?[A-Z0-9\-_]+\}|[a-zA-Z0-9\_\-\+\./]+) -->#', $code, $matches);
140 140
     $include_blocks = $matches[1];
141
-    if($include_blocks)
141
+    if ($include_blocks)
142 142
     {
143
-      foreach($include_blocks as &$included_file)
143
+      foreach ($include_blocks as &$included_file)
144 144
       {
145 145
         $included_file .= '.tpl.html';
146 146
       }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
       {
170 170
         case 'BEGIN':
171 171
           $this->block_else_level[] = false;
172
-          $compile_blocks[] = '<?php ' . $this->compile_tag_block($block_val[2]) . ' ?>';
172
+          $compile_blocks[] = '<?php '.$this->compile_tag_block($block_val[2]).' ?>';
173 173
         break;
174 174
 
175 175
         case 'BEGINELSE':
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
 
180 180
         case 'END':
181 181
           array_pop($this->block_names);
182
-          $compile_blocks[] = '<?php ' . ((array_pop($this->block_else_level)) ? '}' : '}}') . ' ?>';
182
+          $compile_blocks[] = '<?php '.((array_pop($this->block_else_level)) ? '}' : '}}').' ?>';
183 183
         break;
184 184
 
185 185
         case 'IF':
186
-          $compile_blocks[] = '<?php ' . $this->compile_tag_if($block_val[2], false) . ' ?>';
186
+          $compile_blocks[] = '<?php '.$this->compile_tag_if($block_val[2], false).' ?>';
187 187
         break;
188 188
 
189 189
         case 'ELSE':
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
         break;
192 192
 
193 193
         case 'ELSEIF':
194
-          $compile_blocks[] = '<?php ' . $this->compile_tag_if($block_val[2], true) . ' ?>';
194
+          $compile_blocks[] = '<?php '.$this->compile_tag_if($block_val[2], true).' ?>';
195 195
         break;
196 196
 
197 197
         case 'ENDIF':
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
         break;
200 200
 
201 201
         case 'DEFINE':
202
-          $compile_blocks[] = '<?php ' . $this->compile_tag_define($block_val[2], true) . ' ?>';
202
+          $compile_blocks[] = '<?php '.$this->compile_tag_define($block_val[2], true).' ?>';
203 203
         break;
204 204
 
205 205
         case 'UNDEFINE':
206
-          $compile_blocks[] = '<?php ' . $this->compile_tag_define($block_val[2], false) . ' ?>';
206
+          $compile_blocks[] = '<?php '.$this->compile_tag_define($block_val[2], false).' ?>';
207 207
         break;
208 208
 
209 209
         case 'INCLUDE':
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
             $file = $temp;
235 235
           }
236 236
 
237
-          $compile_blocks[] = '<?php ' . $this->compile_tag_include($temp) . ' ?>';
237
+          $compile_blocks[] = '<?php '.$this->compile_tag_include($temp).' ?>';
238 238
 
239 239
           // No point in checking variable includes
240 240
           if ($file)
@@ -244,11 +244,11 @@  discard block
 block discarded – undo
244 244
         break;
245 245
 
246 246
         case 'INCLUDEPHP':
247
-          $compile_blocks[] = (classSupernova::$config->tpl_allow_php) ? '<?php ' . $this->compile_tag_include_php(array_shift($includephp_blocks)) . ' ?>' : '';
247
+          $compile_blocks[] = (classSupernova::$config->tpl_allow_php) ? '<?php '.$this->compile_tag_include_php(array_shift($includephp_blocks)).' ?>' : '';
248 248
         break;
249 249
 
250 250
         case 'PHP':
251
-          $compile_blocks[] = (classSupernova::$config->tpl_allow_php) ? '<?php ' . array_shift($php_blocks) . ' ?>' : '';
251
+          $compile_blocks[] = (classSupernova::$config->tpl_allow_php) ? '<?php '.array_shift($php_blocks).' ?>' : '';
252 252
         break;
253 253
 
254 254
         default:
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
     for ($i = 0, $size = sizeof($text_blocks); $i < $size; $i++)
264 264
     {
265 265
       $trim_check_text = trim($text_blocks[$i]);
266
-      $template_php .= (!$no_echo) ? (($trim_check_text != '') ? $text_blocks[$i] : '') . ((isset($compile_blocks[$i])) ? $compile_blocks[$i] : '') : (($trim_check_text != '') ? $text_blocks[$i] : '') . ((isset($compile_blocks[$i])) ? $compile_blocks[$i] : '');
266
+      $template_php .= (!$no_echo) ? (($trim_check_text != '') ? $text_blocks[$i] : '').((isset($compile_blocks[$i])) ? $compile_blocks[$i] : '') : (($trim_check_text != '') ? $text_blocks[$i] : '').((isset($compile_blocks[$i])) ? $compile_blocks[$i] : '');
267 267
     }
268 268
 
269 269
     // Remove unused opening/closing tags
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
     // we'll strip out such occurences, minimising such switching
279 279
     if ($no_echo)
280 280
     {
281
-      return "\$$echo_var .= '" . $template_php . "'";
281
+      return "\$$echo_var .= '".$template_php."'";
282 282
     }
283 283
 
284 284
     return $template_php;
@@ -373,30 +373,30 @@  discard block
 block discarded – undo
373 373
 
374 374
       if ($match[2] < 0)
375 375
       {
376
-        $loop_start = '($_' . $tag_args . '_count ' . $match[2] . ' < 0 ? 0 : $_' . $tag_args . '_count ' . $match[2] . ')';
376
+        $loop_start = '($_'.$tag_args.'_count '.$match[2].' < 0 ? 0 : $_'.$tag_args.'_count '.$match[2].')';
377 377
       }
378 378
       else
379 379
       {
380
-        $loop_start = '($_' . $tag_args . '_count < ' . $match[2] . ' ? $_' . $tag_args . '_count : ' . $match[2] . ')';
380
+        $loop_start = '($_'.$tag_args.'_count < '.$match[2].' ? $_'.$tag_args.'_count : '.$match[2].')';
381 381
       }
382 382
 
383 383
       if (strlen($match[3]) < 1 || $match[3] == -1)
384 384
       {
385
-        $loop_end = '$_' . $tag_args . '_count';
385
+        $loop_end = '$_'.$tag_args.'_count';
386 386
       }
387 387
       else if ($match[3] >= 0)
388 388
       {
389
-        $loop_end = '(' . ($match[3] + 1) . ' > $_' . $tag_args . '_count ? $_' . $tag_args . '_count : ' . ($match[3] + 1) . ')';
389
+        $loop_end = '('.($match[3] + 1).' > $_'.$tag_args.'_count ? $_'.$tag_args.'_count : '.($match[3] + 1).')';
390 390
       }
391 391
       else //if ($match[3] < -1)
392 392
       {
393
-        $loop_end = '$_' . $tag_args . '_count' . ($match[3] + 1);
393
+        $loop_end = '$_'.$tag_args.'_count'.($match[3] + 1);
394 394
       }
395 395
     }
396 396
     else
397 397
     {
398 398
       $loop_start = 0;
399
-      $loop_end = '$_' . $tag_args . '_count';
399
+      $loop_end = '$_'.$tag_args.'_count';
400 400
     }
401 401
 
402 402
     $tag_template_php = '';
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
     if (sizeof($block) < 2)
416 416
     {
417 417
       // Block is not nested.
418
-      $tag_template_php = '$_' . $tag_args . "_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;";
418
+      $tag_template_php = '$_'.$tag_args."_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;";
419 419
       $varref = "\$this->_tpldata['$tag_args']";
420 420
     }
421 421
     else
@@ -429,10 +429,10 @@  discard block
 block discarded – undo
429 429
       $varref = $this->generate_block_data_ref($namespace, false);
430 430
 
431 431
       // Create the for loop code to iterate over this block.
432
-      $tag_template_php = '$_' . $tag_args . '_count = (isset(' . $varref . ')) ? sizeof(' . $varref . ') : 0;';
432
+      $tag_template_php = '$_'.$tag_args.'_count = (isset('.$varref.')) ? sizeof('.$varref.') : 0;';
433 433
     }
434 434
 
435
-    $tag_template_php .= 'if ($_' . $tag_args . '_count) {';
435
+    $tag_template_php .= 'if ($_'.$tag_args.'_count) {';
436 436
 
437 437
     /**
438 438
     * 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
@@ -444,10 +444,10 @@  discard block
 block discarded – undo
444 444
     * </code>
445 445
     */
446 446
 
447
-    $tag_template_php .= 'for ($_' . $tag_args . '_i = ' . $loop_start . '; $_' . $tag_args . '_i < ' . $loop_end . '; ++$_' . $tag_args . '_i){';
447
+    $tag_template_php .= 'for ($_'.$tag_args.'_i = '.$loop_start.'; $_'.$tag_args.'_i < '.$loop_end.'; ++$_'.$tag_args.'_i){';
448 448
 //    $tag_template_php .= '$this->_block_counter["'. $tag_args . '"] = $_' . $tag_args . '_i;';
449
-    $tag_template_php .= '$_'. $tag_args . '_val = &' . $varref . '[$_'. $tag_args. '_i];';
450
-    $tag_template_php .= '$this->_block_value["'. $tag_args . '"] = &' . $varref . '[$_'. $tag_args. '_i];';
449
+    $tag_template_php .= '$_'.$tag_args.'_val = &'.$varref.'[$_'.$tag_args.'_i];';
450
+    $tag_template_php .= '$this->_block_value["'.$tag_args.'"] = &'.$varref.'[$_'.$tag_args.'_i];';
451 451
 
452 452
     return $tag_template_php;
453 453
   }
@@ -551,10 +551,10 @@  discard block
 block discarded – undo
551 551
         break;
552 552
 
553 553
         case 'is':
554
-          $is_arg_start = ($tokens[$i-1] == ')') ? array_pop($is_arg_stack) : $i-1;
554
+          $is_arg_start = ($tokens[$i - 1] == ')') ? array_pop($is_arg_stack) : $i - 1;
555 555
           $is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start));
556 556
 
557
-          $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1));
557
+          $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i + 1));
558 558
 
559 559
           array_splice($tokens, $is_arg_start, sizeof($tokens), $new_tokens);
560 560
 
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
         default:
566 566
           if (preg_match('#^((?:[a-z0-9\-_]+\.)+)?(\$)?(?=[A-Za-z])([A-Za-z0-9\-_]+)#s', $token, $varrefs))
567 567
           {
568
-            $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] . '\']');
568
+            $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].'\']');
569 569
           }
570 570
           else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs))
571 571
           {
@@ -582,20 +582,20 @@  discard block
 block discarded – undo
582 582
               $varref = $this->generate_block_data_ref($namespace, true);
583 583
 
584 584
               // Add the block reference for the last child.
585
-              $varref .= "['" . $block . "']";
585
+              $varref .= "['".$block."']";
586 586
             }
587 587
             else
588 588
             {
589 589
               $varref = '$this->_tpldata';
590 590
 
591 591
               // Add the block reference for the last child.
592
-              $varref .= "['" . $blocks[0] . "']";
592
+              $varref .= "['".$blocks[0]."']";
593 593
             }
594 594
             $token = "sizeof($varref)";
595 595
           }
596 596
           else if (!empty($token))
597 597
           {
598
-            $token = '(' . $token . ')';
598
+            $token = '('.$token.')';
599 599
           }
600 600
 
601 601
         break;
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
     {
608 608
       $tokens = array('false');
609 609
     }
610
-    return (($elseif) ? '} else if (' : 'if (') . (implode(' ', $tokens) . ') { ');
610
+    return (($elseif) ? '} else if (' : 'if (').(implode(' ', $tokens).') { ');
611 611
   }
612 612
 
613 613
   /**
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
 
626 626
     if (!$op)
627 627
     {
628
-      return 'unset(' . (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true) . '[\'' . $match[2] . '\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $match[2] . '\']') . ');';
628
+      return 'unset('.(($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true).'[\''.$match[2].'\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\''.$match[2].'\']').');';
629 629
     }
630 630
 
631 631
     // Are we a string?
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
       $match[4] = $this->compile($match[4]);
638 638
 
639 639
       // Now replace the php code
640
-      $match[4] = "'" . str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4]) . "'";
640
+      $match[4] = "'".str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4])."'";
641 641
     }
642 642
     else
643 643
     {
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
       }
661 661
     }
662 662
 
663
-    return (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true) . '[\'' . $match[2] . '\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $match[2] . '\']') . ' = ' . $match[4] . ';';
663
+    return (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true).'[\''.$match[2].'\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\''.$match[2].'\']').' = '.$match[4].';';
664 664
   }
665 665
 
666 666
   /**
@@ -801,24 +801,24 @@  discard block
 block discarded – undo
801 801
       // Build up the string with everything but the last child.
802 802
       for ($i = 0; $i < $blockcount; $i++)
803 803
       {
804
-        $varref .= "['" . $blocks[$i] . "'][\$_" . $blocks[$i] . '_i]';
804
+        $varref .= "['".$blocks[$i]."'][\$_".$blocks[$i].'_i]';
805 805
       }
806 806
       // Add the block reference for the last child.
807
-      $varref .= "['" . $blocks[$blockcount] . "']";
807
+      $varref .= "['".$blocks[$blockcount]."']";
808 808
       // Add the iterator for the last child if requried.
809 809
       if ($include_last_iterator)
810 810
       {
811
-        $varref .= '[$_' . $blocks[$blockcount] . '_i]';
811
+        $varref .= '[$_'.$blocks[$blockcount].'_i]';
812 812
       }
813 813
       return $varref;
814 814
     }
815 815
     else if ($include_last_iterator)
816 816
     {
817
-      return '$_'. $blocks[$blockcount] . '_val';
817
+      return '$_'.$blocks[$blockcount].'_val';
818 818
     }
819 819
     else
820 820
     {
821
-      return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']';
821
+      return '$_'.$blocks[$blockcount - 1].'_val[\''.$blocks[$blockcount].'\']';
822 822
     }
823 823
   }
824 824
 
@@ -828,14 +828,14 @@  discard block
 block discarded – undo
828 828
   */
829 829
   function compile_write($handle, $data)
830 830
   {
831
-    $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX;
831
+    $filename = $this->template->cachepath.str_replace('/', '.', $this->template->filename[$handle]).DOT_PHP_EX;
832 832
 
833
-    $data = "<?php if (!defined('INSIDE')) exit;" . ((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>' . $data);
833
+    $data = "<?php if (!defined('INSIDE')) exit;".((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>'.$data);
834 834
 
835 835
     if ($fp = @fopen($filename, 'wb'))
836 836
     {
837 837
       @flock($fp, LOCK_EX);
838
-      @fwrite ($fp, $data);
838
+      @fwrite($fp, $data);
839 839
       @flock($fp, LOCK_UN);
840 840
       @fclose($fp);
841 841
 
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
   */
853 853
   private function minify($html)
854 854
   {
855
-    if(!classSupernova::$config->tpl_minifier)
855
+    if (!classSupernova::$config->tpl_minifier)
856 856
     {
857 857
       return $html;
858 858
     }
@@ -862,14 +862,14 @@  discard block
 block discarded – undo
862 862
     $html = preg_replace('/(<script[^>]*?>.*?<\/script>)/si', '#pre#', $html);
863 863
     $html = preg_replace('/>[\s]*</', '><', $html); // Strip spacechars between tags
864 864
     $html = preg_replace('/[\s]+/', ' ', $html); // Replace several spacechars with one space
865
-    if(!empty($pre[0]))
865
+    if (!empty($pre[0]))
866 866
     {
867
-      foreach($pre[0] as $tag)
867
+      foreach ($pre[0] as $tag)
868 868
       {
869 869
         $tag = preg_replace('/^\ *\/\/[^\<]*?$/m', ' ', $tag); // Strips comments - except those that contains HTML comment inside
870 870
         $tag = preg_replace('/[\ \t]{2,}/', ' ', $tag); // Replace several spaces by one
871 871
         $tag = preg_replace('/\s{2,}/', "\r\n", $tag); // Replace several linefeeds by one
872
-        $html = preg_replace('/#pre#/', $tag, $html,1);
872
+        $html = preg_replace('/#pre#/', $tag, $html, 1);
873 873
       }
874 874
     }
875 875
 
Please login to merge, or discard this patch.
Braces   +18 added lines, -36 removed lines patch added patch discarded remove patch
@@ -66,8 +66,7 @@  discard block
 block discarded – undo
66 66
       {
67 67
         return;
68 68
         trigger_error("template->_tpl_load_file(): File {$this->template->files[$handle]} does not exist or is empty", E_USER_ERROR);
69
-      }
70
-      else
69
+      } else
71 70
       {
72 71
         $this->template->files[$handle] = $this->template->files_inherit[$handle];
73 72
       }
@@ -225,15 +224,13 @@  discard block
 block discarded – undo
225 224
               $var = substr($temp, 2, -1);
226 225
               //$file = $this->template->_tpldata['DEFINE']['.'][$var];
227 226
               $temp = "\$this->_tpldata['DEFINE']['.']['$var']";
228
-            }
229
-            else
227
+            } else
230 228
             {
231 229
               $var = substr($temp, 1, -1);
232 230
               //$file = $this->template->_rootref[$var];
233 231
               $temp = "\$this->_rootref['$var']";
234 232
             }
235
-          }
236
-          else
233
+          } else
237 234
           {
238 235
             $file = $temp;
239 236
           }
@@ -381,8 +378,7 @@  discard block
 block discarded – undo
381 378
       if ($match[2] < 0)
382 379
       {
383 380
         $loop_start = '($_' . $tag_args . '_count ' . $match[2] . ' < 0 ? 0 : $_' . $tag_args . '_count ' . $match[2] . ')';
384
-      }
385
-      else
381
+      } else
386 382
       {
387 383
         $loop_start = '($_' . $tag_args . '_count < ' . $match[2] . ' ? $_' . $tag_args . '_count : ' . $match[2] . ')';
388 384
       }
@@ -390,17 +386,14 @@  discard block
 block discarded – undo
390 386
       if (strlen($match[3]) < 1 || $match[3] == -1)
391 387
       {
392 388
         $loop_end = '$_' . $tag_args . '_count';
393
-      }
394
-      else if ($match[3] >= 0)
389
+      } else if ($match[3] >= 0)
395 390
       {
396 391
         $loop_end = '(' . ($match[3] + 1) . ' > $_' . $tag_args . '_count ? $_' . $tag_args . '_count : ' . ($match[3] + 1) . ')';
397
-      }
398
-      else //if ($match[3] < -1)
392
+      } else //if ($match[3] < -1)
399 393
       {
400 394
         $loop_end = '$_' . $tag_args . '_count' . ($match[3] + 1);
401 395
       }
402
-    }
403
-    else
396
+    } else
404 397
     {
405 398
       $loop_start = 0;
406 399
       $loop_end = '$_' . $tag_args . '_count';
@@ -413,8 +406,7 @@  discard block
 block discarded – undo
413 406
     {
414 407
       // We need to implode $no_nesting times from the end...
415 408
       $block = array_slice($this->block_names, -$no_nesting);
416
-    }
417
-    else
409
+    } else
418 410
     {
419 411
       $block = $this->block_names;
420 412
     }
@@ -424,8 +416,7 @@  discard block
 block discarded – undo
424 416
       // Block is not nested.
425 417
       $tag_template_php = '$_' . $tag_args . "_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;";
426 418
       $varref = "\$this->_tpldata['$tag_args']";
427
-    }
428
-    else
419
+    } else
429 420
     {
430 421
       // This block is nested.
431 422
       // Generate a namespace string for this block.
@@ -573,8 +564,7 @@  discard block
 block discarded – undo
573 564
           if (preg_match('#^((?:[a-z0-9\-_]+\.)+)?(\$)?(?=[A-Za-z])([A-Za-z0-9\-_]+)#s', $token, $varrefs))
574 565
           {
575 566
             $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] . '\']');
576
-          }
577
-          else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs))
567
+          } else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs))
578 568
           {
579 569
             // Allow checking if loops are set with .loopname
580 570
             // It is also possible to check the loop count by doing <!-- IF .loopname > 1 --> for example
@@ -590,8 +580,7 @@  discard block
 block discarded – undo
590 580
 
591 581
               // Add the block reference for the last child.
592 582
               $varref .= "['" . $block . "']";
593
-            }
594
-            else
583
+            } else
595 584
             {
596 585
               $varref = '$this->_tpldata';
597 586
 
@@ -599,8 +588,7 @@  discard block
 block discarded – undo
599 588
               $varref .= "['" . $blocks[0] . "']";
600 589
             }
601 590
             $token = "sizeof($varref)";
602
-          }
603
-          else if (!empty($token))
591
+          } else if (!empty($token))
604 592
           {
605 593
             $token = '(' . $token . ')';
606 594
           }
@@ -645,8 +633,7 @@  discard block
 block discarded – undo
645 633
 
646 634
       // Now replace the php code
647 635
       $match[4] = "'" . str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4]) . "'";
648
-    }
649
-    else
636
+    } else
650 637
     {
651 638
       preg_match('#true|false|\.#i', $match[4], $type);
652 639
 
@@ -708,8 +695,7 @@  discard block
 block discarded – undo
708 695
     {
709 696
       $negate_expr = true;
710 697
       $expr_type = array_shift($tokens);
711
-    }
712
-    else
698
+    } else
713 699
     {
714 700
       $expr_type = $first_token;
715 701
     }
@@ -722,8 +708,7 @@  discard block
 block discarded – undo
722 708
           $expr_end++;
723 709
           $expr_arg = $tokens[$expr_end++];
724 710
           $expr = "!(($is_arg / $expr_arg) % $expr_arg)";
725
-        }
726
-        else
711
+        } else
727 712
         {
728 713
           $expr = "!($is_arg & 1)";
729 714
         }
@@ -735,8 +720,7 @@  discard block
 block discarded – undo
735 720
           $expr_end++;
736 721
           $expr_arg = $tokens[$expr_end++];
737 722
           $expr = "(($is_arg / $expr_arg) % $expr_arg)";
738
-        }
739
-        else
723
+        } else
740 724
         {
741 725
           $expr = "($is_arg & 1)";
742 726
         }
@@ -818,12 +802,10 @@  discard block
 block discarded – undo
818 802
         $varref .= '[$_' . $blocks[$blockcount] . '_i]';
819 803
       }
820 804
       return $varref;
821
-    }
822
-    else if ($include_last_iterator)
805
+    } else if ($include_last_iterator)
823 806
     {
824 807
       return '$_'. $blocks[$blockcount] . '_val';
825
-    }
826
-    else
808
+    } else
827 809
     {
828 810
       return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']';
829 811
     }
Please login to merge, or discard this patch.
classes/UBE/ArrayAccessV2.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@
 block discarded – undo
118 118
    * @param mixed $offset <p>
119 119
    * The offset to assign the value to.
120 120
    * </p>
121
-   * @param mixed $value <p>
121
+   * @param Unit $value <p>
122 122
    * The value to set.
123 123
    * </p>
124 124
    *
Please login to merge, or discard this patch.
classes/UBE/UBE.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
    * Преобразовывает данные симулятора в данные для расчета боя
460 460
    *
461 461
    * @param     $side_info
462
-   * @param     $attacker
462
+   * @param     boolean $attacker
463 463
    * @param int $player_id
464 464
    *
465 465
    */
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
   }
522 522
 
523 523
   /**
524
-   * @return int
524
+   * @return double
525 525
    */
526 526
   public function get_time_spent() {
527 527
     return $this->time_spent;
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
   }
565 565
 
566 566
   /**
567
-   * @param $template
567
+   * @param null|template $template
568 568
    *
569 569
    * @return template
570 570
    */
Please login to merge, or discard this patch.
Spacing   +47 added lines, -48 removed lines patch added patch discarded remove patch
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     $this->players->db_load_player_by_id($player_id, UBE_PLAYER_IS_DEFENDER);
148 148
 
149 149
     $player_db_row = $this->players[$player_id]->getDbRow();
150
-    if($fortifier_level = mrc_get_level($player_db_row, $this->combatMission->dst_planet, MRC_FORTIFIER)) {
150
+    if ($fortifier_level = mrc_get_level($player_db_row, $this->combatMission->dst_planet, MRC_FORTIFIER)) {
151 151
       $this->planet_bonus->add_unit_by_snid(MRC_FORTIFIER, $fortifier_level);
152 152
     }
153 153
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
     $this->rounds[0] = new UBERound(0);
179 179
     $this->rounds[0]->make_snapshot($this->fleet_list);
180 180
 
181
-    for($round = 1; $round <= 10; $round++) {
181
+    for ($round = 1; $round <= 10; $round++) {
182 182
       // Проводим раунд
183 183
       defined('DEBUG_UBE') ? print("Round {$round}<br>") : false;
184 184
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 
192 192
       // Анализируем итоги текущего раунда и готовим данные для следующего
193 193
       $this->combat_result = $this->fleet_list->ubeAnalyzeFleetOutcome($round);
194
-      if($this->combat_result != UBE_COMBAT_RESULT_DRAW) {
194
+      if ($this->combat_result != UBE_COMBAT_RESULT_DRAW) {
195 195
         break;
196 196
       }
197 197
 
@@ -220,11 +220,11 @@  discard block
 block discarded – undo
220 220
     // Генерируем результат боя
221 221
     $this->fleet_list->ube_analyze_fleets($this->is_simulator, $this->debris, $this->resource_exchange_rates);
222 222
 
223
-    if(!$this->is_ube_loaded) {
223
+    if (!$this->is_ube_loaded) {
224 224
       $this->moon_calculator->calculate_moon($this);
225 225
 
226 226
       // Лутаем ресурсы - если аттакер выиграл
227
-      if($this->combat_result == UBE_COMBAT_RESULT_WIN) {
227
+      if ($this->combat_result == UBE_COMBAT_RESULT_WIN) {
228 228
         $this->sn_ube_combat_analyze_loot();
229 229
       }
230 230
     }
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
       RES_DEUTERIUM => 0,
245 245
     );
246 246
 
247
-    if(
247
+    if (
248 248
       (($planet_resource_total = $this->fleet_list[0]->get_resources_amount()) > 0)
249 249
       &&
250 250
       (($total_capacity = $this->fleet_list->ube_get_capacity_attackers()) > 0)
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
       $planet_lootable_percent = $planet_lootable / $planet_resource_total;
257 257
 
258 258
       // Вычисляем сколько ресурсов вывезено
259
-      foreach($this->fleet_list->_container as $fleet_id => $fleet) {
259
+      foreach ($this->fleet_list->_container as $fleet_id => $fleet) {
260 260
         $looted_in_metal = 0;
261
-        foreach($this->fleet_list[0]->resource_list as $resource_id => $resource_amount) {
261
+        foreach ($this->fleet_list[0]->resource_list as $resource_id => $resource_amount) {
262 262
           // Вычисляем какой процент общей емкости трюмов атакующих будет задействован
263 263
           $fleet_lootable_percent = $fleet->fleet_capacity / $total_capacity;
264 264
           $looted = floor($resource_amount * $planet_lootable_percent * $fleet_lootable_percent);
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
     $destination_user_id = $this->fleet_list[0]->owner_id;
324 324
 
325 325
     // Обновляем поле обломков на планете
326
-    if(!$this->is_admin_in_combat && $this->debris->debris_total() > 0) {
326
+    if (!$this->is_admin_in_combat && $this->debris->debris_total() > 0) {
327 327
       DBStaticPlanet::db_planet_update_by_gspt(
328 328
         $this->ube_planet_info[PLANET_GALAXY], $this->ube_planet_info[PLANET_SYSTEM], $this->ube_planet_info[PLANET_PLANET], PT_PLANET,
329 329
         array(),
@@ -334,10 +334,10 @@  discard block
 block discarded – undo
334 334
       );
335 335
     }
336 336
 
337
-    foreach($this->fleet_list->_container as $fleet_id => $UBEFleet) {
337
+    foreach ($this->fleet_list->_container as $fleet_id => $UBEFleet) {
338 338
       $ship_count_lost = $UBEFleet->unit_list->unitCountLost();
339 339
 
340
-      if($fleet_id) {
340
+      if ($fleet_id) {
341 341
         // Флот
342 342
         $UBEFleet->db_save_combat_result_fleet($this->is_small_fleet_recce, $this->moon_calculator->get_reapers_status());
343 343
       } else {
@@ -345,18 +345,18 @@  discard block
 block discarded – undo
345 345
 
346 346
         // Сохраняем изменения ресурсов - если они есть
347 347
         $resource_delta = $UBEFleet->ube_combat_result_calculate_resources();
348
-        if(!empty($resource_delta)) {
348
+        if (!empty($resource_delta)) {
349 349
           $temp = array();
350
-          foreach($resource_delta as $resource_id => $resource_amount) {
350
+          foreach ($resource_delta as $resource_id => $resource_amount) {
351 351
             $resource_db_name = pname_resource_name($resource_id);
352 352
             $temp[] = "`{$resource_db_name}` = `{$resource_db_name}` + ({$resource_amount})";
353 353
           }
354 354
           DBStaticPlanet::db_planet_update_set_by_id_DEPRECATED($this->ube_planet_info[PLANET_ID], implode(',', $temp));
355 355
         }
356 356
 
357
-        if($ship_count_lost) {
357
+        if ($ship_count_lost) {
358 358
           $planet_row_cache = $this->players[$destination_user_id]->getDbRow();
359
-          foreach($UBEFleet->unit_list->_container as $UBEUnit) {
359
+          foreach ($UBEFleet->unit_list->_container as $UBEUnit) {
360 360
             DBStaticUnit::dbUpdateOrInsertUnit($UBEUnit->unitId, -$UBEUnit->units_lost, $planet_row_cache, $this->ube_planet_info[PLANET_ID]);
361 361
           }
362 362
         }
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
     // TODO: Связать сабы с флотами констраинтами ON DELETE SET NULL
367 367
     // Для САБов
368 368
     $fleet_group_id_list = $this->fleet_list->ube_get_groups();
369
-    if(!empty($fleet_group_id_list)) {
369
+    if (!empty($fleet_group_id_list)) {
370 370
       $fleet_group_id_list = implode(',', $fleet_group_id_list);
371 371
       DBStaticFleetACS::db_acs_delete_by_list($fleet_group_id_list);
372 372
     }
@@ -375,19 +375,19 @@  discard block
 block discarded – undo
375 375
 
376 376
     $bashing_list = array();
377 377
     $players_sides = $this->players->get_player_sides();
378
-    foreach($players_sides as $player_id => $player_side) {
379
-      if($player_side != UBE_PLAYER_IS_ATTACKER) {
378
+    foreach ($players_sides as $player_id => $player_side) {
379
+      if ($player_side != UBE_PLAYER_IS_ATTACKER) {
380 380
         continue;
381 381
       }
382
-      if($this->moon_calculator->get_status() != UBE_MOON_DESTROY_SUCCESS) {
382
+      if ($this->moon_calculator->get_status() != UBE_MOON_DESTROY_SUCCESS) {
383 383
         $bashing_list[] = "({$player_id}, {$this->ube_planet_info[PLANET_ID]}, {$this->combat_timestamp})";
384 384
       }
385
-      if($this->mission_type_id == MT_ATTACK && $this->is_defender_active_player) {
385
+      if ($this->mission_type_id == MT_ATTACK && $this->is_defender_active_player) {
386 386
         $str_loose_or_win = $this->combat_result == UBE_COMBAT_RESULT_WIN ? 'raidswin' : 'raidsloose';
387 387
         DBStaticUser::db_user_set_by_id_DEPRECATED($player_id, "`xpraid` = `xpraid` + 1, `raids` = `raids` + 1, `{$str_loose_or_win}` = `{$str_loose_or_win}` + 1");
388 388
       }
389 389
     }
390
-    if(!empty($bashing_list)) {
390
+    if (!empty($bashing_list)) {
391 391
       DBStaticFleetBashing::db_bashing_insert($bashing_list);
392 392
     }
393 393
 
@@ -413,20 +413,19 @@  discard block
 block discarded – undo
413 413
       $planet_info[PLANET_SYSTEM],
414 414
       $planet_info[PLANET_PLANET],
415 415
       htmlentities($planet_info[PLANET_NAME], ENT_COMPAT, 'UTF-8'),
416
-      classLocale::$lang[$this->combat_result == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' :
417
-        ($this->combat_result == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')]
416
+      classLocale::$lang[$this->combat_result == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' : ($this->combat_result == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')]
418 417
     );
419 418
 
420 419
     $text_defender = '';
421 420
     $debris = $this->debris->get_debris();
422
-    foreach($debris as $resource_id => $resource_amount) {
423
-      if($resource_id == RES_DEUTERIUM) {
421
+    foreach ($debris as $resource_id => $resource_amount) {
422
+      if ($resource_id == RES_DEUTERIUM) {
424 423
         continue;
425 424
       }
426 425
 
427
-      $text_defender .= "{$classLocale['tech'][$resource_id]}: " . pretty_number($resource_amount) . '<br />';
426
+      $text_defender .= "{$classLocale['tech'][$resource_id]}: ".pretty_number($resource_amount).'<br />';
428 427
     }
429
-    if($text_defender) {
428
+    if ($text_defender) {
430 429
       $text_defender = "{$classLocale['ube_report_msg_body_debris']}{$text_defender}<br />";
431 430
     }
432 431
 
@@ -436,8 +435,8 @@  discard block
 block discarded – undo
436 435
 
437 436
     // TODO: Оптимизировать отсылку сообщений - отсылать пакетами
438 437
     $player_sides = $this->players->get_player_sides();
439
-    foreach($player_sides as $player_id => $player_side) {
440
-      $message = $text_common . ($this->is_small_fleet_recce && ($player_side == UBE_PLAYER_IS_ATTACKER) ? classLocale::$lang['ube_report_msg_body_sfr'] : $text_defender);
438
+    foreach ($player_sides as $player_id => $player_side) {
439
+      $message = $text_common.($this->is_small_fleet_recce && ($player_side == UBE_PLAYER_IS_ATTACKER) ? classLocale::$lang['ube_report_msg_body_sfr'] : $text_defender);
441 440
       DBStaticMessages::msg_send_simple_message($player_id, '', $this->combat_timestamp, MSG_TYPE_COMBAT, classLocale::$lang['sys_mess_tower'], classLocale::$lang['sys_mess_attack_report'], $message);
442 441
     }
443 442
 
@@ -472,11 +471,11 @@  discard block
 block discarded – undo
472 471
     $player_id = $player_id == -1 ? $this->players->count() : $player_id;
473 472
     $fleet_id = $player_id; // FOR SIMULATOR!
474 473
 
475
-    if(empty($this->players[$player_id])) {
474
+    if (empty($this->players[$player_id])) {
476 475
       $this->players[$player_id] = new UBEPlayer();
477 476
     }
478 477
 
479
-    foreach($side_info as $fleet_data) {
478
+    foreach ($side_info as $fleet_data) {
480 479
       $this->players[$player_id]->name = $player_id;
481 480
       $this->players[$player_id]->setSide($attacker);
482 481
 
@@ -484,32 +483,32 @@  discard block
 block discarded – undo
484 483
       $this->fleet_list[$fleet_id] = $objFleet;
485 484
 
486 485
       $this->fleet_list[$fleet_id]->owner_id = $player_id;
487
-      foreach($fleet_data as $unit_id => $unit_count) {
488
-        if(!$unit_count) {
486
+      foreach ($fleet_data as $unit_id => $unit_count) {
487
+        if (!$unit_count) {
489 488
           continue;
490 489
         }
491 490
 
492 491
         $unit_type = get_unit_param($unit_id, P_UNIT_TYPE);
493 492
 
494
-        if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
493
+        if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
495 494
           $this->fleet_list[$fleet_id]->unit_list->unitAdjustCount($unit_id, $unit_count);
496
-        } elseif($unit_type == UNIT_RESOURCES) {
495
+        } elseif ($unit_type == UNIT_RESOURCES) {
497 496
           $this->fleet_list[$fleet_id]->resource_list[$unit_id] = $unit_count;
498
-        } elseif($unit_type == UNIT_TECHNOLOGIES) {
499
-          if($unit_id == TECH_WEAPON) {
497
+        } elseif ($unit_type == UNIT_TECHNOLOGIES) {
498
+          if ($unit_id == TECH_WEAPON) {
500 499
             $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_WEAPON, $unit_count);
501
-          } elseif($unit_id == TECH_SHIELD) {
500
+          } elseif ($unit_id == TECH_SHIELD) {
502 501
             $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_SHIELD, $unit_count);
503
-          } elseif($unit_id == TECH_ARMOR) {
502
+          } elseif ($unit_id == TECH_ARMOR) {
504 503
             $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_ARMOR, $unit_count);
505 504
           }
506
-        } elseif($unit_type == UNIT_GOVERNORS) {
507
-          if($unit_id == MRC_FORTIFIER) {
505
+        } elseif ($unit_type == UNIT_GOVERNORS) {
506
+          if ($unit_id == MRC_FORTIFIER) {
508 507
             // Фортифаер даёт бонус ко всему
509 508
             $this->planet_bonus->add_unit_by_snid(MRC_FORTIFIER, $unit_count);
510 509
           }
511
-        } elseif($unit_type == UNIT_MERCENARIES) {
512
-          if($unit_id == MRC_ADMIRAL) {
510
+        } elseif ($unit_type == UNIT_MERCENARIES) {
511
+          if ($unit_id == MRC_ADMIRAL) {
513 512
             $this->players[$player_id]->player_bonus->add_unit_by_snid(MRC_ADMIRAL, $unit_count);
514 513
           }
515 514
         }
@@ -563,7 +562,7 @@  discard block
 block discarded – undo
563 562
 
564 563
     $ube->sn_ube_message_send();
565 564
 
566
-    defined('DEBUG_UBE') ? die('DIE at ' . __FILE__ . ' ' . __LINE__) : false;
565
+    defined('DEBUG_UBE') ? die('DIE at '.__FILE__.' '.__LINE__) : false;
567 566
 
568 567
     return false;
569 568
   }
@@ -578,7 +577,7 @@  discard block
 block discarded – undo
578 577
 
579 578
     $ube_report = new UBEReport();
580 579
     $ube = $ube_report->sn_ube_report_load(sys_get_param_str('cypher'));
581
-    if($ube != UBE_REPORT_NOT_FOUND) {
580
+    if ($ube != UBE_REPORT_NOT_FOUND) {
582 581
       $ube_report->sn_ube_report_generate($ube, $template_result);
583 582
 
584 583
       $template = gettemplate('ube_combat_report', $template);
@@ -606,9 +605,9 @@  discard block
 block discarded – undo
606 605
     $ube->sn_ube_combat();
607 606
     $ube_report = new UBEReport();
608 607
 
609
-    if(sys_get_param_str('reload')) {
608
+    if (sys_get_param_str('reload')) {
610 609
       $ube_new = $ube_report->sn_ube_report_load($ube->get_cypher()); // $combat_data = sn_ube_report_load($combat_data[UBE_REPORT_CYPHER]);
611
-      if($ube_new != UBE_REPORT_NOT_FOUND && is_object($ube_new)) {
610
+      if ($ube_new != UBE_REPORT_NOT_FOUND && is_object($ube_new)) {
612 611
         $ube = $ube_new;
613 612
       }
614 613
     }
@@ -656,7 +655,7 @@  discard block
 block discarded – undo
656 655
     $this->debris->load_from_report_row($report_row);
657 656
 
658 657
     $query = classSupernova::$db->doSelect("SELECT * FROM {{ube_report_player}} WHERE `ube_report_id` = {$report_row['ube_report_id']}");
659
-    while($player_row = db_fetch($query)) {
658
+    while ($player_row = db_fetch($query)) {
660 659
       $this->players->init_player_from_report_info($player_row);
661 660
     }
662 661
 
Please login to merge, or discard this patch.
classes/UBE/UBEFleet.php 2 patches
Doc Comments   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
   }
151 151
 
152 152
   /**
153
-   * @param $ube_report_id
153
+   * @param integer $ube_report_id
154 154
    *
155 155
    * @return array
156 156
    *
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 
289 289
 
290 290
   /**
291
-   * @param $ube_report_id
291
+   * @param integer $ube_report_id
292 292
    *
293 293
    * @return array
294 294
    */
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
   // Рендерит таблицу общего результата боя
337 337
   /**
338 338
    * @param $array
339
-   * @param $lang_header_index
339
+   * @param string $lang_header_index
340 340
    *
341 341
    * @return array
342 342
    */
@@ -362,6 +362,9 @@  discard block
 block discarded – undo
362 362
   }
363 363
 
364 364
 
365
+  /**
366
+   * @param integer $ube_report_id
367
+   */
365 368
   public function sql_generate_outcome_unit_array(&$sql_perform_report_unit, $ube_report_id) {
366 369
     $fleet_id = $this->db_id;
367 370
 
@@ -468,6 +471,10 @@  discard block
 block discarded – undo
468 471
     $this->fleet_capacity -= $fleet_total_resources;
469 472
   }
470 473
 
474
+  /**
475
+   * @param integer $is_small_fleet_recce
476
+   * @param integer $reapers_status
477
+   */
471 478
   public function db_save_combat_result_fleet($is_small_fleet_recce, $reapers_status) {
472 479
     $ship_count_initial = $this->unit_list->unitsCount();
473 480
     $ship_count_lost = $this->unit_list->unitCountLost();
@@ -535,7 +542,7 @@  discard block
 block discarded – undo
535 542
 
536 543
   /**
537 544
    * @param UBEFleetList $fleet_list
538
-   * @param              $is_simulator
545
+   * @param              boolean $is_simulator
539 546
    *
540 547
    * @version 2016-02-25 23:42:45 41a4.68
541 548
    */
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -162,20 +162,20 @@  discard block
 block discarded – undo
162 162
       $this->owner_id,
163 163
       $this->db_id,
164 164
 
165
-      (float)$this->UBE_PLANET[PLANET_ID],
166
-      "'" . db_escape($this->UBE_PLANET[PLANET_NAME]) . "'",
167
-      (int)$this->UBE_PLANET[PLANET_GALAXY],
168
-      (int)$this->UBE_PLANET[PLANET_SYSTEM],
169
-      (int)$this->UBE_PLANET[PLANET_PLANET],
170
-      (int)$this->UBE_PLANET[PLANET_TYPE],
171
-
172
-      (float)$this->resource_list[RES_METAL],
173
-      (float)$this->resource_list[RES_CRYSTAL],
174
-      (float)$this->resource_list[RES_DEUTERIUM],
175
-
176
-      (float)$this->fleet_bonus->calcBonus(P_ATTACK),
177
-      (float)$this->fleet_bonus->calcBonus(P_SHIELD),
178
-      (float)$this->fleet_bonus->calcBonus(P_ARMOR),
165
+      (float) $this->UBE_PLANET[PLANET_ID],
166
+      "'".db_escape($this->UBE_PLANET[PLANET_NAME])."'",
167
+      (int) $this->UBE_PLANET[PLANET_GALAXY],
168
+      (int) $this->UBE_PLANET[PLANET_SYSTEM],
169
+      (int) $this->UBE_PLANET[PLANET_PLANET],
170
+      (int) $this->UBE_PLANET[PLANET_TYPE],
171
+
172
+      (float) $this->resource_list[RES_METAL],
173
+      (float) $this->resource_list[RES_CRYSTAL],
174
+      (float) $this->resource_list[RES_DEUTERIUM],
175
+
176
+      (float) $this->fleet_bonus->calcBonus(P_ATTACK),
177
+      (float) $this->fleet_bonus->calcBonus(P_SHIELD),
178
+      (float) $this->fleet_bonus->calcBonus(P_ARMOR),
179 179
     );
180 180
   }
181 181
 
@@ -189,13 +189,13 @@  discard block
 block discarded – undo
189 189
     $this->owner_id = $objFleet->playerOwnerId;
190 190
     $this->group_id = $objFleet->group_id;
191 191
 
192
-    foreach($objFleet->shipsIterator() as $unit_id => $unit) {
193
-      if(!$unit->count) {
192
+    foreach ($objFleet->shipsIterator() as $unit_id => $unit) {
193
+      if (!$unit->count) {
194 194
         continue;
195 195
       }
196 196
 
197 197
       $unit_type = get_unit_param($unit_id, P_UNIT_TYPE);
198
-      if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
198
+      if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
199 199
         $this->unit_list->unitAdjustCount($unit_id, $unit->count);
200 200
       }
201 201
     }
@@ -231,13 +231,13 @@  discard block
 block discarded – undo
231 231
 //      }
232 232
 //    }
233 233
 
234
-    foreach($sn_group_combat as $unit_id) {
235
-      if($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) {
234
+    foreach ($sn_group_combat as $unit_id) {
235
+      if ($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) {
236 236
         $this->unit_list->unitAdjustCount($unit_id, $unit_count);
237 237
       }
238 238
     }
239 239
 
240
-    foreach(sn_get_groups('resources_loot') as $resource_id) {
240
+    foreach (sn_get_groups('resources_loot') as $resource_id) {
241 241
       $this->resource_list[$resource_id] = floor(mrc_get_level($player_db_row, $planet_row, $resource_id));
242 242
     }
243 243
 
@@ -296,27 +296,27 @@  discard block
 block discarded – undo
296 296
       $ube_report_id,
297 297
       $this->db_id,
298 298
 
299
-      (float)$this->resources_lost_on_units[RES_METAL],
300
-      (float)$this->resources_lost_on_units[RES_CRYSTAL],
301
-      (float)$this->resources_lost_on_units[RES_DEUTERIUM],
302
-      (float)$this->cargo_dropped[RES_METAL],
303
-      (float)$this->cargo_dropped[RES_CRYSTAL],
304
-      (float)$this->cargo_dropped[RES_DEUTERIUM],
305
-      (float)$this->resources_looted[RES_METAL],
306
-      (float)$this->resources_looted[RES_CRYSTAL],
307
-      (float)$this->resources_looted[RES_DEUTERIUM],
308
-      (float)$this->resources_lost_in_metal[RES_METAL],
299
+      (float) $this->resources_lost_on_units[RES_METAL],
300
+      (float) $this->resources_lost_on_units[RES_CRYSTAL],
301
+      (float) $this->resources_lost_on_units[RES_DEUTERIUM],
302
+      (float) $this->cargo_dropped[RES_METAL],
303
+      (float) $this->cargo_dropped[RES_CRYSTAL],
304
+      (float) $this->cargo_dropped[RES_DEUTERIUM],
305
+      (float) $this->resources_looted[RES_METAL],
306
+      (float) $this->resources_looted[RES_CRYSTAL],
307
+      (float) $this->resources_looted[RES_DEUTERIUM],
308
+      (float) $this->resources_lost_in_metal[RES_METAL],
309 309
     );
310 310
   }
311 311
 
312 312
   public function report_render_outcome_side_fleet() {
313 313
     $UBE_DEFENCE_RESTORE = array();
314 314
     $UBE_UNITS_LOST = array();
315
-    foreach($this->unit_list->_container as $UBEUnit) {
316
-      if($UBEUnit->units_restored) {
315
+    foreach ($this->unit_list->_container as $UBEUnit) {
316
+      if ($UBEUnit->units_restored) {
317 317
         $UBE_DEFENCE_RESTORE[$UBEUnit->unitId] = $UBEUnit->units_restored;
318 318
       }
319
-      if($UBEUnit->units_lost) {
319
+      if ($UBEUnit->units_lost) {
320 320
         $UBE_UNITS_LOST[$UBEUnit->unitId] = $UBEUnit->units_lost;
321 321
       }
322 322
     }
@@ -341,16 +341,16 @@  discard block
 block discarded – undo
341 341
    */
342 342
   protected function report_render_outcome_side_fleet_line(&$array, $lang_header_index) {
343 343
     $result = array();
344
-    if(!empty($array)) {
345
-      foreach($array as $unit_id => $unit_count) {
346
-        if($unit_count) {
344
+    if (!empty($array)) {
345
+      foreach ($array as $unit_id => $unit_count) {
346
+        if ($unit_count) {
347 347
           $result[] = array(
348 348
             'NAME' => classLocale::$lang['tech'][$unit_id],
349 349
             'LOSS' => pretty_number($unit_count),
350 350
           );
351 351
         }
352 352
       }
353
-      if($lang_header_index && count($result)) {
353
+      if ($lang_header_index && count($result)) {
354 354
         array_unshift($result, array('NAME' => classLocale::$lang[$lang_header_index]));
355 355
       }
356 356
     }
@@ -363,16 +363,16 @@  discard block
 block discarded – undo
363 363
     $fleet_id = $this->db_id;
364 364
 
365 365
     $unit_sort_order = 0;
366
-    foreach($this->unit_list->_container as $UBEUnit) {
367
-      if($UBEUnit->units_lost || $UBEUnit->units_restored) {
366
+    foreach ($this->unit_list->_container as $UBEUnit) {
367
+      if ($UBEUnit->units_lost || $UBEUnit->units_restored) {
368 368
         $unit_sort_order++;
369 369
         $sql_perform_report_unit[] = array(
370 370
           $ube_report_id,
371 371
           $fleet_id,
372 372
 
373 373
           $UBEUnit->unitId,
374
-          (float)$UBEUnit->units_restored,
375
-          (float)$UBEUnit->units_lost,
374
+          (float) $UBEUnit->units_restored,
375
+          (float) $UBEUnit->units_lost,
376 376
 
377 377
           $unit_sort_order,
378 378
         );
@@ -388,9 +388,9 @@  discard block
 block discarded – undo
388 388
   function ube_combat_result_calculate_resources() {
389 389
     $resource_delta_fleet = array();
390 390
     // Если во флоте остались юниты или это планета - генерируем изменение ресурсов
391
-    foreach(sn_get_groups('resources_loot') as $resource_id) {
392
-      $resource_change = (float)$this->resources_looted[$resource_id] + (float)$this->cargo_dropped[$resource_id];
393
-      if($resource_change) {
391
+    foreach (sn_get_groups('resources_loot') as $resource_id) {
392
+      $resource_change = (float) $this->resources_looted[$resource_id] + (float) $this->cargo_dropped[$resource_id];
393
+      if ($resource_change) {
394 394
         $resource_delta_fleet[$resource_id] = -($resource_change);
395 395
       }
396 396
     }
@@ -423,12 +423,12 @@  discard block
 block discarded – undo
423 423
     );
424 424
 
425 425
     $this->fleet_capacity = 0;
426
-    foreach($this->unit_list->_container as $UBEUnit) {
426
+    foreach ($this->unit_list->_container as $UBEUnit) {
427 427
       $this->fleet_capacity += $UBEUnit->capacity * $UBEUnit->getCount();
428 428
 
429
-      if($UBEUnit->units_lost) {
430
-        foreach($UBEUnit->price as $resource_id => $unit_resource_price) {
431
-          if(!$unit_resource_price) {
429
+      if ($UBEUnit->units_lost) {
430
+        foreach ($UBEUnit->price as $resource_id => $unit_resource_price) {
431
+          if (!$unit_resource_price) {
432 432
             continue;
433 433
           }
434 434
 
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
           $this->resources_lost_on_units[$resource_id] += $resources_lost;
437 437
           // Если это корабль - прибавляем потери к обломкам на орбите
438 438
           // TODO - опция выбрасывания обороны в обломки
439
-          if($UBEUnit->getType() == UNIT_SHIPS) {
439
+          if ($UBEUnit->getType() == UNIT_SHIPS) {
440 440
             $this->resources_lost_on_ships[$resource_id] += $resources_lost;
441 441
           }
442 442
         }
@@ -448,11 +448,11 @@  discard block
 block discarded – undo
448 448
 
449 449
     // Если емкость трюмов меньше количество ресурсов - часть ресов выбрасываем нахуй
450 450
     // На планете ($fleet_id = 0) ресурсы в космос не выбрасываются
451
-    if($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) {
451
+    if ($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) {
452 452
       $drop_share = 1 - $this->fleet_capacity / $fleet_total_resources; // Какая часть ресурсов выброшена
453
-      foreach($this->resource_list as $resource_id => &$resource_amount) {
453
+      foreach ($this->resource_list as $resource_id => &$resource_amount) {
454 454
         // Не просчитываем ресурсы, которых нет на борту кораблей флота
455
-        if(!$resource_amount) {
455
+        if (!$resource_amount) {
456 456
           continue;
457 457
         }
458 458
 
@@ -473,19 +473,19 @@  discard block
 block discarded – undo
473 473
     $objFleet2->setDbId($this->db_id);
474 474
 
475 475
     // Если это была миссия Уничтожения И звезда смерти взорвалась И мы работаем с аттакерами - значит все аттакеры умерли
476
-    if($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) {
476
+    if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) {
477 477
       $objFleet2->dbDelete();
478
-    } elseif($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial ||
478
+    } elseif ($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial ||
479 479
       $objFleet2->dbDelete();
480 480
     } else {
481
-      if($ship_count_lost) {
481
+      if ($ship_count_lost) {
482 482
         // Просматриваем результаты изменения флотов
483
-        foreach($this->unit_list->_container as $UBEUnit) {
483
+        foreach ($this->unit_list->_container as $UBEUnit) {
484 484
           // Перебираем аутком на случай восстановления юнитов
485 485
 //          if(($units_left = $UBEUnit->getCount() - (float)$UBEUnit->units_lost) > 0) {
486 486
 //            $fleet_real_array[$UBEUnit->unitId] = $units_left;
487 487
 //          };
488
-          if(floatval($UBEUnit->units_lost) != 0) {
488
+          if (floatval($UBEUnit->units_lost) != 0) {
489 489
             $objFleet2->shipAdjustCount($UBEUnit->unitId, floatval($UBEUnit->units_lost));
490 490
           };
491 491
         }
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
       $objFleet2->resourcesAdjust($resource_delta_fleet);
496 496
 
497 497
       // Если защитник и не РМФ - отправляем флот назад
498
-      if($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) {
498
+      if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) {
499 499
         $objFleet2->markReturned();
500 500
       }
501 501
       $objFleet2->dbSave();
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
   public function calculate_unit_partial_data(UBEASA $side_ASA) {
526 526
     $this->fleet_share_of_side_armor = $this->total_stats[P_ARMOR] / $side_ASA->getArmor();
527 527
 
528
-    foreach($this->unit_list->_container as $UBEUnit) {
528
+    foreach ($this->unit_list->_container as $UBEUnit) {
529 529
       $UBEUnit->share_of_side_armor = $UBEUnit->pool_armor / $side_ASA->getArmor();
530 530
     }
531 531
   }
@@ -537,9 +537,9 @@  discard block
 block discarded – undo
537 537
    * @version 2016-02-25 23:42:45 41a4.68
538 538
    */
539 539
   public function attack_fleets(UBEFleetList $fleet_list, $is_simulator) {
540
-    foreach($fleet_list->_container as $defending_fleet) {
540
+    foreach ($fleet_list->_container as $defending_fleet) {
541 541
       // Не атакуются флоты на своей стороне
542
-      if($this->is_attacker == $defending_fleet->is_attacker) {
542
+      if ($this->is_attacker == $defending_fleet->is_attacker) {
543 543
         continue;
544 544
       }
545 545
       $this->attack_fleet($defending_fleet, $is_simulator);
@@ -555,12 +555,12 @@  discard block
 block discarded – undo
555 555
   public function attack_fleet(UBEFleet $defending_fleet, $is_simulator) {
556 556
     UBEDebug::unit_dump_header();
557 557
 
558
-    foreach($this->unit_list->_container as $attacking_unit_pool) {
558
+    foreach ($this->unit_list->_container as $attacking_unit_pool) {
559 559
       UBEDebug::unit_dump($attacking_unit_pool, 'attacker');
560 560
 
561 561
       // if($attack_unit_count <= 0) continue; // TODO: Это пока нельзя включать - вот если будут "боевые порядки юнитов..."
562
-      foreach($defending_fleet->unit_list->_container as $defending_unit_pool) {
563
-        if($defending_unit_pool->isEmpty()) {
562
+      foreach ($defending_fleet->unit_list->_container as $defending_unit_pool) {
563
+        if ($defending_unit_pool->isEmpty()) {
564 564
           continue;
565 565
         }
566 566
 
Please login to merge, or discard this patch.
classes/UBE/UBEFleetList.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -278,6 +278,9 @@
 block discarded – undo
278 278
     return count($this->ube_side_present_at_round_start);
279 279
   }
280 280
 
281
+  /**
282
+   * @param integer $round
283
+   */
281 284
   public function ubeAnalyzeFleetOutcome($round) {
282 285
     $this->ube_actualize_sides();
283 286
 
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -82,13 +82,13 @@  discard block
 block discarded – undo
82 82
    */
83 83
   public function ube_db_load_fleets_outcome($report_row) {
84 84
     $query = doquery("SELECT * FROM {{ube_report_outcome_fleet}} WHERE `ube_report_id` = {$report_row['ube_report_id']}");
85
-    while($row = db_fetch($query)) {
85
+    while ($row = db_fetch($query)) {
86 86
       $fleet_id = $row['ube_report_outcome_fleet_fleet_id'];
87 87
       $this[$fleet_id]->load_outcome_from_report_row($row);
88 88
     }
89 89
 
90 90
     $query = doquery("SELECT * FROM {{ube_report_outcome_unit}} WHERE `ube_report_id` = {$report_row['ube_report_id']} ORDER BY `ube_report_outcome_unit_sort_order`");
91
-    while($row = db_fetch($query)) {
91
+    while ($row = db_fetch($query)) {
92 92
       $fleet_id = $row['ube_report_outcome_unit_fleet_id'];
93 93
       $this[$fleet_id]->load_unit_outcome_from_row($row);
94 94
     }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
       UBE_PLAYER_IS_DEFENDER => array(),
109 109
     );
110 110
 
111
-    foreach($this->_container as $fleet_id => $UBEFleet) {
111
+    foreach ($this->_container as $fleet_id => $UBEFleet) {
112 112
       $result[$UBEFleet->is_attacker][] = array(
113 113
         'ID'          => $fleet_id,
114 114
         'NAME'        => $ube->players[$UBEFleet->owner_id]->name,
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
    */
132 132
   public function ube_analyze_fleets($is_simulator, UBEDebris $debris, array $resource_exchange_rates) {
133 133
     // Генерируем результат боя
134
-    foreach($this->_container as $fleet_id => $UBEFleet) {
134
+    foreach ($this->_container as $fleet_id => $UBEFleet) {
135 135
       // Инициализируем массив результатов для флота
136 136
 //      $this->init_fleet_outcome_and_link_to_side($UBEFleet);
137 137
 
138
-      foreach($UBEFleet->unit_list->_container as $UBEUnit) {
138
+      foreach ($UBEFleet->unit_list->_container as $UBEUnit) {
139 139
         $UBEUnit->ube_analyze_unit($is_simulator);
140 140
       }
141 141
 
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
       $this->resources_lost_in_metal = array(
153 153
         RES_METAL => 0,
154 154
       );
155
-      foreach($UBEFleet->resources_lost_on_units as $resource_id => $resource_amount) {
155
+      foreach ($UBEFleet->resources_lost_on_units as $resource_id => $resource_amount) {
156 156
         $UBEFleet->resources_lost_in_metal[RES_METAL] += $resource_amount * $resource_exchange_rates[$resource_id];
157 157
       }
158
-      foreach($UBEFleet->cargo_dropped as $resource_id => $resource_amount) {
158
+      foreach ($UBEFleet->cargo_dropped as $resource_id => $resource_amount) {
159 159
         $UBEFleet->resources_lost_in_metal[RES_METAL] += $resource_amount * $resource_exchange_rates[$resource_id];
160 160
       }
161 161
     }
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
    */
167 167
   public function ube_get_groups() {
168 168
     $result = array();
169
-    foreach($this->_container as $UBEFleet) {
170
-      if($UBEFleet->group_id) {
169
+    foreach ($this->_container as $UBEFleet) {
170
+      if ($UBEFleet->group_id) {
171 171
         $result[$UBEFleet->group_id] = $UBEFleet->group_id;
172 172
       }
173 173
     }
@@ -180,8 +180,8 @@  discard block
 block discarded – undo
180 180
    */
181 181
   public function ube_get_capacity_attackers() {
182 182
     $result = 0;
183
-    foreach($this->_container as $UBEFleet) {
184
-      if($UBEFleet->is_attacker) {
183
+    foreach ($this->_container as $UBEFleet) {
184
+      if ($UBEFleet->is_attacker) {
185 185
         $result += $UBEFleet->fleet_capacity;
186 186
       }
187 187
     }
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
    */
196 196
   public function ube_db_load_from_report_row(array $report_row, UBE $ube) {
197 197
     $query = doquery("SELECT * FROM {{ube_report_fleet}} WHERE `ube_report_id` = {$report_row['ube_report_id']}");
198
-    while($fleet_row = db_fetch($query)) {
198
+    while ($fleet_row = db_fetch($query)) {
199 199
       $objFleet = new UBEFleet();
200 200
       $objFleet->load_from_report($fleet_row, $ube);
201 201
       $this[$objFleet->db_id] = $objFleet;
@@ -209,20 +209,20 @@  discard block
 block discarded – undo
209 209
    * @version 2016-02-25 23:42:45 41a4.68
210 210
    */
211 211
   public function ube_prepare_for_next_round($is_simulator) {
212
-    foreach($this->_container as $fleet_id => $UBEFleet) {
212
+    foreach ($this->_container as $fleet_id => $UBEFleet) {
213 213
       $UBEFleet->prepare_for_next_round($is_simulator);
214 214
     }
215 215
 
216 216
     // Суммируем данные по атакующим и защитникам
217 217
     $this->ube_total[UBE_PLAYER_IS_ATTACKER]->_reset();
218 218
     $this->ube_total[UBE_PLAYER_IS_DEFENDER]->_reset();
219
-    foreach($this->_container as $fleet_id => $UBEFleet) {
219
+    foreach ($this->_container as $fleet_id => $UBEFleet) {
220 220
       $this->ube_total[$UBEFleet->is_attacker]->add_unit_stats_array($UBEFleet->total_stats);
221 221
     }
222 222
 //pvar_dump($this->ube_total);
223 223
 
224 224
     // Высчитываем долю атаки, приходящейся на юнит равную отношению брони юнита к общей броне - крупные цели атакуют чаще
225
-    foreach($this->_container as $fleet_id => $UBEFleet) {
225
+    foreach ($this->_container as $fleet_id => $UBEFleet) {
226 226
       $UBEFleet->calculate_unit_partial_data($this->ube_total[$UBEFleet->is_attacker]);
227 227
     }
228 228
   }
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
    */
237 237
   public function ube_calculate_attack_results(UBE $ube) {
238 238
     // Каждый флот атакует все
239
-    foreach($this->_container as $attack_fleet_data) {
239
+    foreach ($this->_container as $attack_fleet_data) {
240 240
       defined('DEBUG_UBE') ? print("Fleet {$attack_fleet_data->db_id} attacks<br /><div style='margin-left: 30px;'>") : false;
241 241
 
242 242
       $attack_fleet_data->attack_fleets($this, $ube->is_simulator);
@@ -251,8 +251,8 @@  discard block
 block discarded – undo
251 251
    * @version 2016-02-25 23:42:45 41a4.68
252 252
    */
253 253
   public function ube_actualize_sides() {
254
-    foreach($this->_container as $UBEFleet) {
255
-      if($UBEFleet->get_unit_count() > 0) {
254
+    foreach ($this->_container as $UBEFleet) {
255
+      if ($UBEFleet->get_unit_count() > 0) {
256 256
         $this->ube_side_present_at_round_start[$UBEFleet->is_attacker] = 1;
257 257
       }
258 258
     }
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
    */
266 266
   public function ube_calculate_attack_reapers() {
267 267
     $reapers = 0;
268
-    foreach($this->_container as $fleet_id => $UBERoundFleetCombat) {
269
-      if($UBERoundFleetCombat->is_attacker == UBE_PLAYER_IS_ATTACKER) {
268
+    foreach ($this->_container as $fleet_id => $UBERoundFleetCombat) {
269
+      if ($UBERoundFleetCombat->is_attacker == UBE_PLAYER_IS_ATTACKER) {
270 270
         $reapers += $UBERoundFleetCombat->unit_list->unitCountReapers();
271 271
       }
272 272
     }
@@ -283,10 +283,10 @@  discard block
 block discarded – undo
283 283
 
284 284
     $result = UBE_COMBAT_RESULT_DRAW;
285 285
     // Проверяем результат боя
286
-    if($this->ube_get_sides_count() == 0 || $round >= 10) {
286
+    if ($this->ube_get_sides_count() == 0 || $round >= 10) {
287 287
       // Если кого-то не осталось или не осталось обоих - заканчиваем цикл
288 288
       $result = UBE_COMBAT_RESULT_DRAW_END;
289
-    } elseif($this->ube_get_sides_count() == 1) {
289
+    } elseif ($this->ube_get_sides_count() == 1) {
290 290
       // Если осталась одна сторона - она и выиграла
291 291
       $result = isset($this->ube_side_present_at_round_start[UBE_PLAYER_IS_ATTACKER]) ? UBE_COMBAT_RESULT_WIN : UBE_COMBAT_RESULT_LOSS;
292 292
     }
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
    * @version 41a6.16
304 304
    */
305 305
   public function ubeInitGetAttackers(Fleet $objFleet, UBEPlayerList $players) {
306
-    if($objFleet->group_id) {
306
+    if ($objFleet->group_id) {
307 307
       $fleets_added = $this->dbLoadWhere("`fleet_group` = {$objFleet->group_id}");
308 308
     } else {
309 309
       $this->ube_insert_from_Fleet($objFleet);
Please login to merge, or discard this patch.
classes/UBE/UBEReport.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
   /**
8 8
    * @param UBE $ube
9 9
    *
10
-   * @return bool|string
10
+   * @return false|string
11 11
    *
12 12
    * @version 2016-02-25 23:42:45 41a4.68
13 13
    */
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
    */
14 14
   public function sn_ube_report_save($ube) {
15 15
     // Если уже есть ИД репорта - значит репорт был взят из таблицы. С таким мы не работаем
16
-    if($ube->get_cypher()) {
16
+    if ($ube->get_cypher()) {
17 17
       return false;
18 18
     }
19 19
 
20 20
     // Генерируем уникальный секретный ключ и проверяем наличие в базе
21 21
     do {
22 22
       $ube->report_cypher = sys_random_string(32);
23
-    } while(classSupernova::$db->doSelectFetchArray("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE"));
23
+    } while (classSupernova::$db->doSelectFetchArray("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE"));
24 24
 
25 25
     // Инициализация таблицы для пакетной вставки информации
26 26
     $sql_perform = array(
@@ -106,21 +106,21 @@  discard block
 block discarded – undo
106 106
 
107 107
     // Сохраняем общую информацию о бое
108 108
     classSupernova::$db->doInsertSet(TABLE_UBE_REPORT, array(
109
-        'ube_report_cypher'             => (string)$ube->report_cypher,
110
-        'ube_report_time_combat'        => (string)date(FMT_DATE_TIME_SQL, $ube->combat_timestamp),
111
-        'ube_report_time_spent'         => (float)$ube->time_spent,
112
-        'ube_report_combat_admin'       => (int)$ube->is_admin_in_combat,
113
-        'ube_report_mission_type'       => (int)$ube->mission_type_id,
114
-        'ube_report_combat_result'      => (int)$ube->combat_result,
115
-        'ube_report_combat_sfr'         => (int)$ube->is_small_fleet_recce,
116
-        'ube_report_planet_id'          => (int)$ube->ube_planet_info[PLANET_ID],
117
-        'ube_report_planet_name'        => (string)$ube->ube_planet_info[PLANET_NAME],
118
-        'ube_report_planet_size'        => (int)$ube->ube_planet_info[PLANET_SIZE],
119
-        'ube_report_planet_galaxy'      => (int)$ube->ube_planet_info[PLANET_GALAXY],
120
-        'ube_report_planet_system'      => (int)$ube->ube_planet_info[PLANET_SYSTEM],
121
-        'ube_report_planet_planet'      => (int)$ube->ube_planet_info[PLANET_PLANET],
122
-        'ube_report_planet_planet_type' => (int)$ube->ube_planet_info[PLANET_TYPE],
123
-        'ube_report_capture_result'     => (int)$ube->capture_result,
109
+        'ube_report_cypher'             => (string) $ube->report_cypher,
110
+        'ube_report_time_combat'        => (string) date(FMT_DATE_TIME_SQL, $ube->combat_timestamp),
111
+        'ube_report_time_spent'         => (float) $ube->time_spent,
112
+        'ube_report_combat_admin'       => (int) $ube->is_admin_in_combat,
113
+        'ube_report_mission_type'       => (int) $ube->mission_type_id,
114
+        'ube_report_combat_result'      => (int) $ube->combat_result,
115
+        'ube_report_combat_sfr'         => (int) $ube->is_small_fleet_recce,
116
+        'ube_report_planet_id'          => (int) $ube->ube_planet_info[PLANET_ID],
117
+        'ube_report_planet_name'        => (string) $ube->ube_planet_info[PLANET_NAME],
118
+        'ube_report_planet_size'        => (int) $ube->ube_planet_info[PLANET_SIZE],
119
+        'ube_report_planet_galaxy'      => (int) $ube->ube_planet_info[PLANET_GALAXY],
120
+        'ube_report_planet_system'      => (int) $ube->ube_planet_info[PLANET_SYSTEM],
121
+        'ube_report_planet_planet'      => (int) $ube->ube_planet_info[PLANET_PLANET],
122
+        'ube_report_planet_planet_type' => (int) $ube->ube_planet_info[PLANET_TYPE],
123
+        'ube_report_capture_result'     => (int) $ube->capture_result,
124 124
       )
125 125
       + $ube->debris->report_generate_array()
126 126
       + $ube->moon_calculator->report_generate_array()
@@ -129,22 +129,22 @@  discard block
 block discarded – undo
129 129
 
130 130
     // Сохраняем общую информацию по игрокам
131 131
     $player_sides = $ube->players->get_player_sides();
132
-    foreach($player_sides as $player_id => $player_side) {
132
+    foreach ($player_sides as $player_id => $player_side) {
133 133
       $sql_perform['ube_report_player'][] = array(
134 134
         $ube_report_id,
135 135
         $player_id,
136 136
 
137
-        "'" . db_escape($ube->players[$player_id]->name) . "'",
137
+        "'".db_escape($ube->players[$player_id]->name)."'",
138 138
         $ube->players[$player_id]->getSide() == UBE_PLAYER_IS_ATTACKER ? 1 : 0,
139 139
 
140
-        (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK),
141
-        (float)$ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD),
142
-        (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR),
140
+        (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK),
141
+        (float) $ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD),
142
+        (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR),
143 143
       );
144 144
     }
145 145
 
146 146
     // Всякая информация по флотам
147
-    foreach($ube->fleet_list->_container as $fleet_id => $UBEFleet) {
147
+    foreach ($ube->fleet_list->_container as $fleet_id => $UBEFleet) {
148 148
       // Сохраняем общую информацию по флотам
149 149
       $sql_perform['ube_report_fleet'][] = $UBEFleet->sql_generate_array($ube_report_id);
150 150
 
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
     $ube->rounds->sql_generate_unit_array($sql_perform['ube_report_unit'], $ube_report_id, $ube->fleet_list);
160 160
 
161 161
     // Пакетная вставка данных
162
-    foreach($sql_perform as $table_name => $table_data) {
163
-      if(count($table_data) < 2) {
162
+    foreach ($sql_perform as $table_name => $table_data) {
163
+      if (count($table_data) < 2) {
164 164
         continue;
165 165
       }
166
-      foreach($table_data as &$record_data) {
167
-        $record_data = '(' . implode(',', $record_data) . ')';
166
+      foreach ($table_data as &$record_data) {
167
+        $record_data = '('.implode(',', $record_data).')';
168 168
       }
169 169
       $fields = $table_data[0];
170 170
       unset($table_data[0]);
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
     $report_cypher = db_escape($report_cypher);
187 187
 
188 188
     $report_row = classSupernova::$db->doSelectFetchArray("SELECT * FROM {{ube_report}} WHERE ube_report_cypher = '{$report_cypher}' LIMIT 1");
189
-    if(!$report_row) {
189
+    if (!$report_row) {
190 190
       return UBE_REPORT_NOT_FOUND;
191 191
     }
192 192
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
    * @param     $template_result
203 203
    */
204 204
   public function sn_ube_report_generate(UBE $ube, &$template_result) {
205
-    if(!is_object($ube)) {
205
+    if (!is_object($ube)) {
206 206
       return;
207 207
     }
208 208
 
@@ -217,15 +217,15 @@  discard block
 block discarded – undo
217 217
 
218 218
     // Координаты, тип и название планеты - если есть
219 219
 //R  $planet_owner_id = $combat_data[UBE_FLEETS][0][UBE_OWNER];
220
-    if(isset($ube->ube_planet_info)) {
220
+    if (isset($ube->ube_planet_info)) {
221 221
       $template_result += $ube->ube_planet_info;
222 222
       $template_result[PLANET_NAME] = str_replace(' ', '&nbsp;', htmlentities($template_result[PLANET_NAME], ENT_COMPAT, 'UTF-8'));
223 223
     }
224 224
 
225 225
     // Обломки
226 226
     $debris = array();
227
-    foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) {
228
-      if($resource_amount = $ube->debris->debris_get_resource($resource_id)) {
227
+    foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id) {
228
+      if ($resource_amount = $ube->debris->debris_get_resource($resource_id)) {
229 229
         $debris[] = array(
230 230
           'NAME'   => classLocale::$lang['tech'][$resource_id],
231 231
           'AMOUNT' => pretty_number($resource_amount),
Please login to merge, or discard this patch.
classes/userOptions.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -151,6 +151,9 @@
 block discarded – undo
151 151
   }
152 152
 
153 153
 
154
+  /**
155
+   * @param integer $user_id
156
+   */
154 157
   public function __construct($user_id) {
155 158
     $this->user_change($user_id);
156 159
   }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
 
123 123
     $update_cache = false;
124 124
 
125
-    if(!empty($this->to_write)) {
126
-      foreach($this->to_write as $key => $cork) {
125
+    if (!empty($this->to_write)) {
126
+      foreach ($this->to_write as $key => $cork) {
127 127
         $value = is_array($this->data[$key]) ? serialize($this->data[$key]) : $this->data[$key]; // Сериализация для массивов при сохранении в БД
128
-        $this->to_write[$key] = "({$this->user_id}, '" . db_escape($key) . "', '" . db_escape($value) . "')";
128
+        $this->to_write[$key] = "({$this->user_id}, '".db_escape($key)."', '".db_escape($value)."')";
129 129
       }
130 130
 
131 131
       classSupernova::$gc->db->doReplaceValuesDeprecated(
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
       $update_cache = true;
144 144
     }
145 145
 
146
-    if(!empty($this->to_delete)) {
147
-      foreach($this->to_delete as $key => &$value) {
148
-        $value = is_string($key) ? "'". db_escape($key) . "'" : $key;
146
+    if (!empty($this->to_delete)) {
147
+      foreach ($this->to_delete as $key => &$value) {
148
+        $value = is_string($key) ? "'".db_escape($key)."'" : $key;
149 149
       }
150 150
 
151 151
       classSupernova::$db->doDeleteDanger(
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
           'player_id' => $this->user_id,
155 155
         ),
156 156
         array(
157
-          "`option_id` IN (" . implode(',', $this->to_delete) . ")",
157
+          "`option_id` IN (".implode(',', $this->to_delete).")",
158 158
         )
159 159
       );
160 160
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
       $update_cache = true;
163 163
     }
164 164
 
165
-    if($update_cache) {
165
+    if ($update_cache) {
166 166
       $field_name = $this->cached_name();
167 167
       classSupernova::$cache->$field_name = $this->data;
168 168
     }
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
     $this->load();
182 182
   }
183 183
   protected function cached_name() {
184
-    return 'options_' . $this->user_id;
184
+    return 'options_'.$this->user_id;
185 185
   }
186 186
 
187 187
   protected function load() {
188
-    if($this->loaded) {
188
+    if ($this->loaded) {
189 189
       return;
190 190
     }
191 191
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
     $this->to_write = array();
194 194
     $this->to_delete = array();
195 195
 
196
-    if(!$this->user_id) {
196
+    if (!$this->user_id) {
197 197
       $this->loaded = true;
198 198
       return;
199 199
     }
@@ -201,13 +201,13 @@  discard block
 block discarded – undo
201 201
     $field_name = $this->cached_name();
202 202
     $a_data = classSupernova::$cache->$field_name;
203 203
 
204
-    if(!empty($a_data)) {
204
+    if (!empty($a_data)) {
205 205
       $this->data = array_replace_recursive($this->data, $a_data);
206 206
       return;
207 207
     }
208 208
 
209 209
     $query = classSupernova::$db->doSelect("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE");
210
-    while($row = db_fetch($query)) {
210
+    while ($row = db_fetch($query)) {
211 211
       // $this->data[$row['option_id']] = $row['value'];
212 212
       $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация
213 213
     }
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
   }
285 285
 
286 286
   protected function cached_name() {
287
-    return 'options_' . $this->user_id;
287
+    return 'options_'.$this->user_id;
288 288
   }
289 289
 
290 290
   // TODO - serialize/unserialize options
@@ -292,14 +292,14 @@  discard block
 block discarded – undo
292 292
     // Если в массиве индекса только один элемент - значит это просто индекс
293 293
     is_array($option_id) && count($option_id) == 1 ? $option_id = reset($option_id) : false;
294 294
 
295
-    if(!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) {
295
+    if (!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) {
296 296
       $this->load();
297 297
     }
298 298
 
299
-    if(is_array($option_id)) {
299
+    if (is_array($option_id)) {
300 300
       $result = $this->data;
301
-      foreach($option_id as $sub_key) {
302
-        if(!isset($result) || !isset($result[$sub_key])) {
301
+      foreach ($option_id as $sub_key) {
302
+        if (!isset($result) || !isset($result[$sub_key])) {
303 303
           $result = null;
304 304
           break;
305 305
         }
@@ -317,12 +317,12 @@  discard block
 block discarded – undo
317 317
    * @param null|mixed $value
318 318
    */
319 319
   public function __set($option, $value = null) {
320
-    if(empty($option) || !$this->user_id) {
320
+    if (empty($option) || !$this->user_id) {
321 321
       return;
322 322
     }
323 323
 
324 324
     // Если в массиве индекса только один элемент - значит это просто индекс
325
-    if(is_array($option) && count($option) == 1) {
325
+    if (is_array($option) && count($option) == 1) {
326 326
       // Разворачиваем его в индекс
327 327
       $option = array(reset($option) => $value);
328 328
       unset($value);
@@ -331,13 +331,13 @@  discard block
 block discarded – undo
331 331
 
332 332
     $to_write = array();
333 333
     // Адресация многомерного массива через массив индексов в $option
334
-    if(is_array($option) && isset($value)) {
334
+    if (is_array($option) && isset($value)) {
335 335
       $a_data = &$this->data;
336
-      foreach($option as $option_id) {
336
+      foreach ($option as $option_id) {
337 337
         !is_array($a_data[$option_id]) ? $a_data[$option_id] = array() : false;
338 338
         $a_data = &$a_data[$option_id];
339 339
       }
340
-      if($a_data != $value) {
340
+      if ($a_data != $value) {
341 341
         $a_data = $value;
342 342
         $to_write[reset($option)] = null;
343 343
       }
@@ -345,11 +345,11 @@  discard block
 block discarded – undo
345 345
       // Пакетная запись из массива ключ -> значение
346 346
       !is_array($option) ? $option = array($option => $value) : false;
347 347
 
348
-      foreach($option as $option_id => $option_value) {
349
-        if($this->data[$option_id] !== $option_value) {
348
+      foreach ($option as $option_id => $option_value) {
349
+        if ($this->data[$option_id] !== $option_value) {
350 350
           // TODO - вынести отдельно в обработчик
351
-          if($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON &&  $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) {
352
-            sn_setcookie(SN_COOKIE . '_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE);
351
+          if ($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON && $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) {
352
+            sn_setcookie(SN_COOKIE.'_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE);
353 353
           }
354 354
 
355 355
           $this->data[$option_id] = $option_value;
@@ -358,13 +358,13 @@  discard block
 block discarded – undo
358 358
       }
359 359
     }
360 360
 
361
-    if(!empty($to_write)) {
361
+    if (!empty($to_write)) {
362 362
       $field_name = $this->cached_name();
363 363
       classSupernova::$cache->$field_name = $this->data;
364 364
 
365
-      foreach($to_write as $option_id => &$option_value) {
365
+      foreach ($to_write as $option_id => &$option_value) {
366 366
         $option_value = is_array($this->data[$option_id]) ? serialize($this->data[$option_id]) : $this->data[$option_id]; // Сериализация для массивов при сохранении в БД
367
-        $to_write[$option_id] = "({$this->user_id}, '" . db_escape($option_id) . "', '" . db_escape($option_value) . "')";
367
+        $to_write[$option_id] = "({$this->user_id}, '".db_escape($option_id)."', '".db_escape($option_value)."')";
368 368
       }
369 369
 
370 370
       classSupernova::$gc->db->doReplaceValuesDeprecated(
@@ -380,26 +380,26 @@  discard block
 block discarded – undo
380 380
   }
381 381
 
382 382
   protected function load() {
383
-    if($this->loaded) {
383
+    if ($this->loaded) {
384 384
       return;
385 385
     }
386 386
 
387 387
     $this->data = $this->defaults;
388 388
 
389
-    if(!$this->user_id) {
389
+    if (!$this->user_id) {
390 390
       return;
391 391
     }
392 392
 
393 393
     $field_name = $this->cached_name();
394 394
     $a_data = classSupernova::$cache->$field_name;
395 395
 
396
-    if(!empty($a_data)) {
396
+    if (!empty($a_data)) {
397 397
       $this->data = array_replace($this->data, $a_data);
398 398
       return;
399 399
     }
400 400
 
401 401
     $query = classSupernova::$db->doSelect("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE");
402
-    while($row = db_fetch($query)) {
402
+    while ($row = db_fetch($query)) {
403 403
       // $this->data[$row['option_id']] = $row['value'];
404 404
       $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация
405 405
     }
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
     return $this->__get($offset);
416 416
   }
417 417
   public function offsetSet($offset, $value) {
418
-    if(!is_null($offset)) {
418
+    if (!is_null($offset)) {
419 419
       // $this->data[$offset] = $value;
420 420
       $this->__set($offset, $value);
421 421
     } else {
Please login to merge, or discard this patch.
classes/RequestInfo.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -87,15 +87,15 @@  discard block
 block discarded – undo
87 87
     // Инфа об устройстве и браузере - общая для всех
88 88
     sn_db_transaction_start();
89 89
     $this->device_cypher = $_COOKIE[SN_COOKIE_D];
90
-    if($this->device_cypher) {
90
+    if ($this->device_cypher) {
91 91
       $cypher_safe = db_escape($this->device_cypher);
92 92
       $device_id = classSupernova::$db->doSelectFetch("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE");
93
-      if(!empty($device_id['device_id'])) {
93
+      if (!empty($device_id['device_id'])) {
94 94
         $this->device_id = $device_id['device_id'];
95 95
       }
96 96
     }
97 97
 
98
-    if($this->device_id <= 0) {
98
+    if ($this->device_id <= 0) {
99 99
       do {
100 100
         $cypher_safe = db_escape($this->device_cypher = sys_random_string());
101 101
         $row = classSupernova::$db->doSelectFetch("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE");
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
     $this->page_address_id = db_get_set_unique_id_value($this->page_address, 'url_id', 'security_url', 'url_string');
119 119
     sn_db_transaction_commit();
120 120
 
121
-    if($this->write_full_url) {
121
+    if ($this->write_full_url) {
122 122
       sn_db_transaction_start();
123 123
       $this->page_url = substr($_SERVER['REQUEST_URI'], strlen(SN_ROOT_RELATIVE));
124
-      if(strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) {
124
+      if (strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) {
125 125
         $this->page_url = '/simulator.php';
126 126
       }
127 127
       $this->page_url_id = db_get_set_unique_id_value($this->page_url, 'url_id', 'security_url', 'url_string');
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
    */
145 145
   public function db_security_entry_insert($user_id_unsafe) {
146 146
     // TODO $user_id = !empty(self::$user['id']) ? self::$user['id'] : 'NULL';
147
-    if(empty($user_id_unsafe)) {
147
+    if (empty($user_id_unsafe)) {
148 148
       // self::flog('Нет ИД пользователя');
149 149
       return true;
150 150
     }
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
   public function db_counter_insert($user_id_unsafe) {
167 167
     global $sys_stop_log_hit;
168 168
 
169
-    if($sys_stop_log_hit || !classSupernova::$config->game_counter) {
169
+    if ($sys_stop_log_hit || !classSupernova::$config->game_counter) {
170 170
       return;
171 171
     }
172 172
 
Please login to merge, or discard this patch.
classes/PlayerList.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
    * @version 41a6.16
24 24
    */
25 25
   protected function db_load_player_by_id($player_id) {
26
-    if(isset($this[$player_id])) {
26
+    if (isset($this[$player_id])) {
27 27
       return;
28 28
     }
29 29
 
Please login to merge, or discard this patch.