@@ -57,33 +57,33 @@ |
||
57 | 57 | global $app_strings; |
58 | 58 | |
59 | 59 | if(isset($params['type']) && $params['type'] == 'php') { |
60 | - if(!isset($params['file'])) { |
|
61 | - $smarty->trigger_error($app_strings['ERR_MISSING_REQUIRED_FIELDS'] . 'include'); |
|
62 | - } |
|
60 | + if(!isset($params['file'])) { |
|
61 | + $smarty->trigger_error($app_strings['ERR_MISSING_REQUIRED_FIELDS'] . 'include'); |
|
62 | + } |
|
63 | 63 | |
64 | - $includeFile = $params['file']; |
|
65 | - if(!file_exists($includeFile)) { |
|
66 | - $smarty->trigger_error($app_strings['ERR_NO_SUCH_FILE'] . ': ' . $includeFile); |
|
67 | - } |
|
64 | + $includeFile = $params['file']; |
|
65 | + if(!file_exists($includeFile)) { |
|
66 | + $smarty->trigger_error($app_strings['ERR_NO_SUCH_FILE'] . ': ' . $includeFile); |
|
67 | + } |
|
68 | 68 | |
69 | - ob_start(); |
|
70 | - require($includeFile); |
|
71 | - $output_html = ob_get_contents(); |
|
72 | - ob_end_clean(); |
|
73 | - echo $output_html; |
|
69 | + ob_start(); |
|
70 | + require($includeFile); |
|
71 | + $output_html = ob_get_contents(); |
|
72 | + ob_end_clean(); |
|
73 | + echo $output_html; |
|
74 | 74 | } else if(is_array($params['include'])) { |
75 | - $code = ''; |
|
76 | - foreach($params['include'] as $include) { |
|
77 | - if(isset($include['file'])) { |
|
78 | - $file = $include['file']; |
|
79 | - if(preg_match('/[\.]js$/si',$file)) { |
|
80 | - $code .= "<script src=\"". getJSPath($include['file']) ."\"></script>"; |
|
81 | - } else if(preg_match('/[\.]php$/si', $file)) { |
|
82 | - require_once($file); |
|
83 | - } |
|
84 | - } |
|
85 | - } //foreach |
|
86 | - return $code; |
|
87 | - } //if |
|
75 | + $code = ''; |
|
76 | + foreach($params['include'] as $include) { |
|
77 | + if(isset($include['file'])) { |
|
78 | + $file = $include['file']; |
|
79 | + if(preg_match('/[\.]js$/si',$file)) { |
|
80 | + $code .= "<script src=\"". getJSPath($include['file']) ."\"></script>"; |
|
81 | + } else if(preg_match('/[\.]php$/si', $file)) { |
|
82 | + require_once($file); |
|
83 | + } |
|
84 | + } |
|
85 | + } //foreach |
|
86 | + return $code; |
|
87 | + } //if |
|
88 | 88 | } |
89 | 89 | ?> |
90 | 90 | \ No newline at end of file |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | { |
57 | 57 | global $app_strings; |
58 | 58 | |
59 | - if(isset($params['type']) && $params['type'] == 'php') { |
|
60 | - if(!isset($params['file'])) { |
|
61 | - $smarty->trigger_error($app_strings['ERR_MISSING_REQUIRED_FIELDS'] . 'include'); |
|
59 | + if (isset($params['type']) && $params['type'] == 'php') { |
|
60 | + if (!isset($params['file'])) { |
|
61 | + $smarty->trigger_error($app_strings['ERR_MISSING_REQUIRED_FIELDS'].'include'); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | $includeFile = $params['file']; |
65 | - if(!file_exists($includeFile)) { |
|
66 | - $smarty->trigger_error($app_strings['ERR_NO_SUCH_FILE'] . ': ' . $includeFile); |
|
65 | + if (!file_exists($includeFile)) { |
|
66 | + $smarty->trigger_error($app_strings['ERR_NO_SUCH_FILE'].': '.$includeFile); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | ob_start(); |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | $output_html = ob_get_contents(); |
72 | 72 | ob_end_clean(); |
73 | 73 | echo $output_html; |
74 | - } else if(is_array($params['include'])) { |
|
74 | + } else if (is_array($params['include'])) { |
|
75 | 75 | $code = ''; |
76 | - foreach($params['include'] as $include) { |
|
77 | - if(isset($include['file'])) { |
|
76 | + foreach ($params['include'] as $include) { |
|
77 | + if (isset($include['file'])) { |
|
78 | 78 | $file = $include['file']; |
79 | - if(preg_match('/[\.]js$/si',$file)) { |
|
80 | - $code .= "<script src=\"". getJSPath($include['file']) ."\"></script>"; |
|
81 | - } else if(preg_match('/[\.]php$/si', $file)) { |
|
79 | + if (preg_match('/[\.]js$/si', $file)) { |
|
80 | + $code .= "<script src=\"".getJSPath($include['file'])."\"></script>"; |
|
81 | + } else if (preg_match('/[\.]php$/si', $file)) { |
|
82 | 82 | require_once($file); |
83 | 83 | } |
84 | 84 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | |
131 | 131 | // matches all valid variables (no quotes, no modifiers) |
132 | 132 | $this->_avar_regexp = '(?:' . $this->_dvar_regexp . '|' |
133 | - . $this->_cvar_regexp . '|' . $this->_svar_regexp . ')'; |
|
133 | + . $this->_cvar_regexp . '|' . $this->_svar_regexp . ')'; |
|
134 | 134 | |
135 | 135 | // matches valid variable syntax: |
136 | 136 | // $foo |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | // |foo|bar |
173 | 173 | // |foo:$foo->bar |
174 | 174 | $this->_mod_regexp = '(?:\|@?\w+(?::(?:\w+|' . $this->_num_const_regexp . '|' |
175 | - . $this->_obj_call_regexp . '|' . $this->_avar_regexp . '|' . $this->_qstr_regexp .'))*)'; |
|
175 | + . $this->_obj_call_regexp . '|' . $this->_avar_regexp . '|' . $this->_qstr_regexp .'))*)'; |
|
176 | 176 | |
177 | 177 | // matches valid function name: |
178 | 178 | // foo123 |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | // "text"|bar |
194 | 194 | // $foo->bar |
195 | 195 | $this->_param_regexp = '(?:\s*(?:' . $this->_obj_call_regexp . '|' |
196 | - . $this->_var_regexp . '|' . $this->_num_const_regexp . '|\w+)(?>' . $this->_mod_regexp . '*)\s*)'; |
|
196 | + . $this->_var_regexp . '|' . $this->_num_const_regexp . '|\w+)(?>' . $this->_mod_regexp . '*)\s*)'; |
|
197 | 197 | |
198 | 198 | // matches valid parenthesised function parameters: |
199 | 199 | // |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | // _foo_bar($foo,"bar") |
211 | 211 | // foo123($foo,$foo->bar(),"foo") |
212 | 212 | $this->_func_call_regexp = '(?:' . $this->_func_regexp . '\s*(?:' |
213 | - . $this->_parenth_param_regexp . '))'; |
|
213 | + . $this->_parenth_param_regexp . '))'; |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
@@ -263,11 +263,11 @@ discard block |
||
263 | 263 | |
264 | 264 | /* replace special blocks by "{php}" */ |
265 | 265 | $source_content = preg_replace_callback($search, create_function ('$matches', "return '" |
266 | - . $this->_quote_replace($this->left_delimiter) . 'php' |
|
267 | - . "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'" |
|
268 | - . $this->_quote_replace($this->right_delimiter) |
|
269 | - . "';") |
|
270 | - , $source_content); |
|
266 | + . $this->_quote_replace($this->left_delimiter) . 'php' |
|
267 | + . "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'" |
|
268 | + . $this->_quote_replace($this->right_delimiter) |
|
269 | + . "';") |
|
270 | + , $source_content); |
|
271 | 271 | |
272 | 272 | /* Gather all template tags. */ |
273 | 273 | preg_match_all("~{$ldq}\s*(.*?)\s*{$rdq}~s", $source_content, $_match); |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | if ($postfilter === false) continue; |
389 | 389 | if ($postfilter[3] || is_callable($postfilter[0])) { |
390 | 390 | $compiled_content = call_user_func_array($postfilter[0], |
391 | - array($compiled_content, &$this)); |
|
391 | + array($compiled_content, &$this)); |
|
392 | 392 | $this->_plugins['postfilter'][$filter_name][3] = true; |
393 | 393 | } else { |
394 | 394 | $this->_trigger_fatal_error("Smarty plugin error: postfilter '$filter_name' is not implemented"); |
@@ -649,8 +649,8 @@ discard block |
||
649 | 649 | $output = call_user_func_array($plugin_func, array($tag_args, &$this)); |
650 | 650 | if($output != '') { |
651 | 651 | $output = '<?php ' . $this->_push_cacheable_state('compiler', $tag_command) |
652 | - . $output |
|
653 | - . $this->_pop_cacheable_state('compiler', $tag_command) . ' ?>'; |
|
652 | + . $output |
|
653 | + . $this->_pop_cacheable_state('compiler', $tag_command) . ' ?>'; |
|
654 | 654 | } |
655 | 655 | } else { |
656 | 656 | $this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__); |
@@ -1115,7 +1115,7 @@ discard block |
||
1115 | 1115 | $output .= "{$section_props}['max'] = {$section_props}['loop'];\n"; |
1116 | 1116 | else |
1117 | 1117 | $output .= "if ({$section_props}['max'] < 0)\n" . |
1118 | - " {$section_props}['max'] = {$section_props}['loop'];\n"; |
|
1118 | + " {$section_props}['max'] = {$section_props}['loop'];\n"; |
|
1119 | 1119 | |
1120 | 1120 | if (!isset($attrs['step'])) |
1121 | 1121 | $output .= "{$section_props}['step'] = 1;\n"; |
@@ -1124,9 +1124,9 @@ discard block |
||
1124 | 1124 | $output .= "{$section_props}['start'] = {$section_props}['step'] > 0 ? 0 : {$section_props}['loop']-1;\n"; |
1125 | 1125 | else { |
1126 | 1126 | $output .= "if ({$section_props}['start'] < 0)\n" . |
1127 | - " {$section_props}['start'] = max({$section_props}['step'] > 0 ? 0 : -1, {$section_props}['loop'] + {$section_props}['start']);\n" . |
|
1128 | - "else\n" . |
|
1129 | - " {$section_props}['start'] = min({$section_props}['start'], {$section_props}['step'] > 0 ? {$section_props}['loop'] : {$section_props}['loop']-1);\n"; |
|
1127 | + " {$section_props}['start'] = max({$section_props}['step'] > 0 ? 0 : -1, {$section_props}['loop'] + {$section_props}['start']);\n" . |
|
1128 | + "else\n" . |
|
1129 | + " {$section_props}['start'] = min({$section_props}['start'], {$section_props}['step'] > 0 ? {$section_props}['loop'] : {$section_props}['loop']-1);\n"; |
|
1130 | 1130 | } |
1131 | 1131 | |
1132 | 1132 | $output .= "if ({$section_props}['show']) {\n"; |
@@ -1136,9 +1136,9 @@ discard block |
||
1136 | 1136 | $output .= " {$section_props}['total'] = min(ceil(({$section_props}['step'] > 0 ? {$section_props}['loop'] - {$section_props}['start'] : {$section_props}['start']+1)/abs({$section_props}['step'])), {$section_props}['max']);\n"; |
1137 | 1137 | } |
1138 | 1138 | $output .= " if ({$section_props}['total'] == 0)\n" . |
1139 | - " {$section_props}['show'] = false;\n" . |
|
1140 | - "} else\n" . |
|
1141 | - " {$section_props}['total'] = 0;\n"; |
|
1139 | + " {$section_props}['show'] = false;\n" . |
|
1140 | + "} else\n" . |
|
1141 | + " {$section_props}['total'] = 0;\n"; |
|
1142 | 1142 | |
1143 | 1143 | $output .= "if ({$section_props}['show']):\n"; |
1144 | 1144 | $output .= " |
@@ -1987,8 +1987,8 @@ discard block |
||
1987 | 1987 | } |
1988 | 1988 | if (!isset($this->_plugin_info[$type][$name])) { |
1989 | 1989 | $this->_plugin_info[$type][$name] = array($this->_current_file, |
1990 | - $this->_current_line_no, |
|
1991 | - $delayed_loading); |
|
1990 | + $this->_current_line_no, |
|
1991 | + $delayed_loading); |
|
1992 | 1992 | } |
1993 | 1993 | } |
1994 | 1994 | |
@@ -2056,7 +2056,7 @@ discard block |
||
2056 | 2056 | case 'get': |
2057 | 2057 | if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) { |
2058 | 2058 | $this->_syntax_error("(secure mode) super global access not permitted", |
2059 | - E_USER_WARNING, __FILE__, __LINE__); |
|
2059 | + E_USER_WARNING, __FILE__, __LINE__); |
|
2060 | 2060 | return; |
2061 | 2061 | } |
2062 | 2062 | $compiled_ref = "\$_GET"; |
@@ -2065,7 +2065,7 @@ discard block |
||
2065 | 2065 | case 'post': |
2066 | 2066 | if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) { |
2067 | 2067 | $this->_syntax_error("(secure mode) super global access not permitted", |
2068 | - E_USER_WARNING, __FILE__, __LINE__); |
|
2068 | + E_USER_WARNING, __FILE__, __LINE__); |
|
2069 | 2069 | return; |
2070 | 2070 | } |
2071 | 2071 | $compiled_ref = "\$_POST"; |
@@ -2074,7 +2074,7 @@ discard block |
||
2074 | 2074 | case 'cookies': |
2075 | 2075 | if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) { |
2076 | 2076 | $this->_syntax_error("(secure mode) super global access not permitted", |
2077 | - E_USER_WARNING, __FILE__, __LINE__); |
|
2077 | + E_USER_WARNING, __FILE__, __LINE__); |
|
2078 | 2078 | return; |
2079 | 2079 | } |
2080 | 2080 | $compiled_ref = "\$_COOKIE"; |
@@ -2083,7 +2083,7 @@ discard block |
||
2083 | 2083 | case 'env': |
2084 | 2084 | if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) { |
2085 | 2085 | $this->_syntax_error("(secure mode) super global access not permitted", |
2086 | - E_USER_WARNING, __FILE__, __LINE__); |
|
2086 | + E_USER_WARNING, __FILE__, __LINE__); |
|
2087 | 2087 | return; |
2088 | 2088 | } |
2089 | 2089 | $compiled_ref = "\$_ENV"; |
@@ -2092,7 +2092,7 @@ discard block |
||
2092 | 2092 | case 'server': |
2093 | 2093 | if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) { |
2094 | 2094 | $this->_syntax_error("(secure mode) super global access not permitted", |
2095 | - E_USER_WARNING, __FILE__, __LINE__); |
|
2095 | + E_USER_WARNING, __FILE__, __LINE__); |
|
2096 | 2096 | return; |
2097 | 2097 | } |
2098 | 2098 | $compiled_ref = "\$_SERVER"; |
@@ -2101,7 +2101,7 @@ discard block |
||
2101 | 2101 | case 'session': |
2102 | 2102 | if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) { |
2103 | 2103 | $this->_syntax_error("(secure mode) super global access not permitted", |
2104 | - E_USER_WARNING, __FILE__, __LINE__); |
|
2104 | + E_USER_WARNING, __FILE__, __LINE__); |
|
2105 | 2105 | return; |
2106 | 2106 | } |
2107 | 2107 | $compiled_ref = "\$_SESSION"; |
@@ -2114,7 +2114,7 @@ discard block |
||
2114 | 2114 | case 'request': |
2115 | 2115 | if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) { |
2116 | 2116 | $this->_syntax_error("(secure mode) super global access not permitted", |
2117 | - E_USER_WARNING, __FILE__, __LINE__); |
|
2117 | + E_USER_WARNING, __FILE__, __LINE__); |
|
2118 | 2118 | return; |
2119 | 2119 | } |
2120 | 2120 | if ($this->request_use_auto_globals) { |
@@ -2141,7 +2141,7 @@ discard block |
||
2141 | 2141 | case 'const': |
2142 | 2142 | if ($this->security && !$this->security_settings['ALLOW_CONSTANTS']) { |
2143 | 2143 | $this->_syntax_error("(secure mode) constants not permitted", |
2144 | - E_USER_WARNING, __FILE__, __LINE__); |
|
2144 | + E_USER_WARNING, __FILE__, __LINE__); |
|
2145 | 2145 | return; |
2146 | 2146 | } |
2147 | 2147 | array_shift($indexes); |
@@ -2197,7 +2197,7 @@ discard block |
||
2197 | 2197 | return ((is_object($this->_plugins[$type][$name][0][0])) ? |
2198 | 2198 | "\$this->_plugins['$type']['$name'][0][0]->" /* method callback */ |
2199 | 2199 | : (string)($this->_plugins[$type][$name][0][0]).'::' /* class callback */ |
2200 | - ). $this->_plugins[$type][$name][0][1]; |
|
2200 | + ). $this->_plugins[$type][$name][0][1]; |
|
2201 | 2201 | |
2202 | 2202 | } else { |
2203 | 2203 | /* function callback */ |
@@ -2342,7 +2342,7 @@ discard block |
||
2342 | 2342 | $message = " expected {/$_open_tag} (opened line $_line_no)."; |
2343 | 2343 | } |
2344 | 2344 | $this->_syntax_error("mismatched tag {/$close_tag}.$message", |
2345 | - E_USER_ERROR, __FILE__, __LINE__); |
|
2345 | + E_USER_ERROR, __FILE__, __LINE__); |
|
2346 | 2346 | } |
2347 | 2347 | |
2348 | 2348 | } |
@@ -38,41 +38,41 @@ discard block |
||
38 | 38 | /**#@+ |
39 | 39 | * @access private |
40 | 40 | */ |
41 | - var $_folded_blocks = array(); // keeps folded template blocks |
|
42 | - var $_current_file = null; // the current template being compiled |
|
43 | - var $_current_line_no = 1; // line number for error messages |
|
44 | - var $_capture_stack = array(); // keeps track of nested capture buffers |
|
45 | - var $_plugin_info = array(); // keeps track of plugins to load |
|
46 | - var $_init_smarty_vars = false; |
|
47 | - var $_permitted_tokens = array('true','false','yes','no','on','off','null'); |
|
48 | - var $_db_qstr_regexp = null; // regexps are setup in the constructor |
|
49 | - var $_si_qstr_regexp = null; |
|
50 | - var $_qstr_regexp = null; |
|
51 | - var $_func_regexp = null; |
|
52 | - var $_reg_obj_regexp = null; |
|
53 | - var $_var_bracket_regexp = null; |
|
54 | - var $_num_const_regexp = null; |
|
55 | - var $_dvar_guts_regexp = null; |
|
56 | - var $_dvar_regexp = null; |
|
57 | - var $_cvar_regexp = null; |
|
58 | - var $_svar_regexp = null; |
|
59 | - var $_avar_regexp = null; |
|
60 | - var $_mod_regexp = null; |
|
61 | - var $_var_regexp = null; |
|
62 | - var $_parenth_param_regexp = null; |
|
63 | - var $_func_call_regexp = null; |
|
64 | - var $_obj_ext_regexp = null; |
|
65 | - var $_obj_start_regexp = null; |
|
66 | - var $_obj_params_regexp = null; |
|
67 | - var $_obj_call_regexp = null; |
|
68 | - var $_cacheable_state = 0; |
|
69 | - var $_cache_attrs_count = 0; |
|
70 | - var $_nocache_count = 0; |
|
71 | - var $_cache_serial = null; |
|
72 | - var $_cache_include = null; |
|
73 | - |
|
74 | - var $_strip_depth = 0; |
|
75 | - var $_additional_newline = "\n"; |
|
41 | + var $_folded_blocks = array(); // keeps folded template blocks |
|
42 | + var $_current_file = null; // the current template being compiled |
|
43 | + var $_current_line_no = 1; // line number for error messages |
|
44 | + var $_capture_stack = array(); // keeps track of nested capture buffers |
|
45 | + var $_plugin_info = array(); // keeps track of plugins to load |
|
46 | + var $_init_smarty_vars = false; |
|
47 | + var $_permitted_tokens = array('true', 'false', 'yes', 'no', 'on', 'off', 'null'); |
|
48 | + var $_db_qstr_regexp = null; // regexps are setup in the constructor |
|
49 | + var $_si_qstr_regexp = null; |
|
50 | + var $_qstr_regexp = null; |
|
51 | + var $_func_regexp = null; |
|
52 | + var $_reg_obj_regexp = null; |
|
53 | + var $_var_bracket_regexp = null; |
|
54 | + var $_num_const_regexp = null; |
|
55 | + var $_dvar_guts_regexp = null; |
|
56 | + var $_dvar_regexp = null; |
|
57 | + var $_cvar_regexp = null; |
|
58 | + var $_svar_regexp = null; |
|
59 | + var $_avar_regexp = null; |
|
60 | + var $_mod_regexp = null; |
|
61 | + var $_var_regexp = null; |
|
62 | + var $_parenth_param_regexp = null; |
|
63 | + var $_func_call_regexp = null; |
|
64 | + var $_obj_ext_regexp = null; |
|
65 | + var $_obj_start_regexp = null; |
|
66 | + var $_obj_params_regexp = null; |
|
67 | + var $_obj_call_regexp = null; |
|
68 | + var $_cacheable_state = 0; |
|
69 | + var $_cache_attrs_count = 0; |
|
70 | + var $_nocache_count = 0; |
|
71 | + var $_cache_serial = null; |
|
72 | + var $_cache_include = null; |
|
73 | + |
|
74 | + var $_strip_depth = 0; |
|
75 | + var $_additional_newline = "\n"; |
|
76 | 76 | |
77 | 77 | /**#@-*/ |
78 | 78 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $this->_si_qstr_regexp = '\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\''; |
92 | 92 | |
93 | 93 | // matches single or double quoted strings |
94 | - $this->_qstr_regexp = '(?:' . $this->_db_qstr_regexp . '|' . $this->_si_qstr_regexp . ')'; |
|
94 | + $this->_qstr_regexp = '(?:'.$this->_db_qstr_regexp.'|'.$this->_si_qstr_regexp.')'; |
|
95 | 95 | |
96 | 96 | // matches bracket portion of vars |
97 | 97 | // [0] |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | // $foo[5].bar[$foobar][4] |
116 | 116 | $this->_dvar_math_regexp = '(?:[\+\*\/\%]|(?:-(?!>)))'; |
117 | 117 | $this->_dvar_math_var_regexp = '[\$\w\.\+\-\*\/\%\d\>\[\]]'; |
118 | - $this->_dvar_guts_regexp = '\w+(?:' . $this->_var_bracket_regexp |
|
119 | - . ')*(?:\.\$?\w+(?:' . $this->_var_bracket_regexp . ')*)*(?:' . $this->_dvar_math_regexp . '(?:' . $this->_num_const_regexp . '|' . $this->_dvar_math_var_regexp . ')*)?'; |
|
120 | - $this->_dvar_regexp = '\$' . $this->_dvar_guts_regexp; |
|
118 | + $this->_dvar_guts_regexp = '\w+(?:'.$this->_var_bracket_regexp |
|
119 | + . ')*(?:\.\$?\w+(?:'.$this->_var_bracket_regexp.')*)*(?:'.$this->_dvar_math_regexp.'(?:'.$this->_num_const_regexp.'|'.$this->_dvar_math_var_regexp.')*)?'; |
|
120 | + $this->_dvar_regexp = '\$'.$this->_dvar_guts_regexp; |
|
121 | 121 | |
122 | 122 | // matches config vars: |
123 | 123 | // #foo# |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | $this->_svar_regexp = '\%\w+\.\w+\%'; |
130 | 130 | |
131 | 131 | // matches all valid variables (no quotes, no modifiers) |
132 | - $this->_avar_regexp = '(?:' . $this->_dvar_regexp . '|' |
|
133 | - . $this->_cvar_regexp . '|' . $this->_svar_regexp . ')'; |
|
132 | + $this->_avar_regexp = '(?:'.$this->_dvar_regexp.'|' |
|
133 | + . $this->_cvar_regexp.'|'.$this->_svar_regexp.')'; |
|
134 | 134 | |
135 | 135 | // matches valid variable syntax: |
136 | 136 | // $foo |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | // #foo# |
140 | 140 | // "text" |
141 | 141 | // "text" |
142 | - $this->_var_regexp = '(?:' . $this->_avar_regexp . '|' . $this->_qstr_regexp . ')'; |
|
142 | + $this->_var_regexp = '(?:'.$this->_avar_regexp.'|'.$this->_qstr_regexp.')'; |
|
143 | 143 | |
144 | 144 | // matches valid object call (one level of object nesting allowed in parameters): |
145 | 145 | // $foo->bar |
@@ -152,16 +152,16 @@ discard block |
||
152 | 152 | // $foo->bar($foo->bar) |
153 | 153 | // $foo->bar($foo->bar()) |
154 | 154 | // $foo->bar($foo->bar($blah,$foo,44,"foo",$foo[0].bar)) |
155 | - $this->_obj_ext_regexp = '\->(?:\$?' . $this->_dvar_guts_regexp . ')'; |
|
155 | + $this->_obj_ext_regexp = '\->(?:\$?'.$this->_dvar_guts_regexp.')'; |
|
156 | 156 | $this->_obj_restricted_param_regexp = '(?:' |
157 | - . '(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . ')(?:' . $this->_obj_ext_regexp . '(?:\((?:(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . ')' |
|
158 | - . '(?:\s*,\s*(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . '))*)?\))?)*)'; |
|
159 | - $this->_obj_single_param_regexp = '(?:\w+|' . $this->_obj_restricted_param_regexp . '(?:\s*,\s*(?:(?:\w+|' |
|
160 | - . $this->_var_regexp . $this->_obj_restricted_param_regexp . ')))*)'; |
|
161 | - $this->_obj_params_regexp = '\((?:' . $this->_obj_single_param_regexp |
|
162 | - . '(?:\s*,\s*' . $this->_obj_single_param_regexp . ')*)?\)'; |
|
163 | - $this->_obj_start_regexp = '(?:' . $this->_dvar_regexp . '(?:' . $this->_obj_ext_regexp . ')+)'; |
|
164 | - $this->_obj_call_regexp = '(?:' . $this->_obj_start_regexp . '(?:' . $this->_obj_params_regexp . ')?(?:' . $this->_dvar_math_regexp . '(?:' . $this->_num_const_regexp . '|' . $this->_dvar_math_var_regexp . ')*)?)'; |
|
157 | + . '(?:'.$this->_var_regexp.'|'.$this->_num_const_regexp.')(?:'.$this->_obj_ext_regexp.'(?:\((?:(?:'.$this->_var_regexp.'|'.$this->_num_const_regexp.')' |
|
158 | + . '(?:\s*,\s*(?:'.$this->_var_regexp.'|'.$this->_num_const_regexp.'))*)?\))?)*)'; |
|
159 | + $this->_obj_single_param_regexp = '(?:\w+|'.$this->_obj_restricted_param_regexp.'(?:\s*,\s*(?:(?:\w+|' |
|
160 | + . $this->_var_regexp.$this->_obj_restricted_param_regexp.')))*)'; |
|
161 | + $this->_obj_params_regexp = '\((?:'.$this->_obj_single_param_regexp |
|
162 | + . '(?:\s*,\s*'.$this->_obj_single_param_regexp.')*)?\)'; |
|
163 | + $this->_obj_start_regexp = '(?:'.$this->_dvar_regexp.'(?:'.$this->_obj_ext_regexp.')+)'; |
|
164 | + $this->_obj_call_regexp = '(?:'.$this->_obj_start_regexp.'(?:'.$this->_obj_params_regexp.')?(?:'.$this->_dvar_math_regexp.'(?:'.$this->_num_const_regexp.'|'.$this->_dvar_math_var_regexp.')*)?)'; |
|
165 | 165 | |
166 | 166 | // matches valid modifier syntax: |
167 | 167 | // |foo |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | // |foo:"bar":$foobar |
172 | 172 | // |foo|bar |
173 | 173 | // |foo:$foo->bar |
174 | - $this->_mod_regexp = '(?:\|@?\w+(?::(?:\w+|' . $this->_num_const_regexp . '|' |
|
175 | - . $this->_obj_call_regexp . '|' . $this->_avar_regexp . '|' . $this->_qstr_regexp .'))*)'; |
|
174 | + $this->_mod_regexp = '(?:\|@?\w+(?::(?:\w+|'.$this->_num_const_regexp.'|' |
|
175 | + . $this->_obj_call_regexp.'|'.$this->_avar_regexp.'|'.$this->_qstr_regexp.'))*)'; |
|
176 | 176 | |
177 | 177 | // matches valid function name: |
178 | 178 | // foo123 |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | // "text" |
193 | 193 | // "text"|bar |
194 | 194 | // $foo->bar |
195 | - $this->_param_regexp = '(?:\s*(?:' . $this->_obj_call_regexp . '|' |
|
196 | - . $this->_var_regexp . '|' . $this->_num_const_regexp . '|\w+)(?>' . $this->_mod_regexp . '*)\s*)'; |
|
195 | + $this->_param_regexp = '(?:\s*(?:'.$this->_obj_call_regexp.'|' |
|
196 | + . $this->_var_regexp.'|'.$this->_num_const_regexp.'|\w+)(?>'.$this->_mod_regexp.'*)\s*)'; |
|
197 | 197 | |
198 | 198 | // matches valid parenthesised function parameters: |
199 | 199 | // |
@@ -201,16 +201,16 @@ discard block |
||
201 | 201 | // $foo, $bar, "text" |
202 | 202 | // $foo|bar, "foo"|bar, $foo->bar($foo)|bar |
203 | 203 | $this->_parenth_param_regexp = '(?:\((?:\w+|' |
204 | - . $this->_param_regexp . '(?:\s*,\s*(?:(?:\w+|' |
|
205 | - . $this->_param_regexp . ')))*)?\))'; |
|
204 | + . $this->_param_regexp.'(?:\s*,\s*(?:(?:\w+|' |
|
205 | + . $this->_param_regexp.')))*)?\))'; |
|
206 | 206 | |
207 | 207 | // matches valid function call: |
208 | 208 | // foo() |
209 | 209 | // foo_bar($foo) |
210 | 210 | // _foo_bar($foo,"bar") |
211 | 211 | // foo123($foo,$foo->bar(),"foo") |
212 | - $this->_func_call_regexp = '(?:' . $this->_func_regexp . '\s*(?:' |
|
213 | - . $this->_parenth_param_regexp . '))'; |
|
212 | + $this->_func_call_regexp = '(?:'.$this->_func_regexp.'\s*(?:' |
|
213 | + . $this->_parenth_param_regexp.'))'; |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
@@ -257,13 +257,13 @@ discard block |
||
257 | 257 | /* fetch all special blocks */ |
258 | 258 | $search = "~{$ldq}\*(.*?)\*{$rdq}|{$ldq}\s*literal\s*{$rdq}(.*?){$ldq}\s*/literal\s*{$rdq}|{$ldq}\s*php\s*{$rdq}(.*?){$ldq}\s*/php\s*{$rdq}~s"; |
259 | 259 | |
260 | - preg_match_all($search, $source_content, $match, PREG_SET_ORDER); |
|
260 | + preg_match_all($search, $source_content, $match, PREG_SET_ORDER); |
|
261 | 261 | $this->_folded_blocks = $match; |
262 | 262 | reset($this->_folded_blocks); |
263 | 263 | |
264 | 264 | /* replace special blocks by "{php}" */ |
265 | - $source_content = preg_replace_callback($search, create_function ('$matches', "return '" |
|
266 | - . $this->_quote_replace($this->left_delimiter) . 'php' |
|
265 | + $source_content = preg_replace_callback($search, create_function('$matches', "return '" |
|
266 | + . $this->_quote_replace($this->left_delimiter).'php' |
|
267 | 267 | . "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'" |
268 | 268 | . $this->_quote_replace($this->right_delimiter) |
269 | 269 | . "';") |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | $sp_match[1] = array_unique($sp_match[1]); |
284 | 284 | usort($sp_match[1], '_smarty_sort_length'); |
285 | 285 | for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp < $for_max2; $curr_sp++) { |
286 | - $text_blocks[$curr_tb] = str_replace($sp_match[1][$curr_sp],'%%%SMARTYSP'.$curr_sp.'%%%',$text_blocks[$curr_tb]); |
|
286 | + $text_blocks[$curr_tb] = str_replace($sp_match[1][$curr_sp], '%%%SMARTYSP'.$curr_sp.'%%%', $text_blocks[$curr_tb]); |
|
287 | 287 | } |
288 | 288 | /* process each one */ |
289 | 289 | for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp < $for_max2; $curr_sp++) { |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | $compiled_tags[] = $this->_compile_tag($template_tags[$i]); |
313 | 313 | $this->_current_line_no += substr_count($template_tags[$i], "\n"); |
314 | 314 | } |
315 | - if (count($this->_tag_stack)>0) { |
|
315 | + if (count($this->_tag_stack) > 0) { |
|
316 | 316 | list($_open_tag, $_line_no) = end($this->_tag_stack); |
317 | 317 | $this->_syntax_error("unclosed tag \{$_open_tag} (opened line $_line_no).", E_USER_ERROR, __FILE__, __LINE__); |
318 | 318 | return; |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | /* remove trailing whitespaces from the last text_block */ |
338 | 338 | $text_blocks[$j] = rtrim($text_blocks[$j]); |
339 | 339 | } |
340 | - $text_blocks[$j] = "<?php echo '" . strtr($text_blocks[$j], array("'"=>"\'", "\\"=>"\\\\")) . "'; ?>"; |
|
340 | + $text_blocks[$j] = "<?php echo '".strtr($text_blocks[$j], array("'"=>"\'", "\\"=>"\\\\"))."'; ?>"; |
|
341 | 341 | if ($compiled_tags[$j] == '{/strip}') { |
342 | 342 | $compiled_tags[$j] = "\n"; /* slurped by php, but necessary |
343 | 343 | if a newline is following the closing strip-tag */ |
@@ -350,19 +350,19 @@ discard block |
||
350 | 350 | } |
351 | 351 | $compiled_content = ''; |
352 | 352 | |
353 | - $tag_guard = '%%%SMARTYOTG' . md5(uniqid(rand(), true)) . '%%%'; |
|
353 | + $tag_guard = '%%%SMARTYOTG'.md5(uniqid(rand(), true)).'%%%'; |
|
354 | 354 | |
355 | 355 | /* Interleave the compiled contents and text blocks to get the final result. */ |
356 | 356 | for ($i = 0, $for_max = count($compiled_tags); $i < $for_max; $i++) { |
357 | 357 | if ($compiled_tags[$i] == '') { |
358 | 358 | // tag result empty, remove first newline from following text block |
359 | - $text_blocks[$i+1] = preg_replace('~^(\r\n|\r|\n)~', '', $text_blocks[$i+1]); |
|
359 | + $text_blocks[$i + 1] = preg_replace('~^(\r\n|\r|\n)~', '', $text_blocks[$i + 1]); |
|
360 | 360 | } |
361 | 361 | // replace legit PHP tags with placeholder |
362 | 362 | $text_blocks[$i] = str_replace('<?', $tag_guard, $text_blocks[$i]); |
363 | 363 | $compiled_tags[$i] = str_replace('<?', $tag_guard, $compiled_tags[$i]); |
364 | 364 | |
365 | - $compiled_content .= $text_blocks[$i] . $compiled_tags[$i]; |
|
365 | + $compiled_content .= $text_blocks[$i].$compiled_tags[$i]; |
|
366 | 366 | } |
367 | 367 | $compiled_content .= str_replace('<?', $tag_guard, $text_blocks[$i]); |
368 | 368 | |
@@ -374,12 +374,12 @@ discard block |
||
374 | 374 | $compiled_content = str_replace($tag_guard, '<?', $compiled_content); |
375 | 375 | |
376 | 376 | // remove \n from the end of the file, if any |
377 | - if (strlen($compiled_content) && (substr($compiled_content, -1) == "\n") ) { |
|
377 | + if (strlen($compiled_content) && (substr($compiled_content, -1) == "\n")) { |
|
378 | 378 | $compiled_content = substr($compiled_content, 0, -1); |
379 | 379 | } |
380 | 380 | |
381 | 381 | if (!empty($this->_cache_serial)) { |
382 | - $compiled_content = "<?php \$this->_cache_serials['".$this->_cache_include."'] = '".$this->_cache_serial."'; ?>" . $compiled_content; |
|
382 | + $compiled_content = "<?php \$this->_cache_serials['".$this->_cache_include."'] = '".$this->_cache_serial."'; ?>".$compiled_content; |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | // run compiled template through postfilter functions |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | $_plugins_params = "array('plugins' => array("; |
407 | 407 | foreach ($this->_plugin_info as $plugin_type => $plugins) { |
408 | 408 | foreach ($plugins as $plugin_name => $plugin_info) { |
409 | - $_plugins_params .= "array('$plugin_type', '$plugin_name', '" . strtr($plugin_info[0], array("'" => "\\'", "\\" => "\\\\")) . "', $plugin_info[1], "; |
|
409 | + $_plugins_params .= "array('$plugin_type', '$plugin_name', '".strtr($plugin_info[0], array("'" => "\\'", "\\" => "\\\\"))."', $plugin_info[1], "; |
|
410 | 410 | $_plugins_params .= $plugin_info[2] ? 'true),' : 'false),'; |
411 | 411 | } |
412 | 412 | } |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | $this->_init_smarty_vars = false; |
423 | 423 | } |
424 | 424 | |
425 | - $compiled_content = $template_header . $compiled_content; |
|
425 | + $compiled_content = $template_header.$compiled_content; |
|
426 | 426 | return true; |
427 | 427 | } |
428 | 428 | |
@@ -439,8 +439,8 @@ discard block |
||
439 | 439 | return ''; |
440 | 440 | |
441 | 441 | /* Split tag into two three parts: command, command modifiers and the arguments. */ |
442 | - if(! preg_match('~^(?:(' . $this->_num_const_regexp . '|' . $this->_obj_call_regexp . '|' . $this->_var_regexp |
|
443 | - . '|\/?' . $this->_reg_obj_regexp . '|\/?' . $this->_func_regexp . ')(' . $this->_mod_regexp . '*)) |
|
442 | + if (!preg_match('~^(?:('.$this->_num_const_regexp.'|'.$this->_obj_call_regexp.'|'.$this->_var_regexp |
|
443 | + . '|\/?'.$this->_reg_obj_regexp.'|\/?'.$this->_func_regexp.')('.$this->_mod_regexp.'*)) |
|
444 | 444 | (?:\s+(.*))?$ |
445 | 445 | ~xs', $template_tag, $match)) { |
446 | 446 | $this->_syntax_error("unrecognized tag: $template_tag", E_USER_ERROR, __FILE__, __LINE__); |
@@ -450,14 +450,14 @@ discard block |
||
450 | 450 | $tag_modifier = isset($match[2]) ? $match[2] : null; |
451 | 451 | $tag_args = isset($match[3]) ? $match[3] : null; |
452 | 452 | |
453 | - if (preg_match('~^' . $this->_num_const_regexp . '|' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '$~', $tag_command)) { |
|
453 | + if (preg_match('~^'.$this->_num_const_regexp.'|'.$this->_obj_call_regexp.'|'.$this->_var_regexp.'$~', $tag_command)) { |
|
454 | 454 | /* tag name is a variable or object */ |
455 | - $_return = $this->_parse_var_props($tag_command . $tag_modifier); |
|
456 | - return "<?php echo $_return; ?>" . $this->_additional_newline; |
|
455 | + $_return = $this->_parse_var_props($tag_command.$tag_modifier); |
|
456 | + return "<?php echo $_return; ?>".$this->_additional_newline; |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | /* If the tag name is a registered object, we process it. */ |
460 | - if (preg_match('~^\/?' . $this->_reg_obj_regexp . '$~', $tag_command)) { |
|
460 | + if (preg_match('~^\/?'.$this->_reg_obj_regexp.'$~', $tag_command)) { |
|
461 | 461 | return $this->_compile_registered_object_tag($tag_command, $this->_parse_attrs($tag_args), $tag_modifier); |
462 | 462 | } |
463 | 463 | |
@@ -539,17 +539,17 @@ discard block |
||
539 | 539 | |
540 | 540 | case 'strip': |
541 | 541 | case '/strip': |
542 | - if (substr($tag_command, 0, 1)=='/') { |
|
542 | + if (substr($tag_command, 0, 1) == '/') { |
|
543 | 543 | $this->_pop_tag('strip'); |
544 | - if (--$this->_strip_depth==0) { /* outermost closing {/strip} */ |
|
544 | + if (--$this->_strip_depth == 0) { /* outermost closing {/strip} */ |
|
545 | 545 | $this->_additional_newline = "\n"; |
546 | - return '{' . $tag_command . '}'; |
|
546 | + return '{'.$tag_command.'}'; |
|
547 | 547 | } |
548 | 548 | } else { |
549 | 549 | $this->_push_tag('strip'); |
550 | - if ($this->_strip_depth++==0) { /* outermost opening {strip} */ |
|
550 | + if ($this->_strip_depth++ == 0) { /* outermost opening {strip} */ |
|
551 | 551 | $this->_additional_newline = ""; |
552 | - return '{' . $tag_command . '}'; |
|
552 | + return '{'.$tag_command.'}'; |
|
553 | 553 | } |
554 | 554 | } |
555 | 555 | return ''; |
@@ -565,14 +565,14 @@ discard block |
||
565 | 565 | return ''; |
566 | 566 | |
567 | 567 | case 3: /* literal */ |
568 | - return "<?php echo '" . strtr($block[2], array("'"=>"\'", "\\"=>"\\\\")) . "'; ?>" . $this->_additional_newline; |
|
568 | + return "<?php echo '".strtr($block[2], array("'"=>"\'", "\\"=>"\\\\"))."'; ?>".$this->_additional_newline; |
|
569 | 569 | |
570 | 570 | case 4: /* php */ |
571 | 571 | if ($this->security && !$this->security_settings['PHP_TAGS']) { |
572 | 572 | $this->_syntax_error("(secure mode) php tags not permitted", E_USER_WARNING, __FILE__, __LINE__); |
573 | 573 | return; |
574 | 574 | } |
575 | - return '<?php ' . $block[3] .' ?>'; |
|
575 | + return '<?php '.$block[3].' ?>'; |
|
576 | 576 | } |
577 | 577 | break; |
578 | 578 | |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | |
630 | 630 | include_once $plugin_file; |
631 | 631 | |
632 | - $plugin_func = 'smarty_compiler_' . $tag_command; |
|
632 | + $plugin_func = 'smarty_compiler_'.$tag_command; |
|
633 | 633 | if (!is_callable($plugin_func)) { |
634 | 634 | $message = "plugin function $plugin_func() not found in $plugin_file\n"; |
635 | 635 | $have_function = false; |
@@ -647,10 +647,10 @@ discard block |
||
647 | 647 | if ($found) { |
648 | 648 | if ($have_function) { |
649 | 649 | $output = call_user_func_array($plugin_func, array($tag_args, &$this)); |
650 | - if($output != '') { |
|
651 | - $output = '<?php ' . $this->_push_cacheable_state('compiler', $tag_command) |
|
650 | + if ($output != '') { |
|
651 | + $output = '<?php '.$this->_push_cacheable_state('compiler', $tag_command) |
|
652 | 652 | . $output |
653 | - . $this->_pop_cacheable_state('compiler', $tag_command) . ' ?>'; |
|
653 | + . $this->_pop_cacheable_state('compiler', $tag_command).' ?>'; |
|
654 | 654 | } |
655 | 655 | } else { |
656 | 656 | $this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__); |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | |
705 | 705 | include_once $plugin_file; |
706 | 706 | |
707 | - $plugin_func = 'smarty_block_' . $tag_command; |
|
707 | + $plugin_func = 'smarty_block_'.$tag_command; |
|
708 | 708 | if (!function_exists($plugin_func)) { |
709 | 709 | $message = "plugin function $plugin_func() not found in $plugin_file\n"; |
710 | 710 | $have_function = false; |
@@ -734,12 +734,12 @@ discard block |
||
734 | 734 | $this->_pop_tag($tag_command); |
735 | 735 | |
736 | 736 | if ($start_tag) { |
737 | - $output = '<?php ' . $this->_push_cacheable_state('block', $tag_command); |
|
737 | + $output = '<?php '.$this->_push_cacheable_state('block', $tag_command); |
|
738 | 738 | $attrs = $this->_parse_attrs($tag_args); |
739 | - $_cache_attrs=''; |
|
739 | + $_cache_attrs = ''; |
|
740 | 740 | $arg_list = $this->_compile_arg_list('block', $tag_command, $attrs, $_cache_attrs); |
741 | 741 | $output .= "$_cache_attrs\$this->_tag_stack[] = array('$tag_command', array(".implode(',', $arg_list).')); '; |
742 | - $output .= '$_block_repeat=true;' . $this->_compile_plugin_call('block', $tag_command).'($this->_tag_stack[count($this->_tag_stack)-1][1], null, $this, $_block_repeat);'; |
|
742 | + $output .= '$_block_repeat=true;'.$this->_compile_plugin_call('block', $tag_command).'($this->_tag_stack[count($this->_tag_stack)-1][1], null, $this, $_block_repeat);'; |
|
743 | 743 | $output .= 'while ($_block_repeat) { ob_start(); ?>'; |
744 | 744 | } else { |
745 | 745 | $output = '<?php $_block_content = ob_get_contents(); ob_end_clean(); '; |
@@ -747,8 +747,8 @@ discard block |
||
747 | 747 | if ($tag_modifier != '') { |
748 | 748 | $this->_parse_modifiers($_out_tag_text, $tag_modifier); |
749 | 749 | } |
750 | - $output .= '$_block_repeat=false;echo ' . $_out_tag_text . '; } '; |
|
751 | - $output .= " array_pop(\$this->_tag_stack); " . $this->_pop_cacheable_state('block', $tag_command) . '?>'; |
|
750 | + $output .= '$_block_repeat=false;echo '.$_out_tag_text.'; } '; |
|
751 | + $output .= " array_pop(\$this->_tag_stack); ".$this->_pop_cacheable_state('block', $tag_command).'?>'; |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | return true; |
@@ -789,7 +789,7 @@ discard block |
||
789 | 789 | |
790 | 790 | include_once $plugin_file; |
791 | 791 | |
792 | - $plugin_func = 'smarty_function_' . $tag_command; |
|
792 | + $plugin_func = 'smarty_function_'.$tag_command; |
|
793 | 793 | if (!function_exists($plugin_func)) { |
794 | 794 | $message = "plugin function $plugin_func() not found in $plugin_file\n"; |
795 | 795 | $have_function = false; |
@@ -816,13 +816,13 @@ discard block |
||
816 | 816 | $arg_list = $this->_compile_arg_list('function', $tag_command, $attrs, $_cache_attrs); |
817 | 817 | |
818 | 818 | $output = $this->_compile_plugin_call('function', $tag_command).'(array('.implode(',', $arg_list)."), \$this)"; |
819 | - if($tag_modifier != '') { |
|
819 | + if ($tag_modifier != '') { |
|
820 | 820 | $this->_parse_modifiers($output, $tag_modifier); |
821 | 821 | } |
822 | 822 | |
823 | - if($output != '') { |
|
824 | - $output = '<?php ' . $_cacheable_state . $_cache_attrs . 'echo ' . $output . ';' |
|
825 | - . $this->_pop_cacheable_state('function', $tag_command) . "?>" . $this->_additional_newline; |
|
823 | + if ($output != '') { |
|
824 | + $output = '<?php '.$_cacheable_state.$_cache_attrs.'echo '.$output.';' |
|
825 | + . $this->_pop_cacheable_state('function', $tag_command)."?>".$this->_additional_newline; |
|
826 | 826 | } |
827 | 827 | |
828 | 828 | return true; |
@@ -848,10 +848,10 @@ discard block |
||
848 | 848 | list($object, $obj_comp) = explode('->', $tag_command); |
849 | 849 | |
850 | 850 | $arg_list = array(); |
851 | - if(count($attrs)) { |
|
851 | + if (count($attrs)) { |
|
852 | 852 | $_assign_var = false; |
853 | 853 | foreach ($attrs as $arg_name => $arg_value) { |
854 | - if($arg_name == 'assign') { |
|
854 | + if ($arg_name == 'assign') { |
|
855 | 855 | $_assign_var = $arg_value; |
856 | 856 | unset($attrs['assign']); |
857 | 857 | continue; |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | } |
863 | 863 | } |
864 | 864 | |
865 | - if($this->_reg_objects[$object][2]) { |
|
865 | + if ($this->_reg_objects[$object][2]) { |
|
866 | 866 | // smarty object argument format |
867 | 867 | $args = "array(".implode(',', (array)$arg_list)."), \$this"; |
868 | 868 | } else { |
@@ -876,13 +876,13 @@ discard block |
||
876 | 876 | $prefix = ''; |
877 | 877 | $postfix = ''; |
878 | 878 | $newline = ''; |
879 | - if(!is_object($this->_reg_objects[$object][0])) { |
|
880 | - $this->_trigger_fatal_error("registered '$object' is not an object" , $this->_current_file, $this->_current_line_no, __FILE__, __LINE__); |
|
881 | - } elseif(!empty($this->_reg_objects[$object][1]) && !in_array($obj_comp, $this->_reg_objects[$object][1])) { |
|
879 | + if (!is_object($this->_reg_objects[$object][0])) { |
|
880 | + $this->_trigger_fatal_error("registered '$object' is not an object", $this->_current_file, $this->_current_line_no, __FILE__, __LINE__); |
|
881 | + } elseif (!empty($this->_reg_objects[$object][1]) && !in_array($obj_comp, $this->_reg_objects[$object][1])) { |
|
882 | 882 | $this->_trigger_fatal_error("'$obj_comp' is not a registered component of object '$object'", $this->_current_file, $this->_current_line_no, __FILE__, __LINE__); |
883 | - } elseif(method_exists($this->_reg_objects[$object][0], $obj_comp)) { |
|
883 | + } elseif (method_exists($this->_reg_objects[$object][0], $obj_comp)) { |
|
884 | 884 | // method |
885 | - if(in_array($obj_comp, $this->_reg_objects[$object][3])) { |
|
885 | + if (in_array($obj_comp, $this->_reg_objects[$object][3])) { |
|
886 | 886 | // block method |
887 | 887 | if ($start_tag) { |
888 | 888 | $prefix = "\$this->_tag_stack[] = array('$obj_comp', $args); "; |
@@ -904,22 +904,22 @@ discard block |
||
904 | 904 | $return = "\$this->_reg_objects['$object'][0]->$obj_comp"; |
905 | 905 | } |
906 | 906 | |
907 | - if($return != null) { |
|
908 | - if($tag_modifier != '') { |
|
907 | + if ($return != null) { |
|
908 | + if ($tag_modifier != '') { |
|
909 | 909 | $this->_parse_modifiers($return, $tag_modifier); |
910 | 910 | } |
911 | 911 | |
912 | - if(!empty($_assign_var)) { |
|
913 | - $output = "\$this->assign('" . $this->_dequote($_assign_var) ."', $return);"; |
|
912 | + if (!empty($_assign_var)) { |
|
913 | + $output = "\$this->assign('".$this->_dequote($_assign_var)."', $return);"; |
|
914 | 914 | } else { |
915 | - $output = 'echo ' . $return . ';'; |
|
915 | + $output = 'echo '.$return.';'; |
|
916 | 916 | $newline = $this->_additional_newline; |
917 | 917 | } |
918 | 918 | } else { |
919 | 919 | $output = ''; |
920 | 920 | } |
921 | 921 | |
922 | - return '<?php ' . $prefix . $output . $postfix . "?>" . $newline; |
|
922 | + return '<?php '.$prefix.$output.$postfix."?>".$newline; |
|
923 | 923 | } |
924 | 924 | |
925 | 925 | /** |
@@ -957,7 +957,7 @@ discard block |
||
957 | 957 | |
958 | 958 | $_params = "array('args' => array(".implode(', ', (array)$arg_list)."))"; |
959 | 959 | |
960 | - return "<?php require_once(SMARTY_CORE_DIR . 'core.run_insert_handler.php');\necho smarty_core_run_insert_handler($_params, \$this); ?>" . $this->_additional_newline; |
|
960 | + return "<?php require_once(SMARTY_CORE_DIR . 'core.run_insert_handler.php');\necho smarty_core_run_insert_handler($_params, \$this); ?>".$this->_additional_newline; |
|
961 | 961 | } |
962 | 962 | |
963 | 963 | /** |
@@ -992,8 +992,8 @@ discard block |
||
992 | 992 | $arg_list[] = "'$arg_name' => $arg_value"; |
993 | 993 | } |
994 | 994 | |
995 | - if ( $theme_template == 'true' ) |
|
996 | - $include_file = '"'.SugarThemeRegistry::current()->getTemplate(str_replace(array('"',"'"),'',$include_file)).'"'; |
|
995 | + if ($theme_template == 'true') |
|
996 | + $include_file = '"'.SugarThemeRegistry::current()->getTemplate(str_replace(array('"', "'"), '', $include_file)).'"'; |
|
997 | 997 | |
998 | 998 | $output = '<?php '; |
999 | 999 | |
@@ -1005,13 +1005,13 @@ discard block |
||
1005 | 1005 | "\$_smarty_tpl_vars = \$this->_tpl_vars;\n"; |
1006 | 1006 | |
1007 | 1007 | |
1008 | - $_params = "array('smarty_include_tpl_file' => " . $include_file . ", 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))"; |
|
1009 | - $output .= "\$this->_smarty_include($_params);\n" . |
|
1010 | - "\$this->_tpl_vars = \$_smarty_tpl_vars;\n" . |
|
1008 | + $_params = "array('smarty_include_tpl_file' => ".$include_file.", 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))"; |
|
1009 | + $output .= "\$this->_smarty_include($_params);\n". |
|
1010 | + "\$this->_tpl_vars = \$_smarty_tpl_vars;\n". |
|
1011 | 1011 | "unset(\$_smarty_tpl_vars);\n"; |
1012 | 1012 | |
1013 | 1013 | if (isset($assign_var)) { |
1014 | - $output .= "\$this->assign(" . $assign_var . ", ob_get_contents()); ob_end_clean();\n"; |
|
1014 | + $output .= "\$this->assign(".$assign_var.", ob_get_contents()); ob_end_clean();\n"; |
|
1015 | 1015 | } |
1016 | 1016 | |
1017 | 1017 | $output .= ' ?>'; |
@@ -1035,20 +1035,20 @@ discard block |
||
1035 | 1035 | } |
1036 | 1036 | |
1037 | 1037 | $assign_var = (empty($attrs['assign'])) ? '' : $this->_dequote($attrs['assign']); |
1038 | - $once_var = (empty($attrs['once']) || $attrs['once']=='false') ? 'false' : 'true'; |
|
1038 | + $once_var = (empty($attrs['once']) || $attrs['once'] == 'false') ? 'false' : 'true'; |
|
1039 | 1039 | |
1040 | 1040 | $arg_list = array(); |
1041 | - foreach($attrs as $arg_name => $arg_value) { |
|
1042 | - if($arg_name != 'file' AND $arg_name != 'once' AND $arg_name != 'assign') { |
|
1043 | - if(is_bool($arg_value)) |
|
1041 | + foreach ($attrs as $arg_name => $arg_value) { |
|
1042 | + if ($arg_name != 'file' AND $arg_name != 'once' AND $arg_name != 'assign') { |
|
1043 | + if (is_bool($arg_value)) |
|
1044 | 1044 | $arg_value = $arg_value ? 'true' : 'false'; |
1045 | 1045 | $arg_list[] = "'$arg_name' => $arg_value"; |
1046 | 1046 | } |
1047 | 1047 | } |
1048 | 1048 | |
1049 | - $_params = "array('smarty_file' => " . $attrs['file'] . ", 'smarty_assign' => '$assign_var', 'smarty_once' => $once_var, 'smarty_include_vars' => array(".implode(',', $arg_list)."))"; |
|
1049 | + $_params = "array('smarty_file' => ".$attrs['file'].", 'smarty_assign' => '$assign_var', 'smarty_once' => $once_var, 'smarty_include_vars' => array(".implode(',', $arg_list)."))"; |
|
1050 | 1050 | |
1051 | - return "<?php require_once(SMARTY_CORE_DIR . 'core.smarty_include_php.php');\nsmarty_core_smarty_include_php($_params, \$this); ?>" . $this->_additional_newline; |
|
1051 | + return "<?php require_once(SMARTY_CORE_DIR . 'core.smarty_include_php.php');\nsmarty_core_smarty_include_php($_params, \$this); ?>".$this->_additional_newline; |
|
1052 | 1052 | } |
1053 | 1053 | |
1054 | 1054 | |
@@ -1114,7 +1114,7 @@ discard block |
||
1114 | 1114 | if (!isset($attrs['max'])) |
1115 | 1115 | $output .= "{$section_props}['max'] = {$section_props}['loop'];\n"; |
1116 | 1116 | else |
1117 | - $output .= "if ({$section_props}['max'] < 0)\n" . |
|
1117 | + $output .= "if ({$section_props}['max'] < 0)\n". |
|
1118 | 1118 | " {$section_props}['max'] = {$section_props}['loop'];\n"; |
1119 | 1119 | |
1120 | 1120 | if (!isset($attrs['step'])) |
@@ -1123,9 +1123,9 @@ discard block |
||
1123 | 1123 | if (!isset($attrs['start'])) |
1124 | 1124 | $output .= "{$section_props}['start'] = {$section_props}['step'] > 0 ? 0 : {$section_props}['loop']-1;\n"; |
1125 | 1125 | else { |
1126 | - $output .= "if ({$section_props}['start'] < 0)\n" . |
|
1127 | - " {$section_props}['start'] = max({$section_props}['step'] > 0 ? 0 : -1, {$section_props}['loop'] + {$section_props}['start']);\n" . |
|
1128 | - "else\n" . |
|
1126 | + $output .= "if ({$section_props}['start'] < 0)\n". |
|
1127 | + " {$section_props}['start'] = max({$section_props}['step'] > 0 ? 0 : -1, {$section_props}['loop'] + {$section_props}['start']);\n". |
|
1128 | + "else\n". |
|
1129 | 1129 | " {$section_props}['start'] = min({$section_props}['start'], {$section_props}['step'] > 0 ? {$section_props}['loop'] : {$section_props}['loop']-1);\n"; |
1130 | 1130 | } |
1131 | 1131 | |
@@ -1135,9 +1135,9 @@ discard block |
||
1135 | 1135 | } else { |
1136 | 1136 | $output .= " {$section_props}['total'] = min(ceil(({$section_props}['step'] > 0 ? {$section_props}['loop'] - {$section_props}['start'] : {$section_props}['start']+1)/abs({$section_props}['step'])), {$section_props}['max']);\n"; |
1137 | 1137 | } |
1138 | - $output .= " if ({$section_props}['total'] == 0)\n" . |
|
1139 | - " {$section_props}['show'] = false;\n" . |
|
1140 | - "} else\n" . |
|
1138 | + $output .= " if ({$section_props}['total'] == 0)\n". |
|
1139 | + " {$section_props}['show'] = false;\n". |
|
1140 | + "} else\n". |
|
1141 | 1141 | " {$section_props}['total'] = 0;\n"; |
1142 | 1142 | |
1143 | 1143 | $output .= "if ({$section_props}['show']):\n"; |
@@ -1182,7 +1182,7 @@ discard block |
||
1182 | 1182 | } |
1183 | 1183 | |
1184 | 1184 | if (isset($attrs['key'])) { |
1185 | - $key = $this->_dequote($attrs['key']); |
|
1185 | + $key = $this->_dequote($attrs['key']); |
|
1186 | 1186 | if (!preg_match('~^\w+$~', $key)) { |
1187 | 1187 | return $this->_syntax_error("foreach: 'key' must to be a variable name (literal string)", E_USER_ERROR, __FILE__, __LINE__); |
1188 | 1188 | } |
@@ -1262,8 +1262,8 @@ discard block |
||
1262 | 1262 | |
1263 | 1263 | /* Tokenize args for 'if' tag. */ |
1264 | 1264 | preg_match_all('~(?> |
1265 | - ' . $this->_obj_call_regexp . '(?:' . $this->_mod_regexp . '*)? | # valid object call |
|
1266 | - ' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*)? | # var or quoted string |
|
1265 | + ' . $this->_obj_call_regexp.'(?:'.$this->_mod_regexp.'*)? | # valid object call |
|
1266 | + ' . $this->_var_regexp.'(?:'.$this->_mod_regexp.'*)? | # var or quoted string |
|
1267 | 1267 | \-?0[xX][0-9a-fA-F]+|\-?\d+(?:\.\d+)?|\.\d+|!==|===|==|!=|<>|<<|>>|<=|>=|\&\&|\|\||\(|\)|,|\!|\^|=|\&|\~|<|>|\||\%|\+|\-|\/|\*|\@ | # valid non-word token |
1268 | 1268 | \b\w+\b | # valid word token |
1269 | 1269 | \S+ # anything else |
@@ -1271,7 +1271,7 @@ discard block |
||
1271 | 1271 | |
1272 | 1272 | $tokens = $match[0]; |
1273 | 1273 | |
1274 | - if(empty($tokens)) { |
|
1274 | + if (empty($tokens)) { |
|
1275 | 1275 | $_error_msg = $elseif ? "'elseif'" : "'if'"; |
1276 | 1276 | $_error_msg .= ' statement requires arguments'; |
1277 | 1277 | $this->_syntax_error($_error_msg, E_USER_ERROR, __FILE__, __LINE__); |
@@ -1280,7 +1280,7 @@ discard block |
||
1280 | 1280 | |
1281 | 1281 | // make sure we have balanced parenthesis |
1282 | 1282 | $token_count = array_count_values($tokens); |
1283 | - if(isset($token_count['(']) && $token_count['('] != $token_count[')']) { |
|
1283 | + if (isset($token_count['(']) && $token_count['('] != $token_count[')']) { |
|
1284 | 1284 | $this->_syntax_error("unbalanced parenthesis in if statement", E_USER_ERROR, __FILE__, __LINE__); |
1285 | 1285 | } |
1286 | 1286 | |
@@ -1370,15 +1370,15 @@ discard block |
||
1370 | 1370 | /* If last token was a ')', we operate on the parenthesized |
1371 | 1371 | expression. The start of the expression is on the stack. |
1372 | 1372 | Otherwise, we operate on the last encountered token. */ |
1373 | - if ($tokens[$i-1] == ')') { |
|
1373 | + if ($tokens[$i - 1] == ')') { |
|
1374 | 1374 | $is_arg_start = array_pop($is_arg_stack); |
1375 | 1375 | if ($is_arg_start != 0) { |
1376 | - if (preg_match('~^' . $this->_func_regexp . '$~', $tokens[$is_arg_start-1])) { |
|
1376 | + if (preg_match('~^'.$this->_func_regexp.'$~', $tokens[$is_arg_start - 1])) { |
|
1377 | 1377 | $is_arg_start--; |
1378 | 1378 | } |
1379 | 1379 | } |
1380 | 1380 | } else |
1381 | - $is_arg_start = $i-1; |
|
1381 | + $is_arg_start = $i - 1; |
|
1382 | 1382 | /* Construct the argument for 'is' expression, so it knows |
1383 | 1383 | what to operate on. */ |
1384 | 1384 | $is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start)); |
@@ -1388,7 +1388,7 @@ discard block |
||
1388 | 1388 | return modified tokens, where the first one is the result |
1389 | 1389 | of the 'is' expression and the rest are the tokens it |
1390 | 1390 | didn't touch. */ |
1391 | - $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1)); |
|
1391 | + $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i + 1)); |
|
1392 | 1392 | |
1393 | 1393 | /* Replace the old tokens with the new ones. */ |
1394 | 1394 | array_splice($tokens, $is_arg_start, count($tokens), $new_tokens); |
@@ -1399,19 +1399,19 @@ discard block |
||
1399 | 1399 | break; |
1400 | 1400 | |
1401 | 1401 | default: |
1402 | - if(preg_match('~^' . $this->_func_regexp . '$~', $token) ) { |
|
1402 | + if (preg_match('~^'.$this->_func_regexp.'$~', $token)) { |
|
1403 | 1403 | // function call |
1404 | - if($this->security && |
|
1404 | + if ($this->security && |
|
1405 | 1405 | !in_array($token, $this->security_settings['IF_FUNCS'])) { |
1406 | 1406 | $this->_syntax_error("(secure mode) '$token' not allowed in if statement", E_USER_ERROR, __FILE__, __LINE__); |
1407 | 1407 | } |
1408 | - } elseif(preg_match('~^' . $this->_var_regexp . '$~', $token) && (strpos('+-*/^%&|', substr($token, -1)) === false) && isset($tokens[$i+1]) && $tokens[$i+1] == '(') { |
|
1408 | + } elseif (preg_match('~^'.$this->_var_regexp.'$~', $token) && (strpos('+-*/^%&|', substr($token, -1)) === false) && isset($tokens[$i + 1]) && $tokens[$i + 1] == '(') { |
|
1409 | 1409 | // variable function call |
1410 | 1410 | $this->_syntax_error("variable function call '$token' not allowed in if statement", E_USER_ERROR, __FILE__, __LINE__); |
1411 | - } elseif(preg_match('~^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*)$~', $token)) { |
|
1411 | + } elseif (preg_match('~^'.$this->_obj_call_regexp.'|'.$this->_var_regexp.'(?:'.$this->_mod_regexp.'*)$~', $token)) { |
|
1412 | 1412 | // object or variable |
1413 | 1413 | $token = $this->_parse_var_props($token); |
1414 | - } elseif(is_numeric($token)) { |
|
1414 | + } elseif (is_numeric($token)) { |
|
1415 | 1415 | // number, skip it |
1416 | 1416 | } else { |
1417 | 1417 | $this->_syntax_error("unidentified token '$token'", E_USER_ERROR, __FILE__, __LINE__); |
@@ -1483,7 +1483,7 @@ discard block |
||
1483 | 1483 | if (isset($tokens[$expr_end]) && $tokens[$expr_end] == 'by') { |
1484 | 1484 | $expr_end++; |
1485 | 1485 | $expr_arg = $tokens[$expr_end++]; |
1486 | - $expr = "!(1 & ($is_arg / " . $this->_parse_var_props($expr_arg) . "))"; |
|
1486 | + $expr = "!(1 & ($is_arg / ".$this->_parse_var_props($expr_arg)."))"; |
|
1487 | 1487 | } else |
1488 | 1488 | $expr = "!(1 & $is_arg)"; |
1489 | 1489 | break; |
@@ -1492,7 +1492,7 @@ discard block |
||
1492 | 1492 | if (isset($tokens[$expr_end]) && $tokens[$expr_end] == 'by') { |
1493 | 1493 | $expr_end++; |
1494 | 1494 | $expr_arg = $tokens[$expr_end++]; |
1495 | - $expr = "(1 & ($is_arg / " . $this->_parse_var_props($expr_arg) . "))"; |
|
1495 | + $expr = "(1 & ($is_arg / ".$this->_parse_var_props($expr_arg)."))"; |
|
1496 | 1496 | } else |
1497 | 1497 | $expr = "(1 & $is_arg)"; |
1498 | 1498 | break; |
@@ -1501,7 +1501,7 @@ discard block |
||
1501 | 1501 | if (@$tokens[$expr_end] == 'by') { |
1502 | 1502 | $expr_end++; |
1503 | 1503 | $expr_arg = $tokens[$expr_end++]; |
1504 | - $expr = "!($is_arg % " . $this->_parse_var_props($expr_arg) . ")"; |
|
1504 | + $expr = "!($is_arg % ".$this->_parse_var_props($expr_arg).")"; |
|
1505 | 1505 | } else { |
1506 | 1506 | $this->_syntax_error("expecting 'by' after 'div'", E_USER_ERROR, __FILE__, __LINE__); |
1507 | 1507 | } |
@@ -1532,11 +1532,11 @@ discard block |
||
1532 | 1532 | { |
1533 | 1533 | |
1534 | 1534 | /* Tokenize tag attributes. */ |
1535 | - preg_match_all('~(?:' . $this->_obj_call_regexp . '|' . $this->_qstr_regexp . ' | (?>[^"\'=\s]+) |
|
1535 | + preg_match_all('~(?:'.$this->_obj_call_regexp.'|'.$this->_qstr_regexp.' | (?>[^"\'=\s]+) |
|
1536 | 1536 | )+ | |
1537 | 1537 | [=] |
1538 | 1538 | ~x', $tag_args, $match); |
1539 | - $tokens = $match[0]; |
|
1539 | + $tokens = $match[0]; |
|
1540 | 1540 | |
1541 | 1541 | $attrs = array(); |
1542 | 1542 | /* Parse state: |
@@ -1577,9 +1577,9 @@ discard block |
||
1577 | 1577 | $token = 'false'; |
1578 | 1578 | } else if ($token == 'null') { |
1579 | 1579 | $token = 'null'; |
1580 | - } else if (preg_match('~^' . $this->_num_const_regexp . '|0[xX][0-9a-fA-F]+$~', $token)) { |
|
1580 | + } else if (preg_match('~^'.$this->_num_const_regexp.'|0[xX][0-9a-fA-F]+$~', $token)) { |
|
1581 | 1581 | /* treat integer literally */ |
1582 | - } else if (!preg_match('~^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . ')*$~', $token)) { |
|
1582 | + } else if (!preg_match('~^'.$this->_obj_call_regexp.'|'.$this->_var_regexp.'(?:'.$this->_mod_regexp.')*$~', $token)) { |
|
1583 | 1583 | /* treat as a string, double-quote it escaping quotes */ |
1584 | 1584 | $token = '"'.addslashes($token).'"'; |
1585 | 1585 | } |
@@ -1593,8 +1593,8 @@ discard block |
||
1593 | 1593 | $last_token = $token; |
1594 | 1594 | } |
1595 | 1595 | |
1596 | - if($state != 0) { |
|
1597 | - if($state == 1) { |
|
1596 | + if ($state != 0) { |
|
1597 | + if ($state == 1) { |
|
1598 | 1598 | $this->_syntax_error("expecting '=' after attribute name '$last_token'", E_USER_ERROR, __FILE__, __LINE__); |
1599 | 1599 | } else { |
1600 | 1600 | $this->_syntax_error("missing attribute value", E_USER_ERROR, __FILE__, __LINE__); |
@@ -1614,7 +1614,7 @@ discard block |
||
1614 | 1614 | */ |
1615 | 1615 | function _parse_vars_props(&$tokens) |
1616 | 1616 | { |
1617 | - foreach($tokens as $key => $val) { |
|
1617 | + foreach ($tokens as $key => $val) { |
|
1618 | 1618 | $tokens[$key] = $this->_parse_var_props($val); |
1619 | 1619 | } |
1620 | 1620 | } |
@@ -1631,52 +1631,52 @@ discard block |
||
1631 | 1631 | { |
1632 | 1632 | $val = trim($val); |
1633 | 1633 | |
1634 | - if(preg_match('~^(' . $this->_obj_call_regexp . '|' . $this->_dvar_regexp . ')(' . $this->_mod_regexp . '*)$~', $val, $match)) { |
|
1634 | + if (preg_match('~^('.$this->_obj_call_regexp.'|'.$this->_dvar_regexp.')('.$this->_mod_regexp.'*)$~', $val, $match)) { |
|
1635 | 1635 | // $ variable or object |
1636 | 1636 | $return = $this->_parse_var($match[1]); |
1637 | 1637 | $modifiers = $match[2]; |
1638 | - if (!empty($this->default_modifiers) && !preg_match('~(^|\|)smarty:nodefaults($|\|)~',$modifiers)) { |
|
1639 | - $_default_mod_string = implode('|',(array)$this->default_modifiers); |
|
1640 | - $modifiers = empty($modifiers) ? $_default_mod_string : $_default_mod_string . '|' . $modifiers; |
|
1638 | + if (!empty($this->default_modifiers) && !preg_match('~(^|\|)smarty:nodefaults($|\|)~', $modifiers)) { |
|
1639 | + $_default_mod_string = implode('|', (array)$this->default_modifiers); |
|
1640 | + $modifiers = empty($modifiers) ? $_default_mod_string : $_default_mod_string.'|'.$modifiers; |
|
1641 | 1641 | } |
1642 | 1642 | $this->_parse_modifiers($return, $modifiers); |
1643 | 1643 | return $return; |
1644 | - } elseif (preg_match('~^' . $this->_db_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) { |
|
1644 | + } elseif (preg_match('~^'.$this->_db_qstr_regexp.'(?:'.$this->_mod_regexp.'*)$~', $val)) { |
|
1645 | 1645 | // double quoted text |
1646 | - preg_match('~^(' . $this->_db_qstr_regexp . ')('. $this->_mod_regexp . '*)$~', $val, $match); |
|
1646 | + preg_match('~^('.$this->_db_qstr_regexp.')('.$this->_mod_regexp.'*)$~', $val, $match); |
|
1647 | 1647 | $return = $this->_expand_quoted_text($match[1]); |
1648 | - if($match[2] != '') { |
|
1648 | + if ($match[2] != '') { |
|
1649 | 1649 | $this->_parse_modifiers($return, $match[2]); |
1650 | 1650 | } |
1651 | 1651 | return $return; |
1652 | 1652 | } |
1653 | - elseif(preg_match('~^' . $this->_num_const_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) { |
|
1653 | + elseif (preg_match('~^'.$this->_num_const_regexp.'(?:'.$this->_mod_regexp.'*)$~', $val)) { |
|
1654 | 1654 | // numerical constant |
1655 | - preg_match('~^(' . $this->_num_const_regexp . ')('. $this->_mod_regexp . '*)$~', $val, $match); |
|
1656 | - if($match[2] != '') { |
|
1655 | + preg_match('~^('.$this->_num_const_regexp.')('.$this->_mod_regexp.'*)$~', $val, $match); |
|
1656 | + if ($match[2] != '') { |
|
1657 | 1657 | $this->_parse_modifiers($match[1], $match[2]); |
1658 | 1658 | return $match[1]; |
1659 | 1659 | } |
1660 | 1660 | } |
1661 | - elseif(preg_match('~^' . $this->_si_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) { |
|
1661 | + elseif (preg_match('~^'.$this->_si_qstr_regexp.'(?:'.$this->_mod_regexp.'*)$~', $val)) { |
|
1662 | 1662 | // single quoted text |
1663 | - preg_match('~^(' . $this->_si_qstr_regexp . ')('. $this->_mod_regexp . '*)$~', $val, $match); |
|
1664 | - if($match[2] != '') { |
|
1663 | + preg_match('~^('.$this->_si_qstr_regexp.')('.$this->_mod_regexp.'*)$~', $val, $match); |
|
1664 | + if ($match[2] != '') { |
|
1665 | 1665 | $this->_parse_modifiers($match[1], $match[2]); |
1666 | 1666 | return $match[1]; |
1667 | 1667 | } |
1668 | 1668 | } |
1669 | - elseif(preg_match('~^' . $this->_cvar_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) { |
|
1669 | + elseif (preg_match('~^'.$this->_cvar_regexp.'(?:'.$this->_mod_regexp.'*)$~', $val)) { |
|
1670 | 1670 | // config var |
1671 | 1671 | return $this->_parse_conf_var($val); |
1672 | 1672 | } |
1673 | - elseif(preg_match('~^' . $this->_svar_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) { |
|
1673 | + elseif (preg_match('~^'.$this->_svar_regexp.'(?:'.$this->_mod_regexp.'*)$~', $val)) { |
|
1674 | 1674 | // section var |
1675 | 1675 | return $this->_parse_section_prop($val); |
1676 | 1676 | } |
1677 | - elseif(!in_array($val, $this->_permitted_tokens) && !is_numeric($val)) { |
|
1677 | + elseif (!in_array($val, $this->_permitted_tokens) && !is_numeric($val)) { |
|
1678 | 1678 | // literal string |
1679 | - return $this->_expand_quoted_text('"' . strtr($val, array('\\' => '\\\\', '"' => '\\"')) .'"'); |
|
1679 | + return $this->_expand_quoted_text('"'.strtr($val, array('\\' => '\\\\', '"' => '\\"')).'"'); |
|
1680 | 1680 | } |
1681 | 1681 | return $val; |
1682 | 1682 | } |
@@ -1690,11 +1690,11 @@ discard block |
||
1690 | 1690 | function _expand_quoted_text($var_expr) |
1691 | 1691 | { |
1692 | 1692 | // if contains unescaped $, expand it |
1693 | - if(preg_match_all('~(?:\`(?<!\\\\)\$' . $this->_dvar_guts_regexp . '(?:' . $this->_obj_ext_regexp . ')*\`)|(?:(?<!\\\\)\$\w+(\[[a-zA-Z0-9]+\])*)~', $var_expr, $_match)) { |
|
1693 | + if (preg_match_all('~(?:\`(?<!\\\\)\$'.$this->_dvar_guts_regexp.'(?:'.$this->_obj_ext_regexp.')*\`)|(?:(?<!\\\\)\$\w+(\[[a-zA-Z0-9]+\])*)~', $var_expr, $_match)) { |
|
1694 | 1694 | $_match = $_match[0]; |
1695 | 1695 | $_replace = array(); |
1696 | - foreach($_match as $_var) { |
|
1697 | - $_replace[$_var] = '".(' . $this->_parse_var(str_replace('`','',$_var)) . ')."'; |
|
1696 | + foreach ($_match as $_var) { |
|
1697 | + $_replace[$_var] = '".('.$this->_parse_var(str_replace('`', '', $_var)).')."'; |
|
1698 | 1698 | } |
1699 | 1699 | $var_expr = strtr($var_expr, $_replace); |
1700 | 1700 | $_return = preg_replace('~\.""|(?<!\\\\)""\.~', '', $var_expr); |
@@ -1702,7 +1702,7 @@ discard block |
||
1702 | 1702 | $_return = $var_expr; |
1703 | 1703 | } |
1704 | 1704 | // replace double quoted literal string with single quotes |
1705 | - $_return = preg_replace('~^"([\s\w]+)"$~',"'\\1'",$_return); |
|
1705 | + $_return = preg_replace('~^"([\s\w]+)"$~', "'\\1'", $_return); |
|
1706 | 1706 | return $_return; |
1707 | 1707 | } |
1708 | 1708 | |
@@ -1718,26 +1718,26 @@ discard block |
||
1718 | 1718 | $_has_math = false; |
1719 | 1719 | $_math_vars = preg_split('~('.$this->_dvar_math_regexp.'|'.$this->_qstr_regexp.')~', $var_expr, -1, PREG_SPLIT_DELIM_CAPTURE); |
1720 | 1720 | |
1721 | - if(count($_math_vars) > 1) { |
|
1721 | + if (count($_math_vars) > 1) { |
|
1722 | 1722 | $_first_var = ""; |
1723 | 1723 | $_complete_var = ""; |
1724 | 1724 | $_output = ""; |
1725 | 1725 | // simple check if there is any math, to stop recursion (due to modifiers with "xx % yy" as parameter) |
1726 | - foreach($_math_vars as $_k => $_math_var) { |
|
1726 | + foreach ($_math_vars as $_k => $_math_var) { |
|
1727 | 1727 | $_math_var = $_math_vars[$_k]; |
1728 | 1728 | |
1729 | - if(!empty($_math_var) || is_numeric($_math_var)) { |
|
1729 | + if (!empty($_math_var) || is_numeric($_math_var)) { |
|
1730 | 1730 | // hit a math operator, so process the stuff which came before it |
1731 | - if(preg_match('~^' . $this->_dvar_math_regexp . '$~', $_math_var)) { |
|
1731 | + if (preg_match('~^'.$this->_dvar_math_regexp.'$~', $_math_var)) { |
|
1732 | 1732 | $_has_math = true; |
1733 | - if(!empty($_complete_var) || is_numeric($_complete_var)) { |
|
1733 | + if (!empty($_complete_var) || is_numeric($_complete_var)) { |
|
1734 | 1734 | $_output .= $this->_parse_var($_complete_var); |
1735 | 1735 | } |
1736 | 1736 | |
1737 | 1737 | // just output the math operator to php |
1738 | 1738 | $_output .= $_math_var; |
1739 | 1739 | |
1740 | - if(empty($_first_var)) |
|
1740 | + if (empty($_first_var)) |
|
1741 | 1741 | $_first_var = $_complete_var; |
1742 | 1742 | |
1743 | 1743 | $_complete_var = ""; |
@@ -1746,8 +1746,8 @@ discard block |
||
1746 | 1746 | } |
1747 | 1747 | } |
1748 | 1748 | } |
1749 | - if($_has_math) { |
|
1750 | - if(!empty($_complete_var) || is_numeric($_complete_var)) |
|
1749 | + if ($_has_math) { |
|
1750 | + if (!empty($_complete_var) || is_numeric($_complete_var)) |
|
1751 | 1751 | $_output .= $this->_parse_var($_complete_var); |
1752 | 1752 | |
1753 | 1753 | // get the modifiers working (only the last var from math + modifier is left) |
@@ -1756,15 +1756,15 @@ discard block |
||
1756 | 1756 | } |
1757 | 1757 | |
1758 | 1758 | // 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))) |
|
1759 | + if (is_numeric(substr($var_expr, 0, 1))) |
|
1760 | 1760 | $_var_ref = $var_expr; |
1761 | 1761 | else |
1762 | 1762 | $_var_ref = substr($var_expr, 1); |
1763 | 1763 | |
1764 | - if(!$_has_math) { |
|
1764 | + if (!$_has_math) { |
|
1765 | 1765 | |
1766 | 1766 | // get [foo] and .foo and ->foo and (...) pieces |
1767 | - preg_match_all('~(?:^\w+)|' . $this->_obj_params_regexp . '|(?:' . $this->_var_bracket_regexp . ')|->\$?\w+|\.\$?\w+|\S+~', $_var_ref, $match); |
|
1767 | + preg_match_all('~(?:^\w+)|'.$this->_obj_params_regexp.'|(?:'.$this->_var_bracket_regexp.')|->\$?\w+|\.\$?\w+|\S+~', $_var_ref, $match); |
|
1768 | 1768 | |
1769 | 1769 | $_indexes = $match[0]; |
1770 | 1770 | $_var_name = array_shift($_indexes); |
@@ -1782,9 +1782,9 @@ discard block |
||
1782 | 1782 | $_var_name = substr(array_shift($_indexes), 1); |
1783 | 1783 | $_output = "\$this->_smarty_vars['$_var_name']"; |
1784 | 1784 | } |
1785 | - } elseif(is_numeric($_var_name) && is_numeric(substr($var_expr, 0, 1))) { |
|
1785 | + } elseif (is_numeric($_var_name) && is_numeric(substr($var_expr, 0, 1))) { |
|
1786 | 1786 | // because . is the operator for accessing arrays thru inidizes we need to put it together again for floating point numbers |
1787 | - if(count($_indexes) > 0) |
|
1787 | + if (count($_indexes) > 0) |
|
1788 | 1788 | { |
1789 | 1789 | $_var_name .= implode("", $_indexes); |
1790 | 1790 | $_indexes = array(); |
@@ -1801,9 +1801,9 @@ discard block |
||
1801 | 1801 | $_output .= "[$_index]"; |
1802 | 1802 | } elseif (substr($_index, 0, 1) == '$') { |
1803 | 1803 | if (strpos($_index, '.') !== false) { |
1804 | - $_output .= '[' . $this->_parse_var($_index) . ']'; |
|
1804 | + $_output .= '['.$this->_parse_var($_index).']'; |
|
1805 | 1805 | } else { |
1806 | - $_output .= "[\$this->_tpl_vars['" . substr($_index, 1) . "']]"; |
|
1806 | + $_output .= "[\$this->_tpl_vars['".substr($_index, 1)."']]"; |
|
1807 | 1807 | } |
1808 | 1808 | } else { |
1809 | 1809 | $_var_parts = explode('.', $_index); |
@@ -1813,19 +1813,19 @@ discard block |
||
1813 | 1813 | } |
1814 | 1814 | } else if (substr($_index, 0, 1) == '.') { |
1815 | 1815 | if (substr($_index, 1, 1) == '$') |
1816 | - $_output .= "[\$this->_tpl_vars['" . substr($_index, 2) . "']]"; |
|
1816 | + $_output .= "[\$this->_tpl_vars['".substr($_index, 2)."']]"; |
|
1817 | 1817 | else |
1818 | - $_output .= "['" . substr($_index, 1) . "']"; |
|
1819 | - } else if (substr($_index,0,2) == '->') { |
|
1820 | - if(substr($_index,2,2) == '__') { |
|
1818 | + $_output .= "['".substr($_index, 1)."']"; |
|
1819 | + } else if (substr($_index, 0, 2) == '->') { |
|
1820 | + if (substr($_index, 2, 2) == '__') { |
|
1821 | 1821 | $this->_syntax_error('call to internal object members is not allowed', E_USER_ERROR, __FILE__, __LINE__); |
1822 | - } elseif($this->security && substr($_index, 2, 1) == '_') { |
|
1822 | + } elseif ($this->security && substr($_index, 2, 1) == '_') { |
|
1823 | 1823 | $this->_syntax_error('(secure) call to private object member is not allowed', E_USER_ERROR, __FILE__, __LINE__); |
1824 | 1824 | } elseif (substr($_index, 2, 1) == '$') { |
1825 | 1825 | if ($this->security) { |
1826 | 1826 | $this->_syntax_error('(secure) call to dynamic object member is not allowed', E_USER_ERROR, __FILE__, __LINE__); |
1827 | 1827 | } else { |
1828 | - $_output .= '->{(($_var=$this->_tpl_vars[\''.substr($_index,3).'\']) && substr($_var,0,2)!=\'__\') ? $_var : $this->trigger_error("cannot access property \\"$_var\\"")}'; |
|
1828 | + $_output .= '->{(($_var=$this->_tpl_vars[\''.substr($_index, 3).'\']) && substr($_var,0,2)!=\'__\') ? $_var : $this->trigger_error("cannot access property \\"$_var\\"")}'; |
|
1829 | 1829 | } |
1830 | 1830 | } else { |
1831 | 1831 | $_output .= $_index; |
@@ -1850,7 +1850,7 @@ discard block |
||
1850 | 1850 | */ |
1851 | 1851 | function _parse_parenth_args($parenth_args) |
1852 | 1852 | { |
1853 | - preg_match_all('~' . $this->_param_regexp . '~',$parenth_args, $match); |
|
1853 | + preg_match_all('~'.$this->_param_regexp.'~', $parenth_args, $match); |
|
1854 | 1854 | $orig_vals = $match = $match[0]; |
1855 | 1855 | $this->_parse_vars_props($match); |
1856 | 1856 | $replace = array(); |
@@ -1913,18 +1913,18 @@ discard block |
||
1913 | 1913 | */ |
1914 | 1914 | function _parse_modifiers(&$output, $modifier_string) |
1915 | 1915 | { |
1916 | - preg_match_all('~\|(@?\w+)((?>:(?:'. $this->_qstr_regexp . '|[^|]+))*)~', '|' . $modifier_string, $_match); |
|
1916 | + preg_match_all('~\|(@?\w+)((?>:(?:'.$this->_qstr_regexp.'|[^|]+))*)~', '|'.$modifier_string, $_match); |
|
1917 | 1917 | list(, $_modifiers, $modifier_arg_strings) = $_match; |
1918 | 1918 | |
1919 | 1919 | for ($_i = 0, $_for_max = count($_modifiers); $_i < $_for_max; $_i++) { |
1920 | 1920 | $_modifier_name = $_modifiers[$_i]; |
1921 | 1921 | |
1922 | - if($_modifier_name == 'smarty') { |
|
1922 | + if ($_modifier_name == 'smarty') { |
|
1923 | 1923 | // skip smarty modifier |
1924 | 1924 | continue; |
1925 | 1925 | } |
1926 | 1926 | |
1927 | - preg_match_all('~:(' . $this->_qstr_regexp . '|[^:]+)~', $modifier_arg_strings[$_i], $_match); |
|
1927 | + preg_match_all('~:('.$this->_qstr_regexp.'|[^:]+)~', $modifier_arg_strings[$_i], $_match); |
|
1928 | 1928 | $_modifier_args = $_match[1]; |
1929 | 1929 | |
1930 | 1930 | if (substr($_modifier_name, 0, 1) == '@') { |
@@ -1938,22 +1938,22 @@ discard block |
||
1938 | 1938 | && !$this->_get_plugin_filepath('modifier', $_modifier_name) |
1939 | 1939 | && function_exists($_modifier_name)) { |
1940 | 1940 | if ($this->security && !in_array($_modifier_name, $this->security_settings['MODIFIER_FUNCS'])) { |
1941 | - $this->_trigger_fatal_error("[plugin] (secure mode) modifier '$_modifier_name' is not allowed" , $this->_current_file, $this->_current_line_no, __FILE__, __LINE__); |
|
1941 | + $this->_trigger_fatal_error("[plugin] (secure mode) modifier '$_modifier_name' is not allowed", $this->_current_file, $this->_current_line_no, __FILE__, __LINE__); |
|
1942 | 1942 | } else { |
1943 | - $this->_plugins['modifier'][$_modifier_name] = array($_modifier_name, null, null, false); |
|
1943 | + $this->_plugins['modifier'][$_modifier_name] = array($_modifier_name, null, null, false); |
|
1944 | 1944 | } |
1945 | 1945 | } |
1946 | 1946 | $this->_add_plugin('modifier', $_modifier_name); |
1947 | 1947 | |
1948 | 1948 | $this->_parse_vars_props($_modifier_args); |
1949 | 1949 | |
1950 | - if($_modifier_name == 'default') { |
|
1950 | + if ($_modifier_name == 'default') { |
|
1951 | 1951 | // supress notifications of default modifier vars and args |
1952 | - if(substr($output, 0, 1) == '$') { |
|
1953 | - $output = '@' . $output; |
|
1952 | + if (substr($output, 0, 1) == '$') { |
|
1953 | + $output = '@'.$output; |
|
1954 | 1954 | } |
1955 | - if(isset($_modifier_args[0]) && substr($_modifier_args[0], 0, 1) == '$') { |
|
1956 | - $_modifier_args[0] = '@' . $_modifier_args[0]; |
|
1955 | + if (isset($_modifier_args[0]) && substr($_modifier_args[0], 0, 1) == '$') { |
|
1956 | + $_modifier_args[0] = '@'.$_modifier_args[0]; |
|
1957 | 1957 | } |
1958 | 1958 | } |
1959 | 1959 | if (count($_modifier_args) > 0) |
@@ -1962,7 +1962,7 @@ discard block |
||
1962 | 1962 | $_modifier_args = ''; |
1963 | 1963 | |
1964 | 1964 | if ($_map_array) { |
1965 | - $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))"; |
|
1965 | + $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))"; |
|
1966 | 1966 | |
1967 | 1967 | } else { |
1968 | 1968 | |
@@ -2003,9 +2003,9 @@ discard block |
||
2003 | 2003 | { |
2004 | 2004 | /* Extract the reference name. */ |
2005 | 2005 | $_ref = substr($indexes[0], 1); |
2006 | - foreach($indexes as $_index_no=>$_index) { |
|
2007 | - if (substr($_index, 0, 1) != '.' && $_index_no<2 || !preg_match('~^(\.|\[|->)~', $_index)) { |
|
2008 | - $this->_syntax_error('$smarty' . implode('', array_slice($indexes, 0, 2)) . ' is an invalid reference', E_USER_ERROR, __FILE__, __LINE__); |
|
2006 | + foreach ($indexes as $_index_no=>$_index) { |
|
2007 | + if (substr($_index, 0, 1) != '.' && $_index_no < 2 || !preg_match('~^(\.|\[|->)~', $_index)) { |
|
2008 | + $this->_syntax_error('$smarty'.implode('', array_slice($indexes, 0, 2)).' is an invalid reference', E_USER_ERROR, __FILE__, __LINE__); |
|
2009 | 2009 | } |
2010 | 2010 | } |
2011 | 2011 | |
@@ -2129,7 +2129,7 @@ discard block |
||
2129 | 2129 | return null; |
2130 | 2130 | |
2131 | 2131 | case 'template': |
2132 | - $compiled_ref = "'" . addslashes($this->_current_file) . "'"; |
|
2132 | + $compiled_ref = "'".addslashes($this->_current_file)."'"; |
|
2133 | 2133 | $_max_index = 1; |
2134 | 2134 | break; |
2135 | 2135 | |
@@ -2146,10 +2146,10 @@ discard block |
||
2146 | 2146 | } |
2147 | 2147 | array_shift($indexes); |
2148 | 2148 | if (preg_match('!^\.\w+$!', $indexes[0])) { |
2149 | - $compiled_ref = '@' . substr($indexes[0], 1); |
|
2149 | + $compiled_ref = '@'.substr($indexes[0], 1); |
|
2150 | 2150 | } else { |
2151 | 2151 | $_val = $this->_parse_var_props(substr($indexes[0], 1)); |
2152 | - $compiled_ref = '@constant(' . $_val . ')'; |
|
2152 | + $compiled_ref = '@constant('.$_val.')'; |
|
2153 | 2153 | } |
2154 | 2154 | $_max_index = 1; |
2155 | 2155 | break; |
@@ -2168,12 +2168,12 @@ discard block |
||
2168 | 2168 | break; |
2169 | 2169 | |
2170 | 2170 | default: |
2171 | - $this->_syntax_error('$smarty.' . $_ref . ' is an unknown reference', E_USER_ERROR, __FILE__, __LINE__); |
|
2171 | + $this->_syntax_error('$smarty.'.$_ref.' is an unknown reference', E_USER_ERROR, __FILE__, __LINE__); |
|
2172 | 2172 | break; |
2173 | 2173 | } |
2174 | 2174 | |
2175 | 2175 | if (isset($_max_index) && count($indexes) > $_max_index) { |
2176 | - $this->_syntax_error('$smarty' . implode('', $indexes) .' is an invalid reference', E_USER_ERROR, __FILE__, __LINE__); |
|
2176 | + $this->_syntax_error('$smarty'.implode('', $indexes).' is an invalid reference', E_USER_ERROR, __FILE__, __LINE__); |
|
2177 | 2177 | } |
2178 | 2178 | |
2179 | 2179 | array_shift($indexes); |
@@ -2197,7 +2197,7 @@ discard block |
||
2197 | 2197 | return ((is_object($this->_plugins[$type][$name][0][0])) ? |
2198 | 2198 | "\$this->_plugins['$type']['$name'][0][0]->" /* method callback */ |
2199 | 2199 | : (string)($this->_plugins[$type][$name][0][0]).'::' /* class callback */ |
2200 | - ). $this->_plugins[$type][$name][0][1]; |
|
2200 | + ).$this->_plugins[$type][$name][0][1]; |
|
2201 | 2201 | |
2202 | 2202 | } else { |
2203 | 2203 | /* function callback */ |
@@ -2221,7 +2221,7 @@ discard block |
||
2221 | 2221 | if ($prefilter === false) { |
2222 | 2222 | unset($this->_plugins['prefilter'][$filter_name]); |
2223 | 2223 | $_params = array('plugins' => array(array('prefilter', $filter_name, null, null, false))); |
2224 | - require_once(SMARTY_CORE_DIR . 'core.load_plugins.php'); |
|
2224 | + require_once(SMARTY_CORE_DIR.'core.load_plugins.php'); |
|
2225 | 2225 | smarty_core_load_plugins($_params, $this); |
2226 | 2226 | } |
2227 | 2227 | } |
@@ -2231,7 +2231,7 @@ discard block |
||
2231 | 2231 | if ($postfilter === false) { |
2232 | 2232 | unset($this->_plugins['postfilter'][$filter_name]); |
2233 | 2233 | $_params = array('plugins' => array(array('postfilter', $filter_name, null, null, false))); |
2234 | - require_once(SMARTY_CORE_DIR . 'core.load_plugins.php'); |
|
2234 | + require_once(SMARTY_CORE_DIR.'core.load_plugins.php'); |
|
2235 | 2235 | smarty_core_load_plugins($_params, $this); |
2236 | 2236 | } |
2237 | 2237 | } |
@@ -2258,7 +2258,7 @@ discard block |
||
2258 | 2258 | * @param string $file |
2259 | 2259 | * @param integer $line |
2260 | 2260 | */ |
2261 | - function _syntax_error($error_msg, $error_type = E_USER_ERROR, $file=null, $line=null) |
|
2261 | + function _syntax_error($error_msg, $error_type = E_USER_ERROR, $file = null, $line = null) |
|
2262 | 2262 | { |
2263 | 2263 | $this->_trigger_fatal_error("syntax error: $error_msg", $this->_current_file, $this->_current_line_no, $file, $line, $error_type); |
2264 | 2264 | } |
@@ -2273,10 +2273,10 @@ discard block |
||
2273 | 2273 | function _push_cacheable_state($type, $name) { |
2274 | 2274 | $_cacheable = !isset($this->_plugins[$type][$name]) || $this->_plugins[$type][$name][4]; |
2275 | 2275 | if ($_cacheable |
2276 | - || 0<$this->_cacheable_state++) return ''; |
|
2276 | + || 0 < $this->_cacheable_state++) return ''; |
|
2277 | 2277 | if (!isset($this->_cache_serial)) $this->_cache_serial = md5(uniqid('Smarty')); |
2278 | 2278 | $_ret = 'if ($this->caching && !$this->_cache_including): echo \'{nocache:' |
2279 | - . $this->_cache_serial . '#' . $this->_nocache_count |
|
2279 | + . $this->_cache_serial.'#'.$this->_nocache_count |
|
2280 | 2280 | . '}\'; endif;'; |
2281 | 2281 | return $_ret; |
2282 | 2282 | } |
@@ -2291,9 +2291,9 @@ discard block |
||
2291 | 2291 | function _pop_cacheable_state($type, $name) { |
2292 | 2292 | $_cacheable = !isset($this->_plugins[$type][$name]) || $this->_plugins[$type][$name][4]; |
2293 | 2293 | if ($_cacheable |
2294 | - || --$this->_cacheable_state>0) return ''; |
|
2294 | + || --$this->_cacheable_state > 0) return ''; |
|
2295 | 2295 | return 'if ($this->caching && !$this->_cache_including): echo \'{/nocache:' |
2296 | - . $this->_cache_serial . '#' . ($this->_nocache_count++) |
|
2296 | + . $this->_cache_serial.'#'.($this->_nocache_count++) |
|
2297 | 2297 | . '}\'; endif;'; |
2298 | 2298 | } |
2299 | 2299 | |
@@ -2316,12 +2316,12 @@ discard block |
||
2316 | 2316 | function _pop_tag($close_tag) |
2317 | 2317 | { |
2318 | 2318 | $message = ''; |
2319 | - if (count($this->_tag_stack)>0) { |
|
2319 | + if (count($this->_tag_stack) > 0) { |
|
2320 | 2320 | list($_open_tag, $_line_no) = array_pop($this->_tag_stack); |
2321 | 2321 | if ($close_tag == $_open_tag) { |
2322 | 2322 | return $_open_tag; |
2323 | 2323 | } |
2324 | - if ($close_tag == 'if' && ($_open_tag == 'else' || $_open_tag == 'elseif' )) { |
|
2324 | + if ($close_tag == 'if' && ($_open_tag == 'else' || $_open_tag == 'elseif')) { |
|
2325 | 2325 | return $this->_pop_tag($close_tag); |
2326 | 2326 | } |
2327 | 2327 | if ($close_tag == 'section' && $_open_tag == 'sectionelse') { |
@@ -2357,10 +2357,10 @@ discard block |
||
2357 | 2357 | */ |
2358 | 2358 | function _smarty_sort_length($a, $b) |
2359 | 2359 | { |
2360 | - if($a == $b) |
|
2360 | + if ($a == $b) |
|
2361 | 2361 | return 0; |
2362 | 2362 | |
2363 | - if(strlen($a) == strlen($b)) |
|
2363 | + if (strlen($a) == strlen($b)) |
|
2364 | 2364 | return ($a > $b) ? -1 : 1; |
2365 | 2365 | |
2366 | 2366 | return (strlen($a) > strlen($b)) ? -1 : 1; |
@@ -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 | } |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @param string $resource_name |
221 | 221 | * @param string $source_content |
222 | 222 | * @param string $compiled_content |
223 | - * @return true |
|
223 | + * @return null|boolean |
|
224 | 224 | */ |
225 | 225 | function _compile_file($resource_name, $source_content, &$compiled_content) |
226 | 226 | { |
@@ -761,7 +761,8 @@ discard block |
||
761 | 761 | * @param string $tag_command |
762 | 762 | * @param string $tag_args |
763 | 763 | * @param string $tag_modifier |
764 | - * @return string |
|
764 | + * @param string $output |
|
765 | + * @return boolean |
|
765 | 766 | */ |
766 | 767 | function _compile_custom_tag($tag_command, $tag_args, $tag_modifier, &$output) |
767 | 768 | { |
@@ -1427,6 +1428,11 @@ discard block |
||
1427 | 1428 | } |
1428 | 1429 | |
1429 | 1430 | |
1431 | + /** |
|
1432 | + * @param string $type |
|
1433 | + * @param string $name |
|
1434 | + * @param string $cache_code |
|
1435 | + */ |
|
1430 | 1436 | function _compile_arg_list($type, $name, $attrs, &$cache_code) { |
1431 | 1437 | $arg_list = array(); |
1432 | 1438 | |
@@ -1624,7 +1630,6 @@ discard block |
||
1624 | 1630 | * PHP code |
1625 | 1631 | * |
1626 | 1632 | * @param string $val |
1627 | - * @param string $tag_attrs |
|
1628 | 1633 | * @return string |
1629 | 1634 | */ |
1630 | 1635 | function _parse_var_props($val) |
@@ -1710,7 +1715,6 @@ discard block |
||
1710 | 1715 | * parse variable expression into PHP code |
1711 | 1716 | * |
1712 | 1717 | * @param string $var_expr |
1713 | - * @param string $output |
|
1714 | 1718 | * @return string |
1715 | 1719 | */ |
1716 | 1720 | function _parse_var($var_expr) |
@@ -1978,7 +1982,7 @@ discard block |
||
1978 | 1982 | * |
1979 | 1983 | * @param string $type |
1980 | 1984 | * @param string $name |
1981 | - * @param boolean? $delayed_loading |
|
1985 | + * @param boolean $delayed_loading |
|
1982 | 1986 | */ |
1983 | 1987 | function _add_plugin($type, $name, $delayed_loading = null) |
1984 | 1988 | { |
@@ -2268,6 +2272,8 @@ discard block |
||
2268 | 2272 | * check if the compilation changes from cacheable to |
2269 | 2273 | * non-cacheable state with the beginning of the current |
2270 | 2274 | * plugin. return php-code to reflect the transition. |
2275 | + * @param string $type |
|
2276 | + * @param string $name |
|
2271 | 2277 | * @return string |
2272 | 2278 | */ |
2273 | 2279 | function _push_cacheable_state($type, $name) { |
@@ -2286,6 +2292,8 @@ discard block |
||
2286 | 2292 | * check if the compilation changes from non-cacheable to |
2287 | 2293 | * cacheable state with the end of the current plugin return |
2288 | 2294 | * php-code to reflect the transition. |
2295 | + * @param string $type |
|
2296 | + * @param string $name |
|
2289 | 2297 | * @return string |
2290 | 2298 | */ |
2291 | 2299 | function _pop_cacheable_state($type, $name) { |
@@ -2301,6 +2309,7 @@ discard block |
||
2301 | 2309 | /** |
2302 | 2310 | * push opening tag-name, file-name and line-number on the tag-stack |
2303 | 2311 | * @param string the opening tag's name |
2312 | + * @param string $open_tag |
|
2304 | 2313 | */ |
2305 | 2314 | function _push_tag($open_tag) |
2306 | 2315 | { |
@@ -2311,6 +2320,7 @@ discard block |
||
2311 | 2320 | * pop closing tag-name |
2312 | 2321 | * raise an error if this stack-top doesn't match with the closing tag |
2313 | 2322 | * @param string the closing tag's name |
2323 | + * @param string $close_tag |
|
2314 | 2324 | * @return string the opening tag's name |
2315 | 2325 | */ |
2316 | 2326 | function _pop_tag($close_tag) |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | require_once("data/BeanFactory.php"); |
46 | 46 | |
47 | 47 | |
48 | -define('REL_LHS','LHS'); |
|
49 | -define('REL_RHS','RHS'); |
|
50 | -define('REL_BOTH','BOTH_SIDES'); |
|
48 | +define('REL_LHS', 'LHS'); |
|
49 | +define('REL_RHS', 'RHS'); |
|
50 | +define('REL_BOTH', 'BOTH_SIDES'); |
|
51 | 51 | define('REL_MANY_MANY', 'many-to-many'); |
52 | 52 | define('REL_ONE_MANY', 'one-to-many'); |
53 | 53 | define('REL_ONE_ONE', 'one-to-one'); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $focus = $link->getFocus(); |
127 | 127 | $related = $link->getBeans(); |
128 | 128 | $result = true; |
129 | - foreach($related as $relBean) |
|
129 | + foreach ($related as $relBean) |
|
130 | 130 | { |
131 | 131 | if (empty($relBean->id)) { |
132 | 132 | continue; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @param $rowID id of SugarBean to remove from the relationship |
152 | 152 | * @return void |
153 | 153 | */ |
154 | - public function removeById($rowID){ |
|
154 | + public function removeById($rowID) { |
|
155 | 155 | $this->removeRow(array("id" => $rowID)); |
156 | 156 | } |
157 | 157 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | return $this->updateRow($existing['id'], array_merge($existing, $row)); |
207 | 207 | |
208 | 208 | $values = array(); |
209 | - foreach($this->getFields() as $def) |
|
209 | + foreach ($this->getFields() as $def) |
|
210 | 210 | { |
211 | 211 | $field = $def['name']; |
212 | 212 | if (isset($row[$field])) |
@@ -233,12 +233,12 @@ discard block |
||
233 | 233 | $newVals = array(); |
234 | 234 | //Unset the ID since we are using it to update the row |
235 | 235 | if (isset($values['id'])) unset($values['id']); |
236 | - foreach($values as $field => $val) |
|
236 | + foreach ($values as $field => $val) |
|
237 | 237 | { |
238 | 238 | $newVals[] = "$field='$val'"; |
239 | 239 | } |
240 | 240 | |
241 | - $newVals = implode(",",$newVals); |
|
241 | + $newVals = implode(",", $newVals); |
|
242 | 242 | |
243 | 243 | $query = "UPDATE {$this->getRelationshipTable()} set $newVals WHERE id='$id'"; |
244 | 244 | |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | { |
262 | 262 | $stringSets[] = "$field = '$val'"; |
263 | 263 | } |
264 | - $whereString = "WHERE " . implode(" AND ", $stringSets); |
|
264 | + $whereString = "WHERE ".implode(" AND ", $stringSets); |
|
265 | 265 | |
266 | 266 | $query = "UPDATE {$this->getRelationshipTable()} set deleted=1 , date_modified = '$date_modified' $whereString"; |
267 | 267 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | { |
279 | 279 | $leftIDName = $this->def['join_key_lhs']; |
280 | 280 | $rightIDName = $this->def['join_key_rhs']; |
281 | - if (empty($row[$leftIDName]) || empty($row[$rightIDName])) |
|
281 | + if (empty($row[$leftIDName]) || empty($row[$rightIDName])) |
|
282 | 282 | return false; |
283 | 283 | |
284 | 284 | $leftID = $row[$leftIDName]; |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | if (!empty($row)) |
295 | 295 | { |
296 | 296 | return $row; |
297 | - } else{ |
|
297 | + } else { |
|
298 | 298 | return false; |
299 | 299 | } |
300 | 300 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | $roleCheck = ""; |
311 | 311 | if (empty ($table)) |
312 | 312 | $table = $this->getRelationshipTable(); |
313 | - if (!empty($this->def['relationship_role_column']) && !empty($this->def["relationship_role_column_value"]) && !$ignore_role_filter ) |
|
313 | + if (!empty($this->def['relationship_role_column']) && !empty($this->def["relationship_role_column_value"]) && !$ignore_role_filter) |
|
314 | 314 | { |
315 | 315 | if (empty($table)) |
316 | 316 | $roleCheck = " AND $this->relationship_role_column"; |
@@ -319,9 +319,9 @@ discard block |
||
319 | 319 | //role column value. |
320 | 320 | if (empty($this->def['relationship_role_column_value'])) |
321 | 321 | { |
322 | - $roleCheck.=' IS NULL'; |
|
322 | + $roleCheck .= ' IS NULL'; |
|
323 | 323 | } else { |
324 | - $roleCheck.= " = '$this->relationship_role_column_value'"; |
|
324 | + $roleCheck .= " = '$this->relationship_role_column_value'"; |
|
325 | 325 | } |
326 | 326 | } |
327 | 327 | return $roleCheck; |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | * @param string $link_name name of link being triggerd |
355 | 355 | * @return void |
356 | 356 | */ |
357 | - protected function callBeforeAdd($focus, $related, $link_name="") |
|
357 | + protected function callBeforeAdd($focus, $related, $link_name = "") |
|
358 | 358 | { |
359 | 359 | $custom_logic_arguments = $this->getCustomLogicArguments($focus, $related, $link_name); |
360 | 360 | $focus->call_custom_logic('before_relationship_add', $custom_logic_arguments); |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | * @param string $link_name name of link being triggerd |
368 | 368 | * @return void |
369 | 369 | */ |
370 | - protected function callAfterAdd($focus, $related, $link_name="") |
|
370 | + protected function callAfterAdd($focus, $related, $link_name = "") |
|
371 | 371 | { |
372 | 372 | $custom_logic_arguments = $this->getCustomLogicArguments($focus, $related, $link_name); |
373 | 373 | $focus->call_custom_logic('after_relationship_add', $custom_logic_arguments); |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | * @param string $link_name |
380 | 380 | * @return void |
381 | 381 | */ |
382 | - protected function callBeforeDelete($focus, $related, $link_name="") |
|
382 | + protected function callBeforeDelete($focus, $related, $link_name = "") |
|
383 | 383 | { |
384 | 384 | $custom_logic_arguments = $this->getCustomLogicArguments($focus, $related, $link_name); |
385 | 385 | $focus->call_custom_logic('before_relationship_delete', $custom_logic_arguments); |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * @param string $link_name |
392 | 392 | * @return void |
393 | 393 | */ |
394 | - protected function callAfterDelete($focus, $related, $link_name="") |
|
394 | + protected function callAfterDelete($focus, $related, $link_name = "") |
|
395 | 395 | { |
396 | 396 | $custom_logic_arguments = $this->getCustomLogicArguments($focus, $related, $link_name); |
397 | 397 | $focus->call_custom_logic('after_relationship_delete', $custom_logic_arguments); |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | */ |
406 | 406 | protected function getOptionalWhereClause($optional_array) { |
407 | 407 | //lhs_field, operator, and rhs_value must be set in optional_array |
408 | - foreach(array("lhs_field", "operator", "rhs_value") as $required){ |
|
408 | + foreach (array("lhs_field", "operator", "rhs_value") as $required) { |
|
409 | 409 | if (empty($optional_array[$required])) |
410 | 410 | return ""; |
411 | 411 | } |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | $GLOBALS['resavingRelatedBeans'] = true; |
439 | 439 | |
440 | 440 | //Resave any bean not currently in the middle of a save operation |
441 | - foreach(self::$beansToResave as $module => $beans) |
|
441 | + foreach (self::$beansToResave as $module => $beans) |
|
442 | 442 | { |
443 | 443 | foreach ($beans as $bean) |
444 | 444 | { |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | public function isParentRelationship() |
470 | 470 | { |
471 | 471 | //check role fields to see if this is a parent (flex relate) relationship |
472 | - if(!empty($this->def["relationship_role_column"]) && !empty($this->def["relationship_role_column_value"]) |
|
472 | + if (!empty($this->def["relationship_role_column"]) && !empty($this->def["relationship_role_column_value"]) |
|
473 | 473 | && $this->def["relationship_role_column"] == "parent_type" && $this->def['rhs_key'] == "parent_id") |
474 | 474 | { |
475 | 475 | return true; |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | if (isset($this->def[$name])) |
483 | 483 | return $this->def[$name]; |
484 | 484 | |
485 | - switch($name) |
|
485 | + switch ($name) |
|
486 | 486 | { |
487 | 487 | case "relationship_type": |
488 | 488 | return $this->type; |
@@ -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. |
@@ -135,8 +137,7 @@ discard block |
||
135 | 137 | if ($link->getSide() == REL_LHS) |
136 | 138 | { |
137 | 139 | $sub_result = $this->remove($focus, $relBean); |
138 | - } |
|
139 | - else |
|
140 | + } else |
|
140 | 141 | { |
141 | 142 | $sub_result = $this->remove($relBean, $focus); |
142 | 143 | } |
@@ -202,8 +203,10 @@ discard block |
||
202 | 203 | protected function addRow($row) |
203 | 204 | { |
204 | 205 | $existing = $this->checkExisting($row); |
205 | - if (!empty($existing)) //Update the existing row, overriding the values with those passed in |
|
206 | + if (!empty($existing)) { |
|
207 | + //Update the existing row, overriding the values with those passed in |
|
206 | 208 | return $this->updateRow($existing['id'], array_merge($existing, $row)); |
209 | + } |
|
207 | 210 | |
208 | 211 | $values = array(); |
209 | 212 | foreach($this->getFields() as $def) |
@@ -232,7 +235,9 @@ discard block |
||
232 | 235 | { |
233 | 236 | $newVals = array(); |
234 | 237 | //Unset the ID since we are using it to update the row |
235 | - if (isset($values['id'])) unset($values['id']); |
|
238 | + if (isset($values['id'])) { |
|
239 | + unset($values['id']); |
|
240 | + } |
|
236 | 241 | foreach($values as $field => $val) |
237 | 242 | { |
238 | 243 | $newVals[] = "$field='$val'"; |
@@ -252,8 +257,9 @@ discard block |
||
252 | 257 | */ |
253 | 258 | protected function removeRow($where) |
254 | 259 | { |
255 | - if (empty($where)) |
|
256 | - return false; |
|
260 | + if (empty($where)) { |
|
261 | + return false; |
|
262 | + } |
|
257 | 263 | |
258 | 264 | $date_modified = TimeDate::getInstance()->getNow()->asDb(); |
259 | 265 | $stringSets = array(); |
@@ -278,8 +284,9 @@ discard block |
||
278 | 284 | { |
279 | 285 | $leftIDName = $this->def['join_key_lhs']; |
280 | 286 | $rightIDName = $this->def['join_key_rhs']; |
281 | - if (empty($row[$leftIDName]) || empty($row[$rightIDName])) |
|
282 | - return false; |
|
287 | + if (empty($row[$leftIDName]) || empty($row[$rightIDName])) { |
|
288 | + return false; |
|
289 | + } |
|
283 | 290 | |
284 | 291 | $leftID = $row[$leftIDName]; |
285 | 292 | $rightID = $row[$rightIDName]; |
@@ -308,14 +315,16 @@ discard block |
||
308 | 315 | { |
309 | 316 | $ignore_role_filter = $ignore_role_filter || $this->ignore_role_filter; |
310 | 317 | $roleCheck = ""; |
311 | - if (empty ($table)) |
|
312 | - $table = $this->getRelationshipTable(); |
|
318 | + if (empty ($table)) { |
|
319 | + $table = $this->getRelationshipTable(); |
|
320 | + } |
|
313 | 321 | if (!empty($this->def['relationship_role_column']) && !empty($this->def["relationship_role_column_value"]) && !$ignore_role_filter ) |
314 | 322 | { |
315 | - if (empty($table)) |
|
316 | - $roleCheck = " AND $this->relationship_role_column"; |
|
317 | - else |
|
318 | - $roleCheck = " AND $table.{$this->relationship_role_column}"; |
|
323 | + if (empty($table)) { |
|
324 | + $roleCheck = " AND $this->relationship_role_column"; |
|
325 | + } else { |
|
326 | + $roleCheck = " AND $table.{$this->relationship_role_column}"; |
|
327 | + } |
|
319 | 328 | //role column value. |
320 | 329 | if (empty($this->def['relationship_role_column_value'])) |
321 | 330 | { |
@@ -406,8 +415,9 @@ discard block |
||
406 | 415 | protected function getOptionalWhereClause($optional_array) { |
407 | 416 | //lhs_field, operator, and rhs_value must be set in optional_array |
408 | 417 | foreach(array("lhs_field", "operator", "rhs_value") as $required){ |
409 | - if (empty($optional_array[$required])) |
|
410 | - return ""; |
|
418 | + if (empty($optional_array[$required])) { |
|
419 | + return ""; |
|
420 | + } |
|
411 | 421 | } |
412 | 422 | |
413 | 423 | return $optional_array['lhs_field']."".$optional_array['operator']."'".$optional_array['rhs_value']."'"; |
@@ -445,8 +455,7 @@ discard block |
||
445 | 455 | if (empty($bean->deleted) && empty($bean->in_save)) |
446 | 456 | { |
447 | 457 | $bean->save(); |
448 | - } |
|
449 | - else |
|
458 | + } else |
|
450 | 459 | { |
451 | 460 | // Bug 55942 save the in-save id which will be used to send workflow alert later |
452 | 461 | if (isset($bean->id) && !empty($_SESSION['WORKFLOW_ALERTS'])) |
@@ -479,8 +488,9 @@ discard block |
||
479 | 488 | |
480 | 489 | public function __get($name) |
481 | 490 | { |
482 | - if (isset($this->def[$name])) |
|
483 | - return $this->def[$name]; |
|
491 | + if (isset($this->def[$name])) { |
|
492 | + return $this->def[$name]; |
|
493 | + } |
|
484 | 494 | |
485 | 495 | switch($name) |
486 | 496 | { |
@@ -500,8 +510,9 @@ discard block |
||
500 | 510 | return array('lhs_table', 'lhs_key', 'rhs_module', 'rhs_table', 'rhs_key', 'relationship_type'); |
501 | 511 | } |
502 | 512 | |
503 | - if (isset($this->$name)) |
|
504 | - return $this->$name; |
|
513 | + if (isset($this->$name)) { |
|
514 | + return $this->$name; |
|
515 | + } |
|
505 | 516 | |
506 | 517 | return null; |
507 | 518 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | |
198 | 198 | /** |
199 | 199 | * @param array $row values to be inserted into the relationship |
200 | - * @return bool|void null if new row was inserted and true if an existing row was updated |
|
200 | + * @return resource|null null if new row was inserted and true if an existing row was updated |
|
201 | 201 | */ |
202 | 202 | protected function addRow($row) |
203 | 203 | { |
@@ -399,8 +399,6 @@ discard block |
||
399 | 399 | |
400 | 400 | /** |
401 | 401 | * @param $optional_array clause to add to the where query when populating this relationship. It should be in the |
402 | - * @param string $add_and |
|
403 | - * @param string $prefix |
|
404 | 402 | * @return string |
405 | 403 | */ |
406 | 404 | protected function getOptionalWhereClause($optional_array) { |
@@ -102,9 +102,9 @@ |
||
102 | 102 | |
103 | 103 | //join the related module's table |
104 | 104 | $join .= "$join_type $targetTableWithAlias ON $targetTable.$targetKey=$startingTable.$startingKey" |
105 | - . " AND $targetTable.deleted=$deleted\n" |
|
105 | + . " AND $targetTable.deleted=$deleted\n" |
|
106 | 106 | //Next add any role filters |
107 | - . $this->getRoleWhere(); |
|
107 | + . $this->getRoleWhere(); |
|
108 | 108 | |
109 | 109 | if($return_array){ |
110 | 110 | return array( |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -87,14 +87,14 @@ discard block |
||
87 | 87 | $targetTable = $linkIsLHS ? $this->def['rhs_table'] : $this->def['lhs_table']; |
88 | 88 | $targetTableWithAlias = $targetTable; |
89 | 89 | $targetKey = $linkIsLHS ? $this->def['rhs_key'] : $this->def['lhs_key']; |
90 | - $join_type= isset($params['join_type']) ? $params['join_type'] : ' INNER JOIN '; |
|
90 | + $join_type = isset($params['join_type']) ? $params['join_type'] : ' INNER JOIN '; |
|
91 | 91 | |
92 | 92 | $join = ''; |
93 | 93 | |
94 | 94 | //Set up any table aliases required |
95 | - if ( ! empty($params['join_table_alias'])) |
|
95 | + if (!empty($params['join_table_alias'])) |
|
96 | 96 | { |
97 | - $targetTableWithAlias = $targetTable . " ". $params['join_table_alias']; |
|
97 | + $targetTableWithAlias = $targetTable." ".$params['join_table_alias']; |
|
98 | 98 | $targetTable = $params['join_table_alias']; |
99 | 99 | } |
100 | 100 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | //Next add any role filters |
107 | 107 | . $this->getRoleWhere(); |
108 | 108 | |
109 | - if($return_array){ |
|
109 | + if ($return_array) { |
|
110 | 110 | return array( |
111 | 111 | 'join' => $join, |
112 | 112 | 'type' => $this->type, |
@@ -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. |
@@ -72,11 +74,13 @@ discard block |
||
72 | 74 | protected function updateLinks($lhs, $lhsLinkName, $rhs, $rhsLinkName) |
73 | 75 | { |
74 | 76 | //RHS and LHS only ever have one bean |
75 | - if (isset($lhs->$lhsLinkName)) |
|
76 | - $lhs->$lhsLinkName->beans = array($rhs->id => $rhs); |
|
77 | + if (isset($lhs->$lhsLinkName)) { |
|
78 | + $lhs->$lhsLinkName->beans = array($rhs->id => $rhs); |
|
79 | + } |
|
77 | 80 | |
78 | - if (isset($rhs->$rhsLinkName)) |
|
79 | - $rhs->$rhsLinkName->beans = array($lhs->id => $lhs); |
|
81 | + if (isset($rhs->$rhsLinkName)) { |
|
82 | + $rhs->$rhsLinkName->beans = array($lhs->id => $lhs); |
|
83 | + } |
|
80 | 84 | } |
81 | 85 | |
82 | 86 | public function getJoin($link, $params = array(), $return_array = false) |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | //First join the relationship table |
296 | 296 | $join .= "$join_type $targetTableWithAlias ON $startingTable.$startingKey=$targetTable.$targetKey AND $targetTable.deleted=0\n" |
297 | 297 | //Next add any role filters |
298 | - . $this->getRoleWhere(($linkIsLHS) ? $targetTable : $startingTable) . "\n"; |
|
298 | + . $this->getRoleWhere(($linkIsLHS) ? $targetTable : $startingTable) . "\n"; |
|
299 | 299 | |
300 | 300 | if($return_array){ |
301 | 301 | return array( |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | |
355 | 355 | $query .= "$join_type $targetTableWithAlias ON $startingTable.$startingKey=$targetTable.$targetKey AND $targetTable.deleted=0\n" |
356 | 356 | //Next add any role filters |
357 | - . $this->getRoleWhere($tableInRoleFilter) . "\n"; |
|
357 | + . $this->getRoleWhere($tableInRoleFilter) . "\n"; |
|
358 | 358 | |
359 | 359 | if (!empty($params['return_as_array'])) { |
360 | 360 | $return_array = true; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | // test to see if the relationship exist if the relationship between the two beans |
67 | 67 | // exist then we just fail out with false as we don't want to re-trigger this |
68 | 68 | // the save and such as it causes problems with the related() in sugarlogic |
69 | - if($this->relationship_exists($lhs, $rhs) && !empty($GLOBALS['resavingRelatedBeans'])) return false; |
|
69 | + if ($this->relationship_exists($lhs, $rhs) && !empty($GLOBALS['resavingRelatedBeans'])) return false; |
|
70 | 70 | |
71 | 71 | $lhsLinkName = $this->lhsLink; |
72 | 72 | $rhsLinkName = $this->rhsLink; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | { |
78 | 78 | $oldLink = $rhs->$rhsLinkName; |
79 | 79 | $prevRelated = $oldLink->getBeans(null); |
80 | - foreach($prevRelated as $oldLHS) |
|
80 | + foreach ($prevRelated as $oldLHS) |
|
81 | 81 | { |
82 | 82 | if ($oldLHS->id != $lhs->id) |
83 | 83 | $this->remove($oldLHS, $rhs, false); |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | //Now update the RHS bean's ID field |
132 | 132 | $rhsID = $this->def['rhs_key']; |
133 | 133 | $rhs->$rhsID = $lhs->id; |
134 | - foreach($additionalFields as $field => $val) |
|
134 | + foreach ($additionalFields as $field => $val) |
|
135 | 135 | { |
136 | 136 | $rhs->$field = $val; |
137 | 137 | } |
138 | 138 | //Update role fields |
139 | - if(!empty($this->def["relationship_role_column"]) && !empty($this->def["relationship_role_column_value"])) |
|
139 | + if (!empty($this->def["relationship_role_column"]) && !empty($this->def["relationship_role_column_value"])) |
|
140 | 140 | { |
141 | 141 | $roleField = $this->def["relationship_role_column"]; |
142 | 142 | $rhs->$roleField = $this->def["relationship_role_column_value"]; |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | |
241 | 241 | //Add any optional where clause |
242 | 242 | if (!empty($params['where'])) { |
243 | - $add_where = is_string($params['where']) ? $params['where'] : "$rhsTable." . $this->getOptionalWhereClause($params['where']); |
|
243 | + $add_where = is_string($params['where']) ? $params['where'] : "$rhsTable.".$this->getOptionalWhereClause($params['where']); |
|
244 | 244 | if (!empty($add_where)) |
245 | 245 | $where .= " AND $add_where"; |
246 | 246 | } |
@@ -282,22 +282,22 @@ discard block |
||
282 | 282 | $targetTable = $linkIsLHS ? $this->def['rhs_table'] : $this->def['lhs_table']; |
283 | 283 | $targetTableWithAlias = $targetTable; |
284 | 284 | $targetKey = $linkIsLHS ? $this->def['rhs_key'] : $this->def['lhs_key']; |
285 | - $join_type= isset($params['join_type']) ? $params['join_type'] : ' INNER JOIN '; |
|
285 | + $join_type = isset($params['join_type']) ? $params['join_type'] : ' INNER JOIN '; |
|
286 | 286 | $join = ''; |
287 | 287 | |
288 | 288 | //Set up any table aliases required |
289 | - if ( ! empty($params['join_table_alias'])) |
|
289 | + if (!empty($params['join_table_alias'])) |
|
290 | 290 | { |
291 | - $targetTableWithAlias = $targetTable. " ".$params['join_table_alias']; |
|
291 | + $targetTableWithAlias = $targetTable." ".$params['join_table_alias']; |
|
292 | 292 | $targetTable = $params['join_table_alias']; |
293 | 293 | } |
294 | 294 | |
295 | 295 | //First join the relationship table |
296 | 296 | $join .= "$join_type $targetTableWithAlias ON $startingTable.$startingKey=$targetTable.$targetKey AND $targetTable.deleted=0\n" |
297 | 297 | //Next add any role filters |
298 | - . $this->getRoleWhere(($linkIsLHS) ? $targetTable : $startingTable) . "\n"; |
|
298 | + . $this->getRoleWhere(($linkIsLHS) ? $targetTable : $startingTable)."\n"; |
|
299 | 299 | |
300 | - if($return_array){ |
|
300 | + if ($return_array) { |
|
301 | 301 | return array( |
302 | 302 | 'join' => $join, |
303 | 303 | 'type' => $this->type, |
@@ -320,10 +320,10 @@ discard block |
||
320 | 320 | $startingKey = $linkIsLHS ? $this->def['lhs_key'] : $this->def['rhs_key']; |
321 | 321 | $targetTable = $linkIsLHS ? $this->def['rhs_table'] : $this->def['lhs_table']; |
322 | 322 | $targetKey = $linkIsLHS ? $this->def['rhs_key'] : $this->def['lhs_key']; |
323 | - $join_type= isset($params['join_type']) ? $params['join_type'] : ' INNER JOIN '; |
|
323 | + $join_type = isset($params['join_type']) ? $params['join_type'] : ' INNER JOIN '; |
|
324 | 324 | $query = ''; |
325 | 325 | |
326 | - $alias = empty($params['join_table_alias']) ? "{$link->name}_rel": $params['join_table_alias']; |
|
326 | + $alias = empty($params['join_table_alias']) ? "{$link->name}_rel" : $params['join_table_alias']; |
|
327 | 327 | $alias = $GLOBALS['db']->getValidDBName($alias, false, 'alias'); |
328 | 328 | |
329 | 329 | $tableInRoleFilter = ""; |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | || $targetTable == "tasks" |
343 | 343 | || $targetTable == "calls" |
344 | 344 | ) |
345 | - && substr($alias, 0, 12 + strlen($targetTable)) == $targetTable . "_activities_" |
|
345 | + && substr($alias, 0, 12 + strlen($targetTable)) == $targetTable."_activities_" |
|
346 | 346 | ) |
347 | 347 | { |
348 | 348 | $tableInRoleFilter = $linkIsLHS ? $alias : $startingTable; |
@@ -354,13 +354,13 @@ discard block |
||
354 | 354 | |
355 | 355 | $query .= "$join_type $targetTableWithAlias ON $startingTable.$startingKey=$targetTable.$targetKey AND $targetTable.deleted=0\n" |
356 | 356 | //Next add any role filters |
357 | - . $this->getRoleWhere($tableInRoleFilter) . "\n"; |
|
357 | + . $this->getRoleWhere($tableInRoleFilter)."\n"; |
|
358 | 358 | |
359 | 359 | if (!empty($params['return_as_array'])) { |
360 | 360 | $return_array = true; |
361 | 361 | } |
362 | 362 | |
363 | - if($return_array){ |
|
363 | + if ($return_array) { |
|
364 | 364 | return array( |
365 | 365 | 'join' => $query, |
366 | 366 | 'type' => $this->type, |
@@ -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. |
@@ -66,7 +68,9 @@ discard block |
||
66 | 68 | // test to see if the relationship exist if the relationship between the two beans |
67 | 69 | // exist then we just fail out with false as we don't want to re-trigger this |
68 | 70 | // the save and such as it causes problems with the related() in sugarlogic |
69 | - if($this->relationship_exists($lhs, $rhs) && !empty($GLOBALS['resavingRelatedBeans'])) return false; |
|
71 | + if($this->relationship_exists($lhs, $rhs) && !empty($GLOBALS['resavingRelatedBeans'])) { |
|
72 | + return false; |
|
73 | + } |
|
70 | 74 | |
71 | 75 | $lhsLinkName = $this->lhsLink; |
72 | 76 | $rhsLinkName = $this->rhsLink; |
@@ -79,8 +83,9 @@ discard block |
||
79 | 83 | $prevRelated = $oldLink->getBeans(null); |
80 | 84 | foreach($prevRelated as $oldLHS) |
81 | 85 | { |
82 | - if ($oldLHS->id != $lhs->id) |
|
83 | - $this->remove($oldLHS, $rhs, false); |
|
86 | + if ($oldLHS->id != $lhs->id) { |
|
87 | + $this->remove($oldLHS, $rhs, false); |
|
88 | + } |
|
84 | 89 | } |
85 | 90 | } |
86 | 91 | |
@@ -111,19 +116,22 @@ discard block |
||
111 | 116 | |
112 | 117 | //One2MBean relationships require that the RHS bean be saved or else the relationship will not be saved. |
113 | 118 | //If we aren't already in a relationship save, intitiate a save now. |
114 | - if (empty($GLOBALS['resavingRelatedBeans'])) |
|
115 | - SugarRelationship::resaveRelatedBeans(); |
|
119 | + if (empty($GLOBALS['resavingRelatedBeans'])) { |
|
120 | + SugarRelationship::resaveRelatedBeans(); |
|
121 | + } |
|
116 | 122 | |
117 | 123 | return true; |
118 | 124 | } |
119 | 125 | |
120 | 126 | protected function updateLinks($lhs, $lhsLinkName, $rhs, $rhsLinkName) |
121 | 127 | { |
122 | - if (isset($lhs->$lhsLinkName)) |
|
123 | - $lhs->$lhsLinkName->addBean($rhs); |
|
128 | + if (isset($lhs->$lhsLinkName)) { |
|
129 | + $lhs->$lhsLinkName->addBean($rhs); |
|
130 | + } |
|
124 | 131 | //RHS only has one bean ever, so we don't need to preload the relationship |
125 | - if (isset($rhs->$rhsLinkName)) |
|
126 | - $rhs->$rhsLinkName->beans = array($lhs->id => $lhs); |
|
132 | + if (isset($rhs->$rhsLinkName)) { |
|
133 | + $rhs->$rhsLinkName->beans = array($lhs->id => $lhs); |
|
134 | + } |
|
127 | 135 | } |
128 | 136 | |
129 | 137 | protected function updateFields($lhs, $rhs, $additionalFields) |
@@ -148,8 +156,9 @@ discard block |
||
148 | 156 | $rhsID = $this->def['rhs_key']; |
149 | 157 | |
150 | 158 | //If this relationship has already been removed, we can just return |
151 | - if ($rhs->$rhsID != $lhs->id) |
|
152 | - return false; |
|
159 | + if ($rhs->$rhsID != $lhs->id) { |
|
160 | + return false; |
|
161 | + } |
|
153 | 162 | |
154 | 163 | $rhs->$rhsID = ''; |
155 | 164 | |
@@ -192,8 +201,7 @@ discard block |
||
192 | 201 | { |
193 | 202 | $rows[$id] = array('id' => $id); |
194 | 203 | } |
195 | - } |
|
196 | - else //If the link is LHS, we need to query to get the full list and load all the beans. |
|
204 | + } else //If the link is LHS, we need to query to get the full list and load all the beans. |
|
197 | 205 | { |
198 | 206 | $db = DBManagerFactory::getInstance(); |
199 | 207 | $query = $this->getQuery($link, $params); |
@@ -241,8 +249,9 @@ discard block |
||
241 | 249 | //Add any optional where clause |
242 | 250 | if (!empty($params['where'])) { |
243 | 251 | $add_where = is_string($params['where']) ? $params['where'] : "$rhsTable." . $this->getOptionalWhereClause($params['where']); |
244 | - if (!empty($add_where)) |
|
245 | - $where .= " AND $add_where"; |
|
252 | + if (!empty($add_where)) { |
|
253 | + $where .= " AND $add_where"; |
|
254 | + } |
|
246 | 255 | } |
247 | 256 | |
248 | 257 | //Add any optional order clauses |
@@ -255,7 +264,9 @@ discard block |
||
255 | 264 | if (empty($params['return_as_array'])) { |
256 | 265 | //Limit is not compatible with return_as_array |
257 | 266 | $query = "SELECT id FROM $from $where"; |
258 | - if (!empty($order_by)) $query .= ' ORDER BY '.$order_by; |
|
267 | + if (!empty($order_by)) { |
|
268 | + $query .= ' ORDER BY '.$order_by; |
|
269 | + } |
|
259 | 270 | if (!empty($params['limit']) && $params['limit'] > 0) { |
260 | 271 | $offset = isset($params['offset']) ? $params['offset'] : 0; |
261 | 272 | $query = DBManagerFactory::getInstance()->limitQuery($query, $offset, $params['limit'], false, "", false); |
@@ -276,8 +287,9 @@ discard block |
||
276 | 287 | { |
277 | 288 | $linkIsLHS = $link->getSide() == REL_LHS; |
278 | 289 | $startingTable = (empty($params['left_join_table_alias']) ? $this->def['lhs_table'] : $params['left_join_table_alias']); |
279 | - if (!$linkIsLHS) |
|
280 | - $startingTable = (empty($params['right_join_table_alias']) ? $this->def['rhs_table'] : $params['right_join_table_alias']); |
|
290 | + if (!$linkIsLHS) { |
|
291 | + $startingTable = (empty($params['right_join_table_alias']) ? $this->def['rhs_table'] : $params['right_join_table_alias']); |
|
292 | + } |
|
281 | 293 | $startingKey = $linkIsLHS ? $this->def['lhs_key'] : $this->def['rhs_key']; |
282 | 294 | $targetTable = $linkIsLHS ? $this->def['rhs_table'] : $this->def['lhs_table']; |
283 | 295 | $targetTableWithAlias = $targetTable; |
@@ -315,8 +327,9 @@ discard block |
||
315 | 327 | |
316 | 328 | $linkIsLHS = $link->getSide() == REL_RHS; |
317 | 329 | $startingTable = (empty($params['left_join_table_alias']) ? $this->def['lhs_table'] : $params['left_join_table_alias']); |
318 | - if (!$linkIsLHS) |
|
319 | - $startingTable = (empty($params['right_join_table_alias']) ? $this->def['rhs_table'] : $params['right_join_table_alias']); |
|
330 | + if (!$linkIsLHS) { |
|
331 | + $startingTable = (empty($params['right_join_table_alias']) ? $this->def['rhs_table'] : $params['right_join_table_alias']); |
|
332 | + } |
|
320 | 333 | $startingKey = $linkIsLHS ? $this->def['lhs_key'] : $this->def['rhs_key']; |
321 | 334 | $targetTable = $linkIsLHS ? $this->def['rhs_table'] : $this->def['lhs_table']; |
322 | 335 | $targetKey = $linkIsLHS ? $this->def['rhs_key'] : $this->def['lhs_key']; |
@@ -393,9 +406,10 @@ discard block |
||
393 | 406 | |
394 | 407 | public function getRelationshipTable() |
395 | 408 | { |
396 | - if (isset($this->def['table'])) |
|
397 | - return $this->def['table']; |
|
398 | - else |
|
399 | - return $this->def['rhs_table']; |
|
409 | + if (isset($this->def['table'])) { |
|
410 | + return $this->def['table']; |
|
411 | + } else { |
|
412 | + return $this->def['rhs_table']; |
|
413 | + } |
|
400 | 414 | } |
401 | 415 | } |
@@ -131,28 +131,28 @@ discard block |
||
131 | 131 | $lhsLinkName = $this->lhsLink; |
132 | 132 | $rhsLinkName = $this->rhsLink; |
133 | 133 | |
134 | - /* BEGIN - SECURITY GROUPS */ |
|
135 | - //Need to hijack this as security groups will not contain a link on the module side |
|
136 | - //due to the way the module works. Plus it would remove the relative ease of adding custom module support |
|
134 | + /* BEGIN - SECURITY GROUPS */ |
|
135 | + //Need to hijack this as security groups will not contain a link on the module side |
|
136 | + //due to the way the module works. Plus it would remove the relative ease of adding custom module support |
|
137 | 137 | |
138 | - if(get_class($rhs) != 'User' && get_class($rhs) != 'ACLRole' && get_class($lhs) == 'SecurityGroup') { |
|
139 | - $rhs->$rhsLinkName->addBean($lhs); |
|
140 | - $this->callBeforeAdd($rhs, $lhs, $rhsLinkName); |
|
141 | - |
|
142 | - $dataToInsert = $this->getRowToInsert($lhs, $rhs, $additionalFields); |
|
143 | - $this->addRow($dataToInsert); |
|
144 | - $rhs->$rhsLinkName->addBean($lhs); |
|
145 | - $this->callAfterAdd($lhs, $rhs, $lhsLinkName); |
|
146 | - } else if(get_class($lhs) != 'User' && get_class($lhs) != 'ACLRole' && get_class($rhs) == 'SecurityGroup') { |
|
147 | - $lhs->$lhsLinkName->addBean($rhs); |
|
148 | - $this->callBeforeAdd($lhs, $rhs, $lhsLinkName); |
|
149 | - |
|
150 | - $dataToInsert = $this->getRowToInsert($lhs, $rhs, $additionalFields); |
|
151 | - $this->addRow($dataToInsert); |
|
152 | - $lhs->$lhsLinkName->addBean($rhs); |
|
153 | - $this->callAfterAdd($rhs, $lhs, $rhsLinkName); |
|
154 | - } else { |
|
155 | - /* END - SECURITY GROUPS */ |
|
138 | + if(get_class($rhs) != 'User' && get_class($rhs) != 'ACLRole' && get_class($lhs) == 'SecurityGroup') { |
|
139 | + $rhs->$rhsLinkName->addBean($lhs); |
|
140 | + $this->callBeforeAdd($rhs, $lhs, $rhsLinkName); |
|
141 | + |
|
142 | + $dataToInsert = $this->getRowToInsert($lhs, $rhs, $additionalFields); |
|
143 | + $this->addRow($dataToInsert); |
|
144 | + $rhs->$rhsLinkName->addBean($lhs); |
|
145 | + $this->callAfterAdd($lhs, $rhs, $lhsLinkName); |
|
146 | + } else if(get_class($lhs) != 'User' && get_class($lhs) != 'ACLRole' && get_class($rhs) == 'SecurityGroup') { |
|
147 | + $lhs->$lhsLinkName->addBean($rhs); |
|
148 | + $this->callBeforeAdd($lhs, $rhs, $lhsLinkName); |
|
149 | + |
|
150 | + $dataToInsert = $this->getRowToInsert($lhs, $rhs, $additionalFields); |
|
151 | + $this->addRow($dataToInsert); |
|
152 | + $lhs->$lhsLinkName->addBean($rhs); |
|
153 | + $this->callAfterAdd($rhs, $lhs, $rhsLinkName); |
|
154 | + } else { |
|
155 | + /* END - SECURITY GROUPS */ |
|
156 | 156 | |
157 | 157 | if (empty($lhs->$lhsLinkName) && !$lhs->load_relationship($lhsLinkName)) |
158 | 158 | { |
@@ -262,50 +262,50 @@ discard block |
||
262 | 262 | return false; |
263 | 263 | } |
264 | 264 | |
265 | - /* BEGIN - SECURITY GROUPS */ |
|
266 | - //Need to hijack this as security groups will not contain a link on the module side |
|
267 | - //due to the way the module works. Plus it would remove the relative ease of adding custom module support |
|
265 | + /* BEGIN - SECURITY GROUPS */ |
|
266 | + //Need to hijack this as security groups will not contain a link on the module side |
|
267 | + //due to the way the module works. Plus it would remove the relative ease of adding custom module support |
|
268 | 268 | |
269 | - if(get_class($lhs) == 'SecurityGroup' || get_class($rhs) == 'SecurityGroup') { |
|
270 | - $dataToRemove = array( |
|
271 | - $this->def['join_key_lhs'] => $lhs->id, |
|
272 | - $this->def['join_key_rhs'] => $rhs->id |
|
273 | - ); |
|
274 | - |
|
275 | - |
|
276 | - if (empty($_SESSION['disable_workflow']) || $_SESSION['disable_workflow'] != "Yes") |
|
277 | - { |
|
278 | - if (get_class($lhs) != 'SecurityGroup' && $lhs->$lhsLinkName instanceof Link2) |
|
279 | - { |
|
280 | - $lhs->$lhsLinkName->load(); |
|
281 | - $this->callBeforeDelete($lhs, $rhs, $lhsLinkName); |
|
282 | - } |
|
283 | - |
|
284 | - if (get_class($rhs) != 'SecurityGroup' && $rhs->$rhsLinkName instanceof Link2) |
|
285 | - { |
|
286 | - $rhs->$rhsLinkName->load(); |
|
287 | - $this->callBeforeDelete($rhs, $lhs, $rhsLinkName); |
|
288 | - } |
|
289 | - } |
|
290 | - |
|
291 | - $this->removeRow($dataToRemove); |
|
269 | + if(get_class($lhs) == 'SecurityGroup' || get_class($rhs) == 'SecurityGroup') { |
|
270 | + $dataToRemove = array( |
|
271 | + $this->def['join_key_lhs'] => $lhs->id, |
|
272 | + $this->def['join_key_rhs'] => $rhs->id |
|
273 | + ); |
|
274 | + |
|
275 | + |
|
276 | + if (empty($_SESSION['disable_workflow']) || $_SESSION['disable_workflow'] != "Yes") |
|
277 | + { |
|
278 | + if (get_class($lhs) != 'SecurityGroup' && $lhs->$lhsLinkName instanceof Link2) |
|
279 | + { |
|
280 | + $lhs->$lhsLinkName->load(); |
|
281 | + $this->callBeforeDelete($lhs, $rhs, $lhsLinkName); |
|
282 | + } |
|
283 | + |
|
284 | + if (get_class($rhs) != 'SecurityGroup' && $rhs->$rhsLinkName instanceof Link2) |
|
285 | + { |
|
286 | + $rhs->$rhsLinkName->load(); |
|
287 | + $this->callBeforeDelete($rhs, $lhs, $rhsLinkName); |
|
288 | + } |
|
289 | + } |
|
290 | + |
|
291 | + $this->removeRow($dataToRemove); |
|
292 | 292 | |
293 | - if (empty($_SESSION['disable_workflow']) || $_SESSION['disable_workflow'] != "Yes") |
|
294 | - { |
|
295 | - if (get_class($lhs) != 'SecurityGroup' && $lhs->$lhsLinkName instanceof Link2) |
|
296 | - { |
|
297 | - $lhs->$lhsLinkName->load(); |
|
298 | - $this->callAfterDelete($lhs, $rhs, $lhsLinkName); |
|
299 | - } |
|
300 | - |
|
301 | - if (get_class($rhs) != 'SecurityGroup' && $rhs->$rhsLinkName instanceof Link2) |
|
302 | - { |
|
303 | - $rhs->$rhsLinkName->load(); |
|
304 | - $this->callAfterDelete($rhs, $lhs, $rhsLinkName); |
|
305 | - } |
|
306 | - } |
|
307 | - } else { |
|
308 | - /* END - SECURITY GROUPS */ |
|
293 | + if (empty($_SESSION['disable_workflow']) || $_SESSION['disable_workflow'] != "Yes") |
|
294 | + { |
|
295 | + if (get_class($lhs) != 'SecurityGroup' && $lhs->$lhsLinkName instanceof Link2) |
|
296 | + { |
|
297 | + $lhs->$lhsLinkName->load(); |
|
298 | + $this->callAfterDelete($lhs, $rhs, $lhsLinkName); |
|
299 | + } |
|
300 | + |
|
301 | + if (get_class($rhs) != 'SecurityGroup' && $rhs->$rhsLinkName instanceof Link2) |
|
302 | + { |
|
303 | + $rhs->$rhsLinkName->load(); |
|
304 | + $this->callAfterDelete($rhs, $lhs, $rhsLinkName); |
|
305 | + } |
|
306 | + } |
|
307 | + } else { |
|
308 | + /* END - SECURITY GROUPS */ |
|
309 | 309 | if (empty($lhs->$lhsLinkName) && !$lhs->load_relationship($lhsLinkName)) |
310 | 310 | { |
311 | 311 | $GLOBALS['log']->fatal("could not load LHS $lhsLinkName"); |
@@ -512,9 +512,9 @@ discard block |
||
512 | 512 | //First join the relationship table |
513 | 513 | $join .= "$join_type $joinTableWithAlias ON $join1 AND $joinTable.deleted=0\n" |
514 | 514 | //Next add any role filters |
515 | - . $this->getRoleWhere($joinTable) . "\n" |
|
515 | + . $this->getRoleWhere($joinTable) . "\n" |
|
516 | 516 | //Then finally join the related module's table |
517 | - . "$join_type $targetTableWithAlias ON $join2 AND $targetTable.deleted=0\n"; |
|
517 | + . "$join_type $targetTableWithAlias ON $join2 AND $targetTable.deleted=0\n"; |
|
518 | 518 | |
519 | 519 | if($return_array){ |
520 | 520 | return array( |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | //First join the relationship table |
567 | 567 | $query .= "$join_type $joinTableWithAlias ON $where AND $joinTable.deleted=0\n" |
568 | 568 | //Next add any role filters |
569 | - . $this->getRoleWhere($joinTable, $ignoreRole) . "\n"; |
|
569 | + . $this->getRoleWhere($joinTable, $ignoreRole) . "\n"; |
|
570 | 570 | |
571 | 571 | if (!empty($params['return_as_array'])) { |
572 | 572 | $return_array = true; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -73,14 +73,14 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function getLinkedDefForModuleByRelationship($module) |
75 | 75 | { |
76 | - $results = VardefManager::getLinkFieldForRelationship( $module, BeanFactory::getObjectName($module), $this->name); |
|
76 | + $results = VardefManager::getLinkFieldForRelationship($module, BeanFactory::getObjectName($module), $this->name); |
|
77 | 77 | //Only a single link was found |
78 | - if( isset($results['name']) ) |
|
78 | + if (isset($results['name'])) |
|
79 | 79 | { |
80 | 80 | return $results; |
81 | 81 | } |
82 | 82 | //Multiple links with same relationship name |
83 | - else if( is_array($results) ) |
|
83 | + else if (is_array($results)) |
|
84 | 84 | { |
85 | 85 | $GLOBALS['log']->error("Warning: Multiple links found for relationship {$this->name} within module {$module}"); |
86 | 86 | return $this->getMostAppropriateLinkedDefinition($results); |
@@ -101,17 +101,17 @@ discard block |
||
101 | 101 | protected function getMostAppropriateLinkedDefinition($links) |
102 | 102 | { |
103 | 103 | //First priority is to find a link name that matches the relationship name |
104 | - foreach($links as $link) |
|
104 | + foreach ($links as $link) |
|
105 | 105 | { |
106 | - if( isset($link['name']) && $link['name'] == $this->name ) |
|
106 | + if (isset($link['name']) && $link['name'] == $this->name) |
|
107 | 107 | { |
108 | 108 | return $link; |
109 | 109 | } |
110 | 110 | } |
111 | 111 | //Next would be a relationship that has a side defined |
112 | - foreach($links as $link) |
|
112 | + foreach ($links as $link) |
|
113 | 113 | { |
114 | - if( isset($link['id_name'])) |
|
114 | + if (isset($link['id_name'])) |
|
115 | 115 | { |
116 | 116 | return $link; |
117 | 117 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | //Need to hijack this as security groups will not contain a link on the module side |
136 | 136 | //due to the way the module works. Plus it would remove the relative ease of adding custom module support |
137 | 137 | |
138 | - if(get_class($rhs) != 'User' && get_class($rhs) != 'ACLRole' && get_class($lhs) == 'SecurityGroup') { |
|
138 | + if (get_class($rhs) != 'User' && get_class($rhs) != 'ACLRole' && get_class($lhs) == 'SecurityGroup') { |
|
139 | 139 | $rhs->$rhsLinkName->addBean($lhs); |
140 | 140 | $this->callBeforeAdd($rhs, $lhs, $rhsLinkName); |
141 | 141 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $this->addRow($dataToInsert); |
144 | 144 | $rhs->$rhsLinkName->addBean($lhs); |
145 | 145 | $this->callAfterAdd($lhs, $rhs, $lhsLinkName); |
146 | - } else if(get_class($lhs) != 'User' && get_class($lhs) != 'ACLRole' && get_class($rhs) == 'SecurityGroup') { |
|
146 | + } else if (get_class($lhs) != 'User' && get_class($lhs) != 'ACLRole' && get_class($rhs) == 'SecurityGroup') { |
|
147 | 147 | $lhs->$lhsLinkName->addBean($rhs); |
148 | 148 | $this->callBeforeAdd($lhs, $rhs, $lhsLinkName); |
149 | 149 | |
@@ -205,14 +205,14 @@ discard block |
||
205 | 205 | ); |
206 | 206 | |
207 | 207 | |
208 | - if (!empty($this->def['relationship_role_column']) && !empty($this->def['relationship_role_column_value']) && !$this->ignore_role_filter ) |
|
208 | + if (!empty($this->def['relationship_role_column']) && !empty($this->def['relationship_role_column_value']) && !$this->ignore_role_filter) |
|
209 | 209 | { |
210 | 210 | $row[$this->relationship_role_column] = $this->relationship_role_column_value; |
211 | 211 | } |
212 | 212 | |
213 | 213 | if (!empty($this->def['fields'])) |
214 | 214 | { |
215 | - foreach($this->def['fields'] as $fieldDef) |
|
215 | + foreach ($this->def['fields'] as $fieldDef) |
|
216 | 216 | { |
217 | 217 | if (!empty($fieldDef['name']) && !isset($row[$fieldDef['name']]) && !empty($fieldDef['default'])) |
218 | 218 | { |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | |
247 | 247 | public function remove($lhs, $rhs) |
248 | 248 | { |
249 | - if(!($lhs instanceof SugarBean) || !($rhs instanceof SugarBean)) { |
|
249 | + if (!($lhs instanceof SugarBean) || !($rhs instanceof SugarBean)) { |
|
250 | 250 | $GLOBALS['log']->fatal("LHS and RHS must be beans"); |
251 | 251 | return false; |
252 | 252 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | //Need to hijack this as security groups will not contain a link on the module side |
267 | 267 | //due to the way the module works. Plus it would remove the relative ease of adding custom module support |
268 | 268 | |
269 | - if(get_class($lhs) == 'SecurityGroup' || get_class($rhs) == 'SecurityGroup') { |
|
269 | + if (get_class($lhs) == 'SecurityGroup' || get_class($rhs) == 'SecurityGroup') { |
|
270 | 270 | $dataToRemove = array( |
271 | 271 | $this->def['join_key_lhs'] => $lhs->id, |
272 | 272 | $this->def['join_key_rhs'] => $rhs->id |
@@ -426,12 +426,12 @@ discard block |
||
426 | 426 | } |
427 | 427 | $rel_table = $this->getRelationshipTable(); |
428 | 428 | |
429 | - $where = "$rel_table.$knownKey = '{$link->getFocus()->id}'" . $this->getRoleWhere(); |
|
429 | + $where = "$rel_table.$knownKey = '{$link->getFocus()->id}'".$this->getRoleWhere(); |
|
430 | 430 | $order_by = ''; |
431 | 431 | |
432 | 432 | //Add any optional where clause |
433 | 433 | if (!empty($params['where'])) { |
434 | - $add_where = is_string($params['where']) ? $params['where'] : "$whereTable." . $this->getOptionalWhereClause($params['where']); |
|
434 | + $add_where = is_string($params['where']) ? $params['where'] : "$whereTable.".$this->getOptionalWhereClause($params['where']); |
|
435 | 435 | if (!empty($add_where)) |
436 | 436 | $where .= " AND $add_where"; |
437 | 437 | } |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | } |
443 | 443 | |
444 | 444 | $deleted = !empty($params['deleted']) ? 1 : 0; |
445 | - $from = $rel_table . " "; |
|
445 | + $from = $rel_table." "; |
|
446 | 446 | if (!empty($params['where']) || !empty($params['order_by'])) { |
447 | 447 | $from .= ", $whereTable"; |
448 | 448 | if (isset($relatedSeed->custom_fields)) { |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | |
455 | 455 | if (empty($params['return_as_array'])) { |
456 | 456 | $query = "SELECT $targetKey id FROM $from WHERE $where AND $rel_table.deleted=$deleted"; |
457 | - if(!empty($order_by)) $query .= ' ORDER BY '.$order_by; |
|
457 | + if (!empty($order_by)) $query .= ' ORDER BY '.$order_by; |
|
458 | 458 | //Limit is not compatible with return_as_array |
459 | 459 | if (!empty($params['limit']) && $params['limit'] > 0) { |
460 | 460 | $offset = isset($params['offset']) ? $params['offset'] : 0; |
@@ -488,19 +488,19 @@ discard block |
||
488 | 488 | $targetTable = $linkIsLHS ? $this->def['rhs_table'] : $this->def['lhs_table']; |
489 | 489 | $targetTableWithAlias = $targetTable; |
490 | 490 | $targetKey = $linkIsLHS ? $this->def['rhs_key'] : $this->def['lhs_key']; |
491 | - $join_type= isset($params['join_type']) ? $params['join_type'] : ' INNER JOIN '; |
|
491 | + $join_type = isset($params['join_type']) ? $params['join_type'] : ' INNER JOIN '; |
|
492 | 492 | |
493 | 493 | $join = ''; |
494 | 494 | |
495 | 495 | //Set up any table aliases required |
496 | 496 | if (!empty($params['join_table_link_alias'])) |
497 | 497 | { |
498 | - $joinTableWithAlias = $joinTable . " ". $params['join_table_link_alias']; |
|
498 | + $joinTableWithAlias = $joinTable." ".$params['join_table_link_alias']; |
|
499 | 499 | $joinTable = $params['join_table_link_alias']; |
500 | 500 | } |
501 | - if ( ! empty($params['join_table_alias'])) |
|
501 | + if (!empty($params['join_table_alias'])) |
|
502 | 502 | { |
503 | - $targetTableWithAlias = $targetTable . " ". $params['join_table_alias']; |
|
503 | + $targetTableWithAlias = $targetTable." ".$params['join_table_alias']; |
|
504 | 504 | $targetTable = $params['join_table_alias']; |
505 | 505 | } |
506 | 506 | |
@@ -512,11 +512,11 @@ discard block |
||
512 | 512 | //First join the relationship table |
513 | 513 | $join .= "$join_type $joinTableWithAlias ON $join1 AND $joinTable.deleted=0\n" |
514 | 514 | //Next add any role filters |
515 | - . $this->getRoleWhere($joinTable) . "\n" |
|
515 | + . $this->getRoleWhere($joinTable)."\n" |
|
516 | 516 | //Then finally join the related module's table |
517 | 517 | . "$join_type $targetTableWithAlias ON $join2 AND $targetTable.deleted=0\n"; |
518 | 518 | |
519 | - if($return_array){ |
|
519 | + if ($return_array) { |
|
520 | 520 | return array( |
521 | 521 | 'join' => $join, |
522 | 522 | 'type' => $this->type, |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | 'select' => "$targetTable.id", |
527 | 527 | ); |
528 | 528 | } |
529 | - return $join . $where; |
|
529 | + return $join.$where; |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | /** |
@@ -540,21 +540,21 @@ discard block |
||
540 | 540 | public function getSubpanelQuery($link, $params = array(), $return_array = false) |
541 | 541 | { |
542 | 542 | $targetIsLHS = $link->getSide() == REL_RHS; |
543 | - $startingTable = $targetIsLHS ? $this->def['lhs_table'] : $this->def['rhs_table'];; |
|
543 | + $startingTable = $targetIsLHS ? $this->def['lhs_table'] : $this->def['rhs_table']; ; |
|
544 | 544 | $startingKey = $targetIsLHS ? $this->def['lhs_key'] : $this->def['rhs_key']; |
545 | 545 | $startingJoinKey = $targetIsLHS ? $this->def['join_key_lhs'] : $this->def['join_key_rhs']; |
546 | 546 | $joinTable = $this->getRelationshipTable(); |
547 | 547 | $joinTableWithAlias = $joinTable; |
548 | 548 | $joinKey = $targetIsLHS ? $this->def['join_key_rhs'] : $this->def['join_key_lhs']; |
549 | 549 | $targetKey = $targetIsLHS ? $this->def['rhs_key'] : $this->def['lhs_key']; |
550 | - $join_type= isset($params['join_type']) ? $params['join_type'] : ' INNER JOIN '; |
|
550 | + $join_type = isset($params['join_type']) ? $params['join_type'] : ' INNER JOIN '; |
|
551 | 551 | |
552 | 552 | $query = ''; |
553 | 553 | |
554 | 554 | //Set up any table aliases required |
555 | 555 | if (!empty($params['join_table_link_alias'])) |
556 | 556 | { |
557 | - $joinTableWithAlias = $joinTable . " ". $params['join_table_link_alias']; |
|
557 | + $joinTableWithAlias = $joinTable." ".$params['join_table_link_alias']; |
|
558 | 558 | $joinTable = $params['join_table_link_alias']; |
559 | 559 | } |
560 | 560 | |
@@ -566,12 +566,12 @@ discard block |
||
566 | 566 | //First join the relationship table |
567 | 567 | $query .= "$join_type $joinTableWithAlias ON $where AND $joinTable.deleted=0\n" |
568 | 568 | //Next add any role filters |
569 | - . $this->getRoleWhere($joinTable, $ignoreRole) . "\n"; |
|
569 | + . $this->getRoleWhere($joinTable, $ignoreRole)."\n"; |
|
570 | 570 | |
571 | 571 | if (!empty($params['return_as_array'])) { |
572 | 572 | $return_array = true; |
573 | 573 | } |
574 | - if($return_array){ |
|
574 | + if ($return_array) { |
|
575 | 575 | return array( |
576 | 576 | 'join' => $query, |
577 | 577 | 'type' => $this->type, |
@@ -594,11 +594,11 @@ discard block |
||
594 | 594 | //role column value. |
595 | 595 | if (empty($this->relationship_role_column_value)) |
596 | 596 | { |
597 | - $ret.=' IS NULL'; |
|
597 | + $ret .= ' IS NULL'; |
|
598 | 598 | } else { |
599 | - $ret.= "='".$this->relationship_role_column_value."'"; |
|
599 | + $ret .= "='".$this->relationship_role_column_value."'"; |
|
600 | 600 | } |
601 | - $ret.= "\n"; |
|
601 | + $ret .= "\n"; |
|
602 | 602 | } |
603 | 603 | return $ret; |
604 | 604 | } |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | $query = "SELECT id FROM {$this->getRelationshipTable()} WHERE {$this->join_key_lhs} = '{$lhs->id}' AND {$this->join_key_rhs} = '{$rhs->id}'"; |
614 | 614 | |
615 | 615 | //Roles can allow for multiple links between two records with different roles |
616 | - $query .= $this->getRoleWhere() . " and deleted = 0"; |
|
616 | + $query .= $this->getRoleWhere()." and deleted = 0"; |
|
617 | 617 | |
618 | 618 | return $GLOBALS['db']->getOne($query); |
619 | 619 | } |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | { |
639 | 639 | if (!empty($this->def['table'])) |
640 | 640 | return $this->def['table']; |
641 | - else if(!empty($this->def['join_table'])) |
|
641 | + else if (!empty($this->def['join_table'])) |
|
642 | 642 | return $this->def['join_table']; |
643 | 643 | |
644 | 644 | return false; |
@@ -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. |
@@ -84,8 +86,7 @@ discard block |
||
84 | 86 | { |
85 | 87 | $GLOBALS['log']->error("Warning: Multiple links found for relationship {$this->name} within module {$module}"); |
86 | 88 | return $this->getMostAppropriateLinkedDefinition($results); |
87 | - } |
|
88 | - else |
|
89 | + } else |
|
89 | 90 | { |
90 | 91 | return FALSE; |
91 | 92 | } |
@@ -178,8 +179,9 @@ discard block |
||
178 | 179 | |
179 | 180 | $this->addRow($dataToInsert); |
180 | 181 | |
181 | - if ($this->self_referencing) |
|
182 | - $this->addSelfReferencing($lhs, $rhs, $additionalFields); |
|
182 | + if ($this->self_referencing) { |
|
183 | + $this->addSelfReferencing($lhs, $rhs, $additionalFields); |
|
184 | + } |
|
183 | 185 | |
184 | 186 | $lhs->$lhsLinkName->addBean($rhs); |
185 | 187 | $rhs->$rhsLinkName->addBean($lhs); |
@@ -339,8 +341,9 @@ discard block |
||
339 | 341 | |
340 | 342 | $this->removeRow($dataToRemove); |
341 | 343 | |
342 | - if ($this->self_referencing) |
|
343 | - $this->removeSelfReferencing($lhs, $rhs); |
|
344 | + if ($this->self_referencing) { |
|
345 | + $this->removeSelfReferencing($lhs, $rhs); |
|
346 | + } |
|
344 | 347 | |
345 | 348 | if (empty($_SESSION['disable_workflow']) || $_SESSION['disable_workflow'] != "Yes") |
346 | 349 | { |
@@ -395,8 +398,9 @@ discard block |
||
395 | 398 | $idField = $link->getSide() == REL_LHS ? $this->def['join_key_rhs'] : $this->def['join_key_lhs']; |
396 | 399 | while ($row = $db->fetchByAssoc($result, FALSE)) |
397 | 400 | { |
398 | - if (empty($row['id']) && empty($row[$idField])) |
|
399 | - continue; |
|
401 | + if (empty($row['id']) && empty($row[$idField])) { |
|
402 | + continue; |
|
403 | + } |
|
400 | 404 | $id = empty($row['id']) ? $row[$idField] : $row['id']; |
401 | 405 | $rows[$id] = $row; |
402 | 406 | } |
@@ -414,15 +418,17 @@ discard block |
||
414 | 418 | $targetKey = $this->def['join_key_rhs']; |
415 | 419 | $relatedSeed = BeanFactory::getBean($this->getRHSModule()); |
416 | 420 | $relatedSeedKey = $this->def['rhs_key']; |
417 | - if (!empty($params['where']) || !empty($params['order_by'])) |
|
418 | - $whereTable = (empty($params['right_join_table_alias']) ? $relatedSeed->table_name : $params['right_join_table_alias']); |
|
421 | + if (!empty($params['where']) || !empty($params['order_by'])) { |
|
422 | + $whereTable = (empty($params['right_join_table_alias']) ? $relatedSeed->table_name : $params['right_join_table_alias']); |
|
423 | + } |
|
419 | 424 | } else { |
420 | 425 | $knownKey = $this->def['join_key_rhs']; |
421 | 426 | $targetKey = $this->def['join_key_lhs']; |
422 | 427 | $relatedSeed = BeanFactory::getBean($this->getLHSModule()); |
423 | 428 | $relatedSeedKey = $this->def['lhs_key']; |
424 | - if (!empty($params['where']) || !empty($params['order_by'])) |
|
425 | - $whereTable = (empty($params['left_join_table_alias']) ? $relatedSeed->table_name : $params['left_join_table_alias']); |
|
429 | + if (!empty($params['where']) || !empty($params['order_by'])) { |
|
430 | + $whereTable = (empty($params['left_join_table_alias']) ? $relatedSeed->table_name : $params['left_join_table_alias']); |
|
431 | + } |
|
426 | 432 | } |
427 | 433 | $rel_table = $this->getRelationshipTable(); |
428 | 434 | |
@@ -432,8 +438,9 @@ discard block |
||
432 | 438 | //Add any optional where clause |
433 | 439 | if (!empty($params['where'])) { |
434 | 440 | $add_where = is_string($params['where']) ? $params['where'] : "$whereTable." . $this->getOptionalWhereClause($params['where']); |
435 | - if (!empty($add_where)) |
|
436 | - $where .= " AND $add_where"; |
|
441 | + if (!empty($add_where)) { |
|
442 | + $where .= " AND $add_where"; |
|
443 | + } |
|
437 | 444 | } |
438 | 445 | |
439 | 446 | //Add any optional order clauses |
@@ -454,7 +461,9 @@ discard block |
||
454 | 461 | |
455 | 462 | if (empty($params['return_as_array'])) { |
456 | 463 | $query = "SELECT $targetKey id FROM $from WHERE $where AND $rel_table.deleted=$deleted"; |
457 | - if(!empty($order_by)) $query .= ' ORDER BY '.$order_by; |
|
464 | + if(!empty($order_by)) { |
|
465 | + $query .= ' ORDER BY '.$order_by; |
|
466 | + } |
|
458 | 467 | //Limit is not compatible with return_as_array |
459 | 468 | if (!empty($params['limit']) && $params['limit'] > 0) { |
460 | 469 | $offset = isset($params['offset']) ? $params['offset'] : 0; |
@@ -636,18 +645,20 @@ discard block |
||
636 | 645 | |
637 | 646 | public function getRelationshipTable() |
638 | 647 | { |
639 | - if (!empty($this->def['table'])) |
|
640 | - return $this->def['table']; |
|
641 | - else if(!empty($this->def['join_table'])) |
|
642 | - return $this->def['join_table']; |
|
648 | + if (!empty($this->def['table'])) { |
|
649 | + return $this->def['table']; |
|
650 | + } else if(!empty($this->def['join_table'])) { |
|
651 | + return $this->def['join_table']; |
|
652 | + } |
|
643 | 653 | |
644 | 654 | return false; |
645 | 655 | } |
646 | 656 | |
647 | 657 | public function getFields() |
648 | 658 | { |
649 | - if (!empty($this->def['fields'])) |
|
650 | - return $this->def['fields']; |
|
659 | + if (!empty($this->def['fields'])) { |
|
660 | + return $this->def['fields']; |
|
661 | + } |
|
651 | 662 | $fields = array( |
652 | 663 | "id" => array('name' => 'id'), |
653 | 664 | 'date_modified' => array('name' => 'date_modified'), |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | |
366 | 366 | /** |
367 | 367 | * Removes the reversed version of this relationship |
368 | - * @param $lhs |
|
369 | - * @param $rhs |
|
368 | + * @param SugarBean $lhs |
|
369 | + * @param SugarBean $rhs |
|
370 | 370 | * @param array $additionalFields |
371 | 371 | * @return void |
372 | 372 | */ |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
386 | - * @param $link Link2 loads the relationship for this link. |
|
386 | + * @param Link2 $link Link2 loads the relationship for this link. |
|
387 | 387 | * @return void |
388 | 388 | */ |
389 | 389 | public function load($link, $params = array()) |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | /** |
533 | 533 | * Similar to getQuery or Get join, except this time we are starting from the related table and |
534 | 534 | * searching for items with id's matching the $link->focus->id |
535 | - * @param $link |
|
535 | + * @param Link2 $link |
|
536 | 536 | * @param array $params |
537 | 537 | * @param bool $return_array |
538 | 538 | * @return String|Array |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | ); |
101 | 101 | if (!isset($this->lhsLinkDef['name']) && isset($this->lhsLinkDef[0])) |
102 | 102 | { |
103 | - $this->lhsLinkDef = $this->lhsLinkDef[0]; |
|
103 | + $this->lhsLinkDef = $this->lhsLinkDef[0]; |
|
104 | 104 | } |
105 | 105 | if (!isset($this->rhsLinkDef['name']) && isset($this->rhsLinkDef[0])) { |
106 | 106 | $this->rhsLinkDef = $this->rhsLinkDef[0]; |
@@ -128,35 +128,35 @@ discard block |
||
128 | 128 | //If the current data matches the existing data, don't do anything |
129 | 129 | if (!$this->checkExisting($dataToInsert)) |
130 | 130 | { |
131 | - // Pre-load the RHS relationship, which is used later in the add() function and expects a Bean |
|
132 | - // and we also use it for clearing relationships in case of non self-referencing O2M relations |
|
133 | - // (should be preloaded because when using the relate_to field for updating/saving relationships, |
|
134 | - // only the bean id is loaded into $rhs->$rhsLinkName) |
|
135 | - $rhsLinkName = $this->rhsLink; |
|
136 | - $rhs->load_relationship($rhsLinkName); |
|
131 | + // Pre-load the RHS relationship, which is used later in the add() function and expects a Bean |
|
132 | + // and we also use it for clearing relationships in case of non self-referencing O2M relations |
|
133 | + // (should be preloaded because when using the relate_to field for updating/saving relationships, |
|
134 | + // only the bean id is loaded into $rhs->$rhsLinkName) |
|
135 | + $rhsLinkName = $this->rhsLink; |
|
136 | + $rhs->load_relationship($rhsLinkName); |
|
137 | 137 | |
138 | - // If it's a One2Many self-referencing relationship |
|
139 | - // the positions of the default One (LHS) and Many (RHS) are swaped |
|
140 | - // so we should clear the links from the many (left) side |
|
141 | - if ($this->selfReferencing) { |
|
142 | - // Load right hand side relationship name |
|
143 | - $linkName = $this->rhsLink; |
|
144 | - // Load the relationship into the left hand side bean |
|
145 | - $lhs->load_relationship($linkName); |
|
138 | + // If it's a One2Many self-referencing relationship |
|
139 | + // the positions of the default One (LHS) and Many (RHS) are swaped |
|
140 | + // so we should clear the links from the many (left) side |
|
141 | + if ($this->selfReferencing) { |
|
142 | + // Load right hand side relationship name |
|
143 | + $linkName = $this->rhsLink; |
|
144 | + // Load the relationship into the left hand side bean |
|
145 | + $lhs->load_relationship($linkName); |
|
146 | 146 | |
147 | - // Pick the loaded link |
|
148 | - $link = $lhs->$linkName; |
|
149 | - // Get many (LHS) side bean |
|
150 | - $focus = $link->getFocus(); |
|
151 | - // Get relations |
|
152 | - $related = $link->getBeans(); |
|
147 | + // Pick the loaded link |
|
148 | + $link = $lhs->$linkName; |
|
149 | + // Get many (LHS) side bean |
|
150 | + $focus = $link->getFocus(); |
|
151 | + // Get relations |
|
152 | + $related = $link->getBeans(); |
|
153 | 153 | |
154 | - // Clear the relations from many side bean |
|
155 | - foreach($related as $relBean) { |
|
156 | - $this->remove($focus, $relBean); |
|
157 | - } |
|
154 | + // Clear the relations from many side bean |
|
155 | + foreach($related as $relBean) { |
|
156 | + $this->remove($focus, $relBean); |
|
157 | + } |
|
158 | 158 | } else { // For non self-referencing, remove all the relationships from the many (RHS) side |
159 | - $this->removeAll($rhs->$rhsLinkName); |
|
159 | + $this->removeAll($rhs->$rhsLinkName); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | // Add relationship |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $related = $link->getBeans(); |
153 | 153 | |
154 | 154 | // Clear the relations from many side bean |
155 | - foreach($related as $relBean) { |
|
155 | + foreach ($related as $relBean) { |
|
156 | 156 | $this->remove($focus, $relBean); |
157 | 157 | } |
158 | 158 | } else { // For non self-referencing, remove all the relationships from the many (RHS) side |
@@ -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. |
@@ -67,13 +69,13 @@ discard block |
||
67 | 69 | if (empty($links)) |
68 | 70 | { |
69 | 71 | $GLOBALS['log']->fatal("No Links found for relationship {$this->name}"); |
70 | - } |
|
71 | - else { |
|
72 | - if (!is_array($links)) //Only one link for a self referencing relationship, this is very bad. |
|
72 | + } else { |
|
73 | + if (!is_array($links)) { |
|
74 | + //Only one link for a self referencing relationship, this is very bad. |
|
73 | 75 | { |
74 | 76 | $this->lhsLinkDef = $this->rhsLinkDef = $links; |
75 | 77 | } |
76 | - else if (!empty($links[0]) && !empty($links[1])) |
|
78 | + } else if (!empty($links[0]) && !empty($links[1])) |
|
77 | 79 | { |
78 | 80 | |
79 | 81 | if ((!empty($links[0]['side']) && $links[0]['side'] == "right") |
@@ -119,7 +119,7 @@ |
||
119 | 119 | * @param $lhs SugarBean left side bean to add to the relationship. |
120 | 120 | * @param $rhs SugarBean right side bean to add to the relationship. |
121 | 121 | * @param $additionalFields key=>value pairs of fields to save on the relationship |
122 | - * @return boolean true if successful |
|
122 | + * @return boolean|null true if successful |
|
123 | 123 | */ |
124 | 124 | public function add($lhs, $rhs, $additionalFields = array()) |
125 | 125 | { |
@@ -213,9 +213,9 @@ |
||
213 | 213 | $buildingRelCache = false; |
214 | 214 | } |
215 | 215 | |
216 | - protected function getCacheFile() { |
|
217 | - return sugar_cached("Relationships/relationships.cache.php"); |
|
218 | - } |
|
216 | + protected function getCacheFile() { |
|
217 | + return sugar_cached("Relationships/relationships.cache.php"); |
|
218 | + } |
|
219 | 219 | |
220 | 220 | |
221 | 221 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | protected $relationships; |
53 | 53 | |
54 | - protected function __construct(){ |
|
54 | + protected function __construct() { |
|
55 | 55 | //Load the relationship definitions from the cache. |
56 | 56 | $this->loadRelationships(); |
57 | 57 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | public static function deleteCache() |
76 | 76 | { |
77 | 77 | $file = self::getInstance()->getCacheFile(); |
78 | - if(sugar_is_file($file)) |
|
78 | + if (sugar_is_file($file)) |
|
79 | 79 | { |
80 | 80 | unlink($file); |
81 | 81 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $def = $this->relationships[$relationshipName]; |
99 | 99 | |
100 | 100 | $type = isset($def['true_relationship_type']) ? $def['true_relationship_type'] : $def['relationship_type']; |
101 | - switch($type) |
|
101 | + switch ($type) |
|
102 | 102 | { |
103 | 103 | case "many-to-many": |
104 | 104 | if (isset($def['rhs_module']) && $def['rhs_module'] == 'EmailAddresses') |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | case "one-to-many": |
113 | 113 | require_once("data/Relationships/One2MBeanRelationship.php"); |
114 | 114 | //If a relationship has no table or join keys, it must be bean based |
115 | - if (empty($def['true_relationship_type']) || (empty($def['table']) && empty($def['join_table'])) || empty($def['join_key_rhs'])){ |
|
115 | + if (empty($def['true_relationship_type']) || (empty($def['table']) && empty($def['join_table'])) || empty($def['join_key_rhs'])) { |
|
116 | 116 | return new One2MBeanRelationship($def); |
117 | 117 | } |
118 | 118 | else { |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | } |
121 | 121 | break; |
122 | 122 | case "one-to-one": |
123 | - if (empty($def['true_relationship_type'])){ |
|
123 | + if (empty($def['true_relationship_type'])) { |
|
124 | 124 | require_once("data/Relationships/One2OneBeanRelationship.php"); |
125 | 125 | return new One2OneBeanRelationship($def); |
126 | 126 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | break; |
132 | 132 | } |
133 | 133 | |
134 | - $GLOBALS['log']->fatal ("$relationshipName had an unknown type $type "); |
|
134 | + $GLOBALS['log']->fatal("$relationshipName had an unknown type $type "); |
|
135 | 135 | |
136 | 136 | return false; |
137 | 137 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | |
150 | 150 | protected function loadRelationships() |
151 | 151 | { |
152 | - if(sugar_is_file($this->getCacheFile())) |
|
152 | + if (sugar_is_file($this->getCacheFile())) |
|
153 | 153 | { |
154 | 154 | include($this->getCacheFile()); |
155 | 155 | $this->relationships = $relationships; |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | if (empty($beanList)) |
170 | 170 | include("include/modules.php"); |
171 | 171 | //Reload ALL the module vardefs.... |
172 | - foreach($beanList as $moduleName => $beanName) |
|
172 | + foreach ($beanList as $moduleName => $beanName) |
|
173 | 173 | { |
174 | 174 | VardefManager::loadVardef($moduleName, BeanFactory::getObjectName($moduleName), false, array( |
175 | 175 | //If relationships are not yet loaded, we can't figure out the rel_calc_fields. |
@@ -184,13 +184,13 @@ discard block |
||
184 | 184 | { |
185 | 185 | if (!empty($def['relationships'])) |
186 | 186 | { |
187 | - foreach($def['relationships'] as $relKey => $relDef) |
|
187 | + foreach ($def['relationships'] as $relKey => $relDef) |
|
188 | 188 | { |
189 | 189 | if ($key == $relKey) //Relationship only entry, we need to capture everything |
190 | 190 | $relationships[$key] = array_merge(array('name' => $key), (array)$def, (array)$relDef); |
191 | 191 | else { |
192 | 192 | $relationships[$relKey] = array_merge(array('name' => $relKey), (array)$relDef); |
193 | - if(!empty($relationships[$relKey]['join_table']) && empty($relationships[$relKey]['fields']) |
|
193 | + if (!empty($relationships[$relKey]['join_table']) && empty($relationships[$relKey]['fields']) |
|
194 | 194 | && isset($dictionary[$relationships[$relKey]['join_table']]['fields'])) { |
195 | 195 | $relationships[$relKey]['fields'] = $dictionary[$relationships[$relKey]['join_table']]['fields']; |
196 | 196 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | } |
201 | 201 | //Save it out |
202 | 202 | sugar_mkdir(dirname($this->getCacheFile()), null, true); |
203 | - $out = "<?php \n \$relationships = " . var_export($relationships, true) . ";"; |
|
203 | + $out = "<?php \n \$relationships = ".var_export($relationships, true).";"; |
|
204 | 204 | sugar_file_put_contents_atomic($this->getCacheFile(), $out); |
205 | 205 | |
206 | 206 | $this->relationships = $relationships; |
@@ -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. |
@@ -62,8 +64,9 @@ discard block |
||
62 | 64 | */ |
63 | 65 | public static function getInstance() |
64 | 66 | { |
65 | - if (is_null(self::$rfInstance)) |
|
66 | - self::$rfInstance = new SugarRelationshipFactory(); |
|
67 | + if (is_null(self::$rfInstance)) { |
|
68 | + self::$rfInstance = new SugarRelationshipFactory(); |
|
69 | + } |
|
67 | 70 | return self::$rfInstance; |
68 | 71 | } |
69 | 72 | |
@@ -114,8 +117,7 @@ discard block |
||
114 | 117 | //If a relationship has no table or join keys, it must be bean based |
115 | 118 | if (empty($def['true_relationship_type']) || (empty($def['table']) && empty($def['join_table'])) || empty($def['join_key_rhs'])){ |
116 | 119 | return new One2MBeanRelationship($def); |
117 | - } |
|
118 | - else { |
|
120 | + } else { |
|
119 | 121 | return new One2MRelationship($def); |
120 | 122 | } |
121 | 123 | break; |
@@ -123,8 +125,7 @@ discard block |
||
123 | 125 | if (empty($def['true_relationship_type'])){ |
124 | 126 | require_once("data/Relationships/One2OneBeanRelationship.php"); |
125 | 127 | return new One2OneBeanRelationship($def); |
126 | - } |
|
127 | - else { |
|
128 | + } else { |
|
128 | 129 | require_once("data/Relationships/One2OneRelationship.php"); |
129 | 130 | return new One2OneRelationship($def); |
130 | 131 | } |
@@ -161,13 +162,15 @@ discard block |
||
161 | 162 | protected function buildRelationshipCache() |
162 | 163 | { |
163 | 164 | global $beanList, $dictionary, $buildingRelCache; |
164 | - if ($buildingRelCache) |
|
165 | - return; |
|
165 | + if ($buildingRelCache) { |
|
166 | + return; |
|
167 | + } |
|
166 | 168 | $buildingRelCache = true; |
167 | 169 | include("modules/TableDictionary.php"); |
168 | 170 | |
169 | - if (empty($beanList)) |
|
170 | - include("include/modules.php"); |
|
171 | + if (empty($beanList)) { |
|
172 | + include("include/modules.php"); |
|
173 | + } |
|
171 | 174 | //Reload ALL the module vardefs.... |
172 | 175 | foreach($beanList as $moduleName => $beanName) |
173 | 176 | { |
@@ -186,9 +189,10 @@ discard block |
||
186 | 189 | { |
187 | 190 | foreach($def['relationships'] as $relKey => $relDef) |
188 | 191 | { |
189 | - if ($key == $relKey) //Relationship only entry, we need to capture everything |
|
192 | + if ($key == $relKey) { |
|
193 | + //Relationship only entry, we need to capture everything |
|
190 | 194 | $relationships[$key] = array_merge(array('name' => $key), (array)$def, (array)$relDef); |
191 | - else { |
|
195 | + } else { |
|
192 | 196 | $relationships[$relKey] = array_merge(array('name' => $relKey), (array)$relDef); |
193 | 197 | if(!empty($relationships[$relKey]['join_table']) && empty($relationships[$relKey]['fields']) |
194 | 198 | && isset($dictionary[$relationships[$relKey]['join_table']]['fields'])) { |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | } else { |
154 | 154 | $roleCheck .= " AND $table.bean_module"; |
155 | 155 | } |
156 | - $roleCheck .= " = '" . $this->getLHSModule() . "'"; |
|
156 | + $roleCheck .= " = '".$this->getLHSModule()."'"; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | return $roleCheck; |
@@ -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. |
@@ -65,8 +67,9 @@ discard block |
||
65 | 67 | return false; |
66 | 68 | } |
67 | 69 | |
68 | - if ($lhs->$lhsLinkName->beansAreLoaded()) |
|
69 | - $lhs->$lhsLinkName->addBean($rhs); |
|
70 | + if ($lhs->$lhsLinkName->beansAreLoaded()) { |
|
71 | + $lhs->$lhsLinkName->addBean($rhs); |
|
72 | + } |
|
70 | 73 | |
71 | 74 | $this->callBeforeAdd($lhs, $rhs, $lhsLinkName); |
72 | 75 | |
@@ -75,11 +78,13 @@ discard block |
||
75 | 78 | |
76 | 79 | $this->addRow($dataToInsert); |
77 | 80 | |
78 | - if ($this->self_referencing) |
|
79 | - $this->addSelfReferencing($lhs, $rhs, $additionalFields); |
|
81 | + if ($this->self_referencing) { |
|
82 | + $this->addSelfReferencing($lhs, $rhs, $additionalFields); |
|
83 | + } |
|
80 | 84 | |
81 | - if ($lhs->$lhsLinkName->beansAreLoaded()) |
|
82 | - $lhs->$lhsLinkName->addBean($rhs); |
|
85 | + if ($lhs->$lhsLinkName->beansAreLoaded()) { |
|
86 | + $lhs->$lhsLinkName->addBean($rhs); |
|
87 | + } |
|
83 | 88 | |
84 | 89 | $this->callAfterAdd($lhs, $rhs, $lhsLinkName); |
85 | 90 | |
@@ -120,8 +125,9 @@ discard block |
||
120 | 125 | |
121 | 126 | $this->removeRow($dataToRemove); |
122 | 127 | |
123 | - if ($this->self_referencing) |
|
124 | - $this->removeSelfReferencing($lhs, $rhs); |
|
128 | + if ($this->self_referencing) { |
|
129 | + $this->removeSelfReferencing($lhs, $rhs); |
|
130 | + } |
|
125 | 131 | |
126 | 132 | if (empty($_SESSION['disable_workflow']) || $_SESSION['disable_workflow'] != "Yes") |
127 | 133 | { |