@@ -28,30 +28,30 @@ discard block |
||
28 | 28 | } |
29 | 29 | |
30 | 30 | // strip out backticks, not necessary for math |
31 | - $equation = str_replace('`','',$params['equation']); |
|
31 | + $equation = str_replace('`', '', $params['equation']); |
|
32 | 32 | |
33 | 33 | // make sure parenthesis are balanced |
34 | - if (substr_count($equation,"(") != substr_count($equation,")")) { |
|
34 | + if (substr_count($equation, "(") != substr_count($equation, ")")) { |
|
35 | 35 | $smarty->trigger_error("math: unbalanced parenthesis"); |
36 | 36 | return; |
37 | 37 | } |
38 | 38 | |
39 | 39 | // match all vars in equation, make sure all are passed |
40 | - preg_match_all("!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]*)!",$equation, $match); |
|
41 | - $allowed_funcs = array('int','abs','ceil','cos','exp','floor','log','log10', |
|
42 | - 'max','min','pi','pow','rand','round','sin','sqrt','srand','tan'); |
|
40 | + preg_match_all("!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]*)!", $equation, $match); |
|
41 | + $allowed_funcs = array('int', 'abs', 'ceil', 'cos', 'exp', 'floor', 'log', 'log10', |
|
42 | + 'max', 'min', 'pi', 'pow', 'rand', 'round', 'sin', 'sqrt', 'srand', 'tan'); |
|
43 | 43 | |
44 | - foreach($match[1] as $curr_var) { |
|
44 | + foreach ($match[1] as $curr_var) { |
|
45 | 45 | if ($curr_var && !in_array($curr_var, array_keys($params)) && !in_array($curr_var, $allowed_funcs)) { |
46 | 46 | $smarty->trigger_error("math: function call $curr_var not allowed"); |
47 | 47 | return; |
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | - foreach($params as $key => $val) { |
|
51 | + foreach ($params as $key => $val) { |
|
52 | 52 | if ($key != "equation" && $key != "format" && $key != "assign") { |
53 | 53 | // make sure value is not empty |
54 | - if (strlen($val)==0) { |
|
54 | + if (strlen($val) == 0) { |
|
55 | 55 | $smarty->trigger_error("math: parameter $key is empty"); |
56 | 56 | return; |
57 | 57 | } |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | if (empty($params['assign'])) { |
70 | 70 | return $smarty_math_result; |
71 | 71 | } else { |
72 | - $smarty->assign($params['assign'],$smarty_math_result); |
|
72 | + $smarty->assign($params['assign'], $smarty_math_result); |
|
73 | 73 | } |
74 | 74 | } else { |
75 | - if (empty($params['assign'])){ |
|
76 | - printf($params['format'],$smarty_math_result); |
|
75 | + if (empty($params['assign'])) { |
|
76 | + printf($params['format'], $smarty_math_result); |
|
77 | 77 | } else { |
78 | - $smarty->assign($params['assign'],sprintf($params['format'],$smarty_math_result)); |
|
78 | + $smarty->assign($params['assign'], sprintf($params['format'], $smarty_math_result)); |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | } |
@@ -43,15 +43,15 @@ |
||
43 | 43 | |
44 | 44 | function smarty_function_ext_includes($params, &$smarty) |
45 | 45 | { |
46 | - $ret = '<link rel="stylesheet" type="text/css" href="' . getJSPath("themes/default/ext/resources/css/ext-all.css") . '" />' |
|
47 | - . '<link rel="stylesheet" type="text/css" href="' . getJSPath("themes/default/ext/resources/css/xtheme-gray.css") . '" />'; |
|
46 | + $ret = '<link rel="stylesheet" type="text/css" href="'.getJSPath("themes/default/ext/resources/css/ext-all.css").'" />' |
|
47 | + . '<link rel="stylesheet" type="text/css" href="'.getJSPath("themes/default/ext/resources/css/xtheme-gray.css").'" />'; |
|
48 | 48 | |
49 | 49 | global $theme; |
50 | 50 | if (is_dir("themes/$theme/ext/resources/css")) { |
51 | 51 | $cssDir = opendir("themes/$theme/ext/resources/css"); |
52 | 52 | while (($file = readdir($cssDir)) !== false) { |
53 | 53 | if (strcasecmp(substr($file, -4), '.css' == 0)) { |
54 | - $ret .= "<link rel='stylesheet' type='text/css' href='" . getJSPath("themes/$theme/ext/resources/css/$file") . "' />"; |
|
54 | + $ret .= "<link rel='stylesheet' type='text/css' href='".getJSPath("themes/$theme/ext/resources/css/$file")."' />"; |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | } |
@@ -55,33 +55,33 @@ discard block |
||
55 | 55 | function smarty_function_sugar_field($params, &$smarty) |
56 | 56 | { |
57 | 57 | if (!isset($params['vardef']) || !isset($params['displayType']) || !isset($params['parentFieldArray'])) { |
58 | - if(!isset($params['vardef'])) |
|
58 | + if (!isset($params['vardef'])) |
|
59 | 59 | $smarty->trigger_error("sugar_field: missing 'vardef' parameter"); |
60 | - if(!isset($params['displayType'])) |
|
60 | + if (!isset($params['displayType'])) |
|
61 | 61 | $smarty->trigger_error("sugar_field: missing 'displayType' parameter"); |
62 | - if(!isset($params['parentFieldArray'])) |
|
62 | + if (!isset($params['parentFieldArray'])) |
|
63 | 63 | $smarty->trigger_error("sugar_field: missing 'parentFieldArray' parameter"); |
64 | 64 | |
65 | 65 | return; |
66 | 66 | } |
67 | 67 | |
68 | 68 | static $sfh; |
69 | - if(!isset($sfh)) $sfh = new SugarFieldHandler(); |
|
69 | + if (!isset($sfh)) $sfh = new SugarFieldHandler(); |
|
70 | 70 | |
71 | - if(!isset($params['displayParams'])) $displayParams = array(); |
|
71 | + if (!isset($params['displayParams'])) $displayParams = array(); |
|
72 | 72 | else $displayParams = $params['displayParams']; |
73 | 73 | |
74 | - if(isset($params['labelSpan'])) $displayParams['labelSpan'] = $params['labelSpan']; |
|
74 | + if (isset($params['labelSpan'])) $displayParams['labelSpan'] = $params['labelSpan']; |
|
75 | 75 | else $displayParams['labelSpan'] = null; |
76 | - if(isset($params['fieldSpan'])) $displayParams['fieldSpan'] = $params['fieldSpan']; |
|
76 | + if (isset($params['fieldSpan'])) $displayParams['fieldSpan'] = $params['fieldSpan']; |
|
77 | 77 | else $displayParams['fieldSpan'] = null; |
78 | 78 | |
79 | - if(isset($params['typeOverride'])) { // override the type in the vardef? |
|
79 | + if (isset($params['typeOverride'])) { // override the type in the vardef? |
|
80 | 80 | $params['vardef']['type'] = $params['typeOverride']; |
81 | 81 | } |
82 | - if(isset($params['formName'])) $displayParams['formName'] = $params['formName']; |
|
82 | + if (isset($params['formName'])) $displayParams['formName'] = $params['formName']; |
|
83 | 83 | |
84 | - if(isset($params['field'])) { |
|
84 | + if (isset($params['field'])) { |
|
85 | 85 | $params['vardef']['name'] = $params['field']; |
86 | 86 | } |
87 | 87 | |
@@ -89,15 +89,15 @@ discard block |
||
89 | 89 | $displayParams['call_back_function'] = $params['call_back_function']; |
90 | 90 | } |
91 | 91 | |
92 | - if(isset($params['skipClearButton'])) { |
|
92 | + if (isset($params['skipClearButton'])) { |
|
93 | 93 | $displayParams['skipClearButton'] = $params['skipClearButton']; |
94 | 94 | } |
95 | 95 | |
96 | - if(isset($params['idName'])) { |
|
96 | + if (isset($params['idName'])) { |
|
97 | 97 | $displayParams['idName'] = $params['idName']; |
98 | 98 | } |
99 | 99 | |
100 | - if(isset($params['accesskey'])) { |
|
100 | + if (isset($params['accesskey'])) { |
|
101 | 101 | $displayParams['accesskey'] = $params['accesskey']; |
102 | 102 | } |
103 | 103 |
@@ -18,10 +18,10 @@ |
||
18 | 18 | */ |
19 | 19 | function smarty_function_escape_special_chars($string) |
20 | 20 | { |
21 | - if(!is_array($string)) { |
|
21 | + if (!is_array($string)) { |
|
22 | 22 | $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); |
23 | 23 | $string = htmlspecialchars($string); |
24 | - $string = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $string); |
|
24 | + $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); |
|
25 | 25 | } |
26 | 26 | return $string; |
27 | 27 | } |
@@ -38,7 +38,7 @@ |
||
38 | 38 | return; |
39 | 39 | } |
40 | 40 | if (DIRECTORY_SEPARATOR == '\\') { |
41 | - $_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T'); |
|
41 | + $_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T'); |
|
42 | 42 | $_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S'); |
43 | 43 | if (strpos($format, '%e') !== false) { |
44 | 44 | $_win_from[] = '%e'; |
@@ -71,16 +71,16 @@ |
||
71 | 71 | */ |
72 | 72 | function smarty_function_sugar_help($params, &$smarty) |
73 | 73 | { |
74 | - $text = str_replace("'","\'",htmlspecialchars($params['text'])); |
|
74 | + $text = str_replace("'", "\'", htmlspecialchars($params['text'])); |
|
75 | 75 | //append any additional parameters. |
76 | - $click = "return SUGAR.util.showHelpTips(this,'$text'"; |
|
76 | + $click = "return SUGAR.util.showHelpTips(this,'$text'"; |
|
77 | 77 | |
78 | - if (count( $params) > 1){ |
|
78 | + if (count($params) > 1) { |
|
79 | 79 | |
80 | - $click .=",'".$params['myPos']."','".$params['atPos']."'"; |
|
80 | + $click .= ",'".$params['myPos']."','".$params['atPos']."'"; |
|
81 | 81 | } |
82 | 82 | $helpImage = SugarThemeRegistry::current()->getImageURL('helpInline.png'); |
83 | - $click .= " );" ; |
|
83 | + $click .= " );"; |
|
84 | 84 | $alt_tag = $GLOBALS['app_strings']['LBL_ALT_INFO']; |
85 | 85 | return <<<EOHTML |
86 | 86 | <img border="0" |
@@ -46,21 +46,21 @@ |
||
46 | 46 | function smarty_function_sugar_variable_constructor($params, &$smarty) |
47 | 47 | { |
48 | 48 | if (!isset($params['objectName']) || !isset($params['memberName']) || !isset($params['key'])) { |
49 | - if(!isset($params['objectName'])) |
|
49 | + if (!isset($params['objectName'])) |
|
50 | 50 | $smarty->trigger_error("sugar_variable_constructor: missing 'objectName' parameter"); |
51 | - if(!isset($params['memberName'])) |
|
51 | + if (!isset($params['memberName'])) |
|
52 | 52 | $smarty->trigger_error("sugar_variable_constructor: missing 'memberName' parameter"); |
53 | - if(!isset($params['key'])) |
|
53 | + if (!isset($params['key'])) |
|
54 | 54 | $smarty->trigger_error("sugar_variable_constructor: missing 'key' parameter"); |
55 | 55 | |
56 | 56 | return; |
57 | 57 | } |
58 | 58 | |
59 | - if(isset($params['stringFormat'])) { |
|
60 | - $_contents = '$'. $params['objectName'] . '.' . $params['memberName'] . '.' . $params['key']; |
|
59 | + if (isset($params['stringFormat'])) { |
|
60 | + $_contents = '$'.$params['objectName'].'.'.$params['memberName'].'.'.$params['key']; |
|
61 | 61 | } |
62 | 62 | else { |
63 | - $_contents = '{$' . $params['objectName'] . '.' . $params['memberName'] . '.' . $params['key'] . '}'; |
|
63 | + $_contents = '{$'.$params['objectName'].'.'.$params['memberName'].'.'.$params['key'].'}'; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | return $_contents; |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | // netscape and mozilla do not decode %40 (@) in BCC field (bug?) |
64 | 64 | // so, don't encode it. |
65 | 65 | $search = array('%40', '%2C'); |
66 | - $replace = array('@', ','); |
|
66 | + $replace = array('@', ','); |
|
67 | 67 | $mail_parms = array(); |
68 | 68 | foreach ($params as $var=>$value) { |
69 | 69 | switch ($var) { |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | case 'bcc': |
72 | 72 | case 'followupto': |
73 | 73 | if (!empty($value)) |
74 | - $mail_parms[] = $var.'='.str_replace($search,$replace,rawurlencode($value)); |
|
74 | + $mail_parms[] = $var.'='.str_replace($search, $replace, rawurlencode($value)); |
|
75 | 75 | break; |
76 | 76 | |
77 | 77 | case 'subject': |
@@ -88,39 +88,39 @@ discard block |
||
88 | 88 | } |
89 | 89 | |
90 | 90 | $mail_parm_vals = ''; |
91 | - for ($i=0; $i<count($mail_parms); $i++) { |
|
92 | - $mail_parm_vals .= (0==$i) ? '?' : '&'; |
|
91 | + for ($i = 0; $i < count($mail_parms); $i++) { |
|
92 | + $mail_parm_vals .= (0 == $i) ? '?' : '&'; |
|
93 | 93 | $mail_parm_vals .= $mail_parms[$i]; |
94 | 94 | } |
95 | 95 | $address .= $mail_parm_vals; |
96 | 96 | |
97 | 97 | $encode = (empty($params['encode'])) ? 'none' : $params['encode']; |
98 | - if (!in_array($encode,array('javascript','javascript_charcode','hex','none')) ) { |
|
98 | + if (!in_array($encode, array('javascript', 'javascript_charcode', 'hex', 'none'))) { |
|
99 | 99 | $smarty->trigger_error("mailto: 'encode' parameter must be none, javascript or hex"); |
100 | 100 | return; |
101 | 101 | } |
102 | 102 | |
103 | - if ($encode == 'javascript' ) { |
|
103 | + if ($encode == 'javascript') { |
|
104 | 104 | $string = 'document.write(\'<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>\');'; |
105 | 105 | |
106 | 106 | $js_encode = ''; |
107 | - for ($x=0; $x < strlen($string); $x++) { |
|
108 | - $js_encode .= '%' . bin2hex($string[$x]); |
|
107 | + for ($x = 0; $x < strlen($string); $x++) { |
|
108 | + $js_encode .= '%'.bin2hex($string[$x]); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | return '<script type="text/javascript">eval(unescape(\''.$js_encode.'\'))</script>'; |
112 | 112 | |
113 | - } elseif ($encode == 'javascript_charcode' ) { |
|
113 | + } elseif ($encode == 'javascript_charcode') { |
|
114 | 114 | $string = '<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>'; |
115 | 115 | |
116 | - for($x = 0, $y = strlen($string); $x < $y; $x++ ) { |
|
116 | + for ($x = 0, $y = strlen($string); $x < $y; $x++) { |
|
117 | 117 | $ord[] = ord($string[$x]); |
118 | 118 | } |
119 | 119 | |
120 | 120 | $_ret = "<script type=\"text/javascript\" language=\"javascript\">\n"; |
121 | 121 | $_ret .= "<!--\n"; |
122 | 122 | $_ret .= "{document.write(String.fromCharCode("; |
123 | - $_ret .= implode(',',$ord); |
|
123 | + $_ret .= implode(',', $ord); |
|
124 | 124 | $_ret .= "))"; |
125 | 125 | $_ret .= "}\n"; |
126 | 126 | $_ret .= "//-->\n"; |
@@ -131,22 +131,22 @@ discard block |
||
131 | 131 | |
132 | 132 | } elseif ($encode == 'hex') { |
133 | 133 | |
134 | - preg_match('!^(.*)(\?.*)$!',$address,$match); |
|
135 | - if(!empty($match[2])) { |
|
134 | + preg_match('!^(.*)(\?.*)$!', $address, $match); |
|
135 | + if (!empty($match[2])) { |
|
136 | 136 | $smarty->trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript."); |
137 | 137 | return; |
138 | 138 | } |
139 | 139 | $address_encode = ''; |
140 | - for ($x=0; $x < strlen($address); $x++) { |
|
141 | - if(preg_match('!\w!',$address[$x])) { |
|
142 | - $address_encode .= '%' . bin2hex($address[$x]); |
|
140 | + for ($x = 0; $x < strlen($address); $x++) { |
|
141 | + if (preg_match('!\w!', $address[$x])) { |
|
142 | + $address_encode .= '%'.bin2hex($address[$x]); |
|
143 | 143 | } else { |
144 | 144 | $address_encode .= $address[$x]; |
145 | 145 | } |
146 | 146 | } |
147 | 147 | $text_encode = ''; |
148 | - for ($x=0; $x < strlen($text); $x++) { |
|
149 | - $text_encode .= '&#x' . bin2hex($text[$x]).';'; |
|
148 | + for ($x = 0; $x < strlen($text); $x++) { |
|
149 | + $text_encode .= '&#x'.bin2hex($text[$x]).';'; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | $mailto = "mailto:"; |
@@ -21,7 +21,7 @@ |
||
21 | 21 | function smarty_modifier_count_words($string) |
22 | 22 | { |
23 | 23 | // split text by ' ',\r,\n,\f,\t |
24 | - $split_array = preg_split('/\s+/',$string); |
|
24 | + $split_array = preg_split('/\s+/', $string); |
|
25 | 25 | // count matches that contain alphanumerics |
26 | 26 | $word_count = preg_grep('/[a-zA-Z0-9\\x80-\\xff]/', $split_array); |
27 | 27 |