Completed
Push — console-installer ( 3d54e5...e2b50d )
by Adam
69:10 queued 48:24
created
include/Smarty/plugins/shared.make_timestamp.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
     } elseif (preg_match('/^\d{14}$/', $string)) {
24 24
         // it is mysql timestamp format of YYYYMMDDHHMMSS?            
25 25
         $time = mktime(substr($string, 8, 2),substr($string, 10, 2),substr($string, 12, 2),
26
-                       substr($string, 4, 2),substr($string, 6, 2),substr($string, 0, 4));
26
+                        substr($string, 4, 2),substr($string, 6, 2),substr($string, 0, 4));
27 27
         
28 28
     } elseif (is_numeric($string)) {
29 29
         // it is a numeric string, we handle it as timestamp
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,14 +16,14 @@
 block discarded – undo
16 16
  */
17 17
 function smarty_make_timestamp($string)
18 18
 {
19
-    if(empty($string)) {
19
+    if (empty($string)) {
20 20
         // use "now":
21 21
         $time = time();
22 22
 
23 23
     } elseif (preg_match('/^\d{14}$/', $string)) {
24 24
         // it is mysql timestamp format of YYYYMMDDHHMMSS?            
25
-        $time = mktime(substr($string, 8, 2),substr($string, 10, 2),substr($string, 12, 2),
26
-                       substr($string, 4, 2),substr($string, 6, 2),substr($string, 0, 4));
25
+        $time = mktime(substr($string, 8, 2), substr($string, 10, 2), substr($string, 12, 2),
26
+                       substr($string, 4, 2), substr($string, 6, 2), substr($string, 0, 4));
27 27
         
28 28
     } elseif (is_numeric($string)) {
29 29
         // it is a numeric string, we handle it as timestamp
Please login to merge, or discard this patch.
include/Smarty/plugins/modifier.in_array.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,9 +44,9 @@
 block discarded – undo
44 44
  */
45 45
 function smarty_modifier_in_array($needle = null, $haystack = null)
46 46
 {
47
-	//Smarty barfs if Array is empty
47
+    //Smarty barfs if Array is empty
48 48
     if($haystack == null || empty($haystack)) {
49
-       return false;	
49
+        return false;	
50 50
     }
51 51
     return in_array($needle, $haystack);
52 52
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
 function smarty_modifier_in_array($needle = null, $haystack = null)
46 46
 {
47 47
 	//Smarty barfs if Array is empty
48
-    if($haystack == null || empty($haystack)) {
48
+    if ($haystack == null || empty($haystack)) {
49 49
        return false;	
50 50
     }
51 51
     return in_array($needle, $haystack);
Please login to merge, or discard this patch.
include/Smarty/plugins/function.sugar_email_btn.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -39,24 +39,24 @@
 block discarded – undo
39 39
 
40 40
 
41 41
 
42
- /**
43
- * smarty_function_sugar_email_btn
44
- * This is the constructor for the Smarty plugin.
45
- * This function exists so that the proper email button based on user prefs is loaded into the quotes module.
46
- * 
47
- * @param $params The runtime Smarty key/value arguments
48
- * @param $smarty The reference to the Smarty object used in this invocation
49
- */
42
+    /**
43
+     * smarty_function_sugar_email_btn
44
+     * This is the constructor for the Smarty plugin.
45
+     * This function exists so that the proper email button based on user prefs is loaded into the quotes module.
46
+     * 
47
+     * @param $params The runtime Smarty key/value arguments
48
+     * @param $smarty The reference to the Smarty object used in this invocation
49
+     */
50 50
 function smarty_function_sugar_email_btn($params, &$smarty)
51 51
 {
52
-	global $app_strings, $current_user;
53
-	$pdfButtons = '';
54
-	$client = $current_user->getPreference('email_link_type');
55
-	if ($client != 'sugar') {
56
-		$pdfButtons = '<input title="'. $app_strings["LBL_EMAIL_COMPOSE"] . '" class="button" type="submit" name="button" value="'. $app_strings["LBL_EMAIL_COMPOSE"] . '" onclick="location.href=\'mailto:\';return false;"> ';
57
-	} else {
58
-		$pdfButtons = '<input id="email_as_pdf_button" title="'. $app_strings["LBL_EMAIL_PDF_BUTTON_TITLE"] . '" class="button" type="submit" name="button" value="'. $app_strings["LBL_EMAIL_PDF_BUTTON_LABEL"] . '" onclick="this.form.email_action.value=\'EmailLayout\';"> ';
59
-	}
60
-	return $pdfButtons;
52
+    global $app_strings, $current_user;
53
+    $pdfButtons = '';
54
+    $client = $current_user->getPreference('email_link_type');
55
+    if ($client != 'sugar') {
56
+        $pdfButtons = '<input title="'. $app_strings["LBL_EMAIL_COMPOSE"] . '" class="button" type="submit" name="button" value="'. $app_strings["LBL_EMAIL_COMPOSE"] . '" onclick="location.href=\'mailto:\';return false;"> ';
57
+    } else {
58
+        $pdfButtons = '<input id="email_as_pdf_button" title="'. $app_strings["LBL_EMAIL_PDF_BUTTON_TITLE"] . '" class="button" type="submit" name="button" value="'. $app_strings["LBL_EMAIL_PDF_BUTTON_LABEL"] . '" onclick="this.form.email_action.value=\'EmailLayout\';"> ';
59
+    }
60
+    return $pdfButtons;
61 61
 }
62 62
 ?>
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,9 +53,9 @@
 block discarded – undo
53 53
 	$pdfButtons = '';
54 54
 	$client = $current_user->getPreference('email_link_type');
55 55
 	if ($client != 'sugar') {
56
-		$pdfButtons = '<input title="'. $app_strings["LBL_EMAIL_COMPOSE"] . '" class="button" type="submit" name="button" value="'. $app_strings["LBL_EMAIL_COMPOSE"] . '" onclick="location.href=\'mailto:\';return false;"> ';
56
+		$pdfButtons = '<input title="'.$app_strings["LBL_EMAIL_COMPOSE"].'" class="button" type="submit" name="button" value="'.$app_strings["LBL_EMAIL_COMPOSE"].'" onclick="location.href=\'mailto:\';return false;"> ';
57 57
 	} else {
58
-		$pdfButtons = '<input id="email_as_pdf_button" title="'. $app_strings["LBL_EMAIL_PDF_BUTTON_TITLE"] . '" class="button" type="submit" name="button" value="'. $app_strings["LBL_EMAIL_PDF_BUTTON_LABEL"] . '" onclick="this.form.email_action.value=\'EmailLayout\';"> ';
58
+		$pdfButtons = '<input id="email_as_pdf_button" title="'.$app_strings["LBL_EMAIL_PDF_BUTTON_TITLE"].'" class="button" type="submit" name="button" value="'.$app_strings["LBL_EMAIL_PDF_BUTTON_LABEL"].'" onclick="this.form.email_action.value=\'EmailLayout\';"> ';
59 59
 	}
60 60
 	return $pdfButtons;
61 61
 }
Please login to merge, or discard this patch.
include/Smarty/plugins/modifier.lookup.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,9 +42,9 @@
 block discarded – undo
42 42
 
43 43
 
44 44
 function smarty_modifier_lookup($value='', $from=array()){
45
-	$value = trim($value);
46
-	if (array_key_exists($value, $from)) { 
47
-		return $from[$value]; 
48
-	} 
49
-	return ''; 
45
+    $value = trim($value);
46
+    if (array_key_exists($value, $from)) { 
47
+        return $from[$value]; 
48
+    } 
49
+    return ''; 
50 50
 } 
Please login to merge, or discard this 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.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
Please login to merge, or discard this patch.
include/Smarty/plugins/function.sugarvar_connector.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -74,14 +74,14 @@
 block discarded – undo
74 74
 
75 75
 function smarty_function_sugarvar_connector($params, &$smarty) {
76 76
       
77
-      $displayParams = $smarty->get_template_vars('displayParams');
78
-      if(!isset($displayParams['module'])) {
79
-         $smarty->trigger_error("sugarvar_connector: missing 'module' parameter");
80
-         $GLOBALS['log']->error("sugarvar_connector: missing 'module' parameter");
81
-         return;     	
82
-      }
77
+        $displayParams = $smarty->get_template_vars('displayParams');
78
+        if(!isset($displayParams['module'])) {
79
+            $smarty->trigger_error("sugarvar_connector: missing 'module' parameter");
80
+            $GLOBALS['log']->error("sugarvar_connector: missing 'module' parameter");
81
+            return;     	
82
+        }
83 83
       
84
-      require_once('include/connectors/utils/ConnectorUtils.php');
85
-      echo ConnectorUtils::getConnectorButtonScript($displayParams, $smarty);
84
+        require_once('include/connectors/utils/ConnectorUtils.php');
85
+        echo ConnectorUtils::getConnectorButtonScript($displayParams, $smarty);
86 86
 }
87 87
 ?>
88 88
\ No newline at end of file
Please login to merge, or discard this 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.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
Please login to merge, or discard this patch.
include/Smarty/plugins/function.sugar_include.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -57,33 +57,33 @@
 block discarded – undo
57 57
     global $app_strings;
58 58
 
59 59
     if(isset($params['type']) && $params['type'] == 'php') {
60
-		if(!isset($params['file'])) {
61
-		   $smarty->trigger_error($app_strings['ERR_MISSING_REQUIRED_FIELDS'] . 'include');
62
-		} 
60
+        if(!isset($params['file'])) {
61
+            $smarty->trigger_error($app_strings['ERR_MISSING_REQUIRED_FIELDS'] . 'include');
62
+        } 
63 63
 		
64
-		$includeFile = $params['file'];
65
-		if(!file_exists($includeFile)) {
66
-		   $smarty->trigger_error($app_strings['ERR_NO_SUCH_FILE'] . ': ' . $includeFile);
67
-		}
64
+        $includeFile = $params['file'];
65
+        if(!file_exists($includeFile)) {
66
+            $smarty->trigger_error($app_strings['ERR_NO_SUCH_FILE'] . ': ' . $includeFile);
67
+        }
68 68
 		
69
-	    ob_start();
70
-	    require($includeFile);
71
-	    $output_html = ob_get_contents();
72
-	    ob_end_clean();
73
-	    echo $output_html; 
69
+        ob_start();
70
+        require($includeFile);
71
+        $output_html = ob_get_contents();
72
+        ob_end_clean();
73
+        echo $output_html; 
74 74
     } else if(is_array($params['include'])) {
75
-	   	  $code = '';
76
-	   	  foreach($params['include'] as $include) {
77
-	   	  	      if(isset($include['file'])) {
78
-	   	  	         $file = $include['file'];
79
-	   	  	         if(preg_match('/[\.]js$/si',$file)) {
80
-	   	  	            $code .= "<script src=\"". getJSPath($include['file']) ."\"></script>";
81
-	   	  	         } else if(preg_match('/[\.]php$/si', $file)) {
82
-	   	  	            require_once($file);	
83
-	   	  	         }
84
-	   	  	      } 
85
-	   	  } //foreach
86
-	      return $code;
87
-   	} //if
75
+                $code = '';
76
+                foreach($params['include'] as $include) {
77
+                        if(isset($include['file'])) {
78
+                            $file = $include['file'];
79
+                            if(preg_match('/[\.]js$/si',$file)) {
80
+                                $code .= "<script src=\"". getJSPath($include['file']) ."\"></script>";
81
+                            } else if(preg_match('/[\.]php$/si', $file)) {
82
+                                require_once($file);	
83
+                            }
84
+                        } 
85
+                } //foreach
86
+            return $code;
87
+        } //if
88 88
 }
89 89
 ?>
90 90
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -56,14 +56,14 @@  discard block
 block discarded – undo
56 56
 {
57 57
     global $app_strings;
58 58
 
59
-    if(isset($params['type']) && $params['type'] == 'php') {
60
-		if(!isset($params['file'])) {
61
-		   $smarty->trigger_error($app_strings['ERR_MISSING_REQUIRED_FIELDS'] . 'include');
59
+    if (isset($params['type']) && $params['type'] == 'php') {
60
+		if (!isset($params['file'])) {
61
+		   $smarty->trigger_error($app_strings['ERR_MISSING_REQUIRED_FIELDS'].'include');
62 62
 		} 
63 63
 		
64 64
 		$includeFile = $params['file'];
65
-		if(!file_exists($includeFile)) {
66
-		   $smarty->trigger_error($app_strings['ERR_NO_SUCH_FILE'] . ': ' . $includeFile);
65
+		if (!file_exists($includeFile)) {
66
+		   $smarty->trigger_error($app_strings['ERR_NO_SUCH_FILE'].': '.$includeFile);
67 67
 		}
68 68
 		
69 69
 	    ob_start();
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
 	    $output_html = ob_get_contents();
72 72
 	    ob_end_clean();
73 73
 	    echo $output_html; 
74
-    } else if(is_array($params['include'])) {
74
+    } else if (is_array($params['include'])) {
75 75
 	   	  $code = '';
76
-	   	  foreach($params['include'] as $include) {
77
-	   	  	      if(isset($include['file'])) {
76
+	   	  foreach ($params['include'] as $include) {
77
+	   	  	      if (isset($include['file'])) {
78 78
 	   	  	         $file = $include['file'];
79
-	   	  	         if(preg_match('/[\.]js$/si',$file)) {
80
-	   	  	            $code .= "<script src=\"". getJSPath($include['file']) ."\"></script>";
81
-	   	  	         } else if(preg_match('/[\.]php$/si', $file)) {
79
+	   	  	         if (preg_match('/[\.]js$/si', $file)) {
80
+	   	  	            $code .= "<script src=\"".getJSPath($include['file'])."\"></script>";
81
+	   	  	         } else if (preg_match('/[\.]php$/si', $file)) {
82 82
 	   	  	            require_once($file);	
83 83
 	   	  	         }
84 84
 	   	  	      } 
Please login to merge, or discard this patch.
include/Smarty/Smarty_Compiler.class.php 3 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
         // matches all valid variables (no quotes, no modifiers)
132 132
         $this->_avar_regexp = '(?:' . $this->_dvar_regexp . '|'
133
-           . $this->_cvar_regexp . '|' . $this->_svar_regexp . ')';
133
+            . $this->_cvar_regexp . '|' . $this->_svar_regexp . ')';
134 134
 
135 135
         // matches valid variable syntax:
136 136
         // $foo
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
         // |foo|bar
173 173
         // |foo:$foo->bar
174 174
         $this->_mod_regexp = '(?:\|@?\w+(?::(?:\w+|' . $this->_num_const_regexp . '|'
175
-           . $this->_obj_call_regexp . '|' . $this->_avar_regexp . '|' . $this->_qstr_regexp .'))*)';
175
+            . $this->_obj_call_regexp . '|' . $this->_avar_regexp . '|' . $this->_qstr_regexp .'))*)';
176 176
 
177 177
         // matches valid function name:
178 178
         // foo123
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
         // "text"|bar
194 194
         // $foo->bar
195 195
         $this->_param_regexp = '(?:\s*(?:' . $this->_obj_call_regexp . '|'
196
-           . $this->_var_regexp . '|' . $this->_num_const_regexp  . '|\w+)(?>' . $this->_mod_regexp . '*)\s*)';
196
+            . $this->_var_regexp . '|' . $this->_num_const_regexp  . '|\w+)(?>' . $this->_mod_regexp . '*)\s*)';
197 197
 
198 198
         // matches valid parenthesised function parameters:
199 199
         //
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
         // _foo_bar($foo,"bar")
211 211
         // foo123($foo,$foo->bar(),"foo")
212 212
         $this->_func_call_regexp = '(?:' . $this->_func_regexp . '\s*(?:'
213
-           . $this->_parenth_param_regexp . '))';
213
+            . $this->_parenth_param_regexp . '))';
214 214
     }
215 215
 
216 216
     /**
@@ -263,11 +263,11 @@  discard block
 block discarded – undo
263 263
 
264 264
         /* replace special blocks by "{php}" */
265 265
         $source_content = preg_replace_callback($search, create_function ('$matches', "return '"
266
-                                       . $this->_quote_replace($this->left_delimiter) . 'php'
267
-                                       . "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'"
268
-                                       . $this->_quote_replace($this->right_delimiter)
269
-                                       . "';")
270
-                                       , $source_content);
266
+                                        . $this->_quote_replace($this->left_delimiter) . 'php'
267
+                                        . "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'"
268
+                                        . $this->_quote_replace($this->right_delimiter)
269
+                                        . "';")
270
+                                        , $source_content);
271 271
 
272 272
         /* Gather all template tags. */
273 273
         preg_match_all("~{$ldq}\s*(.*?)\s*{$rdq}~s", $source_content, $_match);
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
                 if ($postfilter === false) continue;
389 389
                 if ($postfilter[3] || is_callable($postfilter[0])) {
390 390
                     $compiled_content = call_user_func_array($postfilter[0],
391
-                                                              array($compiled_content, &$this));
391
+                                                                array($compiled_content, &$this));
392 392
                     $this->_plugins['postfilter'][$filter_name][3] = true;
393 393
                 } else {
394 394
                     $this->_trigger_fatal_error("Smarty plugin error: postfilter '$filter_name' is not implemented");
@@ -649,8 +649,8 @@  discard block
 block discarded – undo
649 649
                 $output = call_user_func_array($plugin_func, array($tag_args, &$this));
650 650
                 if($output != '') {
651 651
                 $output = '<?php ' . $this->_push_cacheable_state('compiler', $tag_command)
652
-                                   . $output
653
-                                   . $this->_pop_cacheable_state('compiler', $tag_command) . ' ?>';
652
+                                    . $output
653
+                                    . $this->_pop_cacheable_state('compiler', $tag_command) . ' ?>';
654 654
                 }
655 655
             } else {
656 656
                 $this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__);
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
             $output .= "{$section_props}['max'] = {$section_props}['loop'];\n";
1116 1116
         else
1117 1117
             $output .= "if ({$section_props}['max'] < 0)\n" .
1118
-                       "    {$section_props}['max'] = {$section_props}['loop'];\n";
1118
+                        "    {$section_props}['max'] = {$section_props}['loop'];\n";
1119 1119
 
1120 1120
         if (!isset($attrs['step']))
1121 1121
             $output .= "{$section_props}['step'] = 1;\n";
@@ -1124,9 +1124,9 @@  discard block
 block discarded – undo
1124 1124
             $output .= "{$section_props}['start'] = {$section_props}['step'] > 0 ? 0 : {$section_props}['loop']-1;\n";
1125 1125
         else {
1126 1126
             $output .= "if ({$section_props}['start'] < 0)\n" .
1127
-                       "    {$section_props}['start'] = max({$section_props}['step'] > 0 ? 0 : -1, {$section_props}['loop'] + {$section_props}['start']);\n" .
1128
-                       "else\n" .
1129
-                       "    {$section_props}['start'] = min({$section_props}['start'], {$section_props}['step'] > 0 ? {$section_props}['loop'] : {$section_props}['loop']-1);\n";
1127
+                        "    {$section_props}['start'] = max({$section_props}['step'] > 0 ? 0 : -1, {$section_props}['loop'] + {$section_props}['start']);\n" .
1128
+                        "else\n" .
1129
+                        "    {$section_props}['start'] = min({$section_props}['start'], {$section_props}['step'] > 0 ? {$section_props}['loop'] : {$section_props}['loop']-1);\n";
1130 1130
         }
1131 1131
 
1132 1132
         $output .= "if ({$section_props}['show']) {\n";
@@ -1136,9 +1136,9 @@  discard block
 block discarded – undo
1136 1136
             $output .= "    {$section_props}['total'] = min(ceil(({$section_props}['step'] > 0 ? {$section_props}['loop'] - {$section_props}['start'] : {$section_props}['start']+1)/abs({$section_props}['step'])), {$section_props}['max']);\n";
1137 1137
         }
1138 1138
         $output .= "    if ({$section_props}['total'] == 0)\n" .
1139
-                   "        {$section_props}['show'] = false;\n" .
1140
-                   "} else\n" .
1141
-                   "    {$section_props}['total'] = 0;\n";
1139
+                    "        {$section_props}['show'] = false;\n" .
1140
+                    "} else\n" .
1141
+                    "    {$section_props}['total'] = 0;\n";
1142 1142
 
1143 1143
         $output .= "if ({$section_props}['show']):\n";
1144 1144
         $output .= "
@@ -1987,8 +1987,8 @@  discard block
 block discarded – undo
1987 1987
         }
1988 1988
         if (!isset($this->_plugin_info[$type][$name])) {
1989 1989
             $this->_plugin_info[$type][$name] = array($this->_current_file,
1990
-                                                      $this->_current_line_no,
1991
-                                                      $delayed_loading);
1990
+                                                        $this->_current_line_no,
1991
+                                                        $delayed_loading);
1992 1992
         }
1993 1993
     }
1994 1994
 
@@ -2056,7 +2056,7 @@  discard block
 block discarded – undo
2056 2056
             case 'get':
2057 2057
                 if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) {
2058 2058
                     $this->_syntax_error("(secure mode) super global access not permitted",
2059
-                                         E_USER_WARNING, __FILE__, __LINE__);
2059
+                                            E_USER_WARNING, __FILE__, __LINE__);
2060 2060
                     return;
2061 2061
                 }
2062 2062
                 $compiled_ref = "\$_GET";
@@ -2065,7 +2065,7 @@  discard block
 block discarded – undo
2065 2065
             case 'post':
2066 2066
                 if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) {
2067 2067
                     $this->_syntax_error("(secure mode) super global access not permitted",
2068
-                                         E_USER_WARNING, __FILE__, __LINE__);
2068
+                                            E_USER_WARNING, __FILE__, __LINE__);
2069 2069
                     return;
2070 2070
                 }
2071 2071
                 $compiled_ref = "\$_POST";
@@ -2074,7 +2074,7 @@  discard block
 block discarded – undo
2074 2074
             case 'cookies':
2075 2075
                 if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) {
2076 2076
                     $this->_syntax_error("(secure mode) super global access not permitted",
2077
-                                         E_USER_WARNING, __FILE__, __LINE__);
2077
+                                            E_USER_WARNING, __FILE__, __LINE__);
2078 2078
                     return;
2079 2079
                 }
2080 2080
                 $compiled_ref = "\$_COOKIE";
@@ -2083,7 +2083,7 @@  discard block
 block discarded – undo
2083 2083
             case 'env':
2084 2084
                 if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) {
2085 2085
                     $this->_syntax_error("(secure mode) super global access not permitted",
2086
-                                         E_USER_WARNING, __FILE__, __LINE__);
2086
+                                            E_USER_WARNING, __FILE__, __LINE__);
2087 2087
                     return;
2088 2088
                 }
2089 2089
                 $compiled_ref = "\$_ENV";
@@ -2092,7 +2092,7 @@  discard block
 block discarded – undo
2092 2092
             case 'server':
2093 2093
                 if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) {
2094 2094
                     $this->_syntax_error("(secure mode) super global access not permitted",
2095
-                                         E_USER_WARNING, __FILE__, __LINE__);
2095
+                                            E_USER_WARNING, __FILE__, __LINE__);
2096 2096
                     return;
2097 2097
                 }
2098 2098
                 $compiled_ref = "\$_SERVER";
@@ -2101,7 +2101,7 @@  discard block
 block discarded – undo
2101 2101
             case 'session':
2102 2102
                 if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) {
2103 2103
                     $this->_syntax_error("(secure mode) super global access not permitted",
2104
-                                         E_USER_WARNING, __FILE__, __LINE__);
2104
+                                            E_USER_WARNING, __FILE__, __LINE__);
2105 2105
                     return;
2106 2106
                 }
2107 2107
                 $compiled_ref = "\$_SESSION";
@@ -2114,7 +2114,7 @@  discard block
 block discarded – undo
2114 2114
             case 'request':
2115 2115
                 if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) {
2116 2116
                     $this->_syntax_error("(secure mode) super global access not permitted",
2117
-                                         E_USER_WARNING, __FILE__, __LINE__);
2117
+                                            E_USER_WARNING, __FILE__, __LINE__);
2118 2118
                     return;
2119 2119
                 }
2120 2120
                 if ($this->request_use_auto_globals) {
@@ -2141,7 +2141,7 @@  discard block
 block discarded – undo
2141 2141
             case 'const':
2142 2142
                 if ($this->security && !$this->security_settings['ALLOW_CONSTANTS']) {
2143 2143
                     $this->_syntax_error("(secure mode) constants not permitted",
2144
-                                         E_USER_WARNING, __FILE__, __LINE__);
2144
+                                            E_USER_WARNING, __FILE__, __LINE__);
2145 2145
                     return;
2146 2146
                 }
2147 2147
                 array_shift($indexes);
@@ -2197,7 +2197,7 @@  discard block
 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 */
@@ -2342,7 +2342,7 @@  discard block
 block discarded – undo
2342 2342
             $message = " expected {/$_open_tag} (opened line $_line_no).";
2343 2343
         }
2344 2344
         $this->_syntax_error("mismatched tag {/$close_tag}.$message",
2345
-                             E_USER_ERROR, __FILE__, __LINE__);
2345
+                                E_USER_ERROR, __FILE__, __LINE__);
2346 2346
     }
2347 2347
 
2348 2348
 }
Please login to merge, or discard this 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.
Braces   +148 added lines, -108 removed lines patch added patch discarded remove patch
@@ -243,7 +243,9 @@  discard block
 block discarded – undo
243 243
         // run template source through prefilter functions
244 244
         if (count($this->_plugins['prefilter']) > 0) {
245 245
             foreach ($this->_plugins['prefilter'] as $filter_name => $prefilter) {
246
-                if ($prefilter === false) continue;
246
+                if ($prefilter === false) {
247
+                    continue;
248
+                }
247 249
                 if ($prefilter[3] || is_callable($prefilter[0])) {
248 250
                     $source_content = call_user_func_array($prefilter[0],
249 251
                                                             array($source_content, &$this));
@@ -385,7 +387,9 @@  discard block
 block discarded – undo
385 387
         // run compiled template through postfilter functions
386 388
         if (count($this->_plugins['postfilter']) > 0) {
387 389
             foreach ($this->_plugins['postfilter'] as $filter_name => $postfilter) {
388
-                if ($postfilter === false) continue;
390
+                if ($postfilter === false) {
391
+                    continue;
392
+                }
389 393
                 if ($postfilter[3] || is_callable($postfilter[0])) {
390 394
                     $compiled_content = call_user_func_array($postfilter[0],
391 395
                                                               array($compiled_content, &$this));
@@ -435,8 +439,9 @@  discard block
 block discarded – undo
435 439
     function _compile_tag($template_tag)
436 440
     {
437 441
         /* Matched comment. */
438
-        if (substr($template_tag, 0, 1) == '*' && substr($template_tag, -1) == '*')
439
-            return '';
442
+        if (substr($template_tag, 0, 1) == '*' && substr($template_tag, -1) == '*') {
443
+                    return '';
444
+        }
440 445
         
441 446
         /* Split tag into two three parts: command, command modifiers and the arguments. */
442 447
         if(! preg_match('~^(?:(' . $this->_num_const_regexp . '|' . $this->_obj_call_regexp . '|' . $this->_var_regexp
@@ -474,18 +479,21 @@  discard block
 block discarded – undo
474 479
 
475 480
             case 'else':
476 481
                 list($_open_tag) = end($this->_tag_stack);
477
-                if ($_open_tag != 'if' && $_open_tag != 'elseif')
478
-                    $this->_syntax_error('unexpected {else}', E_USER_ERROR, __FILE__, __LINE__);
479
-                else
480
-                    $this->_push_tag('else');
482
+                if ($_open_tag != 'if' && $_open_tag != 'elseif') {
483
+                                    $this->_syntax_error('unexpected {else}', E_USER_ERROR, __FILE__, __LINE__);
484
+                } else {
485
+                                    $this->_push_tag('else');
486
+                }
481 487
                 return '<?php else: ?>';
482 488
 
483 489
             case 'elseif':
484 490
                 list($_open_tag) = end($this->_tag_stack);
485
-                if ($_open_tag != 'if' && $_open_tag != 'elseif')
486
-                    $this->_syntax_error('unexpected {elseif}', E_USER_ERROR, __FILE__, __LINE__);
487
-                if ($_open_tag == 'if')
488
-                    $this->_push_tag('elseif');
491
+                if ($_open_tag != 'if' && $_open_tag != 'elseif') {
492
+                                    $this->_syntax_error('unexpected {elseif}', E_USER_ERROR, __FILE__, __LINE__);
493
+                }
494
+                if ($_open_tag == 'if') {
495
+                                    $this->_push_tag('elseif');
496
+                }
489 497
                 return $this->_compile_if_tag($tag_args, true);
490 498
 
491 499
             case '/if':
@@ -515,10 +523,11 @@  discard block
 block discarded – undo
515 523
 
516 524
             case '/section':
517 525
                 $_open_tag = $this->_pop_tag('section');
518
-                if ($_open_tag == 'sectionelse')
519
-                    return "<?php endif; ?>";
520
-                else
521
-                    return "<?php endfor; endif; ?>";
526
+                if ($_open_tag == 'sectionelse') {
527
+                                    return "<?php endif; ?>";
528
+                } else {
529
+                                    return "<?php endfor; endif; ?>";
530
+                }
522 531
 
523 532
             case 'foreach':
524 533
                 $this->_push_tag('foreach');
@@ -531,10 +540,11 @@  discard block
 block discarded – undo
531 540
 
532 541
             case '/foreach':
533 542
                 $_open_tag = $this->_pop_tag('foreach');
534
-                if ($_open_tag == 'foreachelse')
535
-                    return "<?php endif; unset(\$_from); ?>";
536
-                else
537
-                    return "<?php endforeach; endif; unset(\$_from); ?>";
543
+                if ($_open_tag == 'foreachelse') {
544
+                                    return "<?php endif; unset(\$_from); ?>";
545
+                } else {
546
+                                    return "<?php endforeach; endif; unset(\$_from); ?>";
547
+                }
538 548
                 break;
539 549
 
540 550
             case 'strip':
@@ -677,8 +687,9 @@  discard block
 block discarded – undo
677 687
         if (substr($tag_command, 0, 1) == '/') {
678 688
             $start_tag = false;
679 689
             $tag_command = substr($tag_command, 1);
680
-        } else
681
-            $start_tag = true;
690
+        } else {
691
+                    $start_tag = true;
692
+        }
682 693
 
683 694
         $found = false;
684 695
         $have_function = true;
@@ -728,10 +739,11 @@  discard block
 block discarded – undo
728 739
          */
729 740
         $this->_add_plugin('block', $tag_command);
730 741
 
731
-        if ($start_tag)
732
-            $this->_push_tag($tag_command);
733
-        else
734
-            $this->_pop_tag($tag_command);
742
+        if ($start_tag) {
743
+                    $this->_push_tag($tag_command);
744
+        } else {
745
+                    $this->_pop_tag($tag_command);
746
+        }
735 747
 
736 748
         if ($start_tag) {
737 749
             $output = '<?php ' . $this->_push_cacheable_state('block', $tag_command);
@@ -856,8 +868,9 @@  discard block
 block discarded – undo
856 868
                     unset($attrs['assign']);
857 869
                     continue;
858 870
                 }
859
-                if (is_bool($arg_value))
860
-                    $arg_value = $arg_value ? 'true' : 'false';
871
+                if (is_bool($arg_value)) {
872
+                                    $arg_value = $arg_value ? 'true' : 'false';
873
+                }
861 874
                 $arg_list[] = "'$arg_name' => $arg_value";
862 875
             }
863 876
         }
@@ -948,8 +961,9 @@  discard block
 block discarded – undo
948 961
         }
949 962
 
950 963
         foreach ($attrs as $arg_name => $arg_value) {
951
-            if (is_bool($arg_value))
952
-                $arg_value = $arg_value ? 'true' : 'false';
964
+            if (is_bool($arg_value)) {
965
+                            $arg_value = $arg_value ? 'true' : 'false';
966
+            }
953 967
             $arg_list[] = "'$arg_name' => $arg_value";
954 968
         }
955 969
 
@@ -987,13 +1001,15 @@  discard block
 block discarded – undo
987 1001
                 $theme_template = $arg_value;
988 1002
                 continue;
989 1003
             }
990
-            if (is_bool($arg_value))
991
-                $arg_value = $arg_value ? 'true' : 'false';
1004
+            if (is_bool($arg_value)) {
1005
+                            $arg_value = $arg_value ? 'true' : 'false';
1006
+            }
992 1007
             $arg_list[] = "'$arg_name' => $arg_value";
993 1008
         }
994 1009
 
995
-        if ( $theme_template == 'true' )
996
-            $include_file = '"'.SugarThemeRegistry::current()->getTemplate(str_replace(array('"',"'"),'',$include_file)).'"';
1010
+        if ( $theme_template == 'true' ) {
1011
+                    $include_file = '"'.SugarThemeRegistry::current()->getTemplate(str_replace(array('"',"'"),'',$include_file)).'"';
1012
+        }
997 1013
 
998 1014
         $output = '<?php ';
999 1015
 
@@ -1040,8 +1056,9 @@  discard block
 block discarded – undo
1040 1056
         $arg_list = array();
1041 1057
         foreach($attrs as $arg_name => $arg_value) {
1042 1058
             if($arg_name != 'file' AND $arg_name != 'once' AND $arg_name != 'assign') {
1043
-                if(is_bool($arg_value))
1044
-                    $arg_value = $arg_value ? 'true' : 'false';
1059
+                if(is_bool($arg_value)) {
1060
+                                    $arg_value = $arg_value ? 'true' : 'false';
1061
+                }
1045 1062
                 $arg_list[] = "'$arg_name' => $arg_value";
1046 1063
             }
1047 1064
         }
@@ -1079,10 +1096,11 @@  discard block
 block discarded – undo
1079 1096
                     break;
1080 1097
 
1081 1098
                 case 'show':
1082
-                    if (is_bool($attr_value))
1083
-                        $show_attr_value = $attr_value ? 'true' : 'false';
1084
-                    else
1085
-                        $show_attr_value = "(bool)$attr_value";
1099
+                    if (is_bool($attr_value)) {
1100
+                                            $show_attr_value = $attr_value ? 'true' : 'false';
1101
+                    } else {
1102
+                                            $show_attr_value = "(bool)$attr_value";
1103
+                    }
1086 1104
                     $output .= "{$section_props}['show'] = $show_attr_value;\n";
1087 1105
                     break;
1088 1106
 
@@ -1105,24 +1123,28 @@  discard block
 block discarded – undo
1105 1123
             }
1106 1124
         }
1107 1125
 
1108
-        if (!isset($attrs['show']))
1109
-            $output .= "{$section_props}['show'] = true;\n";
1126
+        if (!isset($attrs['show'])) {
1127
+                    $output .= "{$section_props}['show'] = true;\n";
1128
+        }
1110 1129
 
1111
-        if (!isset($attrs['loop']))
1112
-            $output .= "{$section_props}['loop'] = 1;\n";
1130
+        if (!isset($attrs['loop'])) {
1131
+                    $output .= "{$section_props}['loop'] = 1;\n";
1132
+        }
1113 1133
 
1114
-        if (!isset($attrs['max']))
1115
-            $output .= "{$section_props}['max'] = {$section_props}['loop'];\n";
1116
-        else
1117
-            $output .= "if ({$section_props}['max'] < 0)\n" .
1134
+        if (!isset($attrs['max'])) {
1135
+                    $output .= "{$section_props}['max'] = {$section_props}['loop'];\n";
1136
+        } else {
1137
+                    $output .= "if ({$section_props}['max'] < 0)\n" .
1118 1138
                        "    {$section_props}['max'] = {$section_props}['loop'];\n";
1139
+        }
1119 1140
 
1120
-        if (!isset($attrs['step']))
1121
-            $output .= "{$section_props}['step'] = 1;\n";
1141
+        if (!isset($attrs['step'])) {
1142
+                    $output .= "{$section_props}['step'] = 1;\n";
1143
+        }
1122 1144
 
1123
-        if (!isset($attrs['start']))
1124
-            $output .= "{$section_props}['start'] = {$section_props}['step'] > 0 ? 0 : {$section_props}['loop']-1;\n";
1125
-        else {
1145
+        if (!isset($attrs['start'])) {
1146
+                    $output .= "{$section_props}['start'] = {$section_props}['step'] > 0 ? 0 : {$section_props}['loop']-1;\n";
1147
+        } else {
1126 1148
             $output .= "if ({$section_props}['start'] < 0)\n" .
1127 1149
                        "    {$section_props}['start'] = max({$section_props}['step'] > 0 ? 0 : -1, {$section_props}['loop'] + {$section_props}['start']);\n" .
1128 1150
                        "else\n" .
@@ -1377,8 +1399,9 @@  discard block
 block discarded – undo
1377 1399
                                 $is_arg_start--;
1378 1400
                             } 
1379 1401
                         } 
1380
-                    } else
1381
-                        $is_arg_start = $i-1;
1402
+                    } else {
1403
+                                            $is_arg_start = $i-1;
1404
+                    }
1382 1405
                     /* Construct the argument for 'is' expression, so it knows
1383 1406
                        what to operate on. */
1384 1407
                     $is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start));
@@ -1420,10 +1443,11 @@  discard block
 block discarded – undo
1420 1443
             }
1421 1444
         }
1422 1445
 
1423
-        if ($elseif)
1424
-            return '<?php elseif ('.implode(' ', $tokens).'): ?>';
1425
-        else
1426
-            return '<?php if ('.implode(' ', $tokens).'): ?>';
1446
+        if ($elseif) {
1447
+                    return '<?php elseif ('.implode(' ', $tokens).'): ?>';
1448
+        } else {
1449
+                    return '<?php if ('.implode(' ', $tokens).'): ?>';
1450
+        }
1427 1451
     }
1428 1452
 
1429 1453
 
@@ -1447,10 +1471,12 @@  discard block
 block discarded – undo
1447 1471
         }
1448 1472
 
1449 1473
         foreach ($attrs as $arg_name => $arg_value) {
1450
-            if (is_bool($arg_value))
1451
-                $arg_value = $arg_value ? 'true' : 'false';
1452
-            if (is_null($arg_value))
1453
-                $arg_value = 'null';
1474
+            if (is_bool($arg_value)) {
1475
+                            $arg_value = $arg_value ? 'true' : 'false';
1476
+            }
1477
+            if (is_null($arg_value)) {
1478
+                            $arg_value = 'null';
1479
+            }
1454 1480
             if ($_cache_attrs && in_array($arg_name, $_cache_attrs)) {
1455 1481
                 $arg_list[] = "'$arg_name' => (\$this->_cache_including) ? \$_cache_attrs['$arg_name'] : (\$_cache_attrs['$arg_name']=$arg_value)";
1456 1482
             } else {
@@ -1475,8 +1501,9 @@  discard block
 block discarded – undo
1475 1501
         if (($first_token = array_shift($tokens)) == 'not') {
1476 1502
             $negate_expr = true;
1477 1503
             $expr_type = array_shift($tokens);
1478
-        } else
1479
-            $expr_type = $first_token;
1504
+        } else {
1505
+                    $expr_type = $first_token;
1506
+        }
1480 1507
 
1481 1508
         switch ($expr_type) {
1482 1509
             case 'even':
@@ -1484,8 +1511,9 @@  discard block
 block discarded – undo
1484 1511
                     $expr_end++;
1485 1512
                     $expr_arg = $tokens[$expr_end++];
1486 1513
                     $expr = "!(1 & ($is_arg / " . $this->_parse_var_props($expr_arg) . "))";
1487
-                } else
1488
-                    $expr = "!(1 & $is_arg)";
1514
+                } else {
1515
+                                    $expr = "!(1 & $is_arg)";
1516
+                }
1489 1517
                 break;
1490 1518
 
1491 1519
             case 'odd':
@@ -1493,8 +1521,9 @@  discard block
 block discarded – undo
1493 1521
                     $expr_end++;
1494 1522
                     $expr_arg = $tokens[$expr_end++];
1495 1523
                     $expr = "(1 & ($is_arg / " . $this->_parse_var_props($expr_arg) . "))";
1496
-                } else
1497
-                    $expr = "(1 & $is_arg)";
1524
+                } else {
1525
+                                    $expr = "(1 & $is_arg)";
1526
+                }
1498 1527
                 break;
1499 1528
 
1500 1529
             case 'div':
@@ -1553,16 +1582,18 @@  discard block
 block discarded – undo
1553 1582
                     if (preg_match('~^\w+$~', $token)) {
1554 1583
                         $attr_name = $token;
1555 1584
                         $state = 1;
1556
-                    } else
1557
-                        $this->_syntax_error("invalid attribute name: '$token'", E_USER_ERROR, __FILE__, __LINE__);
1585
+                    } else {
1586
+                                            $this->_syntax_error("invalid attribute name: '$token'", E_USER_ERROR, __FILE__, __LINE__);
1587
+                    }
1558 1588
                     break;
1559 1589
 
1560 1590
                 case 1:
1561 1591
                     /* If the token is '=', then we go to state 2. */
1562 1592
                     if ($token == '=') {
1563 1593
                         $state = 2;
1564
-                    } else
1565
-                        $this->_syntax_error("expecting '=' after attribute name '$last_token'", E_USER_ERROR, __FILE__, __LINE__);
1594
+                    } else {
1595
+                                            $this->_syntax_error("expecting '=' after attribute name '$last_token'", E_USER_ERROR, __FILE__, __LINE__);
1596
+                    }
1566 1597
                     break;
1567 1598
 
1568 1599
                 case 2:
@@ -1586,8 +1617,9 @@  discard block
 block discarded – undo
1586 1617
 
1587 1618
                         $attrs[$attr_name] = $token;
1588 1619
                         $state = 0;
1589
-                    } else
1590
-                        $this->_syntax_error("'=' cannot be an attribute value", E_USER_ERROR, __FILE__, __LINE__);
1620
+                    } else {
1621
+                                            $this->_syntax_error("'=' cannot be an attribute value", E_USER_ERROR, __FILE__, __LINE__);
1622
+                    }
1591 1623
                     break;
1592 1624
             }
1593 1625
             $last_token = $token;
@@ -1649,32 +1681,27 @@  discard block
 block discarded – undo
1649 1681
                     $this->_parse_modifiers($return, $match[2]);
1650 1682
                 }
1651 1683
                 return $return;
1652
-            }
1653
-        elseif(preg_match('~^' . $this->_num_const_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
1684
+            } elseif(preg_match('~^' . $this->_num_const_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
1654 1685
                 // numerical constant
1655 1686
                 preg_match('~^(' . $this->_num_const_regexp . ')('. $this->_mod_regexp . '*)$~', $val, $match);
1656 1687
                 if($match[2] != '') {
1657 1688
                     $this->_parse_modifiers($match[1], $match[2]);
1658 1689
                     return $match[1];
1659 1690
                 }
1660
-            }
1661
-        elseif(preg_match('~^' . $this->_si_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
1691
+            } elseif(preg_match('~^' . $this->_si_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
1662 1692
                 // single quoted text
1663 1693
                 preg_match('~^(' . $this->_si_qstr_regexp . ')('. $this->_mod_regexp . '*)$~', $val, $match);
1664 1694
                 if($match[2] != '') {
1665 1695
                     $this->_parse_modifiers($match[1], $match[2]);
1666 1696
                     return $match[1];
1667 1697
                 }
1668
-            }
1669
-        elseif(preg_match('~^' . $this->_cvar_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
1698
+            } elseif(preg_match('~^' . $this->_cvar_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
1670 1699
                 // config var
1671 1700
                 return $this->_parse_conf_var($val);
1672
-            }
1673
-        elseif(preg_match('~^' . $this->_svar_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
1701
+            } elseif(preg_match('~^' . $this->_svar_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
1674 1702
                 // section var
1675 1703
                 return $this->_parse_section_prop($val);
1676
-            }
1677
-        elseif(!in_array($val, $this->_permitted_tokens) && !is_numeric($val)) {
1704
+            } elseif(!in_array($val, $this->_permitted_tokens) && !is_numeric($val)) {
1678 1705
             // literal string
1679 1706
             return $this->_expand_quoted_text('"' . strtr($val, array('\\' => '\\\\', '"' => '\\"')) .'"');
1680 1707
         }
@@ -1737,8 +1764,9 @@  discard block
 block discarded – undo
1737 1764
                         // just output the math operator to php
1738 1765
                         $_output .= $_math_var;
1739 1766
 
1740
-                        if(empty($_first_var))
1741
-                            $_first_var = $_complete_var;
1767
+                        if(empty($_first_var)) {
1768
+                                                    $_first_var = $_complete_var;
1769
+                        }
1742 1770
 
1743 1771
                         $_complete_var = "";
1744 1772
                     } else {
@@ -1747,8 +1775,9 @@  discard block
 block discarded – undo
1747 1775
                 }
1748 1776
             }
1749 1777
             if($_has_math) {
1750
-                if(!empty($_complete_var) || is_numeric($_complete_var))
1751
-                    $_output .= $this->_parse_var($_complete_var);
1778
+                if(!empty($_complete_var) || is_numeric($_complete_var)) {
1779
+                                    $_output .= $this->_parse_var($_complete_var);
1780
+                }
1752 1781
 
1753 1782
                 // get the modifiers working (only the last var from math + modifier is left)
1754 1783
                 $var_expr = $_complete_var;
@@ -1756,10 +1785,11 @@  discard block
 block discarded – undo
1756 1785
         }
1757 1786
 
1758 1787
         // prevent cutting of first digit in the number (we _definitly_ got a number if the first char is a digit)
1759
-        if(is_numeric(substr($var_expr, 0, 1)))
1760
-            $_var_ref = $var_expr;
1761
-        else
1762
-            $_var_ref = substr($var_expr, 1);
1788
+        if(is_numeric(substr($var_expr, 0, 1))) {
1789
+                    $_var_ref = $var_expr;
1790
+        } else {
1791
+                    $_var_ref = substr($var_expr, 1);
1792
+        }
1763 1793
         
1764 1794
         if(!$_has_math) {
1765 1795
             
@@ -1812,10 +1842,11 @@  discard block
 block discarded – undo
1812 1842
                         $_output .= "[\$this->_sections['$_var_section']['$_var_section_prop']]";
1813 1843
                     }
1814 1844
                 } else if (substr($_index, 0, 1) == '.') {
1815
-                    if (substr($_index, 1, 1) == '$')
1816
-                        $_output .= "[\$this->_tpl_vars['" . substr($_index, 2) . "']]";
1817
-                    else
1818
-                        $_output .= "['" . substr($_index, 1) . "']";
1845
+                    if (substr($_index, 1, 1) == '$') {
1846
+                                            $_output .= "[\$this->_tpl_vars['" . substr($_index, 2) . "']]";
1847
+                    } else {
1848
+                                            $_output .= "['" . substr($_index, 1) . "']";
1849
+                    }
1819 1850
                 } else if (substr($_index,0,2) == '->') {
1820 1851
                     if(substr($_index,2,2) == '__') {
1821 1852
                         $this->_syntax_error('call to internal object members is not allowed', E_USER_ERROR, __FILE__, __LINE__);
@@ -1956,10 +1987,11 @@  discard block
 block discarded – undo
1956 1987
                     $_modifier_args[0] = '@' . $_modifier_args[0];
1957 1988
                 }
1958 1989
             }
1959
-            if (count($_modifier_args) > 0)
1960
-                $_modifier_args = ', '.implode(', ', $_modifier_args);
1961
-            else
1962
-                $_modifier_args = '';
1990
+            if (count($_modifier_args) > 0) {
1991
+                            $_modifier_args = ', '.implode(', ', $_modifier_args);
1992
+            } else {
1993
+                            $_modifier_args = '';
1994
+            }
1963 1995
 
1964 1996
             if ($_map_array) {
1965 1997
                 $output = "((is_array(\$_tmp=$output)) ? \$this->_run_mod_handler('$_modifier_name', true, \$_tmp$_modifier_args) : " . $this->_compile_plugin_call('modifier', $_modifier_name) . "(\$_tmp$_modifier_args))";
@@ -2273,8 +2305,12 @@  discard block
 block discarded – undo
2273 2305
     function _push_cacheable_state($type, $name) {
2274 2306
         $_cacheable = !isset($this->_plugins[$type][$name]) || $this->_plugins[$type][$name][4];
2275 2307
         if ($_cacheable
2276
-            || 0<$this->_cacheable_state++) return '';
2277
-        if (!isset($this->_cache_serial)) $this->_cache_serial = md5(uniqid('Smarty'));
2308
+            || 0<$this->_cacheable_state++) {
2309
+            return '';
2310
+        }
2311
+        if (!isset($this->_cache_serial)) {
2312
+            $this->_cache_serial = md5(uniqid('Smarty'));
2313
+        }
2278 2314
         $_ret = 'if ($this->caching && !$this->_cache_including): echo \'{nocache:'
2279 2315
             . $this->_cache_serial . '#' . $this->_nocache_count
2280 2316
             . '}\'; endif;';
@@ -2291,7 +2327,9 @@  discard block
 block discarded – undo
2291 2327
     function _pop_cacheable_state($type, $name) {
2292 2328
         $_cacheable = !isset($this->_plugins[$type][$name]) || $this->_plugins[$type][$name][4];
2293 2329
         if ($_cacheable
2294
-            || --$this->_cacheable_state>0) return '';
2330
+            || --$this->_cacheable_state>0) {
2331
+            return '';
2332
+        }
2295 2333
         return 'if ($this->caching && !$this->_cache_including): echo \'{/nocache:'
2296 2334
             . $this->_cache_serial . '#' . ($this->_nocache_count++)
2297 2335
             . '}\'; endif;';
@@ -2357,11 +2395,13 @@  discard block
 block discarded – undo
2357 2395
  */
2358 2396
 function _smarty_sort_length($a, $b)
2359 2397
 {
2360
-    if($a == $b)
2361
-        return 0;
2398
+    if($a == $b) {
2399
+            return 0;
2400
+    }
2362 2401
 
2363
-    if(strlen($a) == strlen($b))
2364
-        return ($a > $b) ? -1 : 1;
2402
+    if(strlen($a) == strlen($b)) {
2403
+            return ($a > $b) ? -1 : 1;
2404
+    }
2365 2405
 
2366 2406
     return (strlen($a) > strlen($b)) ? -1 : 1;
2367 2407
 }
Please login to merge, or discard this patch.
data/Relationships/SugarRelationship.php 2 patches
Spacing   +23 added lines, -23 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.
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 require_once("data/BeanFactory.php");
46 46
 
47 47
 
48
-define('REL_LHS','LHS');
49
-define('REL_RHS','RHS');
50
-define('REL_BOTH','BOTH_SIDES');
48
+define('REL_LHS', 'LHS');
49
+define('REL_RHS', 'RHS');
50
+define('REL_BOTH', 'BOTH_SIDES');
51 51
 define('REL_MANY_MANY', 'many-to-many');
52 52
 define('REL_ONE_MANY', 'one-to-many');
53 53
 define('REL_ONE_ONE', 'one-to-one');
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
         $focus = $link->getFocus();
127 127
         $related = $link->getBeans();
128 128
         $result = true;
129
-        foreach($related as $relBean)
129
+        foreach ($related as $relBean)
130 130
         {
131 131
             if (empty($relBean->id)) {
132 132
                 continue;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
      * @param $rowID id of SugarBean to remove from the relationship
152 152
      * @return void
153 153
      */
154
-    public function removeById($rowID){
154
+    public function removeById($rowID) {
155 155
         $this->removeRow(array("id" => $rowID));
156 156
     }
157 157
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
             return $this->updateRow($existing['id'], array_merge($existing, $row));
207 207
 
208 208
         $values = array();
209
-        foreach($this->getFields() as  $def)
209
+        foreach ($this->getFields() as  $def)
210 210
         {
211 211
             $field = $def['name'];
212 212
             if (isset($row[$field]))
@@ -233,12 +233,12 @@  discard block
 block discarded – undo
233 233
         $newVals = array();
234 234
         //Unset the ID since we are using it to update the row
235 235
         if (isset($values['id'])) unset($values['id']);
236
-        foreach($values as $field => $val)
236
+        foreach ($values as $field => $val)
237 237
         {
238 238
             $newVals[] = "$field='$val'";
239 239
         }
240 240
 
241
-        $newVals = implode(",",$newVals);
241
+        $newVals = implode(",", $newVals);
242 242
 
243 243
         $query = "UPDATE {$this->getRelationshipTable()} set $newVals WHERE id='$id'";
244 244
 
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
         {
262 262
             $stringSets[] = "$field = '$val'";
263 263
         }
264
-        $whereString = "WHERE " . implode(" AND ", $stringSets);
264
+        $whereString = "WHERE ".implode(" AND ", $stringSets);
265 265
 
266 266
         $query = "UPDATE {$this->getRelationshipTable()} set deleted=1 , date_modified = '$date_modified' $whereString";
267 267
 
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
     {
279 279
         $leftIDName = $this->def['join_key_lhs'];
280 280
         $rightIDName = $this->def['join_key_rhs'];
281
-        if (empty($row[$leftIDName]) ||  empty($row[$rightIDName]))
281
+        if (empty($row[$leftIDName]) || empty($row[$rightIDName]))
282 282
             return false;
283 283
 
284 284
         $leftID = $row[$leftIDName];
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
         if (!empty($row))
295 295
         {
296 296
             return $row;
297
-        } else{
297
+        } else {
298 298
             return false;
299 299
         }
300 300
     }
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
         $roleCheck = "";
311 311
         if (empty ($table))
312 312
             $table = $this->getRelationshipTable();
313
-        if (!empty($this->def['relationship_role_column']) && !empty($this->def["relationship_role_column_value"]) && !$ignore_role_filter )
313
+        if (!empty($this->def['relationship_role_column']) && !empty($this->def["relationship_role_column_value"]) && !$ignore_role_filter)
314 314
         {
315 315
             if (empty($table))
316 316
                 $roleCheck = " AND $this->relationship_role_column";
@@ -319,9 +319,9 @@  discard block
 block discarded – undo
319 319
             //role column value.
320 320
             if (empty($this->def['relationship_role_column_value']))
321 321
             {
322
-                $roleCheck.=' IS NULL';
322
+                $roleCheck .= ' IS NULL';
323 323
             } else {
324
-                $roleCheck.= " = '$this->relationship_role_column_value'";
324
+                $roleCheck .= " = '$this->relationship_role_column_value'";
325 325
             }
326 326
         }
327 327
         return $roleCheck;
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
      * @param string $link_name name of link being triggerd
355 355
      * @return void
356 356
      */
357
-    protected function callBeforeAdd($focus, $related, $link_name="")
357
+    protected function callBeforeAdd($focus, $related, $link_name = "")
358 358
     {
359 359
         $custom_logic_arguments = $this->getCustomLogicArguments($focus, $related, $link_name);
360 360
         $focus->call_custom_logic('before_relationship_add', $custom_logic_arguments);
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
      * @param string $link_name name of link being triggerd
368 368
      * @return void
369 369
      */
370
-    protected function callAfterAdd($focus, $related, $link_name="")
370
+    protected function callAfterAdd($focus, $related, $link_name = "")
371 371
     {
372 372
         $custom_logic_arguments = $this->getCustomLogicArguments($focus, $related, $link_name);
373 373
         $focus->call_custom_logic('after_relationship_add', $custom_logic_arguments);
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
      * @param string $link_name
380 380
      * @return void
381 381
      */
382
-    protected function callBeforeDelete($focus, $related, $link_name="")
382
+    protected function callBeforeDelete($focus, $related, $link_name = "")
383 383
     {
384 384
         $custom_logic_arguments = $this->getCustomLogicArguments($focus, $related, $link_name);
385 385
         $focus->call_custom_logic('before_relationship_delete', $custom_logic_arguments);
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
      * @param string $link_name
392 392
      * @return void
393 393
      */
394
-    protected function callAfterDelete($focus, $related, $link_name="")
394
+    protected function callAfterDelete($focus, $related, $link_name = "")
395 395
     {
396 396
         $custom_logic_arguments = $this->getCustomLogicArguments($focus, $related, $link_name);
397 397
         $focus->call_custom_logic('after_relationship_delete', $custom_logic_arguments);
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
      */
406 406
     protected function getOptionalWhereClause($optional_array) {
407 407
         //lhs_field, operator, and rhs_value must be set in optional_array
408
-        foreach(array("lhs_field", "operator", "rhs_value") as $required){
408
+        foreach (array("lhs_field", "operator", "rhs_value") as $required) {
409 409
             if (empty($optional_array[$required]))
410 410
                 return "";
411 411
         }
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
         $GLOBALS['resavingRelatedBeans'] = true;
439 439
 
440 440
         //Resave any bean not currently in the middle of a save operation
441
-        foreach(self::$beansToResave as $module => $beans)
441
+        foreach (self::$beansToResave as $module => $beans)
442 442
         {
443 443
             foreach ($beans as $bean)
444 444
             {
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
     public function isParentRelationship()
470 470
     {
471 471
         //check role fields to see if this is a parent (flex relate) relationship
472
-        if(!empty($this->def["relationship_role_column"]) && !empty($this->def["relationship_role_column_value"])
472
+        if (!empty($this->def["relationship_role_column"]) && !empty($this->def["relationship_role_column_value"])
473 473
            && $this->def["relationship_role_column"] == "parent_type" && $this->def['rhs_key'] == "parent_id")
474 474
         {
475 475
             return true;
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
         if (isset($this->def[$name]))
483 483
             return $this->def[$name];
484 484
 
485
-        switch($name)
485
+        switch ($name)
486 486
         {
487 487
             case "relationship_type":
488 488
                 return $this->type;
Please login to merge, or discard this patch.
Braces   +34 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -135,8 +137,7 @@  discard block
 block discarded – undo
135 137
             if ($link->getSide() == REL_LHS)
136 138
             {
137 139
                 $sub_result = $this->remove($focus, $relBean);
138
-            }
139
-            else
140
+            } else
140 141
             {
141 142
                 $sub_result = $this->remove($relBean, $focus);
142 143
             }
@@ -202,8 +203,10 @@  discard block
 block discarded – undo
202 203
     protected function addRow($row)
203 204
     {
204 205
         $existing = $this->checkExisting($row);
205
-        if (!empty($existing)) //Update the existing row, overriding the values with those passed in
206
+        if (!empty($existing)) {
207
+            //Update the existing row, overriding the values with those passed in
206 208
             return $this->updateRow($existing['id'], array_merge($existing, $row));
209
+        }
207 210
 
208 211
         $values = array();
209 212
         foreach($this->getFields() as  $def)
@@ -232,7 +235,9 @@  discard block
 block discarded – undo
232 235
     {
233 236
         $newVals = array();
234 237
         //Unset the ID since we are using it to update the row
235
-        if (isset($values['id'])) unset($values['id']);
238
+        if (isset($values['id'])) {
239
+            unset($values['id']);
240
+        }
236 241
         foreach($values as $field => $val)
237 242
         {
238 243
             $newVals[] = "$field='$val'";
@@ -252,8 +257,9 @@  discard block
 block discarded – undo
252 257
      */
253 258
     protected function removeRow($where)
254 259
     {
255
-        if (empty($where))
256
-            return false;
260
+        if (empty($where)) {
261
+                    return false;
262
+        }
257 263
 
258 264
         $date_modified = TimeDate::getInstance()->getNow()->asDb();
259 265
         $stringSets = array();
@@ -278,8 +284,9 @@  discard block
 block discarded – undo
278 284
     {
279 285
         $leftIDName = $this->def['join_key_lhs'];
280 286
         $rightIDName = $this->def['join_key_rhs'];
281
-        if (empty($row[$leftIDName]) ||  empty($row[$rightIDName]))
282
-            return false;
287
+        if (empty($row[$leftIDName]) ||  empty($row[$rightIDName])) {
288
+                    return false;
289
+        }
283 290
 
284 291
         $leftID = $row[$leftIDName];
285 292
         $rightID = $row[$rightIDName];
@@ -308,14 +315,16 @@  discard block
 block discarded – undo
308 315
     {
309 316
         $ignore_role_filter = $ignore_role_filter || $this->ignore_role_filter;
310 317
         $roleCheck = "";
311
-        if (empty ($table))
312
-            $table = $this->getRelationshipTable();
318
+        if (empty ($table)) {
319
+                    $table = $this->getRelationshipTable();
320
+        }
313 321
         if (!empty($this->def['relationship_role_column']) && !empty($this->def["relationship_role_column_value"]) && !$ignore_role_filter )
314 322
         {
315
-            if (empty($table))
316
-                $roleCheck = " AND $this->relationship_role_column";
317
-            else
318
-                $roleCheck = " AND $table.{$this->relationship_role_column}";
323
+            if (empty($table)) {
324
+                            $roleCheck = " AND $this->relationship_role_column";
325
+            } else {
326
+                            $roleCheck = " AND $table.{$this->relationship_role_column}";
327
+            }
319 328
             //role column value.
320 329
             if (empty($this->def['relationship_role_column_value']))
321 330
             {
@@ -406,8 +415,9 @@  discard block
 block discarded – undo
406 415
     protected function getOptionalWhereClause($optional_array) {
407 416
         //lhs_field, operator, and rhs_value must be set in optional_array
408 417
         foreach(array("lhs_field", "operator", "rhs_value") as $required){
409
-            if (empty($optional_array[$required]))
410
-                return "";
418
+            if (empty($optional_array[$required])) {
419
+                            return "";
420
+            }
411 421
         }
412 422
 
413 423
         return $optional_array['lhs_field']."".$optional_array['operator']."'".$optional_array['rhs_value']."'";
@@ -445,8 +455,7 @@  discard block
 block discarded – undo
445 455
                 if (empty($bean->deleted) && empty($bean->in_save))
446 456
                 {
447 457
                     $bean->save();
448
-                }
449
-                else
458
+                } else
450 459
                 {
451 460
                     // Bug 55942 save the in-save id which will be used to send workflow alert later
452 461
                     if (isset($bean->id) && !empty($_SESSION['WORKFLOW_ALERTS']))
@@ -479,8 +488,9 @@  discard block
 block discarded – undo
479 488
 
480 489
     public function __get($name)
481 490
     {
482
-        if (isset($this->def[$name]))
483
-            return $this->def[$name];
491
+        if (isset($this->def[$name])) {
492
+                    return $this->def[$name];
493
+        }
484 494
 
485 495
         switch($name)
486 496
         {
@@ -500,8 +510,9 @@  discard block
 block discarded – undo
500 510
                 return array('lhs_table', 'lhs_key', 'rhs_module', 'rhs_table', 'rhs_key', 'relationship_type');
501 511
         }
502 512
 
503
-        if (isset($this->$name))
504
-            return $this->$name;
513
+        if (isset($this->$name)) {
514
+                    return $this->$name;
515
+        }
505 516
 
506 517
         return null;
507 518
     }
Please login to merge, or discard this patch.
data/Relationships/One2OneBeanRelationship.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -102,9 +102,9 @@
 block discarded – undo
102 102
 
103 103
         //join the related module's table
104 104
         $join .= "$join_type $targetTableWithAlias ON $targetTable.$targetKey=$startingTable.$startingKey"
105
-               . " AND $targetTable.deleted=$deleted\n"
105
+                . " AND $targetTable.deleted=$deleted\n"
106 106
         //Next add any role filters
107
-               . $this->getRoleWhere();
107
+                . $this->getRoleWhere();
108 108
 
109 109
         if($return_array){
110 110
             return array(
Please login to merge, or discard this 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.
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -72,11 +74,13 @@  discard block
 block discarded – undo
72 74
     protected function updateLinks($lhs, $lhsLinkName, $rhs, $rhsLinkName)
73 75
     {
74 76
         //RHS and LHS only ever have one bean
75
-        if (isset($lhs->$lhsLinkName))
76
-            $lhs->$lhsLinkName->beans = array($rhs->id => $rhs);
77
+        if (isset($lhs->$lhsLinkName)) {
78
+                    $lhs->$lhsLinkName->beans = array($rhs->id => $rhs);
79
+        }
77 80
 
78
-        if (isset($rhs->$rhsLinkName))
79
-            $rhs->$rhsLinkName->beans = array($lhs->id => $lhs);
81
+        if (isset($rhs->$rhsLinkName)) {
82
+                    $rhs->$rhsLinkName->beans = array($lhs->id => $lhs);
83
+        }
80 84
     }
81 85
 
82 86
     public function getJoin($link, $params = array(), $return_array = false)
Please login to merge, or discard this patch.