@@ -25,7 +25,7 @@ |
||
25 | 25 | */ |
26 | 26 | function smarty_modifier_cat($string, $cat) |
27 | 27 | { |
28 | - return $string . $cat; |
|
28 | + return $string.$cat; |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /* vim: set expandtab: */ |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | return rawurlencode($string); |
36 | 36 | |
37 | 37 | case 'urlpathinfo': |
38 | - return str_replace('%2F','/',rawurlencode($string)); |
|
38 | + return str_replace('%2F', '/', rawurlencode($string)); |
|
39 | 39 | |
40 | 40 | case 'quotes': |
41 | 41 | // escape unescaped single quotes |
@@ -44,41 +44,41 @@ discard block |
||
44 | 44 | case 'hex': |
45 | 45 | // escape every character into hex |
46 | 46 | $return = ''; |
47 | - for ($x=0; $x < strlen($string); $x++) { |
|
48 | - $return .= '%' . bin2hex($string[$x]); |
|
47 | + for ($x = 0; $x < strlen($string); $x++) { |
|
48 | + $return .= '%'.bin2hex($string[$x]); |
|
49 | 49 | } |
50 | 50 | return $return; |
51 | 51 | |
52 | 52 | case 'hexentity': |
53 | 53 | $return = ''; |
54 | - for ($x=0; $x < strlen($string); $x++) { |
|
55 | - $return .= '&#x' . bin2hex($string[$x]) . ';'; |
|
54 | + for ($x = 0; $x < strlen($string); $x++) { |
|
55 | + $return .= '&#x'.bin2hex($string[$x]).';'; |
|
56 | 56 | } |
57 | 57 | return $return; |
58 | 58 | |
59 | 59 | case 'decentity': |
60 | 60 | $return = ''; |
61 | - for ($x=0; $x < strlen($string); $x++) { |
|
62 | - $return .= '&#' . ord($string[$x]) . ';'; |
|
61 | + for ($x = 0; $x < strlen($string); $x++) { |
|
62 | + $return .= '&#'.ord($string[$x]).';'; |
|
63 | 63 | } |
64 | 64 | return $return; |
65 | 65 | |
66 | 66 | case 'javascript': |
67 | 67 | // escape quotes and backslashes, newlines, etc. |
68 | - return strtr($string, array('\\'=>'\\\\',"'"=>"\\'",'"'=>'\\"',"\r"=>'\\r',"\n"=>'\\n','</'=>'<\/')); |
|
68 | + return strtr($string, array('\\'=>'\\\\', "'"=>"\\'", '"'=>'\\"', "\r"=>'\\r', "\n"=>'\\n', '</'=>'<\/')); |
|
69 | 69 | |
70 | 70 | case 'mail': |
71 | 71 | // safe way to display e-mail address on a web page |
72 | - return str_replace(array('@', '.'),array(' [AT] ', ' [DOT] '), $string); |
|
72 | + return str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string); |
|
73 | 73 | |
74 | 74 | case 'nonstd': |
75 | 75 | // escape non-standard chars, such as ms document quotes |
76 | 76 | $_res = ''; |
77 | - for($_i = 0, $_len = strlen($string); $_i < $_len; $_i++) { |
|
77 | + for ($_i = 0, $_len = strlen($string); $_i < $_len; $_i++) { |
|
78 | 78 | $_ord = ord(substr($string, $_i, 1)); |
79 | 79 | // non-standard char, escape it |
80 | - if($_ord >= 126){ |
|
81 | - $_res .= '&#' . $_ord . ';'; |
|
80 | + if ($_ord >= 126) { |
|
81 | + $_res .= '&#'.$_ord.';'; |
|
82 | 82 | } |
83 | 83 | else { |
84 | 84 | $_res .= substr($string, $_i, 1); |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | $reset = (isset($params['reset'])) ? (bool)$params['reset'] : false; |
52 | 52 | |
53 | 53 | if (!in_array('values', array_keys($params))) { |
54 | - if(!isset($cycle_vars[$name]['values'])) { |
|
54 | + if (!isset($cycle_vars[$name]['values'])) { |
|
55 | 55 | $smarty->trigger_error("cycle: missing 'values' parameter"); |
56 | 56 | return; |
57 | 57 | } |
58 | 58 | } else { |
59 | - if(isset($cycle_vars[$name]['values']) |
|
60 | - && $cycle_vars[$name]['values'] != $params['values'] ) { |
|
59 | + if (isset($cycle_vars[$name]['values']) |
|
60 | + && $cycle_vars[$name]['values'] != $params['values']) { |
|
61 | 61 | $cycle_vars[$name]['index'] = 0; |
62 | 62 | } |
63 | 63 | $cycle_vars[$name]['values'] = $params['values']; |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | $cycle_vars[$name]['delimiter'] = ','; |
70 | 70 | } |
71 | 71 | |
72 | - if(is_array($cycle_vars[$name]['values'])) { |
|
72 | + if (is_array($cycle_vars[$name]['values'])) { |
|
73 | 73 | $cycle_array = $cycle_vars[$name]['values']; |
74 | 74 | } else { |
75 | - $cycle_array = explode($cycle_vars[$name]['delimiter'],$cycle_vars[$name]['values']); |
|
75 | + $cycle_array = explode($cycle_vars[$name]['delimiter'], $cycle_vars[$name]['values']); |
|
76 | 76 | } |
77 | 77 | |
78 | - if(!isset($cycle_vars[$name]['index']) || $reset ) { |
|
78 | + if (!isset($cycle_vars[$name]['index']) || $reset) { |
|
79 | 79 | $cycle_vars[$name]['index'] = 0; |
80 | 80 | } |
81 | 81 | |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | $smarty->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]); |
85 | 85 | } |
86 | 86 | |
87 | - if($print) { |
|
87 | + if ($print) { |
|
88 | 88 | $retval = $cycle_array[$cycle_vars[$name]['index']]; |
89 | 89 | } else { |
90 | 90 | $retval = null; |
91 | 91 | } |
92 | 92 | |
93 | - if($advance) { |
|
94 | - if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) { |
|
93 | + if ($advance) { |
|
94 | + if ($cycle_vars[$name]['index'] >= count($cycle_array) - 1) { |
|
95 | 95 | $cycle_vars[$name]['index'] = 0; |
96 | 96 | } else { |
97 | 97 | $cycle_vars[$name]['index']++; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | |
45 | 45 | |
46 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
46 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
47 | 47 | /********************************************************************************* |
48 | 48 | * SugarCRM Community Edition is a customer relationship management program developed by |
49 | 49 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | */ |
103 | 103 | function smarty_function_sugar_phone($params, &$smarty) |
104 | 104 | { |
105 | - if (!isset($params['value'])){ |
|
105 | + if (!isset($params['value'])) { |
|
106 | 106 | $smarty->trigger_error("sugar_phone: missing 'value' parameter"); |
107 | 107 | return ''; |
108 | 108 | } |
109 | 109 | |
110 | 110 | global $system_config; |
111 | - if(isset($system_config->settings['system_skypeout_on']) && $system_config->settings['system_skypeout_on'] == 1 |
|
112 | - && isset($params['value']) && skype_formatted($params['value']) ) { |
|
111 | + if (isset($system_config->settings['system_skypeout_on']) && $system_config->settings['system_skypeout_on'] == 1 |
|
112 | + && isset($params['value']) && skype_formatted($params['value'])) { |
|
113 | 113 | $GLOBALS['log']->debug($params['value']); |
114 | 114 | return '<a href="callto:'.format_skype($params['value']).'">'.$params['value'].'</a>'; |
115 | 115 | } else { |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | function smarty_function_html_image($params, &$smarty) |
38 | 38 | { |
39 | - require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); |
|
39 | + require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars'); |
|
40 | 40 | |
41 | 41 | $alt = ''; |
42 | 42 | $file = ''; |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | $path_prefix = ''; |
49 | 49 | $server_vars = ($smarty->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS']; |
50 | 50 | $basedir = isset($server_vars['DOCUMENT_ROOT']) ? $server_vars['DOCUMENT_ROOT'] : ''; |
51 | - foreach($params as $_key => $_val) { |
|
52 | - switch($_key) { |
|
51 | + foreach ($params as $_key => $_val) { |
|
52 | + switch ($_key) { |
|
53 | 53 | case 'file': |
54 | 54 | case 'height': |
55 | 55 | case 'width': |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | break; |
61 | 61 | |
62 | 62 | case 'alt': |
63 | - if(!is_array($_val)) { |
|
63 | + if (!is_array($_val)) { |
|
64 | 64 | $$_key = smarty_function_escape_special_chars($_val); |
65 | 65 | } else { |
66 | 66 | $smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | |
70 | 70 | case 'link': |
71 | 71 | case 'href': |
72 | - $prefix = '<a href="' . $_val . '">'; |
|
72 | + $prefix = '<a href="'.$_val.'">'; |
|
73 | 73 | $suffix = '</a>'; |
74 | 74 | break; |
75 | 75 | |
76 | 76 | default: |
77 | - if(!is_array($_val)) { |
|
77 | + if (!is_array($_val)) { |
|
78 | 78 | $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; |
79 | 79 | } else { |
80 | 80 | $smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
@@ -88,18 +88,18 @@ discard block |
||
88 | 88 | return; |
89 | 89 | } |
90 | 90 | |
91 | - if (substr($file,0,1) == '/') { |
|
92 | - $_image_path = $basedir . $file; |
|
91 | + if (substr($file, 0, 1) == '/') { |
|
92 | + $_image_path = $basedir.$file; |
|
93 | 93 | } else { |
94 | 94 | $_image_path = $file; |
95 | 95 | } |
96 | 96 | |
97 | - if(!isset($params['width']) || !isset($params['height'])) { |
|
98 | - if(!$_image_data = @getimagesize($_image_path)) { |
|
99 | - if(!file_exists($_image_path)) { |
|
97 | + if (!isset($params['width']) || !isset($params['height'])) { |
|
98 | + if (!$_image_data = @getimagesize($_image_path)) { |
|
99 | + if (!file_exists($_image_path)) { |
|
100 | 100 | $smarty->trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE); |
101 | 101 | return; |
102 | - } else if(!is_readable($_image_path)) { |
|
102 | + } else if (!is_readable($_image_path)) { |
|
103 | 103 | $smarty->trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE); |
104 | 104 | return; |
105 | 105 | } else { |
@@ -109,32 +109,32 @@ discard block |
||
109 | 109 | } |
110 | 110 | if ($smarty->security && |
111 | 111 | ($_params = array('resource_type' => 'file', 'resource_name' => $_image_path)) && |
112 | - (require_once(SMARTY_CORE_DIR . 'core.is_secure.php')) && |
|
113 | - (!smarty_core_is_secure($_params, $smarty)) ) { |
|
112 | + (require_once(SMARTY_CORE_DIR.'core.is_secure.php')) && |
|
113 | + (!smarty_core_is_secure($_params, $smarty))) { |
|
114 | 114 | $smarty->trigger_error("html_image: (secure) '$_image_path' not in secure directory", E_USER_NOTICE); |
115 | 115 | } |
116 | 116 | |
117 | - if(!isset($params['width'])) { |
|
117 | + if (!isset($params['width'])) { |
|
118 | 118 | $width = $_image_data[0]; |
119 | 119 | } |
120 | - if(!isset($params['height'])) { |
|
120 | + if (!isset($params['height'])) { |
|
121 | 121 | $height = $_image_data[1]; |
122 | 122 | } |
123 | 123 | |
124 | 124 | } |
125 | 125 | |
126 | - if(isset($params['dpi'])) { |
|
127 | - if(strstr($server_vars['HTTP_USER_AGENT'], 'Mac')) { |
|
126 | + if (isset($params['dpi'])) { |
|
127 | + if (strstr($server_vars['HTTP_USER_AGENT'], 'Mac')) { |
|
128 | 128 | $dpi_default = 72; |
129 | 129 | } else { |
130 | 130 | $dpi_default = 96; |
131 | 131 | } |
132 | - $_resize = $dpi_default/$params['dpi']; |
|
132 | + $_resize = $dpi_default / $params['dpi']; |
|
133 | 133 | $width = round($width * $_resize); |
134 | 134 | $height = round($height * $_resize); |
135 | 135 | } |
136 | 136 | |
137 | - return $prefix . '<img src="'.$path_prefix.$file.'" alt="'.$alt.'" width="'.$width.'" height="'.$height.'"'.$extra.' />' . $suffix; |
|
137 | + return $prefix.'<img src="'.$path_prefix.$file.'" alt="'.$alt.'" width="'.$width.'" height="'.$height.'"'.$extra.' />'.$suffix; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /* vim: set expandtab: */ |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | $source = trim(preg_replace('/((?<!\?>)\n)[\s]+/m', '\1', $source)); |
51 | 51 | |
52 | 52 | // replace textarea blocks |
53 | - smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@",$_textarea_blocks, $source); |
|
53 | + smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@", $_textarea_blocks, $source); |
|
54 | 54 | |
55 | 55 | // replace pre blocks |
56 | - smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@",$_pre_blocks, $source); |
|
56 | + smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@", $_pre_blocks, $source); |
|
57 | 57 | |
58 | 58 | // replace script blocks |
59 | - smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@",$_script_blocks, $source); |
|
59 | + smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@", $_script_blocks, $source); |
|
60 | 60 | |
61 | 61 | return $source; |
62 | 62 | } |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | function smarty_outputfilter_trimwhitespace_replace($search_str, $replace, &$subject) { |
65 | 65 | $_len = strlen($search_str); |
66 | 66 | $_pos = 0; |
67 | - for ($_i=0, $_count=count($replace); $_i<$_count; $_i++) |
|
68 | - if (($_pos=strpos($subject, $search_str, $_pos))!==false) |
|
67 | + for ($_i = 0, $_count = count($replace); $_i < $_count; $_i++) |
|
68 | + if (($_pos = strpos($subject, $search_str, $_pos)) !== false) |
|
69 | 69 | $subject = substr_replace($subject, $replace[$_i], $_pos, $_len); |
70 | 70 | else |
71 | 71 | break; |
@@ -68,42 +68,42 @@ |
||
68 | 68 | |
69 | 69 | function smarty_function_sugarvar($params, &$smarty) |
70 | 70 | { |
71 | - if(empty($params['key'])) { |
|
71 | + if (empty($params['key'])) { |
|
72 | 72 | $smarty->trigger_error("sugarvar: missing 'key' parameter"); |
73 | 73 | return; |
74 | 74 | } |
75 | 75 | |
76 | - $object = (empty($params['objectName']))?$smarty->get_template_vars('parentFieldArray'): $params['objectName']; |
|
76 | + $object = (empty($params['objectName'])) ? $smarty->get_template_vars('parentFieldArray') : $params['objectName']; |
|
77 | 77 | $displayParams = $smarty->get_template_vars('displayParams'); |
78 | 78 | |
79 | 79 | |
80 | - if(empty($params['memberName'])){ |
|
80 | + if (empty($params['memberName'])) { |
|
81 | 81 | $member = $smarty->get_template_vars('vardef'); |
82 | 82 | $member = $member['name']; |
83 | - }else{ |
|
83 | + } else { |
|
84 | 84 | $members = explode('.', $params['memberName']); |
85 | - $member = $smarty->get_template_vars($members[0]); |
|
86 | - for($i = 1; $i < count($members); $i++){ |
|
85 | + $member = $smarty->get_template_vars($members[0]); |
|
86 | + for ($i = 1; $i < count($members); $i++) { |
|
87 | 87 | $member = $member[$members[$i]]; |
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | - $_contents = '$'. $object . '.' . $member . '.' . $params['key']; |
|
92 | - if(empty($params['stringFormat']) && empty($params['string'])) { |
|
93 | - $_contents = '{' . $_contents; |
|
94 | - if(!empty($displayParams['htmlescape'])){ |
|
91 | + $_contents = '$'.$object.'.'.$member.'.'.$params['key']; |
|
92 | + if (empty($params['stringFormat']) && empty($params['string'])) { |
|
93 | + $_contents = '{'.$_contents; |
|
94 | + if (!empty($displayParams['htmlescape'])) { |
|
95 | 95 | $_contents .= '|escape:\'html\''; |
96 | 96 | } |
97 | - if(!empty($params['htmlentitydecode'])){ |
|
97 | + if (!empty($params['htmlentitydecode'])) { |
|
98 | 98 | $_contents .= '|escape:\'html_entity_decode\''; |
99 | 99 | } |
100 | - if(!empty($displayParams['strip_tags'])){ |
|
100 | + if (!empty($displayParams['strip_tags'])) { |
|
101 | 101 | $_contents .= '|strip_tags'; |
102 | 102 | } |
103 | - if(!empty($displayParams['url2html'])){ |
|
103 | + if (!empty($displayParams['url2html'])) { |
|
104 | 104 | $_contents .= '|url2html'; |
105 | 105 | } |
106 | - if(!empty($displayParams['nl2br'])){ |
|
106 | + if (!empty($displayParams['nl2br'])) { |
|
107 | 107 | $_contents .= '|nl2br'; |
108 | 108 | } |
109 | 109 |
@@ -27,41 +27,41 @@ |
||
27 | 27 | */ |
28 | 28 | function smarty_function_sugar_button_slider($params, &$smarty) |
29 | 29 | { |
30 | - if(empty($params['module'])) { |
|
30 | + if (empty($params['module'])) { |
|
31 | 31 | $smarty->trigger_error("sugar_button_slider: missing required param (module)"); |
32 | - } else if(empty($params['buttons'])) { |
|
32 | + } else if (empty($params['buttons'])) { |
|
33 | 33 | $smarty->trigger_error("sugar_button_slider: missing required param (buttons)"); |
34 | - } else if(empty($params['view'])) { |
|
34 | + } else if (empty($params['view'])) { |
|
35 | 35 | $smarty->trigger_error("sugar_button_slider: missing required param (view)"); |
36 | 36 | } |
37 | 37 | $module = $params['module']; |
38 | 38 | $view = $params['view']; |
39 | 39 | $buttons = $params['buttons']; |
40 | 40 | $str = ''; |
41 | - if(is_array($buttons)) { |
|
42 | - if(count($buttons) <= 2){ |
|
43 | - foreach($buttons as $val => $button){ |
|
41 | + if (is_array($buttons)) { |
|
42 | + if (count($buttons) <= 2) { |
|
43 | + foreach ($buttons as $val => $button) { |
|
44 | 44 | $str .= smarty_function_sugar_button(array('module' => $module, 'id' => $button, 'view' => $view), $smarty); |
45 | 45 | } |
46 | - }else{ |
|
46 | + } else { |
|
47 | 47 | $str = '<div id="buttonSlide" class="yui-module">'; |
48 | 48 | $str .= '<table border="0">'; |
49 | - $str .='<tr><td>'; |
|
50 | - $str .='<div class="yui-hd">'; |
|
51 | - for($i = 0; $i < 2; $i++){ |
|
49 | + $str .= '<tr><td>'; |
|
50 | + $str .= '<div class="yui-hd">'; |
|
51 | + for ($i = 0; $i < 2; $i++) { |
|
52 | 52 | $button = $buttons[$i]; |
53 | 53 | $str .= smarty_function_sugar_button(array('module' => $module, 'id' => $button, 'view' => $view), $smarty); |
54 | 54 | $str .= ' '; |
55 | 55 | } |
56 | 56 | $str .= '</div></td>'; |
57 | - $str .='<td align="right"> <div class="yui-bd">'; |
|
58 | - for($i = 2; $i < count($buttons); $i++){ |
|
57 | + $str .= '<td align="right"> <div class="yui-bd">'; |
|
58 | + for ($i = 2; $i < count($buttons); $i++) { |
|
59 | 59 | $button = $buttons[$i]; |
60 | 60 | $str .= smarty_function_sugar_button(array('module' => $module, 'id' => $button, 'view' => $view), $smarty); |
61 | 61 | $str .= ' '; |
62 | 62 | } |
63 | - $str .='</div></td>'; |
|
64 | - $str .='</tr></table>'; |
|
63 | + $str .= '</div></td>'; |
|
64 | + $str .= '</tr></table>'; |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | return $str; |
@@ -37,24 +37,24 @@ |
||
37 | 37 | |
38 | 38 | function smarty_function_sugar_fetch($params, &$smarty) |
39 | 39 | { |
40 | - if(empty($params['key'])) { |
|
40 | + if (empty($params['key'])) { |
|
41 | 41 | $smarty->trigger_error("sugar_fetch: missing 'key' parameter"); |
42 | 42 | return; |
43 | 43 | } |
44 | - if(empty($params['object'])) { |
|
44 | + if (empty($params['object'])) { |
|
45 | 45 | $smarty->trigger_error("sugar_fetch: missing 'object' parameter"); |
46 | 46 | return; |
47 | 47 | } |
48 | 48 | |
49 | 49 | $theKey = $params['key']; |
50 | - if(is_object($params['object'])) { |
|
50 | + if (is_object($params['object'])) { |
|
51 | 51 | $theData = $params['object']->$theKey; |
52 | 52 | } else { |
53 | 53 | $theData = $params['object'][$theKey]; |
54 | 54 | } |
55 | 55 | |
56 | - if(!empty($params['assign'])) { |
|
57 | - $smarty->assign($params['assign'],$theData); |
|
56 | + if (!empty($params['assign'])) { |
|
57 | + $smarty->assign($params['assign'], $theData); |
|
58 | 58 | } else { |
59 | 59 | return $theData; |
60 | 60 | } |