@@ -84,8 +84,9 @@ discard block |
||
84 | 84 | if ($display_hours) { |
85 | 85 | $hours = $use_24_hours ? range(0, 23) : range(1, 12); |
86 | 86 | $hour_fmt = $use_24_hours ? '%H' : '%I'; |
87 | - for ($i = 0, $for_max = count($hours); $i < $for_max; $i++) |
|
88 | - $hours[$i] = sprintf('%02d', $hours[$i]); |
|
87 | + for ($i = 0, $for_max = count($hours); $i < $for_max; $i++) { |
|
88 | + $hours[$i] = sprintf('%02d', $hours[$i]); |
|
89 | + } |
|
89 | 90 | $html_result .= '<select name='; |
90 | 91 | if (null !== $field_array) { |
91 | 92 | $html_result .= '"' . $field_array . '[' . $prefix . 'Hour]"'; |
@@ -109,8 +110,9 @@ discard block |
||
109 | 110 | |
110 | 111 | if ($display_minutes) { |
111 | 112 | $all_minutes = range(0, 59); |
112 | - for ($i = 0, $for_max = count($all_minutes); $i < $for_max; $i+= $minute_interval) |
|
113 | - $minutes[] = sprintf('%02d', $all_minutes[$i]); |
|
113 | + for ($i = 0, $for_max = count($all_minutes); $i < $for_max; $i+= $minute_interval) { |
|
114 | + $minutes[] = sprintf('%02d', $all_minutes[$i]); |
|
115 | + } |
|
114 | 116 | $selected = intval(floor(strftime('%M', $time) / $minute_interval) * $minute_interval); |
115 | 117 | $html_result .= '<select name='; |
116 | 118 | if (null !== $field_array) { |
@@ -136,8 +138,9 @@ discard block |
||
136 | 138 | |
137 | 139 | if ($display_seconds) { |
138 | 140 | $all_seconds = range(0, 59); |
139 | - for ($i = 0, $for_max = count($all_seconds); $i < $for_max; $i+= $second_interval) |
|
140 | - $seconds[] = sprintf('%02d', $all_seconds[$i]); |
|
141 | + for ($i = 0, $for_max = count($all_seconds); $i < $for_max; $i+= $second_interval) { |
|
142 | + $seconds[] = sprintf('%02d', $all_seconds[$i]); |
|
143 | + } |
|
141 | 144 | $selected = intval(floor(strftime('%S', $time) / $second_interval) * $second_interval); |
142 | 145 | $html_result .= '<select name='; |
143 | 146 | if (null !== $field_array) { |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -50,12 +52,10 @@ discard block |
||
50 | 52 | if(count($expl) == 1){ |
51 | 53 | if(array_key_exists($value, $field_options)){ |
52 | 54 | return $field_options[$value] . ", "; |
53 | - } |
|
54 | - else{ |
|
55 | + } else{ |
|
55 | 56 | return ''; |
56 | 57 | } |
57 | - } |
|
58 | - else{ |
|
58 | + } else{ |
|
59 | 59 | $final_array = array(); |
60 | 60 | foreach($expl as $key_val){ |
61 | 61 | if(array_key_exists($key_val, $field_options)){ |
@@ -33,7 +33,9 @@ discard block |
||
33 | 33 | */ |
34 | 34 | |
35 | 35 | |
36 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
36 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
37 | + die('Not A Valid Entry Point'); |
|
38 | +} |
|
37 | 39 | /********************************************************************************* |
38 | 40 | * SugarCRM Community Edition is a customer relationship management program developed by |
39 | 41 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -85,7 +87,7 @@ discard block |
||
85 | 87 | $link_url .= 'module=iFrames&action=index'; |
86 | 88 | $link_url .= '&record='.$params['data']['0']; |
87 | 89 | $link_url .= '&tab=true'; |
88 | - }else{ |
|
90 | + } else{ |
|
89 | 91 | $action = (!empty($params['action']))?$params['action']:'index'; |
90 | 92 | |
91 | 93 | $link_url = 'index.php?'; |
@@ -107,12 +109,13 @@ discard block |
||
107 | 109 | $module = ' module="'.$params['module'].'"'; |
108 | 110 | $accesskey = (!empty($params['accesskey']))?' accesskey="'.$params['accesskey'].'" ':''; |
109 | 111 | $options = (!empty($params['options']))?' '.$params['options'].'':''; |
110 | - if(!empty($params['data']) && is_array($params['data'])) |
|
111 | - $label =$params['data']['4']; |
|
112 | - elseif ( !empty($params['label']) ) |
|
113 | - $label = $params['label']; |
|
114 | - else |
|
115 | - $label = (!empty($GLOBALS['app_list_strings']['moduleList'][$params['module']]))?$GLOBALS['app_list_strings']['moduleList'][$params['module']]:$params['module']; |
|
112 | + if(!empty($params['data']) && is_array($params['data'])) { |
|
113 | + $label =$params['data']['4']; |
|
114 | + } elseif ( !empty($params['label']) ) { |
|
115 | + $label = $params['label']; |
|
116 | + } else { |
|
117 | + $label = (!empty($GLOBALS['app_list_strings']['moduleList'][$params['module']]))?$GLOBALS['app_list_strings']['moduleList'][$params['module']]:$params['module']; |
|
118 | + } |
|
116 | 119 | |
117 | 120 | $link = '<a href="'.ajaxLink($link_url).'"'.$id.$class.$style.$options.$title.$module.'>'.$label.'</a>'; |
118 | 121 | return $link; |
@@ -23,8 +23,9 @@ discard block |
||
23 | 23 | function smarty_modifier_regex_replace($string, $search, $replace) |
24 | 24 | { |
25 | 25 | if(is_array($search)) { |
26 | - foreach($search as $idx => $s) |
|
27 | - $search[$idx] = _smarty_regex_replace_check($s); |
|
26 | + foreach($search as $idx => $s) { |
|
27 | + $search[$idx] = _smarty_regex_replace_check($s); |
|
28 | + } |
|
28 | 29 | } else { |
29 | 30 | $search = _smarty_regex_replace_check($search); |
30 | 31 | } |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | |
35 | 36 | function _smarty_regex_replace_check($search) |
36 | 37 | { |
37 | - if (($pos = strpos($search,"\0")) !== false) |
|
38 | - $search = substr($search,0,$pos); |
|
38 | + if (($pos = strpos($search,"\0")) !== false) { |
|
39 | + $search = substr($search,0,$pos); |
|
40 | + } |
|
39 | 41 | if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) { |
40 | 42 | /* remove eval-modifier from $search */ |
41 | 43 | $search = substr($search, 0, -strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]); |
@@ -21,11 +21,12 @@ |
||
21 | 21 | */ |
22 | 22 | function smarty_modifier_strip_tags($string, $replace_with_space = true) |
23 | 23 | { |
24 | - if ($replace_with_space) |
|
25 | - return preg_replace('!<[^>]*?>!', ' ', $string); |
|
26 | - else |
|
27 | - return strip_tags($string); |
|
28 | -} |
|
24 | + if ($replace_with_space) { |
|
25 | + return preg_replace('!<[^>]*?>!', ' ', $string); |
|
26 | + } else { |
|
27 | + return strip_tags($string); |
|
28 | + } |
|
29 | + } |
|
29 | 30 | |
30 | 31 | /* vim: set expandtab: */ |
31 | 32 |
@@ -52,26 +52,35 @@ |
||
52 | 52 | function smarty_function_sugar_getlink($params, &$smarty) { |
53 | 53 | |
54 | 54 | // error checking for required parameters |
55 | - if(!isset($params['url'])) |
|
56 | - $smarty->trigger_error($GLOBALS['app_strings']['ERR_MISSING_REQUIRED_FIELDS'] . 'url'); |
|
57 | - if(!isset($params['title'])) |
|
58 | - $smarty->trigger_error($GLOBALS['app_strings']['ERR_MISSING_REQUIRED_FIELDS'] . 'title'); |
|
55 | + if(!isset($params['url'])) { |
|
56 | + $smarty->trigger_error($GLOBALS['app_strings']['ERR_MISSING_REQUIRED_FIELDS'] . 'url'); |
|
57 | + } |
|
58 | + if(!isset($params['title'])) { |
|
59 | + $smarty->trigger_error($GLOBALS['app_strings']['ERR_MISSING_REQUIRED_FIELDS'] . 'title'); |
|
60 | + } |
|
59 | 61 | |
60 | 62 | // set defaults |
61 | - if(!isset($params['attr'])) |
|
62 | - $params['attr'] = ''; |
|
63 | - if(!isset($params['img_name'])) |
|
64 | - $params['img_name'] = ''; |
|
65 | - if(!isset($params['img_attr'])) |
|
66 | - $params['img_attr'] = ''; |
|
67 | - if(!isset($params['img_width'])) |
|
68 | - $params['img_width'] = null; |
|
69 | - if(!isset($params['img_height'])) |
|
70 | - $params['height'] = null; |
|
71 | - if(!isset($params['img_placement'])) |
|
72 | - $params['img_placement'] = 'imageonly'; |
|
73 | - if(!isset($params['img_alt'])) |
|
74 | - $params['img_alt'] = ''; |
|
63 | + if(!isset($params['attr'])) { |
|
64 | + $params['attr'] = ''; |
|
65 | + } |
|
66 | + if(!isset($params['img_name'])) { |
|
67 | + $params['img_name'] = ''; |
|
68 | + } |
|
69 | + if(!isset($params['img_attr'])) { |
|
70 | + $params['img_attr'] = ''; |
|
71 | + } |
|
72 | + if(!isset($params['img_width'])) { |
|
73 | + $params['img_width'] = null; |
|
74 | + } |
|
75 | + if(!isset($params['img_height'])) { |
|
76 | + $params['height'] = null; |
|
77 | + } |
|
78 | + if(!isset($params['img_placement'])) { |
|
79 | + $params['img_placement'] = 'imageonly'; |
|
80 | + } |
|
81 | + if(!isset($params['img_alt'])) { |
|
82 | + $params['img_alt'] = ''; |
|
83 | + } |
|
75 | 84 | |
76 | 85 | return SugarThemeRegistry::current()->getLink($params['url'], $params['title'], $params['attr'], $params['img_name'], |
77 | 86 | $params['img_attr'], $params['img_width'], $params['img_height'], $params['img_alt'], $params['img_placement']); |
@@ -67,17 +67,19 @@ |
||
67 | 67 | { |
68 | 68 | $ret = ""; |
69 | 69 | if(empty($params['string'])) { |
70 | - if (empty($params['default'])) |
|
71 | - $ret = array(); |
|
72 | - else if(is_array($params['default'])) |
|
73 | - $ret = $params['default']; |
|
74 | - else |
|
75 | - $ret = unencodeMultienum($params['default']); |
|
70 | + if (empty($params['default'])) { |
|
71 | + $ret = array(); |
|
72 | + } else if(is_array($params['default'])) { |
|
73 | + $ret = $params['default']; |
|
74 | + } else { |
|
75 | + $ret = unencodeMultienum($params['default']); |
|
76 | + } |
|
76 | 77 | } else { |
77 | - if (is_array($params['string'])) |
|
78 | - $ret = $params['string']; |
|
79 | - else |
|
80 | - $ret = unencodeMultienum($params['string']); |
|
78 | + if (is_array($params['string'])) { |
|
79 | + $ret = $params['string']; |
|
80 | + } else { |
|
81 | + $ret = unencodeMultienum($params['string']); |
|
82 | + } |
|
81 | 83 | } |
82 | 84 | |
83 | 85 |
@@ -338,7 +338,9 @@ discard block |
||
338 | 338 | break; |
339 | 339 | |
340 | 340 | case "SUBPANELSAVE": |
341 | - if($view == 'QuickCreate' || (isset($_REQUEST['target_action']) && strtolower($_REQUEST['target_action']) == 'quickcreate')) $view = "form_SubpanelQuickCreate_{$module}"; |
|
341 | + if($view == 'QuickCreate' || (isset($_REQUEST['target_action']) && strtolower($_REQUEST['target_action']) == 'quickcreate')) { |
|
342 | + $view = "form_SubpanelQuickCreate_{$module}"; |
|
343 | + } |
|
342 | 344 | |
343 | 345 | /* BEGIN - SECURITY GROUPS - redirect a subpanel save to the detail view if select popup and user in more than 1 group*/ |
344 | 346 | /** |
@@ -475,8 +477,9 @@ discard block |
||
475 | 477 | $set_submit = false; |
476 | 478 | $is_hidden_field = false; |
477 | 479 | //if the code is wrapped with the form element, it will escape the operation for JS replacement |
478 | - if(isset($dom_tree['tag']) && $dom_tree['tag'] == 'form') |
|
479 | - return false; |
|
480 | + if(isset($dom_tree['tag']) && $dom_tree['tag'] == 'form') { |
|
481 | + return false; |
|
482 | + } |
|
480 | 483 | |
481 | 484 | if(isset($dom_tree['type']) && $dom_tree['type'] == 'hidden') { |
482 | 485 | $is_hidden_field = true; |
@@ -486,8 +489,9 @@ discard block |
||
486 | 489 | if(isset($dom_tree['onclick'])) { |
487 | 490 | if(strpos($dom_tree['onclick'], "this.form") !== false) { |
488 | 491 | $dom_tree['onclick'] = str_replace("this.form", "_form", $dom_tree['onclick']); |
489 | - if(substr($dom_tree['onclick'], -1) != ';') |
|
490 | - $dom_tree['onclick'] .= ";"; |
|
492 | + if(substr($dom_tree['onclick'], -1) != ';') { |
|
493 | + $dom_tree['onclick'] .= ";"; |
|
494 | + } |
|
491 | 495 | //Onclick handler contains returning a variable, for example it prompts a confirm message. |
492 | 496 | if(strpos($dom_tree['onclick'], "return ") !== false ) { |
493 | 497 | $dom_tree['onclick'] = $js_form.' var _onclick=(function(){ldelim}'.$dom_tree['onclick']."{rdelim}()); if(_onclick!==false) _form.submit();"; |
@@ -243,7 +243,9 @@ discard block |
||
243 | 243 | // run template source through prefilter functions |
244 | 244 | if (count($this->_plugins['prefilter']) > 0) { |
245 | 245 | foreach ($this->_plugins['prefilter'] as $filter_name => $prefilter) { |
246 | - if ($prefilter === false) continue; |
|
246 | + if ($prefilter === false) { |
|
247 | + continue; |
|
248 | + } |
|
247 | 249 | if ($prefilter[3] || is_callable($prefilter[0])) { |
248 | 250 | $source_content = call_user_func_array($prefilter[0], |
249 | 251 | array($source_content, &$this)); |
@@ -385,7 +387,9 @@ discard block |
||
385 | 387 | // run compiled template through postfilter functions |
386 | 388 | if (count($this->_plugins['postfilter']) > 0) { |
387 | 389 | foreach ($this->_plugins['postfilter'] as $filter_name => $postfilter) { |
388 | - if ($postfilter === false) continue; |
|
390 | + if ($postfilter === false) { |
|
391 | + continue; |
|
392 | + } |
|
389 | 393 | if ($postfilter[3] || is_callable($postfilter[0])) { |
390 | 394 | $compiled_content = call_user_func_array($postfilter[0], |
391 | 395 | array($compiled_content, &$this)); |
@@ -435,8 +439,9 @@ discard block |
||
435 | 439 | function _compile_tag($template_tag) |
436 | 440 | { |
437 | 441 | /* Matched comment. */ |
438 | - if (substr($template_tag, 0, 1) == '*' && substr($template_tag, -1) == '*') |
|
439 | - return ''; |
|
442 | + if (substr($template_tag, 0, 1) == '*' && substr($template_tag, -1) == '*') { |
|
443 | + return ''; |
|
444 | + } |
|
440 | 445 | |
441 | 446 | /* Split tag into two three parts: command, command modifiers and the arguments. */ |
442 | 447 | if(! preg_match('~^(?:(' . $this->_num_const_regexp . '|' . $this->_obj_call_regexp . '|' . $this->_var_regexp |
@@ -474,18 +479,21 @@ discard block |
||
474 | 479 | |
475 | 480 | case 'else': |
476 | 481 | list($_open_tag) = end($this->_tag_stack); |
477 | - if ($_open_tag != 'if' && $_open_tag != 'elseif') |
|
478 | - $this->_syntax_error('unexpected {else}', E_USER_ERROR, __FILE__, __LINE__); |
|
479 | - else |
|
480 | - $this->_push_tag('else'); |
|
482 | + if ($_open_tag != 'if' && $_open_tag != 'elseif') { |
|
483 | + $this->_syntax_error('unexpected {else}', E_USER_ERROR, __FILE__, __LINE__); |
|
484 | + } else { |
|
485 | + $this->_push_tag('else'); |
|
486 | + } |
|
481 | 487 | return '<?php else: ?>'; |
482 | 488 | |
483 | 489 | case 'elseif': |
484 | 490 | list($_open_tag) = end($this->_tag_stack); |
485 | - if ($_open_tag != 'if' && $_open_tag != 'elseif') |
|
486 | - $this->_syntax_error('unexpected {elseif}', E_USER_ERROR, __FILE__, __LINE__); |
|
487 | - if ($_open_tag == 'if') |
|
488 | - $this->_push_tag('elseif'); |
|
491 | + if ($_open_tag != 'if' && $_open_tag != 'elseif') { |
|
492 | + $this->_syntax_error('unexpected {elseif}', E_USER_ERROR, __FILE__, __LINE__); |
|
493 | + } |
|
494 | + if ($_open_tag == 'if') { |
|
495 | + $this->_push_tag('elseif'); |
|
496 | + } |
|
489 | 497 | return $this->_compile_if_tag($tag_args, true); |
490 | 498 | |
491 | 499 | case '/if': |
@@ -515,10 +523,11 @@ discard block |
||
515 | 523 | |
516 | 524 | case '/section': |
517 | 525 | $_open_tag = $this->_pop_tag('section'); |
518 | - if ($_open_tag == 'sectionelse') |
|
519 | - return "<?php endif; ?>"; |
|
520 | - else |
|
521 | - return "<?php endfor; endif; ?>"; |
|
526 | + if ($_open_tag == 'sectionelse') { |
|
527 | + return "<?php endif; ?>"; |
|
528 | + } else { |
|
529 | + return "<?php endfor; endif; ?>"; |
|
530 | + } |
|
522 | 531 | |
523 | 532 | case 'foreach': |
524 | 533 | $this->_push_tag('foreach'); |
@@ -531,10 +540,11 @@ discard block |
||
531 | 540 | |
532 | 541 | case '/foreach': |
533 | 542 | $_open_tag = $this->_pop_tag('foreach'); |
534 | - if ($_open_tag == 'foreachelse') |
|
535 | - return "<?php endif; unset(\$_from); ?>"; |
|
536 | - else |
|
537 | - return "<?php endforeach; endif; unset(\$_from); ?>"; |
|
543 | + if ($_open_tag == 'foreachelse') { |
|
544 | + return "<?php endif; unset(\$_from); ?>"; |
|
545 | + } else { |
|
546 | + return "<?php endforeach; endif; unset(\$_from); ?>"; |
|
547 | + } |
|
538 | 548 | break; |
539 | 549 | |
540 | 550 | case 'strip': |
@@ -677,8 +687,9 @@ discard block |
||
677 | 687 | if (substr($tag_command, 0, 1) == '/') { |
678 | 688 | $start_tag = false; |
679 | 689 | $tag_command = substr($tag_command, 1); |
680 | - } else |
|
681 | - $start_tag = true; |
|
690 | + } else { |
|
691 | + $start_tag = true; |
|
692 | + } |
|
682 | 693 | |
683 | 694 | $found = false; |
684 | 695 | $have_function = true; |
@@ -728,10 +739,11 @@ discard block |
||
728 | 739 | */ |
729 | 740 | $this->_add_plugin('block', $tag_command); |
730 | 741 | |
731 | - if ($start_tag) |
|
732 | - $this->_push_tag($tag_command); |
|
733 | - else |
|
734 | - $this->_pop_tag($tag_command); |
|
742 | + if ($start_tag) { |
|
743 | + $this->_push_tag($tag_command); |
|
744 | + } else { |
|
745 | + $this->_pop_tag($tag_command); |
|
746 | + } |
|
735 | 747 | |
736 | 748 | if ($start_tag) { |
737 | 749 | $output = '<?php ' . $this->_push_cacheable_state('block', $tag_command); |
@@ -856,8 +868,9 @@ discard block |
||
856 | 868 | unset($attrs['assign']); |
857 | 869 | continue; |
858 | 870 | } |
859 | - if (is_bool($arg_value)) |
|
860 | - $arg_value = $arg_value ? 'true' : 'false'; |
|
871 | + if (is_bool($arg_value)) { |
|
872 | + $arg_value = $arg_value ? 'true' : 'false'; |
|
873 | + } |
|
861 | 874 | $arg_list[] = "'$arg_name' => $arg_value"; |
862 | 875 | } |
863 | 876 | } |
@@ -948,8 +961,9 @@ discard block |
||
948 | 961 | } |
949 | 962 | |
950 | 963 | foreach ($attrs as $arg_name => $arg_value) { |
951 | - if (is_bool($arg_value)) |
|
952 | - $arg_value = $arg_value ? 'true' : 'false'; |
|
964 | + if (is_bool($arg_value)) { |
|
965 | + $arg_value = $arg_value ? 'true' : 'false'; |
|
966 | + } |
|
953 | 967 | $arg_list[] = "'$arg_name' => $arg_value"; |
954 | 968 | } |
955 | 969 | |
@@ -987,13 +1001,15 @@ discard block |
||
987 | 1001 | $theme_template = $arg_value; |
988 | 1002 | continue; |
989 | 1003 | } |
990 | - if (is_bool($arg_value)) |
|
991 | - $arg_value = $arg_value ? 'true' : 'false'; |
|
1004 | + if (is_bool($arg_value)) { |
|
1005 | + $arg_value = $arg_value ? 'true' : 'false'; |
|
1006 | + } |
|
992 | 1007 | $arg_list[] = "'$arg_name' => $arg_value"; |
993 | 1008 | } |
994 | 1009 | |
995 | - if ( $theme_template == 'true' ) |
|
996 | - $include_file = '"'.SugarThemeRegistry::current()->getTemplate(str_replace(array('"',"'"),'',$include_file)).'"'; |
|
1010 | + if ( $theme_template == 'true' ) { |
|
1011 | + $include_file = '"'.SugarThemeRegistry::current()->getTemplate(str_replace(array('"',"'"),'',$include_file)).'"'; |
|
1012 | + } |
|
997 | 1013 | |
998 | 1014 | $output = '<?php '; |
999 | 1015 | |
@@ -1040,8 +1056,9 @@ discard block |
||
1040 | 1056 | $arg_list = array(); |
1041 | 1057 | foreach($attrs as $arg_name => $arg_value) { |
1042 | 1058 | if($arg_name != 'file' AND $arg_name != 'once' AND $arg_name != 'assign') { |
1043 | - if(is_bool($arg_value)) |
|
1044 | - $arg_value = $arg_value ? 'true' : 'false'; |
|
1059 | + if(is_bool($arg_value)) { |
|
1060 | + $arg_value = $arg_value ? 'true' : 'false'; |
|
1061 | + } |
|
1045 | 1062 | $arg_list[] = "'$arg_name' => $arg_value"; |
1046 | 1063 | } |
1047 | 1064 | } |
@@ -1079,10 +1096,11 @@ discard block |
||
1079 | 1096 | break; |
1080 | 1097 | |
1081 | 1098 | case 'show': |
1082 | - if (is_bool($attr_value)) |
|
1083 | - $show_attr_value = $attr_value ? 'true' : 'false'; |
|
1084 | - else |
|
1085 | - $show_attr_value = "(bool)$attr_value"; |
|
1099 | + if (is_bool($attr_value)) { |
|
1100 | + $show_attr_value = $attr_value ? 'true' : 'false'; |
|
1101 | + } else { |
|
1102 | + $show_attr_value = "(bool)$attr_value"; |
|
1103 | + } |
|
1086 | 1104 | $output .= "{$section_props}['show'] = $show_attr_value;\n"; |
1087 | 1105 | break; |
1088 | 1106 | |
@@ -1105,24 +1123,28 @@ discard block |
||
1105 | 1123 | } |
1106 | 1124 | } |
1107 | 1125 | |
1108 | - if (!isset($attrs['show'])) |
|
1109 | - $output .= "{$section_props}['show'] = true;\n"; |
|
1126 | + if (!isset($attrs['show'])) { |
|
1127 | + $output .= "{$section_props}['show'] = true;\n"; |
|
1128 | + } |
|
1110 | 1129 | |
1111 | - if (!isset($attrs['loop'])) |
|
1112 | - $output .= "{$section_props}['loop'] = 1;\n"; |
|
1130 | + if (!isset($attrs['loop'])) { |
|
1131 | + $output .= "{$section_props}['loop'] = 1;\n"; |
|
1132 | + } |
|
1113 | 1133 | |
1114 | - if (!isset($attrs['max'])) |
|
1115 | - $output .= "{$section_props}['max'] = {$section_props}['loop'];\n"; |
|
1116 | - else |
|
1117 | - $output .= "if ({$section_props}['max'] < 0)\n" . |
|
1134 | + if (!isset($attrs['max'])) { |
|
1135 | + $output .= "{$section_props}['max'] = {$section_props}['loop'];\n"; |
|
1136 | + } else { |
|
1137 | + $output .= "if ({$section_props}['max'] < 0)\n" . |
|
1118 | 1138 | " {$section_props}['max'] = {$section_props}['loop'];\n"; |
1139 | + } |
|
1119 | 1140 | |
1120 | - if (!isset($attrs['step'])) |
|
1121 | - $output .= "{$section_props}['step'] = 1;\n"; |
|
1141 | + if (!isset($attrs['step'])) { |
|
1142 | + $output .= "{$section_props}['step'] = 1;\n"; |
|
1143 | + } |
|
1122 | 1144 | |
1123 | - if (!isset($attrs['start'])) |
|
1124 | - $output .= "{$section_props}['start'] = {$section_props}['step'] > 0 ? 0 : {$section_props}['loop']-1;\n"; |
|
1125 | - else { |
|
1145 | + if (!isset($attrs['start'])) { |
|
1146 | + $output .= "{$section_props}['start'] = {$section_props}['step'] > 0 ? 0 : {$section_props}['loop']-1;\n"; |
|
1147 | + } else { |
|
1126 | 1148 | $output .= "if ({$section_props}['start'] < 0)\n" . |
1127 | 1149 | " {$section_props}['start'] = max({$section_props}['step'] > 0 ? 0 : -1, {$section_props}['loop'] + {$section_props}['start']);\n" . |
1128 | 1150 | "else\n" . |
@@ -1377,8 +1399,9 @@ discard block |
||
1377 | 1399 | $is_arg_start--; |
1378 | 1400 | } |
1379 | 1401 | } |
1380 | - } else |
|
1381 | - $is_arg_start = $i-1; |
|
1402 | + } else { |
|
1403 | + $is_arg_start = $i-1; |
|
1404 | + } |
|
1382 | 1405 | /* Construct the argument for 'is' expression, so it knows |
1383 | 1406 | what to operate on. */ |
1384 | 1407 | $is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start)); |
@@ -1420,10 +1443,11 @@ discard block |
||
1420 | 1443 | } |
1421 | 1444 | } |
1422 | 1445 | |
1423 | - if ($elseif) |
|
1424 | - return '<?php elseif ('.implode(' ', $tokens).'): ?>'; |
|
1425 | - else |
|
1426 | - return '<?php if ('.implode(' ', $tokens).'): ?>'; |
|
1446 | + if ($elseif) { |
|
1447 | + return '<?php elseif ('.implode(' ', $tokens).'): ?>'; |
|
1448 | + } else { |
|
1449 | + return '<?php if ('.implode(' ', $tokens).'): ?>'; |
|
1450 | + } |
|
1427 | 1451 | } |
1428 | 1452 | |
1429 | 1453 | |
@@ -1447,10 +1471,12 @@ discard block |
||
1447 | 1471 | } |
1448 | 1472 | |
1449 | 1473 | foreach ($attrs as $arg_name => $arg_value) { |
1450 | - if (is_bool($arg_value)) |
|
1451 | - $arg_value = $arg_value ? 'true' : 'false'; |
|
1452 | - if (is_null($arg_value)) |
|
1453 | - $arg_value = 'null'; |
|
1474 | + if (is_bool($arg_value)) { |
|
1475 | + $arg_value = $arg_value ? 'true' : 'false'; |
|
1476 | + } |
|
1477 | + if (is_null($arg_value)) { |
|
1478 | + $arg_value = 'null'; |
|
1479 | + } |
|
1454 | 1480 | if ($_cache_attrs && in_array($arg_name, $_cache_attrs)) { |
1455 | 1481 | $arg_list[] = "'$arg_name' => (\$this->_cache_including) ? \$_cache_attrs['$arg_name'] : (\$_cache_attrs['$arg_name']=$arg_value)"; |
1456 | 1482 | } else { |
@@ -1475,8 +1501,9 @@ discard block |
||
1475 | 1501 | if (($first_token = array_shift($tokens)) == 'not') { |
1476 | 1502 | $negate_expr = true; |
1477 | 1503 | $expr_type = array_shift($tokens); |
1478 | - } else |
|
1479 | - $expr_type = $first_token; |
|
1504 | + } else { |
|
1505 | + $expr_type = $first_token; |
|
1506 | + } |
|
1480 | 1507 | |
1481 | 1508 | switch ($expr_type) { |
1482 | 1509 | case 'even': |
@@ -1484,8 +1511,9 @@ discard block |
||
1484 | 1511 | $expr_end++; |
1485 | 1512 | $expr_arg = $tokens[$expr_end++]; |
1486 | 1513 | $expr = "!(1 & ($is_arg / " . $this->_parse_var_props($expr_arg) . "))"; |
1487 | - } else |
|
1488 | - $expr = "!(1 & $is_arg)"; |
|
1514 | + } else { |
|
1515 | + $expr = "!(1 & $is_arg)"; |
|
1516 | + } |
|
1489 | 1517 | break; |
1490 | 1518 | |
1491 | 1519 | case 'odd': |
@@ -1493,8 +1521,9 @@ discard block |
||
1493 | 1521 | $expr_end++; |
1494 | 1522 | $expr_arg = $tokens[$expr_end++]; |
1495 | 1523 | $expr = "(1 & ($is_arg / " . $this->_parse_var_props($expr_arg) . "))"; |
1496 | - } else |
|
1497 | - $expr = "(1 & $is_arg)"; |
|
1524 | + } else { |
|
1525 | + $expr = "(1 & $is_arg)"; |
|
1526 | + } |
|
1498 | 1527 | break; |
1499 | 1528 | |
1500 | 1529 | case 'div': |
@@ -1553,16 +1582,18 @@ discard block |
||
1553 | 1582 | if (preg_match('~^\w+$~', $token)) { |
1554 | 1583 | $attr_name = $token; |
1555 | 1584 | $state = 1; |
1556 | - } else |
|
1557 | - $this->_syntax_error("invalid attribute name: '$token'", E_USER_ERROR, __FILE__, __LINE__); |
|
1585 | + } else { |
|
1586 | + $this->_syntax_error("invalid attribute name: '$token'", E_USER_ERROR, __FILE__, __LINE__); |
|
1587 | + } |
|
1558 | 1588 | break; |
1559 | 1589 | |
1560 | 1590 | case 1: |
1561 | 1591 | /* If the token is '=', then we go to state 2. */ |
1562 | 1592 | if ($token == '=') { |
1563 | 1593 | $state = 2; |
1564 | - } else |
|
1565 | - $this->_syntax_error("expecting '=' after attribute name '$last_token'", E_USER_ERROR, __FILE__, __LINE__); |
|
1594 | + } else { |
|
1595 | + $this->_syntax_error("expecting '=' after attribute name '$last_token'", E_USER_ERROR, __FILE__, __LINE__); |
|
1596 | + } |
|
1566 | 1597 | break; |
1567 | 1598 | |
1568 | 1599 | case 2: |
@@ -1586,8 +1617,9 @@ discard block |
||
1586 | 1617 | |
1587 | 1618 | $attrs[$attr_name] = $token; |
1588 | 1619 | $state = 0; |
1589 | - } else |
|
1590 | - $this->_syntax_error("'=' cannot be an attribute value", E_USER_ERROR, __FILE__, __LINE__); |
|
1620 | + } else { |
|
1621 | + $this->_syntax_error("'=' cannot be an attribute value", E_USER_ERROR, __FILE__, __LINE__); |
|
1622 | + } |
|
1591 | 1623 | break; |
1592 | 1624 | } |
1593 | 1625 | $last_token = $token; |
@@ -1649,32 +1681,27 @@ discard block |
||
1649 | 1681 | $this->_parse_modifiers($return, $match[2]); |
1650 | 1682 | } |
1651 | 1683 | return $return; |
1652 | - } |
|
1653 | - elseif(preg_match('~^' . $this->_num_const_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) { |
|
1684 | + } elseif(preg_match('~^' . $this->_num_const_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) { |
|
1654 | 1685 | // numerical constant |
1655 | 1686 | preg_match('~^(' . $this->_num_const_regexp . ')('. $this->_mod_regexp . '*)$~', $val, $match); |
1656 | 1687 | if($match[2] != '') { |
1657 | 1688 | $this->_parse_modifiers($match[1], $match[2]); |
1658 | 1689 | return $match[1]; |
1659 | 1690 | } |
1660 | - } |
|
1661 | - elseif(preg_match('~^' . $this->_si_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) { |
|
1691 | + } elseif(preg_match('~^' . $this->_si_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) { |
|
1662 | 1692 | // single quoted text |
1663 | 1693 | preg_match('~^(' . $this->_si_qstr_regexp . ')('. $this->_mod_regexp . '*)$~', $val, $match); |
1664 | 1694 | if($match[2] != '') { |
1665 | 1695 | $this->_parse_modifiers($match[1], $match[2]); |
1666 | 1696 | return $match[1]; |
1667 | 1697 | } |
1668 | - } |
|
1669 | - elseif(preg_match('~^' . $this->_cvar_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) { |
|
1698 | + } elseif(preg_match('~^' . $this->_cvar_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) { |
|
1670 | 1699 | // config var |
1671 | 1700 | return $this->_parse_conf_var($val); |
1672 | - } |
|
1673 | - elseif(preg_match('~^' . $this->_svar_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) { |
|
1701 | + } elseif(preg_match('~^' . $this->_svar_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) { |
|
1674 | 1702 | // section var |
1675 | 1703 | return $this->_parse_section_prop($val); |
1676 | - } |
|
1677 | - elseif(!in_array($val, $this->_permitted_tokens) && !is_numeric($val)) { |
|
1704 | + } elseif(!in_array($val, $this->_permitted_tokens) && !is_numeric($val)) { |
|
1678 | 1705 | // literal string |
1679 | 1706 | return $this->_expand_quoted_text('"' . strtr($val, array('\\' => '\\\\', '"' => '\\"')) .'"'); |
1680 | 1707 | } |
@@ -1737,8 +1764,9 @@ discard block |
||
1737 | 1764 | // just output the math operator to php |
1738 | 1765 | $_output .= $_math_var; |
1739 | 1766 | |
1740 | - if(empty($_first_var)) |
|
1741 | - $_first_var = $_complete_var; |
|
1767 | + if(empty($_first_var)) { |
|
1768 | + $_first_var = $_complete_var; |
|
1769 | + } |
|
1742 | 1770 | |
1743 | 1771 | $_complete_var = ""; |
1744 | 1772 | } else { |
@@ -1747,8 +1775,9 @@ discard block |
||
1747 | 1775 | } |
1748 | 1776 | } |
1749 | 1777 | if($_has_math) { |
1750 | - if(!empty($_complete_var) || is_numeric($_complete_var)) |
|
1751 | - $_output .= $this->_parse_var($_complete_var); |
|
1778 | + if(!empty($_complete_var) || is_numeric($_complete_var)) { |
|
1779 | + $_output .= $this->_parse_var($_complete_var); |
|
1780 | + } |
|
1752 | 1781 | |
1753 | 1782 | // get the modifiers working (only the last var from math + modifier is left) |
1754 | 1783 | $var_expr = $_complete_var; |
@@ -1756,10 +1785,11 @@ discard block |
||
1756 | 1785 | } |
1757 | 1786 | |
1758 | 1787 | // prevent cutting of first digit in the number (we _definitly_ got a number if the first char is a digit) |
1759 | - if(is_numeric(substr($var_expr, 0, 1))) |
|
1760 | - $_var_ref = $var_expr; |
|
1761 | - else |
|
1762 | - $_var_ref = substr($var_expr, 1); |
|
1788 | + if(is_numeric(substr($var_expr, 0, 1))) { |
|
1789 | + $_var_ref = $var_expr; |
|
1790 | + } else { |
|
1791 | + $_var_ref = substr($var_expr, 1); |
|
1792 | + } |
|
1763 | 1793 | |
1764 | 1794 | if(!$_has_math) { |
1765 | 1795 | |
@@ -1812,10 +1842,11 @@ discard block |
||
1812 | 1842 | $_output .= "[\$this->_sections['$_var_section']['$_var_section_prop']]"; |
1813 | 1843 | } |
1814 | 1844 | } else if (substr($_index, 0, 1) == '.') { |
1815 | - if (substr($_index, 1, 1) == '$') |
|
1816 | - $_output .= "[\$this->_tpl_vars['" . substr($_index, 2) . "']]"; |
|
1817 | - else |
|
1818 | - $_output .= "['" . substr($_index, 1) . "']"; |
|
1845 | + if (substr($_index, 1, 1) == '$') { |
|
1846 | + $_output .= "[\$this->_tpl_vars['" . substr($_index, 2) . "']]"; |
|
1847 | + } else { |
|
1848 | + $_output .= "['" . substr($_index, 1) . "']"; |
|
1849 | + } |
|
1819 | 1850 | } else if (substr($_index,0,2) == '->') { |
1820 | 1851 | if(substr($_index,2,2) == '__') { |
1821 | 1852 | $this->_syntax_error('call to internal object members is not allowed', E_USER_ERROR, __FILE__, __LINE__); |
@@ -1956,10 +1987,11 @@ discard block |
||
1956 | 1987 | $_modifier_args[0] = '@' . $_modifier_args[0]; |
1957 | 1988 | } |
1958 | 1989 | } |
1959 | - if (count($_modifier_args) > 0) |
|
1960 | - $_modifier_args = ', '.implode(', ', $_modifier_args); |
|
1961 | - else |
|
1962 | - $_modifier_args = ''; |
|
1990 | + if (count($_modifier_args) > 0) { |
|
1991 | + $_modifier_args = ', '.implode(', ', $_modifier_args); |
|
1992 | + } else { |
|
1993 | + $_modifier_args = ''; |
|
1994 | + } |
|
1963 | 1995 | |
1964 | 1996 | if ($_map_array) { |
1965 | 1997 | $output = "((is_array(\$_tmp=$output)) ? \$this->_run_mod_handler('$_modifier_name', true, \$_tmp$_modifier_args) : " . $this->_compile_plugin_call('modifier', $_modifier_name) . "(\$_tmp$_modifier_args))"; |
@@ -2273,8 +2305,12 @@ discard block |
||
2273 | 2305 | function _push_cacheable_state($type, $name) { |
2274 | 2306 | $_cacheable = !isset($this->_plugins[$type][$name]) || $this->_plugins[$type][$name][4]; |
2275 | 2307 | if ($_cacheable |
2276 | - || 0<$this->_cacheable_state++) return ''; |
|
2277 | - if (!isset($this->_cache_serial)) $this->_cache_serial = md5(uniqid('Smarty')); |
|
2308 | + || 0<$this->_cacheable_state++) { |
|
2309 | + return ''; |
|
2310 | + } |
|
2311 | + if (!isset($this->_cache_serial)) { |
|
2312 | + $this->_cache_serial = md5(uniqid('Smarty')); |
|
2313 | + } |
|
2278 | 2314 | $_ret = 'if ($this->caching && !$this->_cache_including): echo \'{nocache:' |
2279 | 2315 | . $this->_cache_serial . '#' . $this->_nocache_count |
2280 | 2316 | . '}\'; endif;'; |
@@ -2291,7 +2327,9 @@ discard block |
||
2291 | 2327 | function _pop_cacheable_state($type, $name) { |
2292 | 2328 | $_cacheable = !isset($this->_plugins[$type][$name]) || $this->_plugins[$type][$name][4]; |
2293 | 2329 | if ($_cacheable |
2294 | - || --$this->_cacheable_state>0) return ''; |
|
2330 | + || --$this->_cacheable_state>0) { |
|
2331 | + return ''; |
|
2332 | + } |
|
2295 | 2333 | return 'if ($this->caching && !$this->_cache_including): echo \'{/nocache:' |
2296 | 2334 | . $this->_cache_serial . '#' . ($this->_nocache_count++) |
2297 | 2335 | . '}\'; endif;'; |
@@ -2357,11 +2395,13 @@ discard block |
||
2357 | 2395 | */ |
2358 | 2396 | function _smarty_sort_length($a, $b) |
2359 | 2397 | { |
2360 | - if($a == $b) |
|
2361 | - return 0; |
|
2398 | + if($a == $b) { |
|
2399 | + return 0; |
|
2400 | + } |
|
2362 | 2401 | |
2363 | - if(strlen($a) == strlen($b)) |
|
2364 | - return ($a > $b) ? -1 : 1; |
|
2402 | + if(strlen($a) == strlen($b)) { |
|
2403 | + return ($a > $b) ? -1 : 1; |
|
2404 | + } |
|
2365 | 2405 | |
2366 | 2406 | return (strlen($a) > strlen($b)) ? -1 : 1; |
2367 | 2407 | } |