@@ -38,124 +38,124 @@ |
||
38 | 38 | */ |
39 | 39 | function smarty_function_html_image($params, $template) |
40 | 40 | { |
41 | - require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); |
|
42 | - |
|
43 | - $alt = ''; |
|
44 | - $file = ''; |
|
45 | - $height = ''; |
|
46 | - $width = ''; |
|
47 | - $extra = ''; |
|
48 | - $prefix = ''; |
|
49 | - $suffix = ''; |
|
50 | - $path_prefix = ''; |
|
51 | - $basedir = isset($_SERVER[ 'DOCUMENT_ROOT' ]) ? $_SERVER[ 'DOCUMENT_ROOT' ] : ''; |
|
52 | - foreach ($params as $_key => $_val) { |
|
53 | - switch ($_key) { |
|
54 | - case 'file': |
|
55 | - case 'height': |
|
56 | - case 'width': |
|
57 | - case 'dpi': |
|
58 | - case 'path_prefix': |
|
59 | - case 'basedir': |
|
60 | - $$_key = $_val; |
|
61 | - break; |
|
62 | - |
|
63 | - case 'alt': |
|
64 | - if (!is_array($_val)) { |
|
65 | - $$_key = smarty_function_escape_special_chars($_val); |
|
66 | - } else { |
|
67 | - throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
|
68 | - } |
|
69 | - break; |
|
70 | - |
|
71 | - case 'link': |
|
72 | - case 'href': |
|
73 | - $prefix = '<a href="' . $_val . '">'; |
|
74 | - $suffix = '</a>'; |
|
75 | - break; |
|
76 | - |
|
77 | - default: |
|
78 | - if (!is_array($_val)) { |
|
79 | - $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; |
|
80 | - } else { |
|
81 | - throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
|
82 | - } |
|
83 | - break; |
|
84 | - } |
|
85 | - } |
|
86 | - |
|
87 | - if (empty($file)) { |
|
88 | - trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE); |
|
89 | - |
|
90 | - return; |
|
91 | - } |
|
92 | - |
|
93 | - if ($file[ 0 ] == '/') { |
|
94 | - $_image_path = $basedir . $file; |
|
95 | - } else { |
|
96 | - $_image_path = $file; |
|
97 | - } |
|
98 | - |
|
99 | - // strip file protocol |
|
100 | - if (stripos($params[ 'file' ], 'file://') === 0) { |
|
101 | - $params[ 'file' ] = substr($params[ 'file' ], 7); |
|
102 | - } |
|
103 | - |
|
104 | - $protocol = strpos($params[ 'file' ], '://'); |
|
105 | - if ($protocol !== false) { |
|
106 | - $protocol = strtolower(substr($params[ 'file' ], 0, $protocol)); |
|
107 | - } |
|
108 | - |
|
109 | - if (isset($template->smarty->security_policy)) { |
|
110 | - if ($protocol) { |
|
111 | - // remote resource (or php stream, …) |
|
112 | - if (!$template->smarty->security_policy->isTrustedUri($params[ 'file' ])) { |
|
113 | - return; |
|
114 | - } |
|
115 | - } else { |
|
116 | - // local file |
|
117 | - if (!$template->smarty->security_policy->isTrustedResourceDir($_image_path)) { |
|
118 | - return; |
|
119 | - } |
|
120 | - } |
|
121 | - } |
|
122 | - |
|
123 | - if (!isset($params[ 'width' ]) || !isset($params[ 'height' ])) { |
|
124 | - if (!$_image_data = @getimagesize($_image_path)) { |
|
125 | - if (!file_exists($_image_path)) { |
|
126 | - trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE); |
|
127 | - |
|
128 | - return; |
|
129 | - } elseif (!is_readable($_image_path)) { |
|
130 | - trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE); |
|
131 | - |
|
132 | - return; |
|
133 | - } else { |
|
134 | - trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE); |
|
135 | - |
|
136 | - return; |
|
137 | - } |
|
138 | - } |
|
139 | - |
|
140 | - if (!isset($params[ 'width' ])) { |
|
141 | - $width = $_image_data[ 0 ]; |
|
142 | - } |
|
143 | - if (!isset($params[ 'height' ])) { |
|
144 | - $height = $_image_data[ 1 ]; |
|
145 | - } |
|
146 | - } |
|
147 | - |
|
148 | - if (isset($params[ 'dpi' ])) { |
|
149 | - if (strstr($_SERVER[ 'HTTP_USER_AGENT' ], 'Mac')) { |
|
150 | - $dpi_default = 72; |
|
151 | - } else { |
|
152 | - $dpi_default = 96; |
|
153 | - } |
|
154 | - $_resize = $dpi_default / $params[ 'dpi' ]; |
|
155 | - $width = round($width * $_resize); |
|
156 | - $height = round($height * $_resize); |
|
157 | - } |
|
158 | - |
|
159 | - return $prefix . '<img src="' . $path_prefix . $file . '" alt="' . $alt . '" width="' . $width . '" height="' . |
|
160 | - $height . '"' . $extra . ' />' . $suffix; |
|
41 | + require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); |
|
42 | + |
|
43 | + $alt = ''; |
|
44 | + $file = ''; |
|
45 | + $height = ''; |
|
46 | + $width = ''; |
|
47 | + $extra = ''; |
|
48 | + $prefix = ''; |
|
49 | + $suffix = ''; |
|
50 | + $path_prefix = ''; |
|
51 | + $basedir = isset($_SERVER[ 'DOCUMENT_ROOT' ]) ? $_SERVER[ 'DOCUMENT_ROOT' ] : ''; |
|
52 | + foreach ($params as $_key => $_val) { |
|
53 | + switch ($_key) { |
|
54 | + case 'file': |
|
55 | + case 'height': |
|
56 | + case 'width': |
|
57 | + case 'dpi': |
|
58 | + case 'path_prefix': |
|
59 | + case 'basedir': |
|
60 | + $$_key = $_val; |
|
61 | + break; |
|
62 | + |
|
63 | + case 'alt': |
|
64 | + if (!is_array($_val)) { |
|
65 | + $$_key = smarty_function_escape_special_chars($_val); |
|
66 | + } else { |
|
67 | + throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
|
68 | + } |
|
69 | + break; |
|
70 | + |
|
71 | + case 'link': |
|
72 | + case 'href': |
|
73 | + $prefix = '<a href="' . $_val . '">'; |
|
74 | + $suffix = '</a>'; |
|
75 | + break; |
|
76 | + |
|
77 | + default: |
|
78 | + if (!is_array($_val)) { |
|
79 | + $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; |
|
80 | + } else { |
|
81 | + throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
|
82 | + } |
|
83 | + break; |
|
84 | + } |
|
85 | + } |
|
86 | + |
|
87 | + if (empty($file)) { |
|
88 | + trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE); |
|
89 | + |
|
90 | + return; |
|
91 | + } |
|
92 | + |
|
93 | + if ($file[ 0 ] == '/') { |
|
94 | + $_image_path = $basedir . $file; |
|
95 | + } else { |
|
96 | + $_image_path = $file; |
|
97 | + } |
|
98 | + |
|
99 | + // strip file protocol |
|
100 | + if (stripos($params[ 'file' ], 'file://') === 0) { |
|
101 | + $params[ 'file' ] = substr($params[ 'file' ], 7); |
|
102 | + } |
|
103 | + |
|
104 | + $protocol = strpos($params[ 'file' ], '://'); |
|
105 | + if ($protocol !== false) { |
|
106 | + $protocol = strtolower(substr($params[ 'file' ], 0, $protocol)); |
|
107 | + } |
|
108 | + |
|
109 | + if (isset($template->smarty->security_policy)) { |
|
110 | + if ($protocol) { |
|
111 | + // remote resource (or php stream, …) |
|
112 | + if (!$template->smarty->security_policy->isTrustedUri($params[ 'file' ])) { |
|
113 | + return; |
|
114 | + } |
|
115 | + } else { |
|
116 | + // local file |
|
117 | + if (!$template->smarty->security_policy->isTrustedResourceDir($_image_path)) { |
|
118 | + return; |
|
119 | + } |
|
120 | + } |
|
121 | + } |
|
122 | + |
|
123 | + if (!isset($params[ 'width' ]) || !isset($params[ 'height' ])) { |
|
124 | + if (!$_image_data = @getimagesize($_image_path)) { |
|
125 | + if (!file_exists($_image_path)) { |
|
126 | + trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE); |
|
127 | + |
|
128 | + return; |
|
129 | + } elseif (!is_readable($_image_path)) { |
|
130 | + trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE); |
|
131 | + |
|
132 | + return; |
|
133 | + } else { |
|
134 | + trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE); |
|
135 | + |
|
136 | + return; |
|
137 | + } |
|
138 | + } |
|
139 | + |
|
140 | + if (!isset($params[ 'width' ])) { |
|
141 | + $width = $_image_data[ 0 ]; |
|
142 | + } |
|
143 | + if (!isset($params[ 'height' ])) { |
|
144 | + $height = $_image_data[ 1 ]; |
|
145 | + } |
|
146 | + } |
|
147 | + |
|
148 | + if (isset($params[ 'dpi' ])) { |
|
149 | + if (strstr($_SERVER[ 'HTTP_USER_AGENT' ], 'Mac')) { |
|
150 | + $dpi_default = 72; |
|
151 | + } else { |
|
152 | + $dpi_default = 96; |
|
153 | + } |
|
154 | + $_resize = $dpi_default / $params[ 'dpi' ]; |
|
155 | + $width = round($width * $_resize); |
|
156 | + $height = round($height * $_resize); |
|
157 | + } |
|
158 | + |
|
159 | + return $prefix . '<img src="' . $path_prefix . $file . '" alt="' . $alt . '" width="' . $width . '" height="' . |
|
160 | + $height . '"' . $extra . ' />' . $suffix; |
|
161 | 161 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $prefix = ''; |
49 | 49 | $suffix = ''; |
50 | 50 | $path_prefix = ''; |
51 | - $basedir = isset($_SERVER[ 'DOCUMENT_ROOT' ]) ? $_SERVER[ 'DOCUMENT_ROOT' ] : ''; |
|
51 | + $basedir = isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : ''; |
|
52 | 52 | foreach ($params as $_key => $_val) { |
53 | 53 | switch ($_key) { |
54 | 54 | case 'file': |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | if (!is_array($_val)) { |
65 | 65 | $$_key = smarty_function_escape_special_chars($_val); |
66 | 66 | } else { |
67 | - throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
|
67 | + throw new SmartyException("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
|
68 | 68 | } |
69 | 69 | break; |
70 | 70 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | if (!is_array($_val)) { |
79 | 79 | $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; |
80 | 80 | } else { |
81 | - throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
|
81 | + throw new SmartyException("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
|
82 | 82 | } |
83 | 83 | break; |
84 | 84 | } |
@@ -90,26 +90,26 @@ discard block |
||
90 | 90 | return; |
91 | 91 | } |
92 | 92 | |
93 | - if ($file[ 0 ] == '/') { |
|
93 | + if ($file[0] == '/') { |
|
94 | 94 | $_image_path = $basedir . $file; |
95 | 95 | } else { |
96 | 96 | $_image_path = $file; |
97 | 97 | } |
98 | 98 | |
99 | 99 | // strip file protocol |
100 | - if (stripos($params[ 'file' ], 'file://') === 0) { |
|
101 | - $params[ 'file' ] = substr($params[ 'file' ], 7); |
|
100 | + if (stripos($params['file'], 'file://') === 0) { |
|
101 | + $params['file'] = substr($params['file'], 7); |
|
102 | 102 | } |
103 | 103 | |
104 | - $protocol = strpos($params[ 'file' ], '://'); |
|
104 | + $protocol = strpos($params['file'], '://'); |
|
105 | 105 | if ($protocol !== false) { |
106 | - $protocol = strtolower(substr($params[ 'file' ], 0, $protocol)); |
|
106 | + $protocol = strtolower(substr($params['file'], 0, $protocol)); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | if (isset($template->smarty->security_policy)) { |
110 | 110 | if ($protocol) { |
111 | 111 | // remote resource (or php stream, …) |
112 | - if (!$template->smarty->security_policy->isTrustedUri($params[ 'file' ])) { |
|
112 | + if (!$template->smarty->security_policy->isTrustedUri($params['file'])) { |
|
113 | 113 | return; |
114 | 114 | } |
115 | 115 | } else { |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
123 | - if (!isset($params[ 'width' ]) || !isset($params[ 'height' ])) { |
|
123 | + if (!isset($params['width']) || !isset($params['height'])) { |
|
124 | 124 | if (!$_image_data = @getimagesize($_image_path)) { |
125 | 125 | if (!file_exists($_image_path)) { |
126 | 126 | trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE); |
@@ -137,21 +137,21 @@ discard block |
||
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
140 | - if (!isset($params[ 'width' ])) { |
|
141 | - $width = $_image_data[ 0 ]; |
|
140 | + if (!isset($params['width'])) { |
|
141 | + $width = $_image_data[0]; |
|
142 | 142 | } |
143 | - if (!isset($params[ 'height' ])) { |
|
144 | - $height = $_image_data[ 1 ]; |
|
143 | + if (!isset($params['height'])) { |
|
144 | + $height = $_image_data[1]; |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
148 | - if (isset($params[ 'dpi' ])) { |
|
149 | - if (strstr($_SERVER[ 'HTTP_USER_AGENT' ], 'Mac')) { |
|
148 | + if (isset($params['dpi'])) { |
|
149 | + if (strstr($_SERVER['HTTP_USER_AGENT'], 'Mac')) { |
|
150 | 150 | $dpi_default = 72; |
151 | 151 | } else { |
152 | 152 | $dpi_default = 96; |
153 | 153 | } |
154 | - $_resize = $dpi_default / $params[ 'dpi' ]; |
|
154 | + $_resize = $dpi_default / $params['dpi']; |
|
155 | 155 | $width = round($width * $_resize); |
156 | 156 | $height = round($height * $_resize); |
157 | 157 | } |
@@ -23,53 +23,53 @@ discard block |
||
23 | 23 | */ |
24 | 24 | function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = false) |
25 | 25 | { |
26 | - if (Smarty::$_MBSTRING) { |
|
27 | - if ($lc_rest) { |
|
28 | - // uppercase (including hyphenated words) |
|
29 | - $upper_string = mb_convert_case($string, MB_CASE_TITLE, Smarty::$_CHARSET); |
|
30 | - } else { |
|
31 | - // uppercase word breaks |
|
32 | - $upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, |
|
33 | - 'smarty_mod_cap_mbconvert_cb', $string); |
|
34 | - } |
|
35 | - // check uc_digits case |
|
36 | - if (!$uc_digits) { |
|
37 | - if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, |
|
38 | - PREG_OFFSET_CAPTURE)) { |
|
39 | - foreach ($matches[ 1 ] as $match) { |
|
40 | - $upper_string = |
|
41 | - substr_replace($upper_string, mb_strtolower($match[ 0 ], Smarty::$_CHARSET), $match[ 1 ], |
|
42 | - strlen($match[ 0 ])); |
|
43 | - } |
|
44 | - } |
|
45 | - } |
|
46 | - $upper_string = |
|
47 | - preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_mbconvert2_cb', |
|
48 | - $upper_string); |
|
49 | - return $upper_string; |
|
50 | - } |
|
26 | + if (Smarty::$_MBSTRING) { |
|
27 | + if ($lc_rest) { |
|
28 | + // uppercase (including hyphenated words) |
|
29 | + $upper_string = mb_convert_case($string, MB_CASE_TITLE, Smarty::$_CHARSET); |
|
30 | + } else { |
|
31 | + // uppercase word breaks |
|
32 | + $upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, |
|
33 | + 'smarty_mod_cap_mbconvert_cb', $string); |
|
34 | + } |
|
35 | + // check uc_digits case |
|
36 | + if (!$uc_digits) { |
|
37 | + if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, |
|
38 | + PREG_OFFSET_CAPTURE)) { |
|
39 | + foreach ($matches[ 1 ] as $match) { |
|
40 | + $upper_string = |
|
41 | + substr_replace($upper_string, mb_strtolower($match[ 0 ], Smarty::$_CHARSET), $match[ 1 ], |
|
42 | + strlen($match[ 0 ])); |
|
43 | + } |
|
44 | + } |
|
45 | + } |
|
46 | + $upper_string = |
|
47 | + preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_mbconvert2_cb', |
|
48 | + $upper_string); |
|
49 | + return $upper_string; |
|
50 | + } |
|
51 | 51 | |
52 | - // lowercase first |
|
53 | - if ($lc_rest) { |
|
54 | - $string = strtolower($string); |
|
55 | - } |
|
56 | - // uppercase (including hyphenated words) |
|
57 | - $upper_string = |
|
58 | - preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst_cb', |
|
59 | - $string); |
|
60 | - // check uc_digits case |
|
61 | - if (!$uc_digits) { |
|
62 | - if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, |
|
63 | - PREG_OFFSET_CAPTURE)) { |
|
64 | - foreach ($matches[ 1 ] as $match) { |
|
65 | - $upper_string = |
|
66 | - substr_replace($upper_string, strtolower($match[ 0 ]), $match[ 1 ], strlen($match[ 0 ])); |
|
67 | - } |
|
68 | - } |
|
69 | - } |
|
70 | - $upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst2_cb', |
|
71 | - $upper_string); |
|
72 | - return $upper_string; |
|
52 | + // lowercase first |
|
53 | + if ($lc_rest) { |
|
54 | + $string = strtolower($string); |
|
55 | + } |
|
56 | + // uppercase (including hyphenated words) |
|
57 | + $upper_string = |
|
58 | + preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst_cb', |
|
59 | + $string); |
|
60 | + // check uc_digits case |
|
61 | + if (!$uc_digits) { |
|
62 | + if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, |
|
63 | + PREG_OFFSET_CAPTURE)) { |
|
64 | + foreach ($matches[ 1 ] as $match) { |
|
65 | + $upper_string = |
|
66 | + substr_replace($upper_string, strtolower($match[ 0 ]), $match[ 1 ], strlen($match[ 0 ])); |
|
67 | + } |
|
68 | + } |
|
69 | + } |
|
70 | + $upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst2_cb', |
|
71 | + $upper_string); |
|
72 | + return $upper_string; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /* |
@@ -82,20 +82,20 @@ discard block |
||
82 | 82 | */ |
83 | 83 | function smarty_mod_cap_mbconvert_cb($matches) |
84 | 84 | { |
85 | - return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 2 ]), MB_CASE_UPPER, Smarty::$_CHARSET); |
|
85 | + return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 2 ]), MB_CASE_UPPER, Smarty::$_CHARSET); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | function smarty_mod_cap_mbconvert2_cb($matches) |
89 | 89 | { |
90 | - return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 3 ]), MB_CASE_UPPER, Smarty::$_CHARSET); |
|
90 | + return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 3 ]), MB_CASE_UPPER, Smarty::$_CHARSET); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | function smarty_mod_cap_ucfirst_cb($matches) |
94 | 94 | { |
95 | - return stripslashes($matches[ 1 ]) . ucfirst(stripslashes($matches[ 2 ])); |
|
95 | + return stripslashes($matches[ 1 ]) . ucfirst(stripslashes($matches[ 2 ])); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | function smarty_mod_cap_ucfirst2_cb($matches) |
99 | 99 | { |
100 | - return stripslashes($matches[ 1 ]) . ucfirst(stripslashes($matches[ 3 ])); |
|
100 | + return stripslashes($matches[ 1 ]) . ucfirst(stripslashes($matches[ 3 ])); |
|
101 | 101 | } |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | if (!$uc_digits) { |
37 | 37 | if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, |
38 | 38 | PREG_OFFSET_CAPTURE)) { |
39 | - foreach ($matches[ 1 ] as $match) { |
|
39 | + foreach ($matches[1] as $match) { |
|
40 | 40 | $upper_string = |
41 | - substr_replace($upper_string, mb_strtolower($match[ 0 ], Smarty::$_CHARSET), $match[ 1 ], |
|
42 | - strlen($match[ 0 ])); |
|
41 | + substr_replace($upper_string, mb_strtolower($match[0], Smarty::$_CHARSET), $match[1], |
|
42 | + strlen($match[0])); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | if (!$uc_digits) { |
62 | 62 | if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, |
63 | 63 | PREG_OFFSET_CAPTURE)) { |
64 | - foreach ($matches[ 1 ] as $match) { |
|
64 | + foreach ($matches[1] as $match) { |
|
65 | 65 | $upper_string = |
66 | - substr_replace($upper_string, strtolower($match[ 0 ]), $match[ 1 ], strlen($match[ 0 ])); |
|
66 | + substr_replace($upper_string, strtolower($match[0]), $match[1], strlen($match[0])); |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | } |
@@ -82,20 +82,20 @@ discard block |
||
82 | 82 | */ |
83 | 83 | function smarty_mod_cap_mbconvert_cb($matches) |
84 | 84 | { |
85 | - return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 2 ]), MB_CASE_UPPER, Smarty::$_CHARSET); |
|
85 | + return stripslashes($matches[1]) . mb_convert_case(stripslashes($matches[2]), MB_CASE_UPPER, Smarty::$_CHARSET); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | function smarty_mod_cap_mbconvert2_cb($matches) |
89 | 89 | { |
90 | - return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 3 ]), MB_CASE_UPPER, Smarty::$_CHARSET); |
|
90 | + return stripslashes($matches[1]) . mb_convert_case(stripslashes($matches[3]), MB_CASE_UPPER, Smarty::$_CHARSET); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | function smarty_mod_cap_ucfirst_cb($matches) |
94 | 94 | { |
95 | - return stripslashes($matches[ 1 ]) . ucfirst(stripslashes($matches[ 2 ])); |
|
95 | + return stripslashes($matches[1]) . ucfirst(stripslashes($matches[2])); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | function smarty_mod_cap_ucfirst2_cb($matches) |
99 | 99 | { |
100 | - return stripslashes($matches[ 1 ]) . ucfirst(stripslashes($matches[ 3 ])); |
|
100 | + return stripslashes($matches[1]) . ucfirst(stripslashes($matches[3])); |
|
101 | 101 | } |
@@ -21,12 +21,12 @@ |
||
21 | 21 | */ |
22 | 22 | function smarty_modifiercompiler_count_characters($params) |
23 | 23 | { |
24 | - if (!isset($params[ 1 ]) || $params[ 1 ] != 'true') { |
|
25 | - return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[ 0 ] . ', $tmp)'; |
|
26 | - } |
|
27 | - if (Smarty::$_MBSTRING) { |
|
28 | - return 'mb_strlen(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; |
|
29 | - } |
|
30 | - // no MBString fallback |
|
31 | - return 'strlen(' . $params[ 0 ] . ')'; |
|
24 | + if (!isset($params[ 1 ]) || $params[ 1 ] != 'true') { |
|
25 | + return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[ 0 ] . ', $tmp)'; |
|
26 | + } |
|
27 | + if (Smarty::$_MBSTRING) { |
|
28 | + return 'mb_strlen(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; |
|
29 | + } |
|
30 | + // no MBString fallback |
|
31 | + return 'strlen(' . $params[ 0 ] . ')'; |
|
32 | 32 | } |
@@ -21,12 +21,12 @@ |
||
21 | 21 | */ |
22 | 22 | function smarty_modifiercompiler_count_characters($params) |
23 | 23 | { |
24 | - if (!isset($params[ 1 ]) || $params[ 1 ] != 'true') { |
|
25 | - return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[ 0 ] . ', $tmp)'; |
|
24 | + if (!isset($params[1]) || $params[1] != 'true') { |
|
25 | + return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[0] . ', $tmp)'; |
|
26 | 26 | } |
27 | 27 | if (Smarty::$_MBSTRING) { |
28 | - return 'mb_strlen(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; |
|
28 | + return 'mb_strlen(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; |
|
29 | 29 | } |
30 | 30 | // no MBString fallback |
31 | - return 'strlen(' . $params[ 0 ] . ')'; |
|
31 | + return 'strlen(' . $params[0] . ')'; |
|
32 | 32 | } |
@@ -50,103 +50,103 @@ |
||
50 | 50 | */ |
51 | 51 | function smarty_function_mailto($params) |
52 | 52 | { |
53 | - static $_allowed_encoding = |
|
54 | - array('javascript' => true, 'javascript_charcode' => true, 'hex' => true, 'none' => true); |
|
55 | - $extra = ''; |
|
56 | - |
|
57 | - if (empty($params[ 'address' ])) { |
|
58 | - trigger_error("mailto: missing 'address' parameter", E_USER_WARNING); |
|
59 | - |
|
60 | - return; |
|
61 | - } else { |
|
62 | - $address = $params[ 'address' ]; |
|
63 | - } |
|
64 | - |
|
65 | - $text = $address; |
|
66 | - // netscape and mozilla do not decode %40 (@) in BCC field (bug?) |
|
67 | - // so, don't encode it. |
|
68 | - $search = array('%40', '%2C'); |
|
69 | - $replace = array('@', ','); |
|
70 | - $mail_parms = array(); |
|
71 | - foreach ($params as $var => $value) { |
|
72 | - switch ($var) { |
|
73 | - case 'cc': |
|
74 | - case 'bcc': |
|
75 | - case 'followupto': |
|
76 | - if (!empty($value)) { |
|
77 | - $mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value)); |
|
78 | - } |
|
79 | - break; |
|
80 | - |
|
81 | - case 'subject': |
|
82 | - case 'newsgroups': |
|
83 | - $mail_parms[] = $var . '=' . rawurlencode($value); |
|
84 | - break; |
|
85 | - |
|
86 | - case 'extra': |
|
87 | - case 'text': |
|
88 | - $$var = $value; |
|
89 | - |
|
90 | - default: |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - if ($mail_parms) { |
|
95 | - $address .= '?' . join('&', $mail_parms); |
|
96 | - } |
|
97 | - |
|
98 | - $encode = (empty($params[ 'encode' ])) ? 'none' : $params[ 'encode' ]; |
|
99 | - if (!isset($_allowed_encoding[ $encode ])) { |
|
100 | - trigger_error("mailto: 'encode' parameter must be none, javascript, javascript_charcode or hex", |
|
101 | - E_USER_WARNING); |
|
102 | - |
|
103 | - return; |
|
104 | - } |
|
105 | - if ($encode == 'javascript') { |
|
106 | - $string = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');'; |
|
107 | - |
|
108 | - $js_encode = ''; |
|
109 | - for ($x = 0, $_length = strlen($string); $x < $_length; $x ++) { |
|
110 | - $js_encode .= '%' . bin2hex($string[ $x ]); |
|
111 | - } |
|
112 | - |
|
113 | - return '<script type="text/javascript">eval(unescape(\'' . $js_encode . '\'))</script>'; |
|
114 | - } elseif ($encode == 'javascript_charcode') { |
|
115 | - $string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>'; |
|
116 | - |
|
117 | - for ($x = 0, $y = strlen($string); $x < $y; $x ++) { |
|
118 | - $ord[] = ord($string[ $x ]); |
|
119 | - } |
|
120 | - |
|
121 | - $_ret = "<script type=\"text/javascript\" language=\"javascript\">\n" . "{document.write(String.fromCharCode(" . |
|
122 | - implode(',', $ord) . "))" . "}\n" . "</script>\n"; |
|
123 | - |
|
124 | - return $_ret; |
|
125 | - } elseif ($encode == 'hex') { |
|
126 | - preg_match('!^(.*)(\?.*)$!', $address, $match); |
|
127 | - if (!empty($match[ 2 ])) { |
|
128 | - trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.", E_USER_WARNING); |
|
129 | - |
|
130 | - return; |
|
131 | - } |
|
132 | - $address_encode = ''; |
|
133 | - for ($x = 0, $_length = strlen($address); $x < $_length; $x ++) { |
|
134 | - if (preg_match('!\w!' . Smarty::$_UTF8_MODIFIER, $address[ $x ])) { |
|
135 | - $address_encode .= '%' . bin2hex($address[ $x ]); |
|
136 | - } else { |
|
137 | - $address_encode .= $address[ $x ]; |
|
138 | - } |
|
139 | - } |
|
140 | - $text_encode = ''; |
|
141 | - for ($x = 0, $_length = strlen($text); $x < $_length; $x ++) { |
|
142 | - $text_encode .= '&#x' . bin2hex($text[ $x ]) . ';'; |
|
143 | - } |
|
144 | - |
|
145 | - $mailto = "mailto:"; |
|
146 | - |
|
147 | - return '<a href="' . $mailto . $address_encode . '" ' . $extra . '>' . $text_encode . '</a>'; |
|
148 | - } else { |
|
149 | - // no encoding |
|
150 | - return '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>'; |
|
151 | - } |
|
53 | + static $_allowed_encoding = |
|
54 | + array('javascript' => true, 'javascript_charcode' => true, 'hex' => true, 'none' => true); |
|
55 | + $extra = ''; |
|
56 | + |
|
57 | + if (empty($params[ 'address' ])) { |
|
58 | + trigger_error("mailto: missing 'address' parameter", E_USER_WARNING); |
|
59 | + |
|
60 | + return; |
|
61 | + } else { |
|
62 | + $address = $params[ 'address' ]; |
|
63 | + } |
|
64 | + |
|
65 | + $text = $address; |
|
66 | + // netscape and mozilla do not decode %40 (@) in BCC field (bug?) |
|
67 | + // so, don't encode it. |
|
68 | + $search = array('%40', '%2C'); |
|
69 | + $replace = array('@', ','); |
|
70 | + $mail_parms = array(); |
|
71 | + foreach ($params as $var => $value) { |
|
72 | + switch ($var) { |
|
73 | + case 'cc': |
|
74 | + case 'bcc': |
|
75 | + case 'followupto': |
|
76 | + if (!empty($value)) { |
|
77 | + $mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value)); |
|
78 | + } |
|
79 | + break; |
|
80 | + |
|
81 | + case 'subject': |
|
82 | + case 'newsgroups': |
|
83 | + $mail_parms[] = $var . '=' . rawurlencode($value); |
|
84 | + break; |
|
85 | + |
|
86 | + case 'extra': |
|
87 | + case 'text': |
|
88 | + $$var = $value; |
|
89 | + |
|
90 | + default: |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + if ($mail_parms) { |
|
95 | + $address .= '?' . join('&', $mail_parms); |
|
96 | + } |
|
97 | + |
|
98 | + $encode = (empty($params[ 'encode' ])) ? 'none' : $params[ 'encode' ]; |
|
99 | + if (!isset($_allowed_encoding[ $encode ])) { |
|
100 | + trigger_error("mailto: 'encode' parameter must be none, javascript, javascript_charcode or hex", |
|
101 | + E_USER_WARNING); |
|
102 | + |
|
103 | + return; |
|
104 | + } |
|
105 | + if ($encode == 'javascript') { |
|
106 | + $string = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');'; |
|
107 | + |
|
108 | + $js_encode = ''; |
|
109 | + for ($x = 0, $_length = strlen($string); $x < $_length; $x ++) { |
|
110 | + $js_encode .= '%' . bin2hex($string[ $x ]); |
|
111 | + } |
|
112 | + |
|
113 | + return '<script type="text/javascript">eval(unescape(\'' . $js_encode . '\'))</script>'; |
|
114 | + } elseif ($encode == 'javascript_charcode') { |
|
115 | + $string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>'; |
|
116 | + |
|
117 | + for ($x = 0, $y = strlen($string); $x < $y; $x ++) { |
|
118 | + $ord[] = ord($string[ $x ]); |
|
119 | + } |
|
120 | + |
|
121 | + $_ret = "<script type=\"text/javascript\" language=\"javascript\">\n" . "{document.write(String.fromCharCode(" . |
|
122 | + implode(',', $ord) . "))" . "}\n" . "</script>\n"; |
|
123 | + |
|
124 | + return $_ret; |
|
125 | + } elseif ($encode == 'hex') { |
|
126 | + preg_match('!^(.*)(\?.*)$!', $address, $match); |
|
127 | + if (!empty($match[ 2 ])) { |
|
128 | + trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.", E_USER_WARNING); |
|
129 | + |
|
130 | + return; |
|
131 | + } |
|
132 | + $address_encode = ''; |
|
133 | + for ($x = 0, $_length = strlen($address); $x < $_length; $x ++) { |
|
134 | + if (preg_match('!\w!' . Smarty::$_UTF8_MODIFIER, $address[ $x ])) { |
|
135 | + $address_encode .= '%' . bin2hex($address[ $x ]); |
|
136 | + } else { |
|
137 | + $address_encode .= $address[ $x ]; |
|
138 | + } |
|
139 | + } |
|
140 | + $text_encode = ''; |
|
141 | + for ($x = 0, $_length = strlen($text); $x < $_length; $x ++) { |
|
142 | + $text_encode .= '&#x' . bin2hex($text[ $x ]) . ';'; |
|
143 | + } |
|
144 | + |
|
145 | + $mailto = "mailto:"; |
|
146 | + |
|
147 | + return '<a href="' . $mailto . $address_encode . '" ' . $extra . '>' . $text_encode . '</a>'; |
|
148 | + } else { |
|
149 | + // no encoding |
|
150 | + return '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>'; |
|
151 | + } |
|
152 | 152 | } |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | array('javascript' => true, 'javascript_charcode' => true, 'hex' => true, 'none' => true); |
55 | 55 | $extra = ''; |
56 | 56 | |
57 | - if (empty($params[ 'address' ])) { |
|
57 | + if (empty($params['address'])) { |
|
58 | 58 | trigger_error("mailto: missing 'address' parameter", E_USER_WARNING); |
59 | 59 | |
60 | 60 | return; |
61 | 61 | } else { |
62 | - $address = $params[ 'address' ]; |
|
62 | + $address = $params['address']; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | $text = $address; |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | $address .= '?' . join('&', $mail_parms); |
96 | 96 | } |
97 | 97 | |
98 | - $encode = (empty($params[ 'encode' ])) ? 'none' : $params[ 'encode' ]; |
|
99 | - if (!isset($_allowed_encoding[ $encode ])) { |
|
98 | + $encode = (empty($params['encode'])) ? 'none' : $params['encode']; |
|
99 | + if (!isset($_allowed_encoding[$encode])) { |
|
100 | 100 | trigger_error("mailto: 'encode' parameter must be none, javascript, javascript_charcode or hex", |
101 | 101 | E_USER_WARNING); |
102 | 102 | |
@@ -106,16 +106,16 @@ discard block |
||
106 | 106 | $string = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');'; |
107 | 107 | |
108 | 108 | $js_encode = ''; |
109 | - for ($x = 0, $_length = strlen($string); $x < $_length; $x ++) { |
|
110 | - $js_encode .= '%' . bin2hex($string[ $x ]); |
|
109 | + for ($x = 0, $_length = strlen($string); $x < $_length; $x++) { |
|
110 | + $js_encode .= '%' . bin2hex($string[$x]); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | return '<script type="text/javascript">eval(unescape(\'' . $js_encode . '\'))</script>'; |
114 | 114 | } elseif ($encode == 'javascript_charcode') { |
115 | 115 | $string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>'; |
116 | 116 | |
117 | - for ($x = 0, $y = strlen($string); $x < $y; $x ++) { |
|
118 | - $ord[] = ord($string[ $x ]); |
|
117 | + for ($x = 0, $y = strlen($string); $x < $y; $x++) { |
|
118 | + $ord[] = ord($string[$x]); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | $_ret = "<script type=\"text/javascript\" language=\"javascript\">\n" . "{document.write(String.fromCharCode(" . |
@@ -124,22 +124,22 @@ discard block |
||
124 | 124 | return $_ret; |
125 | 125 | } elseif ($encode == 'hex') { |
126 | 126 | preg_match('!^(.*)(\?.*)$!', $address, $match); |
127 | - if (!empty($match[ 2 ])) { |
|
127 | + if (!empty($match[2])) { |
|
128 | 128 | trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.", E_USER_WARNING); |
129 | 129 | |
130 | 130 | return; |
131 | 131 | } |
132 | 132 | $address_encode = ''; |
133 | - for ($x = 0, $_length = strlen($address); $x < $_length; $x ++) { |
|
134 | - if (preg_match('!\w!' . Smarty::$_UTF8_MODIFIER, $address[ $x ])) { |
|
135 | - $address_encode .= '%' . bin2hex($address[ $x ]); |
|
133 | + for ($x = 0, $_length = strlen($address); $x < $_length; $x++) { |
|
134 | + if (preg_match('!\w!' . Smarty::$_UTF8_MODIFIER, $address[$x])) { |
|
135 | + $address_encode .= '%' . bin2hex($address[$x]); |
|
136 | 136 | } else { |
137 | - $address_encode .= $address[ $x ]; |
|
137 | + $address_encode .= $address[$x]; |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | $text_encode = ''; |
141 | - for ($x = 0, $_length = strlen($text); $x < $_length; $x ++) { |
|
142 | - $text_encode .= '&#x' . bin2hex($text[ $x ]) . ';'; |
|
141 | + for ($x = 0, $_length = strlen($text); $x < $_length; $x++) { |
|
142 | + $text_encode .= '&#x' . bin2hex($text[$x]) . ';'; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | $mailto = "mailto:"; |
@@ -23,9 +23,9 @@ |
||
23 | 23 | |
24 | 24 | function smarty_modifiercompiler_lower($params) |
25 | 25 | { |
26 | - if (Smarty::$_MBSTRING) { |
|
27 | - return 'mb_strtolower(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; |
|
28 | - } |
|
29 | - // no MBString fallback |
|
30 | - return 'strtolower(' . $params[ 0 ] . ')'; |
|
26 | + if (Smarty::$_MBSTRING) { |
|
27 | + return 'mb_strtolower(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; |
|
28 | + } |
|
29 | + // no MBString fallback |
|
30 | + return 'strtolower(' . $params[ 0 ] . ')'; |
|
31 | 31 | } |
@@ -24,8 +24,8 @@ |
||
24 | 24 | function smarty_modifiercompiler_lower($params) |
25 | 25 | { |
26 | 26 | if (Smarty::$_MBSTRING) { |
27 | - return 'mb_strtolower(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; |
|
27 | + return 'mb_strtolower(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; |
|
28 | 28 | } |
29 | 29 | // no MBString fallback |
30 | - return 'strtolower(' . $params[ 0 ] . ')'; |
|
30 | + return 'strtolower(' . $params[0] . ')'; |
|
31 | 31 | } |
@@ -21,5 +21,5 @@ |
||
21 | 21 | */ |
22 | 22 | function smarty_modifiercompiler_string_format($params) |
23 | 23 | { |
24 | - return 'sprintf(' . $params[ 1 ] . ',' . $params[ 0 ] . ')'; |
|
24 | + return 'sprintf(' . $params[ 1 ] . ',' . $params[ 0 ] . ')'; |
|
25 | 25 | } |
@@ -21,5 +21,5 @@ |
||
21 | 21 | */ |
22 | 22 | function smarty_modifiercompiler_string_format($params) |
23 | 23 | { |
24 | - return 'sprintf(' . $params[ 1 ] . ',' . $params[ 0 ] . ')'; |
|
24 | + return 'sprintf(' . $params[1] . ',' . $params[0] . ')'; |
|
25 | 25 | } |
@@ -22,12 +22,12 @@ |
||
22 | 22 | |
23 | 23 | function smarty_modifiercompiler_indent($params) |
24 | 24 | { |
25 | - if (!isset($params[ 1 ])) { |
|
26 | - $params[ 1 ] = 4; |
|
27 | - } |
|
28 | - if (!isset($params[ 2 ])) { |
|
29 | - $params[ 2 ] = "' '"; |
|
30 | - } |
|
25 | + if (!isset($params[ 1 ])) { |
|
26 | + $params[ 1 ] = 4; |
|
27 | + } |
|
28 | + if (!isset($params[ 2 ])) { |
|
29 | + $params[ 2 ] = "' '"; |
|
30 | + } |
|
31 | 31 | |
32 | - return 'preg_replace(\'!^!m\',str_repeat(' . $params[ 2 ] . ',' . $params[ 1 ] . '),' . $params[ 0 ] . ')'; |
|
32 | + return 'preg_replace(\'!^!m\',str_repeat(' . $params[ 2 ] . ',' . $params[ 1 ] . '),' . $params[ 0 ] . ')'; |
|
33 | 33 | } |
@@ -22,12 +22,12 @@ |
||
22 | 22 | |
23 | 23 | function smarty_modifiercompiler_indent($params) |
24 | 24 | { |
25 | - if (!isset($params[ 1 ])) { |
|
26 | - $params[ 1 ] = 4; |
|
25 | + if (!isset($params[1])) { |
|
26 | + $params[1] = 4; |
|
27 | 27 | } |
28 | - if (!isset($params[ 2 ])) { |
|
29 | - $params[ 2 ] = "' '"; |
|
28 | + if (!isset($params[2])) { |
|
29 | + $params[2] = "' '"; |
|
30 | 30 | } |
31 | 31 | |
32 | - return 'preg_replace(\'!^!m\',str_repeat(' . $params[ 2 ] . ',' . $params[ 1 ] . '),' . $params[ 0 ] . ')'; |
|
32 | + return 'preg_replace(\'!^!m\',str_repeat(' . $params[2] . ',' . $params[1] . '),' . $params[0] . ')'; |
|
33 | 33 | } |
@@ -23,51 +23,51 @@ |
||
23 | 23 | */ |
24 | 24 | function smarty_function_counter($params, $template) |
25 | 25 | { |
26 | - static $counters = array(); |
|
26 | + static $counters = array(); |
|
27 | 27 | |
28 | - $name = (isset($params[ 'name' ])) ? $params[ 'name' ] : 'default'; |
|
29 | - if (!isset($counters[ $name ])) { |
|
30 | - $counters[ $name ] = array('start' => 1, 'skip' => 1, 'direction' => 'up', 'count' => 1); |
|
31 | - } |
|
32 | - $counter =& $counters[ $name ]; |
|
28 | + $name = (isset($params[ 'name' ])) ? $params[ 'name' ] : 'default'; |
|
29 | + if (!isset($counters[ $name ])) { |
|
30 | + $counters[ $name ] = array('start' => 1, 'skip' => 1, 'direction' => 'up', 'count' => 1); |
|
31 | + } |
|
32 | + $counter =& $counters[ $name ]; |
|
33 | 33 | |
34 | - if (isset($params[ 'start' ])) { |
|
35 | - $counter[ 'start' ] = $counter[ 'count' ] = (int) $params[ 'start' ]; |
|
36 | - } |
|
34 | + if (isset($params[ 'start' ])) { |
|
35 | + $counter[ 'start' ] = $counter[ 'count' ] = (int) $params[ 'start' ]; |
|
36 | + } |
|
37 | 37 | |
38 | - if (!empty($params[ 'assign' ])) { |
|
39 | - $counter[ 'assign' ] = $params[ 'assign' ]; |
|
40 | - } |
|
38 | + if (!empty($params[ 'assign' ])) { |
|
39 | + $counter[ 'assign' ] = $params[ 'assign' ]; |
|
40 | + } |
|
41 | 41 | |
42 | - if (isset($counter[ 'assign' ])) { |
|
43 | - $template->assign($counter[ 'assign' ], $counter[ 'count' ]); |
|
44 | - } |
|
42 | + if (isset($counter[ 'assign' ])) { |
|
43 | + $template->assign($counter[ 'assign' ], $counter[ 'count' ]); |
|
44 | + } |
|
45 | 45 | |
46 | - if (isset($params[ 'print' ])) { |
|
47 | - $print = (bool) $params[ 'print' ]; |
|
48 | - } else { |
|
49 | - $print = empty($counter[ 'assign' ]); |
|
50 | - } |
|
46 | + if (isset($params[ 'print' ])) { |
|
47 | + $print = (bool) $params[ 'print' ]; |
|
48 | + } else { |
|
49 | + $print = empty($counter[ 'assign' ]); |
|
50 | + } |
|
51 | 51 | |
52 | - if ($print) { |
|
53 | - $retval = $counter[ 'count' ]; |
|
54 | - } else { |
|
55 | - $retval = null; |
|
56 | - } |
|
52 | + if ($print) { |
|
53 | + $retval = $counter[ 'count' ]; |
|
54 | + } else { |
|
55 | + $retval = null; |
|
56 | + } |
|
57 | 57 | |
58 | - if (isset($params[ 'skip' ])) { |
|
59 | - $counter[ 'skip' ] = $params[ 'skip' ]; |
|
60 | - } |
|
58 | + if (isset($params[ 'skip' ])) { |
|
59 | + $counter[ 'skip' ] = $params[ 'skip' ]; |
|
60 | + } |
|
61 | 61 | |
62 | - if (isset($params[ 'direction' ])) { |
|
63 | - $counter[ 'direction' ] = $params[ 'direction' ]; |
|
64 | - } |
|
62 | + if (isset($params[ 'direction' ])) { |
|
63 | + $counter[ 'direction' ] = $params[ 'direction' ]; |
|
64 | + } |
|
65 | 65 | |
66 | - if ($counter[ 'direction' ] == "down") { |
|
67 | - $counter[ 'count' ] -= $counter[ 'skip' ]; |
|
68 | - } else { |
|
69 | - $counter[ 'count' ] += $counter[ 'skip' ]; |
|
70 | - } |
|
66 | + if ($counter[ 'direction' ] == "down") { |
|
67 | + $counter[ 'count' ] -= $counter[ 'skip' ]; |
|
68 | + } else { |
|
69 | + $counter[ 'count' ] += $counter[ 'skip' ]; |
|
70 | + } |
|
71 | 71 | |
72 | - return $retval; |
|
72 | + return $retval; |
|
73 | 73 | } |
@@ -25,48 +25,48 @@ |
||
25 | 25 | { |
26 | 26 | static $counters = array(); |
27 | 27 | |
28 | - $name = (isset($params[ 'name' ])) ? $params[ 'name' ] : 'default'; |
|
29 | - if (!isset($counters[ $name ])) { |
|
30 | - $counters[ $name ] = array('start' => 1, 'skip' => 1, 'direction' => 'up', 'count' => 1); |
|
28 | + $name = (isset($params['name'])) ? $params['name'] : 'default'; |
|
29 | + if (!isset($counters[$name])) { |
|
30 | + $counters[$name] = array('start' => 1, 'skip' => 1, 'direction' => 'up', 'count' => 1); |
|
31 | 31 | } |
32 | - $counter =& $counters[ $name ]; |
|
32 | + $counter = & $counters[$name]; |
|
33 | 33 | |
34 | - if (isset($params[ 'start' ])) { |
|
35 | - $counter[ 'start' ] = $counter[ 'count' ] = (int) $params[ 'start' ]; |
|
34 | + if (isset($params['start'])) { |
|
35 | + $counter['start'] = $counter['count'] = (int) $params['start']; |
|
36 | 36 | } |
37 | 37 | |
38 | - if (!empty($params[ 'assign' ])) { |
|
39 | - $counter[ 'assign' ] = $params[ 'assign' ]; |
|
38 | + if (!empty($params['assign'])) { |
|
39 | + $counter['assign'] = $params['assign']; |
|
40 | 40 | } |
41 | 41 | |
42 | - if (isset($counter[ 'assign' ])) { |
|
43 | - $template->assign($counter[ 'assign' ], $counter[ 'count' ]); |
|
42 | + if (isset($counter['assign'])) { |
|
43 | + $template->assign($counter['assign'], $counter['count']); |
|
44 | 44 | } |
45 | 45 | |
46 | - if (isset($params[ 'print' ])) { |
|
47 | - $print = (bool) $params[ 'print' ]; |
|
46 | + if (isset($params['print'])) { |
|
47 | + $print = (bool) $params['print']; |
|
48 | 48 | } else { |
49 | - $print = empty($counter[ 'assign' ]); |
|
49 | + $print = empty($counter['assign']); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | if ($print) { |
53 | - $retval = $counter[ 'count' ]; |
|
53 | + $retval = $counter['count']; |
|
54 | 54 | } else { |
55 | 55 | $retval = null; |
56 | 56 | } |
57 | 57 | |
58 | - if (isset($params[ 'skip' ])) { |
|
59 | - $counter[ 'skip' ] = $params[ 'skip' ]; |
|
58 | + if (isset($params['skip'])) { |
|
59 | + $counter['skip'] = $params['skip']; |
|
60 | 60 | } |
61 | 61 | |
62 | - if (isset($params[ 'direction' ])) { |
|
63 | - $counter[ 'direction' ] = $params[ 'direction' ]; |
|
62 | + if (isset($params['direction'])) { |
|
63 | + $counter['direction'] = $params['direction']; |
|
64 | 64 | } |
65 | 65 | |
66 | - if ($counter[ 'direction' ] == "down") { |
|
67 | - $counter[ 'count' ] -= $counter[ 'skip' ]; |
|
66 | + if ($counter['direction'] == "down") { |
|
67 | + $counter['count'] -= $counter['skip']; |
|
68 | 68 | } else { |
69 | - $counter[ 'count' ] += $counter[ 'skip' ]; |
|
69 | + $counter['count'] += $counter['skip']; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | return $retval; |
@@ -25,5 +25,5 @@ |
||
25 | 25 | */ |
26 | 26 | function smarty_modifiercompiler_cat($params) |
27 | 27 | { |
28 | - return '(' . implode(').(', $params) . ')'; |
|
28 | + return '(' . implode(').(', $params) . ')'; |
|
29 | 29 | } |