Completed
Push — develop ( 7c1bda...edae1e )
by Adam
18:38 queued 03:14
created
include/Smarty/plugins/modifier.lookup.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
4 4
 /*********************************************************************************
5 5
  * SugarCRM Community Edition is a customer relationship management program developed by
6 6
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 
42 42
 
43 43
 
44
-function smarty_modifier_lookup($value='', $from=array()){
44
+function smarty_modifier_lookup($value = '', $from = array()) {
45 45
 	$value = trim($value);
46 46
 	if (array_key_exists($value, $from)) { 
47 47
 		return $from[$value]; 
Please login to merge, or discard this patch.
include/Smarty/plugins/function.sugarvar_connector.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 */
33 33
 
34 34
 
35
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
35
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
36 36
 /*********************************************************************************
37 37
  * SugarCRM Community Edition is a customer relationship management program developed by
38 38
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 function smarty_function_sugarvar_connector($params, &$smarty) {
76 76
       
77 77
       $displayParams = $smarty->get_template_vars('displayParams');
78
-      if(!isset($displayParams['module'])) {
78
+      if (!isset($displayParams['module'])) {
79 79
          $smarty->trigger_error("sugarvar_connector: missing 'module' parameter");
80 80
          $GLOBALS['log']->error("sugarvar_connector: missing 'module' parameter");
81 81
          return;     	
Please login to merge, or discard this patch.
include/Smarty/Smarty_Compiler.class.php 1 patch
Spacing   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -38,41 +38,41 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
data/Relationships/One2OneBeanRelationship.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,
Please login to merge, or discard this patch.
data/Relationships/One2MBeanRelationship.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,
Please login to merge, or discard this patch.
data/Relationships/M2MRelationship.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
data/Relationships/One2MRelationship.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
data/Relationships/EmailAddressRelationship.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
themes/Suite7/css/colourSelector.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // config|_override.php
4
-if(is_file('../../../config.php')) {
4
+if (is_file('../../../config.php')) {
5 5
     require_once('../../../config.php');
6 6
 }
7 7
 
8 8
 // load up the config_override.php file.  This is used to provide default user settings
9
-if(is_file('../../../config_override.php')) {
9
+if (is_file('../../../config_override.php')) {
10 10
     require_once('../../../config_override.php');
11 11
 }
12 12
 
13
-if(!isset($sugar_config['theme_settings']['Suite7'])) return;
13
+if (!isset($sugar_config['theme_settings']['Suite7'])) return;
14 14
 
15 15
 //set file type back to css from php
16 16
 header("Content-type: text/css; charset: UTF-8");
Please login to merge, or discard this patch.