@@ -47,6 +47,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | { |
@@ -44,17 +44,17 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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) |
@@ -91,7 +91,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -66,8 +66,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -151,6 +151,9 @@ |
||
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 | } |
@@ -122,30 +122,30 @@ discard block |
||
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 | - classSupernova::$db->doReplace("REPLACE INTO `{{player_options}}` (`player_id`, `option_id`, `value`) VALUES " . implode(',', $this->to_write)); |
|
131 | + classSupernova::$db->doReplace("REPLACE INTO `{{player_options}}` (`player_id`, `option_id`, `value`) VALUES ".implode(',', $this->to_write)); |
|
132 | 132 | |
133 | 133 | $this->to_write = array(); |
134 | 134 | $update_cache = true; |
135 | 135 | } |
136 | 136 | |
137 | - if(!empty($this->to_delete)) { |
|
138 | - foreach($this->to_delete as $key => &$value) { |
|
139 | - $value = is_string($key) ? "'". db_escape($key) . "'" : $key; |
|
137 | + if (!empty($this->to_delete)) { |
|
138 | + foreach ($this->to_delete as $key => &$value) { |
|
139 | + $value = is_string($key) ? "'".db_escape($key)."'" : $key; |
|
140 | 140 | } |
141 | 141 | |
142 | - classSupernova::$db->doDelete("DELETE FROM {{player_options}} WHERE `player_id` = {$this->user_id} AND `option_id` IN (". implode(',', $this->to_delete) . ") "); |
|
142 | + classSupernova::$db->doDelete("DELETE FROM {{player_options}} WHERE `player_id` = {$this->user_id} AND `option_id` IN (".implode(',', $this->to_delete).") "); |
|
143 | 143 | |
144 | 144 | $this->to_delete = array(); |
145 | 145 | $update_cache = true; |
146 | 146 | } |
147 | 147 | |
148 | - if($update_cache) { |
|
148 | + if ($update_cache) { |
|
149 | 149 | $field_name = $this->cached_name(); |
150 | 150 | classSupernova::$cache->$field_name = $this->data; |
151 | 151 | } |
@@ -164,11 +164,11 @@ discard block |
||
164 | 164 | $this->load(); |
165 | 165 | } |
166 | 166 | protected function cached_name() { |
167 | - return 'options_' . $this->user_id; |
|
167 | + return 'options_'.$this->user_id; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | protected function load() { |
171 | - if($this->loaded) { |
|
171 | + if ($this->loaded) { |
|
172 | 172 | return; |
173 | 173 | } |
174 | 174 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | $this->to_write = array(); |
177 | 177 | $this->to_delete = array(); |
178 | 178 | |
179 | - if(!$this->user_id) { |
|
179 | + if (!$this->user_id) { |
|
180 | 180 | $this->loaded = true; |
181 | 181 | return; |
182 | 182 | } |
@@ -184,13 +184,13 @@ discard block |
||
184 | 184 | $field_name = $this->cached_name(); |
185 | 185 | $a_data = classSupernova::$cache->$field_name; |
186 | 186 | |
187 | - if(!empty($a_data)) { |
|
187 | + if (!empty($a_data)) { |
|
188 | 188 | $this->data = array_replace_recursive($this->data, $a_data); |
189 | 189 | return; |
190 | 190 | } |
191 | 191 | |
192 | 192 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE"); |
193 | - while($row = db_fetch($query)) { |
|
193 | + while ($row = db_fetch($query)) { |
|
194 | 194 | // $this->data[$row['option_id']] = $row['value']; |
195 | 195 | $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация |
196 | 196 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | } |
268 | 268 | |
269 | 269 | protected function cached_name() { |
270 | - return 'options_' . $this->user_id; |
|
270 | + return 'options_'.$this->user_id; |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | // TODO - serialize/unserialize options |
@@ -275,14 +275,14 @@ discard block |
||
275 | 275 | // Если в массиве индекса только один элемент - значит это просто индекс |
276 | 276 | is_array($option_id) && count($option_id) == 1 ? $option_id = reset($option_id) : false; |
277 | 277 | |
278 | - if(!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) { |
|
278 | + if (!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) { |
|
279 | 279 | $this->load(); |
280 | 280 | } |
281 | 281 | |
282 | - if(is_array($option_id)) { |
|
282 | + if (is_array($option_id)) { |
|
283 | 283 | $result = $this->data; |
284 | - foreach($option_id as $sub_key) { |
|
285 | - if(!isset($result) || !isset($result[$sub_key])) { |
|
284 | + foreach ($option_id as $sub_key) { |
|
285 | + if (!isset($result) || !isset($result[$sub_key])) { |
|
286 | 286 | $result = null; |
287 | 287 | break; |
288 | 288 | } |
@@ -300,12 +300,12 @@ discard block |
||
300 | 300 | * @param null|mixed $value |
301 | 301 | */ |
302 | 302 | public function __set($option, $value = null) { |
303 | - if(empty($option) || !$this->user_id) { |
|
303 | + if (empty($option) || !$this->user_id) { |
|
304 | 304 | return; |
305 | 305 | } |
306 | 306 | |
307 | 307 | // Если в массиве индекса только один элемент - значит это просто индекс |
308 | - if(is_array($option) && count($option) == 1) { |
|
308 | + if (is_array($option) && count($option) == 1) { |
|
309 | 309 | // Разворачиваем его в индекс |
310 | 310 | $option = array(reset($option) => $value); |
311 | 311 | unset($value); |
@@ -314,13 +314,13 @@ discard block |
||
314 | 314 | |
315 | 315 | $to_write = array(); |
316 | 316 | // Адресация многомерного массива через массив индексов в $option |
317 | - if(is_array($option) && isset($value)) { |
|
317 | + if (is_array($option) && isset($value)) { |
|
318 | 318 | $a_data = &$this->data; |
319 | - foreach($option as $option_id) { |
|
319 | + foreach ($option as $option_id) { |
|
320 | 320 | !is_array($a_data[$option_id]) ? $a_data[$option_id] = array() : false; |
321 | 321 | $a_data = &$a_data[$option_id]; |
322 | 322 | } |
323 | - if($a_data != $value) { |
|
323 | + if ($a_data != $value) { |
|
324 | 324 | $a_data = $value; |
325 | 325 | $to_write[reset($option)] = null; |
326 | 326 | } |
@@ -328,11 +328,11 @@ discard block |
||
328 | 328 | // Пакетная запись из массива ключ -> значение |
329 | 329 | !is_array($option) ? $option = array($option => $value) : false; |
330 | 330 | |
331 | - foreach($option as $option_id => $option_value) { |
|
332 | - if($this->data[$option_id] !== $option_value) { |
|
331 | + foreach ($option as $option_id => $option_value) { |
|
332 | + if ($this->data[$option_id] !== $option_value) { |
|
333 | 333 | // TODO - вынести отдельно в обработчик |
334 | - if($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON && $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) { |
|
335 | - sn_setcookie(SN_COOKIE . '_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE); |
|
334 | + if ($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON && $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) { |
|
335 | + sn_setcookie(SN_COOKIE.'_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | $this->data[$option_id] = $option_value; |
@@ -341,40 +341,40 @@ discard block |
||
341 | 341 | } |
342 | 342 | } |
343 | 343 | |
344 | - if(!empty($to_write)) { |
|
344 | + if (!empty($to_write)) { |
|
345 | 345 | $field_name = $this->cached_name(); |
346 | 346 | classSupernova::$cache->$field_name = $this->data; |
347 | 347 | |
348 | - foreach($to_write as $option_id => &$option_value) { |
|
348 | + foreach ($to_write as $option_id => &$option_value) { |
|
349 | 349 | $option_value = is_array($this->data[$option_id]) ? serialize($this->data[$option_id]) : $this->data[$option_id]; // Сериализация для массивов при сохранении в БД |
350 | - $to_write[$option_id] = "({$this->user_id}, '" . db_escape($option_id) . "', '" . db_escape($option_value) . "')"; |
|
350 | + $to_write[$option_id] = "({$this->user_id}, '".db_escape($option_id)."', '".db_escape($option_value)."')"; |
|
351 | 351 | } |
352 | 352 | |
353 | - classSupernova::$db->doReplace("REPLACE INTO `{{player_options}}` (`player_id`, `option_id`, `value`) VALUES " . implode(',', $to_write)); |
|
353 | + classSupernova::$db->doReplace("REPLACE INTO `{{player_options}}` (`player_id`, `option_id`, `value`) VALUES ".implode(',', $to_write)); |
|
354 | 354 | } |
355 | 355 | } |
356 | 356 | |
357 | 357 | protected function load() { |
358 | - if($this->loaded) { |
|
358 | + if ($this->loaded) { |
|
359 | 359 | return; |
360 | 360 | } |
361 | 361 | |
362 | 362 | $this->data = $this->defaults; |
363 | 363 | |
364 | - if(!$this->user_id) { |
|
364 | + if (!$this->user_id) { |
|
365 | 365 | return; |
366 | 366 | } |
367 | 367 | |
368 | 368 | $field_name = $this->cached_name(); |
369 | 369 | $a_data = classSupernova::$cache->$field_name; |
370 | 370 | |
371 | - if(!empty($a_data)) { |
|
371 | + if (!empty($a_data)) { |
|
372 | 372 | $this->data = array_replace($this->data, $a_data); |
373 | 373 | return; |
374 | 374 | } |
375 | 375 | |
376 | 376 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE"); |
377 | - while($row = db_fetch($query)) { |
|
377 | + while ($row = db_fetch($query)) { |
|
378 | 378 | // $this->data[$row['option_id']] = $row['value']; |
379 | 379 | $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация |
380 | 380 | } |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | return $this->__get($offset); |
391 | 391 | } |
392 | 392 | public function offsetSet($offset, $value) { |
393 | - if(!is_null($offset)) { |
|
393 | + if (!is_null($offset)) { |
|
394 | 394 | // $this->data[$offset] = $value; |
395 | 395 | $this->__set($offset, $value); |
396 | 396 | } else { |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | !is_array($offset) ? $offset = array($offset) : false; |
39 | 39 | |
40 | 40 | $current_leaf = $this->__get(reset($offset)); |
41 | - while(($leaf_index = next($offset)) !== false) { |
|
42 | - if(!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) { |
|
41 | + while (($leaf_index = next($offset)) !== false) { |
|
42 | + if (!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) { |
|
43 | 43 | unset($current_leaf); |
44 | 44 | break; |
45 | 45 | } |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | |
65 | 65 | !is_array($offset) ? $offset = array($offset) : false; |
66 | 66 | |
67 | - if($this->offsetExists($offset)) { |
|
67 | + if ($this->offsetExists($offset)) { |
|
68 | 68 | $result = $this->__get(reset($offset)); |
69 | - while(($leaf_index = next($offset)) !== false) { |
|
69 | + while (($leaf_index = next($offset)) !== false) { |
|
70 | 70 | $result = $result[$leaf_index]; |
71 | 71 | } |
72 | 72 | } |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function offsetSet($offset, $value = null) { |
93 | 93 | // Если нет никакого индекса - значит нечего записывать |
94 | - if(!isset($offset) || (is_array($offset) && empty($offset))) { |
|
94 | + if (!isset($offset) || (is_array($offset) && empty($offset))) { |
|
95 | 95 | return; |
96 | 96 | } |
97 | 97 | |
98 | 98 | // Если в массиве индекса только один элемент - значит это просто индекс |
99 | - if(is_array($offset) && count($offset) == 1) { |
|
99 | + if (is_array($offset) && count($offset) == 1) { |
|
100 | 100 | // Разворачиваем его в индекс |
101 | 101 | $offset = array(reset($offset) => $value); |
102 | 102 | unset($value); |
@@ -104,20 +104,20 @@ discard block |
||
104 | 104 | } |
105 | 105 | |
106 | 106 | // Адресация многомерного массива через массив индексов в $option |
107 | - if(is_array($offset) && isset($value)) { |
|
107 | + if (is_array($offset) && isset($value)) { |
|
108 | 108 | // TODO - а не переделать ли это всё на __isset() ?? |
109 | 109 | //pdump($offset, '$offset'); |
110 | 110 | //pdump($value, '$value'); |
111 | 111 | // Вытаскиваем корневой элемент |
112 | 112 | $root = $this->__get(reset($offset)); |
113 | 113 | $current_leaf = &$root; |
114 | - while(($leaf_index = next($offset)) !== false) { |
|
114 | + while (($leaf_index = next($offset)) !== false) { |
|
115 | 115 | !is_array($current_leaf[$leaf_index]) ? $current_leaf[$leaf_index] = array() : false; |
116 | 116 | $current_leaf = &$current_leaf[$leaf_index]; |
117 | 117 | } |
118 | 118 | //pdump($current_leaf, '$current_leaf'); |
119 | 119 | //pdump($value, '$value'); |
120 | - if($current_leaf != $value) { |
|
120 | + if ($current_leaf != $value) { |
|
121 | 121 | $current_leaf = $value; |
122 | 122 | //pdump(reset($offset), 'reset($offset)'); |
123 | 123 | //pdump($root, '$root'); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | // Пакетная запись из массива ключ -> значение |
129 | 129 | !is_array($offset) ? $offset = array($offset => $value) : false; |
130 | 130 | |
131 | - foreach($offset as $key => $value) { |
|
131 | + foreach ($offset as $key => $value) { |
|
132 | 132 | $this->__get($key) !== $value ? $this->__set($key, $value) : false; |
133 | 133 | } |
134 | 134 | } |
@@ -149,13 +149,13 @@ discard block |
||
149 | 149 | */ |
150 | 150 | public function offsetUnset($offset) { |
151 | 151 | // Если нет никакого индекса - значит нечего записывать |
152 | - if(!isset($offset) || (is_array($offset) && empty($offset))) { |
|
152 | + if (!isset($offset) || (is_array($offset) && empty($offset))) { |
|
153 | 153 | return; |
154 | 154 | } |
155 | 155 | |
156 | 156 | !is_array($offset) ? $offset = array($offset) : false; |
157 | 157 | |
158 | - if($this->offsetExists($offset)) { |
|
158 | + if ($this->offsetExists($offset)) { |
|
159 | 159 | //pdump($offset); |
160 | 160 | // Перематываем массив в конец |
161 | 161 | $key_to_delete = end($offset); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | //pdump($key_to_delete, '$key_to_delete'); |
164 | 164 | $parent_offset = $offset; |
165 | 165 | array_pop($parent_offset); |
166 | - if(!count($parent_offset)) { |
|
166 | + if (!count($parent_offset)) { |
|
167 | 167 | // В массиве был один элемент - мы удаляем в корне. Просто удаляем элемент |
168 | 168 | $this->__unset($key_to_delete); |
169 | 169 | } else { |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | 'advGoogleLeftMenuCode' => '(Place here code for banner)', |
191 | 191 | |
192 | 192 | // Alliance bonus calculations |
193 | - 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
193 | + 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
194 | 194 | 'ali_bonus_brackets' => 10, // Brackets count for ALI_BONUS_BY_RANK |
195 | - 'ali_bonus_brackets_divisor' => 10,// Bonus divisor for ALI_BONUS_BY_RANK |
|
195 | + 'ali_bonus_brackets_divisor' => 10, // Bonus divisor for ALI_BONUS_BY_RANK |
|
196 | 196 | 'ali_bonus_divisor' => 10000000, // Rank divisor for ALI_BONUS_BY_POINTS |
197 | 197 | 'ali_bonus_members' => 10, // Minumum alliace size to start using bonus |
198 | 198 | |
@@ -223,25 +223,25 @@ discard block |
||
223 | 223 | 'deuterium_basic_income' => 0, |
224 | 224 | 'eco_scale_storage' => 1, |
225 | 225 | 'eco_stockman_fleet' => '', // Black Market - Starting amount of s/h ship merchant to sell |
226 | - 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
226 | + 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
227 | 227 | 'empire_mercenary_base_period' => PERIOD_MONTH, // Base |
228 | 228 | 'empire_mercenary_temporary' => 0, // Temporary empire-wide mercenaries |
229 | 229 | 'energy_basic_income' => 0, |
230 | 230 | |
231 | 231 | // Bashing protection settings |
232 | - 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
233 | - 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
234 | - 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
235 | - 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
236 | - 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
232 | + 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
233 | + 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
234 | + 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
235 | + 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
236 | + 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
237 | 237 | |
238 | 238 | 'Fleet_Cdr' => 30, |
239 | 239 | 'fleet_speed' => 1, |
240 | 240 | |
241 | 241 | 'fleet_update_interval' => 4, |
242 | 242 | |
243 | - 'game_adminEmail' => 'root@localhost', // Admin's email to show to users |
|
244 | - 'game_counter' => 0, // Does built-in page hit counter is on? |
|
243 | + 'game_adminEmail' => 'root@localhost', // Admin's email to show to users |
|
244 | + 'game_counter' => 0, // Does built-in page hit counter is on? |
|
245 | 245 | // Defaults |
246 | 246 | 'game_default_language' => 'ru', |
247 | 247 | 'game_default_skin' => 'skins/EpicBlue/', |
@@ -255,13 +255,13 @@ discard block |
||
255 | 255 | 'game_maxSystem' => 199, |
256 | 256 | 'game_maxPlanet' => 15, |
257 | 257 | // Game global settings |
258 | - 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
258 | + 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
259 | 259 | 'game_name' => 'SuperNova', // Server name (would be on banners and on top of left menu) |
260 | 260 | |
261 | 261 | 'game_news_actual' => 259200, // How long announcement would be marked as "New". In seconds. Default - 3 days |
262 | - 'game_news_overview' => 3, // How much last news to show in Overview page |
|
262 | + 'game_news_overview' => 3, // How much last news to show in Overview page |
|
263 | 263 | // Noob protection |
264 | - 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
264 | + 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
265 | 265 | 'game_noob_points' => 5000, // Below this point user threated as noob. 0 to disable |
266 | 266 | |
267 | 267 | 'game_multiaccount_enabled' => 0, // 1 - allow interactions for players with same IP (multiaccounts) |
@@ -311,8 +311,8 @@ discard block |
||
311 | 311 | 'payment_currency_exchange_wmu' => 30, |
312 | 312 | 'payment_currency_exchange_wmz' => 1, |
313 | 313 | |
314 | - 'payment_lot_price' => 1, // Lot price in default currency |
|
315 | - 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
314 | + 'payment_lot_price' => 1, // Lot price in default currency |
|
315 | + 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
316 | 316 | |
317 | 317 | 'planet_teleport_cost' => 50000, // |
318 | 318 | 'planet_teleport_timeout' => 86400, // |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | 'resource_multiplier' => 1, |
331 | 331 | |
332 | 332 | //Roleplay system |
333 | - 'rpg_bonus_divisor' => 10, // Amount of DM referral shoud get for partner have 1 DM bonus |
|
333 | + 'rpg_bonus_divisor' => 10, // Amount of DM referral shoud get for partner have 1 DM bonus |
|
334 | 334 | 'rpg_bonus_minimum' => 10000, // Minimum DM ammount for starting paying bonuses to affiliate |
335 | 335 | |
336 | 336 | // Black Market - General |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | // classSupernova::$db->sn_db_connect(); |
16 | 16 | if (!(strpos($query, '{{') === false)) { |
17 | 17 | foreach ($update_tables as $tableName => $cork) { |
18 | - $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix . $tableName, $query); |
|
18 | + $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix.$tableName, $query); |
|
19 | 19 | } |
20 | 20 | } |
21 | - !($result = classSupernova::$db->db_sql_query($query)) ? die('Query error for ' . $query . ': ' . classSupernova::$db->db_error()) : false; |
|
21 | + !($result = classSupernova::$db->db_sql_query($query)) ? die('Query error for '.$query.': '.classSupernova::$db->db_error()) : false; |
|
22 | 22 | |
23 | 23 | return $result; |
24 | 24 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | global $update_tables, $update_indexes, $update_indexes_full, $update_foreigns; |
86 | 86 | |
87 | 87 | $tableName = $prefixed ? str_replace(classSupernova::$config->db_prefix, '', $prefix_table_name) : $prefix_table_name; |
88 | - $prefix_table_name = $prefixed ? $prefix_table_name : classSupernova::$config->db_prefix . $prefix_table_name; |
|
88 | + $prefix_table_name = $prefixed ? $prefix_table_name : classSupernova::$config->db_prefix.$prefix_table_name; |
|
89 | 89 | |
90 | 90 | upd_unset_table_info($tableName); |
91 | 91 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $update_indexes_full[$tableName][$r1['Key_name']][$r1['Column_name']] = $r1; |
101 | 101 | } |
102 | 102 | |
103 | - $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '" . db_escape(classSupernova::$db_name) . "' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true); |
|
103 | + $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '".db_escape(classSupernova::$db_name)."' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true); |
|
104 | 104 | while ($r1 = db_fetch($q1)) { |
105 | 105 | $table_referenced = str_replace(classSupernova::$config->db_prefix, '', $r1['REFERENCED_TABLE_NAME']); |
106 | 106 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $result = upd_do_query("CREATE TABLE IF NOT EXISTS `{$db_prefix}{$table_name}` {$declaration}"); |
161 | 161 | $error = classSupernova::$db->db_error(); |
162 | 162 | if ($error) { |
163 | - die("Creating error for table `{$table_name}`: {$error}<br />" . dump($declaration)); |
|
163 | + die("Creating error for table `{$table_name}`: {$error}<br />".dump($declaration)); |
|
164 | 164 | } |
165 | 165 | upd_do_query('set foreign_key_checks = 1;', true); |
166 | 166 | upd_load_table_info($table_name, false); |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | "SELECT {$fields} |
176 | 176 | FROM {{unit}} |
177 | 177 | WHERE |
178 | - `unit_location_type` = {$location_type} AND `unit_location_id` = {$location_id} AND " . DBStaticUnit::db_unit_time_restrictions() . |
|
179 | - ($user_id = intval($user_id) ? " AND `unit_player_id` = {$user_id}" : '') . |
|
180 | - ($unit_snid = intval($unit_snid) ? " AND `unit_snid` = {$unit_snid}" : '') . |
|
181 | - " LIMIT 1" . |
|
178 | + `unit_location_type` = {$location_type} AND `unit_location_id` = {$location_id} AND ".DBStaticUnit::db_unit_time_restrictions(). |
|
179 | + ($user_id = intval($user_id) ? " AND `unit_player_id` = {$user_id}" : ''). |
|
180 | + ($unit_snid = intval($unit_snid) ? " AND `unit_snid` = {$unit_snid}" : ''). |
|
181 | + " LIMIT 1". |
|
182 | 182 | ($for_update ? ' FOR UPDATE' : '') |
183 | 183 | )); |
184 | 184 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | foreach ($table_data as $record_id => $conditions) { |
260 | 260 | $where = ''; |
261 | 261 | if (!empty($conditions['where'])) { |
262 | - $where = 'WHERE ' . implode(' AND ', $conditions['where']); |
|
262 | + $where = 'WHERE '.implode(' AND ', $conditions['where']); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | $fields = array(); |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | $condition = "`{$field_name}` = "; |
269 | 269 | $value = ''; |
270 | 270 | if ($field_data['delta']) { |
271 | - $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta']; |
|
271 | + $value = "`{$field_name}`".($field_data['delta'] >= 0 ? '+' : '').$field_data['delta']; |
|
272 | 272 | } elseif ($field_data['set']) { |
273 | 273 | $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']); |
274 | 274 | } |
275 | 275 | if ($value) { |
276 | - $fields[] = $condition . $value; |
|
276 | + $fields[] = $condition.$value; |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | 'checkSpeedPercentOld' => FLIGHT_FLEET_SPEED_WRONG, |
15 | 15 | 'checkTargetInUniverse' => FLIGHT_VECTOR_BEYOND_UNIVERSE, |
16 | 16 | 'checkTargetNotSource' => FLIGHT_VECTOR_SAME_SOURCE, |
17 | - 'checkSenderNoVacation' => FLIGHT_PLAYER_VACATION_OWN, // tODO |
|
17 | + 'checkSenderNoVacation' => FLIGHT_PLAYER_VACATION_OWN, // tODO |
|
18 | 18 | 'checkTargetNoVacation' => FLIGHT_PLAYER_VACATION, |
19 | 19 | 'checkFleetNotEmpty' => FLIGHT_SHIPS_NO_SHIPS, |
20 | 20 | // 'checkUnitsPositive' => FLIGHT_SHIPS_NEGATIVE, // Unused - 'cause it's not allowed to put negative units into Unit class |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | |
134 | 134 | $checkResult = call_user_func(array($this, $condition)); |
135 | 135 | defined('DEBUG_FLEET_MISSION_VALIDATE_DUMP_STEPS') |
136 | - ? pdump($action, $condition . ' ' . ($checkResult ? 'TRUE' : 'FALSE')) : false; |
|
136 | + ? pdump($action, $condition.' '.($checkResult ? 'TRUE' : 'FALSE')) : false; |
|
137 | 137 | |
138 | 138 | // If check failed and there no alternative actions - throw exception |
139 | 139 | // Shortcut ACTION => FAIL_STATUS instead of ACTION => array(false => FAIL_STATUS) |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $this->checkMissionRestrictions($action); |
157 | 157 | } else { |
158 | 158 | // No - then just performing action |
159 | - if($exception) { |
|
159 | + if ($exception) { |
|
160 | 160 | throw new ExceptionFleetInvalid($action, $action); |
161 | 161 | } else { |
162 | 162 | return $action; |
@@ -598,10 +598,10 @@ discard block |
||
598 | 598 | protected function checkMissionPrefix($name, $prefix) { |
599 | 599 | $result = false; |
600 | 600 | if (strpos($name, $prefix) === 0) { |
601 | - $mission = 'MT_' . strtoupper(substr($name, strlen($prefix))); |
|
601 | + $mission = 'MT_'.strtoupper(substr($name, strlen($prefix))); |
|
602 | 602 | if (!defined($mission)) { |
603 | 603 | // TODO - Ну, как-то получше это обделать |
604 | - throw new Exception('Mission type "' . $mission . '" is not defined', FLIGHT_MISSION_UNKNOWN); |
|
604 | + throw new Exception('Mission type "'.$mission.'" is not defined', FLIGHT_MISSION_UNKNOWN); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | $result = constant($mission); |
@@ -34,7 +34,7 @@ |
||
34 | 34 | * @throws ExceptionFleetInvalid |
35 | 35 | */ |
36 | 36 | public static function build($missionType, $fleet) { |
37 | - if (!empty(self::$missions[$missionType]) && class_exists($className = __NAMESPACE__ . '\\' . self::$missions[$missionType])) { |
|
37 | + if (!empty(self::$missions[$missionType]) && class_exists($className = __NAMESPACE__.'\\'.self::$missions[$missionType])) { |
|
38 | 38 | $result = new $className($fleet); |
39 | 39 | } else { |
40 | 40 | throw new ExceptionFleetInvalid("Mission type {$missionType} unknown", FLIGHT_MISSION_UNKNOWN); |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | function loadModuleRootConfig() { |
75 | - require SN_ROOT_PHYSICAL . 'config.php'; |
|
75 | + require SN_ROOT_PHYSICAL.'config.php'; |
|
76 | 76 | |
77 | - $module_config_array = get_class($this) . '_config'; |
|
78 | - if(!empty($$module_config_array) && is_array($$module_config_array)) { |
|
77 | + $module_config_array = get_class($this).'_config'; |
|
78 | + if (!empty($$module_config_array) && is_array($$module_config_array)) { |
|
79 | 79 | $this->config = $$module_config_array; |
80 | 80 | |
81 | 81 | return true; |
@@ -93,17 +93,17 @@ discard block |
||
93 | 93 | |
94 | 94 | // TODO: Load configuration from DB. Manifest setting |
95 | 95 | // Trying to load configuration from file |
96 | - if(!$config_exists = $this->loadModuleRootConfig()) { |
|
96 | + if (!$config_exists = $this->loadModuleRootConfig()) { |
|
97 | 97 | // Конфигурация может лежать в config_path в манифеста или в корне модуля |
98 | - if(isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'] . '/config.php')) { |
|
98 | + if (isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'].'/config.php')) { |
|
99 | 99 | $config_exists = true; |
100 | - } elseif(file_exists($config_filename = dirname($filename) . '/config.php')) { |
|
100 | + } elseif (file_exists($config_filename = dirname($filename).'/config.php')) { |
|
101 | 101 | $config_exists = true; |
102 | 102 | } |
103 | 103 | |
104 | - if($config_exists) { |
|
104 | + if ($config_exists) { |
|
105 | 105 | include($config_filename); |
106 | - $module_config_array = $class_module_name . '_config'; |
|
106 | + $module_config_array = $class_module_name.'_config'; |
|
107 | 107 | $this->config = $$module_config_array; |
108 | 108 | } |
109 | 109 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | // Checking module status - is it installed and active |
120 | 120 | $this->check_status(); |
121 | - if(!$this->manifest['active']) { |
|
121 | + if (!$this->manifest['active']) { |
|
122 | 122 | return; |
123 | 123 | } |
124 | 124 | |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | |
139 | 139 | protected function setSystemConstants() { |
140 | 140 | // Setting constants - if any |
141 | - if(empty($this->manifest['constants']) || !is_array($this->manifest['constants'])) { |
|
141 | + if (empty($this->manifest['constants']) || !is_array($this->manifest['constants'])) { |
|
142 | 142 | return; |
143 | 143 | } |
144 | 144 | |
145 | - foreach($this->manifest['constants'] as $constant_name => $constant_value) { |
|
145 | + foreach ($this->manifest['constants'] as $constant_name => $constant_value) { |
|
146 | 146 | !defined($constant_name) ? define($constant_name, $constant_value) : false; |
147 | 147 | } |
148 | 148 | } |
@@ -154,48 +154,48 @@ discard block |
||
154 | 154 | // New values from module variables will overwrite previous values (for root variables) and array elements with corresponding indexes (for arrays) |
155 | 155 | // Constants as array indexes are honored - it's make valid such declarations as 'sn_data[ques][QUE_STRUCTURES]' |
156 | 156 | $this->manifest['vars'] = $this->__assign_vars(); |
157 | - if(empty($this->manifest['vars']) || !is_array($this->manifest['vars'])) { |
|
157 | + if (empty($this->manifest['vars']) || !is_array($this->manifest['vars'])) { |
|
158 | 158 | return; |
159 | 159 | } |
160 | 160 | |
161 | 161 | $vars_assigned = array(); |
162 | - foreach($this->manifest['vars'] as $var_name => $var_value) { |
|
162 | + foreach ($this->manifest['vars'] as $var_name => $var_value) { |
|
163 | 163 | $sub_vars = explode('[', str_replace(']', '', $var_name)); |
164 | 164 | $var_name = $sub_vars[0]; |
165 | 165 | |
166 | - if(!isset($vars_assigned[$var_name])) { |
|
166 | + if (!isset($vars_assigned[$var_name])) { |
|
167 | 167 | $vars_assigned[$var_name] = true; |
168 | 168 | global $$var_name; |
169 | 169 | } |
170 | 170 | |
171 | 171 | $pointer = &$$var_name; |
172 | - if(($n = count($sub_vars)) > 1) { |
|
173 | - for($i = 1; $i < $n; $i++) { |
|
174 | - if(defined($sub_vars[$i])) { |
|
172 | + if (($n = count($sub_vars)) > 1) { |
|
173 | + for ($i = 1; $i < $n; $i++) { |
|
174 | + if (defined($sub_vars[$i])) { |
|
175 | 175 | $sub_vars[$i] = constant($sub_vars[$i]); |
176 | 176 | } |
177 | 177 | |
178 | - if(!isset($pointer[$sub_vars[$i]]) && $i != $n) { |
|
178 | + if (!isset($pointer[$sub_vars[$i]]) && $i != $n) { |
|
179 | 179 | $pointer[$sub_vars[$i]] = array(); |
180 | 180 | } |
181 | 181 | $pointer = &$pointer[$sub_vars[$i]]; |
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
185 | - if(!isset($pointer) || !is_array($pointer)) { |
|
185 | + if (!isset($pointer) || !is_array($pointer)) { |
|
186 | 186 | $pointer = $var_value; |
187 | - } elseif(is_array($$var_name)) { |
|
187 | + } elseif (is_array($$var_name)) { |
|
188 | 188 | $pointer = array_merge_recursive_numeric($pointer, $var_value); |
189 | 189 | } |
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
193 | 193 | protected function mergeMenu(&$sn_menu_extra, &$menu_patch) { |
194 | - if(!is_array($menu_patch)) { |
|
194 | + if (!is_array($menu_patch)) { |
|
195 | 195 | return; |
196 | 196 | } |
197 | 197 | |
198 | - foreach($menu_patch as $menu_item_name => $menu_item_data) { |
|
198 | + foreach ($menu_patch as $menu_item_name => $menu_item_data) { |
|
199 | 199 | $sn_menu_extra[$menu_item_name] = $menu_item_data; |
200 | 200 | } |
201 | 201 | } |
@@ -204,34 +204,34 @@ discard block |
||
204 | 204 | // Overriding function if any |
205 | 205 | sn_sys_handler_add(classSupernova::$functions, $this->manifest['functions'], $this); |
206 | 206 | |
207 | - foreach(classSupernova::$sn_mvc as $handler_type => &$handler_data) { |
|
207 | + foreach (classSupernova::$sn_mvc as $handler_type => &$handler_data) { |
|
208 | 208 | sn_sys_handler_add($handler_data, $this->manifest['mvc'][$handler_type], $this, $handler_type); |
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
212 | 212 | protected function mergeNavbarButton() { |
213 | - if(empty($this->manifest['navbar_prefix_button']) || !is_array($this->manifest['navbar_prefix_button'])) { |
|
213 | + if (empty($this->manifest['navbar_prefix_button']) || !is_array($this->manifest['navbar_prefix_button'])) { |
|
214 | 214 | return; |
215 | 215 | } |
216 | 216 | |
217 | - foreach($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) { |
|
217 | + foreach ($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) { |
|
218 | 218 | classSupernova::$sn_mvc['navbar_prefix_button'][$button_image] = $button_url_relative; |
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | 222 | protected function mergeI18N() { |
223 | 223 | $arrayName = 'i18n'; |
224 | - if(empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
224 | + if (empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
225 | 225 | return; |
226 | 226 | } |
227 | 227 | |
228 | - foreach($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
229 | - foreach($contentList as &$i18n_file_data) { |
|
230 | - if(is_array($i18n_file_data) && !$i18n_file_data['path']) { |
|
228 | + foreach ($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
229 | + foreach ($contentList as &$i18n_file_data) { |
|
230 | + if (is_array($i18n_file_data) && !$i18n_file_data['path']) { |
|
231 | 231 | $i18n_file_data['path'] = $this->manifest['root_relative']; |
232 | 232 | } |
233 | 233 | } |
234 | - if(!isset(classSupernova::$sn_mvc[$arrayName][$pageName])) { |
|
234 | + if (!isset(classSupernova::$sn_mvc[$arrayName][$pageName])) { |
|
235 | 235 | classSupernova::$sn_mvc[$arrayName][$pageName] = array(); |
236 | 236 | } |
237 | 237 | classSupernova::$sn_mvc[$arrayName][$pageName] += $contentList; |
@@ -239,13 +239,13 @@ discard block |
||
239 | 239 | } |
240 | 240 | |
241 | 241 | protected function mergeArraySpecial($arrayName) { |
242 | - if(empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
242 | + if (empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
243 | 243 | return; |
244 | 244 | } |
245 | 245 | |
246 | - foreach($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
246 | + foreach ($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
247 | 247 | !isset(classSupernova::$sn_mvc[$arrayName][$pageName]) ? classSupernova::$sn_mvc[$arrayName][$pageName] = array() : false; |
248 | - foreach($contentList as $contentName => &$content) { |
|
248 | + foreach ($contentList as $contentName => &$content) { |
|
249 | 249 | classSupernova::$sn_mvc[$arrayName][$pageName][$contentName] = $content; |
250 | 250 | } |
251 | 251 | } |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | $load_order[$loaded_module_name] = $level; |
300 | 300 | } |
301 | 301 | } |
302 | - } while($prev_order != $load_order); |
|
302 | + } while ($prev_order != $load_order); |
|
303 | 303 | |
304 | 304 | asort($load_order); |
305 | 305 |
@@ -1,18 +1,18 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
3 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
4 | 4 | classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
5 | 5 | } |
6 | 6 | |
7 | 7 | $template = gettemplate('ali_search', true); |
8 | 8 | |
9 | 9 | $ali_search_text = sys_get_param_str('searchtext'); |
10 | -if($ali_search_text) { |
|
10 | +if ($ali_search_text) { |
|
11 | 11 | $template->assign_var('SEARCH_TEXT', $ali_search_text); |
12 | 12 | |
13 | 13 | $search = DBStaticAlly::db_ally_search_by_name_or_tag($ali_search_text); |
14 | - if(classSupernova::$db->db_num_rows($search)) { |
|
15 | - while($ally_row = db_fetch($search)) { |
|
14 | + if (classSupernova::$db->db_num_rows($search)) { |
|
15 | + while ($ally_row = db_fetch($search)) { |
|
16 | 16 | $template->assign_block_vars('alliances', array( |
17 | 17 | 'ID' => $ally_row['id'], |
18 | 18 | 'TAG' => $ally_row['ally_tag'], |