@@ -7,49 +7,49 @@ |
||
7 | 7 | */ |
8 | 8 | if (!function_exists('smarty_mb_str_replace')) { |
9 | 9 | |
10 | - /** |
|
11 | - * Multibyte string replace |
|
12 | - * |
|
13 | - * @param string $search the string to be searched |
|
14 | - * @param string $replace the replacement string |
|
15 | - * @param string $subject the source string |
|
16 | - * @param int &$count number of matches found |
|
17 | - * |
|
18 | - * @return string replaced string |
|
19 | - * @author Rodney Rehm |
|
20 | - */ |
|
21 | - function smarty_mb_str_replace($search, $replace, $subject, &$count = 0) |
|
22 | - { |
|
23 | - if (!is_array($search) && is_array($replace)) { |
|
24 | - return false; |
|
25 | - } |
|
26 | - if (is_array($subject)) { |
|
27 | - // call mb_replace for each single string in $subject |
|
28 | - foreach ($subject as &$string) { |
|
29 | - $string = smarty_mb_str_replace($search, $replace, $string, $c); |
|
30 | - $count += $c; |
|
31 | - } |
|
32 | - } elseif (is_array($search)) { |
|
33 | - if (!is_array($replace)) { |
|
34 | - foreach ($search as &$string) { |
|
35 | - $subject = smarty_mb_str_replace($string, $replace, $subject, $c); |
|
36 | - $count += $c; |
|
37 | - } |
|
38 | - } else { |
|
39 | - $n = max(count($search), count($replace)); |
|
40 | - while ($n --) { |
|
41 | - $subject = smarty_mb_str_replace(current($search), current($replace), $subject, $c); |
|
42 | - $count += $c; |
|
43 | - next($search); |
|
44 | - next($replace); |
|
45 | - } |
|
46 | - } |
|
47 | - } else { |
|
48 | - $parts = mb_split(preg_quote($search), $subject); |
|
49 | - $count = count($parts) - 1; |
|
50 | - $subject = implode($replace, $parts); |
|
51 | - } |
|
10 | + /** |
|
11 | + * Multibyte string replace |
|
12 | + * |
|
13 | + * @param string $search the string to be searched |
|
14 | + * @param string $replace the replacement string |
|
15 | + * @param string $subject the source string |
|
16 | + * @param int &$count number of matches found |
|
17 | + * |
|
18 | + * @return string replaced string |
|
19 | + * @author Rodney Rehm |
|
20 | + */ |
|
21 | + function smarty_mb_str_replace($search, $replace, $subject, &$count = 0) |
|
22 | + { |
|
23 | + if (!is_array($search) && is_array($replace)) { |
|
24 | + return false; |
|
25 | + } |
|
26 | + if (is_array($subject)) { |
|
27 | + // call mb_replace for each single string in $subject |
|
28 | + foreach ($subject as &$string) { |
|
29 | + $string = smarty_mb_str_replace($search, $replace, $string, $c); |
|
30 | + $count += $c; |
|
31 | + } |
|
32 | + } elseif (is_array($search)) { |
|
33 | + if (!is_array($replace)) { |
|
34 | + foreach ($search as &$string) { |
|
35 | + $subject = smarty_mb_str_replace($string, $replace, $subject, $c); |
|
36 | + $count += $c; |
|
37 | + } |
|
38 | + } else { |
|
39 | + $n = max(count($search), count($replace)); |
|
40 | + while ($n --) { |
|
41 | + $subject = smarty_mb_str_replace(current($search), current($replace), $subject, $c); |
|
42 | + $count += $c; |
|
43 | + next($search); |
|
44 | + next($replace); |
|
45 | + } |
|
46 | + } |
|
47 | + } else { |
|
48 | + $parts = mb_split(preg_quote($search), $subject); |
|
49 | + $count = count($parts) - 1; |
|
50 | + $subject = implode($replace, $parts); |
|
51 | + } |
|
52 | 52 | |
53 | - return $subject; |
|
54 | - } |
|
53 | + return $subject; |
|
54 | + } |
|
55 | 55 | } |
@@ -37,7 +37,7 @@ |
||
37 | 37 | } |
38 | 38 | } else { |
39 | 39 | $n = max(count($search), count($replace)); |
40 | - while ($n --) { |
|
40 | + while ($n--) { |
|
41 | 41 | $subject = smarty_mb_str_replace(current($search), current($replace), $subject, $c); |
42 | 42 | $count += $c; |
43 | 43 | next($search); |
@@ -20,15 +20,15 @@ |
||
20 | 20 | */ |
21 | 21 | function smarty_function_escape_special_chars($string) |
22 | 22 | { |
23 | - if (!is_array($string)) { |
|
24 | - if (version_compare(PHP_VERSION, '5.2.3', '>=')) { |
|
25 | - $string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false); |
|
26 | - } else { |
|
27 | - $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); |
|
28 | - $string = htmlspecialchars($string); |
|
29 | - $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); |
|
30 | - } |
|
31 | - } |
|
23 | + if (!is_array($string)) { |
|
24 | + if (version_compare(PHP_VERSION, '5.2.3', '>=')) { |
|
25 | + $string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false); |
|
26 | + } else { |
|
27 | + $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); |
|
28 | + $string = htmlspecialchars($string); |
|
29 | + $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); |
|
30 | + } |
|
31 | + } |
|
32 | 32 | |
33 | - return $string; |
|
33 | + return $string; |
|
34 | 34 | } |
@@ -24,11 +24,11 @@ |
||
24 | 24 | */ |
25 | 25 | function smarty_modifier_replace($string, $search, $replace) |
26 | 26 | { |
27 | - if (Smarty::$_MBSTRING) { |
|
28 | - require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php'); |
|
27 | + if (Smarty::$_MBSTRING) { |
|
28 | + require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php'); |
|
29 | 29 | |
30 | - return smarty_mb_str_replace($search, $replace, $string); |
|
31 | - } |
|
30 | + return smarty_mb_str_replace($search, $replace, $string); |
|
31 | + } |
|
32 | 32 | |
33 | - return str_replace($search, $replace, $string); |
|
33 | + return str_replace($search, $replace, $string); |
|
34 | 34 | } |
@@ -52,336 +52,336 @@ |
||
52 | 52 | */ |
53 | 53 | function smarty_function_html_select_date($params) |
54 | 54 | { |
55 | - // generate timestamps used for month names only |
|
56 | - static $_month_timestamps = null; |
|
57 | - static $_current_year = null; |
|
58 | - if ($_month_timestamps === null) { |
|
59 | - $_current_year = date('Y'); |
|
60 | - $_month_timestamps = array(); |
|
61 | - for ($i = 1; $i <= 12; $i ++) { |
|
62 | - $_month_timestamps[ $i ] = mktime(0, 0, 0, $i, 1, 2000); |
|
63 | - } |
|
64 | - } |
|
55 | + // generate timestamps used for month names only |
|
56 | + static $_month_timestamps = null; |
|
57 | + static $_current_year = null; |
|
58 | + if ($_month_timestamps === null) { |
|
59 | + $_current_year = date('Y'); |
|
60 | + $_month_timestamps = array(); |
|
61 | + for ($i = 1; $i <= 12; $i ++) { |
|
62 | + $_month_timestamps[ $i ] = mktime(0, 0, 0, $i, 1, 2000); |
|
63 | + } |
|
64 | + } |
|
65 | 65 | |
66 | - /* Default values. */ |
|
67 | - $prefix = "Date_"; |
|
68 | - $start_year = null; |
|
69 | - $end_year = null; |
|
70 | - $display_days = true; |
|
71 | - $display_months = true; |
|
72 | - $display_years = true; |
|
73 | - $month_format = "%B"; |
|
74 | - /* Write months as numbers by default GL */ |
|
75 | - $month_value_format = "%m"; |
|
76 | - $day_format = "%02d"; |
|
77 | - /* Write day values using this format MB */ |
|
78 | - $day_value_format = "%d"; |
|
79 | - $year_as_text = false; |
|
80 | - /* Display years in reverse order? Ie. 2000,1999,.... */ |
|
81 | - $reverse_years = false; |
|
82 | - /* Should the select boxes be part of an array when returned from PHP? |
|
66 | + /* Default values. */ |
|
67 | + $prefix = "Date_"; |
|
68 | + $start_year = null; |
|
69 | + $end_year = null; |
|
70 | + $display_days = true; |
|
71 | + $display_months = true; |
|
72 | + $display_years = true; |
|
73 | + $month_format = "%B"; |
|
74 | + /* Write months as numbers by default GL */ |
|
75 | + $month_value_format = "%m"; |
|
76 | + $day_format = "%02d"; |
|
77 | + /* Write day values using this format MB */ |
|
78 | + $day_value_format = "%d"; |
|
79 | + $year_as_text = false; |
|
80 | + /* Display years in reverse order? Ie. 2000,1999,.... */ |
|
81 | + $reverse_years = false; |
|
82 | + /* Should the select boxes be part of an array when returned from PHP? |
|
83 | 83 | e.g. setting it to "birthday", would create "birthday[Day]", |
84 | 84 | "birthday[Month]" & "birthday[Year]". Can be combined with prefix */ |
85 | - $field_array = null; |
|
86 | - /* <select size>'s of the different <select> tags. |
|
85 | + $field_array = null; |
|
86 | + /* <select size>'s of the different <select> tags. |
|
87 | 87 | If not set, uses default dropdown. */ |
88 | - $day_size = null; |
|
89 | - $month_size = null; |
|
90 | - $year_size = null; |
|
91 | - /* Unparsed attributes common to *ALL* the <select>/<input> tags. |
|
88 | + $day_size = null; |
|
89 | + $month_size = null; |
|
90 | + $year_size = null; |
|
91 | + /* Unparsed attributes common to *ALL* the <select>/<input> tags. |
|
92 | 92 | An example might be in the template: all_extra ='class ="foo"'. */ |
93 | - $all_extra = null; |
|
94 | - /* Separate attributes for the tags. */ |
|
95 | - $day_extra = null; |
|
96 | - $month_extra = null; |
|
97 | - $year_extra = null; |
|
98 | - /* Order in which to display the fields. |
|
93 | + $all_extra = null; |
|
94 | + /* Separate attributes for the tags. */ |
|
95 | + $day_extra = null; |
|
96 | + $month_extra = null; |
|
97 | + $year_extra = null; |
|
98 | + /* Order in which to display the fields. |
|
99 | 99 | "D" -> day, "M" -> month, "Y" -> year. */ |
100 | - $field_order = 'MDY'; |
|
101 | - /* String printed between the different fields. */ |
|
102 | - $field_separator = "\n"; |
|
103 | - $option_separator = "\n"; |
|
104 | - $time = null; |
|
105 | - $extra_attrs = ''; |
|
106 | - $all_id = null; |
|
107 | - $day_id = null; |
|
108 | - $month_id = null; |
|
109 | - $year_id = null; |
|
100 | + $field_order = 'MDY'; |
|
101 | + /* String printed between the different fields. */ |
|
102 | + $field_separator = "\n"; |
|
103 | + $option_separator = "\n"; |
|
104 | + $time = null; |
|
105 | + $extra_attrs = ''; |
|
106 | + $all_id = null; |
|
107 | + $day_id = null; |
|
108 | + $month_id = null; |
|
109 | + $year_id = null; |
|
110 | 110 | |
111 | - foreach ($params as $_key => $_value) { |
|
112 | - switch ($_key) { |
|
113 | - case 'time': |
|
114 | - if (!is_array($_value) && $_value !== null) { |
|
115 | - $time = smarty_make_timestamp($_value); |
|
116 | - } |
|
117 | - break; |
|
111 | + foreach ($params as $_key => $_value) { |
|
112 | + switch ($_key) { |
|
113 | + case 'time': |
|
114 | + if (!is_array($_value) && $_value !== null) { |
|
115 | + $time = smarty_make_timestamp($_value); |
|
116 | + } |
|
117 | + break; |
|
118 | 118 | |
119 | - case 'month_names': |
|
120 | - if (is_array($_value) && count($_value) == 12) { |
|
121 | - $$_key = $_value; |
|
122 | - } else { |
|
123 | - trigger_error("html_select_date: month_names must be an array of 12 strings", E_USER_NOTICE); |
|
124 | - } |
|
125 | - break; |
|
119 | + case 'month_names': |
|
120 | + if (is_array($_value) && count($_value) == 12) { |
|
121 | + $$_key = $_value; |
|
122 | + } else { |
|
123 | + trigger_error("html_select_date: month_names must be an array of 12 strings", E_USER_NOTICE); |
|
124 | + } |
|
125 | + break; |
|
126 | 126 | |
127 | - case 'prefix': |
|
128 | - case 'field_array': |
|
129 | - case 'start_year': |
|
130 | - case 'end_year': |
|
131 | - case 'day_format': |
|
132 | - case 'day_value_format': |
|
133 | - case 'month_format': |
|
134 | - case 'month_value_format': |
|
135 | - case 'day_size': |
|
136 | - case 'month_size': |
|
137 | - case 'year_size': |
|
138 | - case 'all_extra': |
|
139 | - case 'day_extra': |
|
140 | - case 'month_extra': |
|
141 | - case 'year_extra': |
|
142 | - case 'field_order': |
|
143 | - case 'field_separator': |
|
144 | - case 'option_separator': |
|
145 | - case 'all_empty': |
|
146 | - case 'month_empty': |
|
147 | - case 'day_empty': |
|
148 | - case 'year_empty': |
|
149 | - case 'all_id': |
|
150 | - case 'month_id': |
|
151 | - case 'day_id': |
|
152 | - case 'year_id': |
|
153 | - $$_key = (string) $_value; |
|
154 | - break; |
|
127 | + case 'prefix': |
|
128 | + case 'field_array': |
|
129 | + case 'start_year': |
|
130 | + case 'end_year': |
|
131 | + case 'day_format': |
|
132 | + case 'day_value_format': |
|
133 | + case 'month_format': |
|
134 | + case 'month_value_format': |
|
135 | + case 'day_size': |
|
136 | + case 'month_size': |
|
137 | + case 'year_size': |
|
138 | + case 'all_extra': |
|
139 | + case 'day_extra': |
|
140 | + case 'month_extra': |
|
141 | + case 'year_extra': |
|
142 | + case 'field_order': |
|
143 | + case 'field_separator': |
|
144 | + case 'option_separator': |
|
145 | + case 'all_empty': |
|
146 | + case 'month_empty': |
|
147 | + case 'day_empty': |
|
148 | + case 'year_empty': |
|
149 | + case 'all_id': |
|
150 | + case 'month_id': |
|
151 | + case 'day_id': |
|
152 | + case 'year_id': |
|
153 | + $$_key = (string) $_value; |
|
154 | + break; |
|
155 | 155 | |
156 | - case 'display_days': |
|
157 | - case 'display_months': |
|
158 | - case 'display_years': |
|
159 | - case 'year_as_text': |
|
160 | - case 'reverse_years': |
|
161 | - $$_key = (bool) $_value; |
|
162 | - break; |
|
156 | + case 'display_days': |
|
157 | + case 'display_months': |
|
158 | + case 'display_years': |
|
159 | + case 'year_as_text': |
|
160 | + case 'reverse_years': |
|
161 | + $$_key = (bool) $_value; |
|
162 | + break; |
|
163 | 163 | |
164 | - default: |
|
165 | - if (!is_array($_value)) { |
|
166 | - $extra_attrs .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_value) . '"'; |
|
167 | - } else { |
|
168 | - trigger_error("html_select_date: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
|
169 | - } |
|
170 | - break; |
|
171 | - } |
|
172 | - } |
|
164 | + default: |
|
165 | + if (!is_array($_value)) { |
|
166 | + $extra_attrs .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_value) . '"'; |
|
167 | + } else { |
|
168 | + trigger_error("html_select_date: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
|
169 | + } |
|
170 | + break; |
|
171 | + } |
|
172 | + } |
|
173 | 173 | |
174 | - // Note: date() is faster than strftime() |
|
175 | - // Note: explode(date()) is faster than date() date() date() |
|
176 | - if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) { |
|
177 | - if (isset($params[ 'time' ][ $prefix . 'Year' ])) { |
|
178 | - // $_REQUEST[$field_array] given |
|
179 | - foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) { |
|
180 | - $_variableName = '_' . strtolower($_elementName); |
|
181 | - $$_variableName = |
|
182 | - isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] : |
|
183 | - date($_elementKey); |
|
184 | - } |
|
185 | - } elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Year' ])) { |
|
186 | - // $_REQUEST given |
|
187 | - foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) { |
|
188 | - $_variableName = '_' . strtolower($_elementName); |
|
189 | - $$_variableName = isset($params[ 'time' ][ $field_array ][ $prefix . $_elementName ]) ? |
|
190 | - $params[ 'time' ][ $field_array ][ $prefix . $_elementName ] : date($_elementKey); |
|
191 | - } |
|
192 | - } else { |
|
193 | - // no date found, use NOW |
|
194 | - list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d')); |
|
195 | - } |
|
196 | - } elseif ($time === null) { |
|
197 | - if (array_key_exists('time', $params)) { |
|
198 | - $_year = $_month = $_day = $time = null; |
|
199 | - } else { |
|
200 | - list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d')); |
|
201 | - } |
|
202 | - } else { |
|
203 | - list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d', $time)); |
|
204 | - } |
|
174 | + // Note: date() is faster than strftime() |
|
175 | + // Note: explode(date()) is faster than date() date() date() |
|
176 | + if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) { |
|
177 | + if (isset($params[ 'time' ][ $prefix . 'Year' ])) { |
|
178 | + // $_REQUEST[$field_array] given |
|
179 | + foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) { |
|
180 | + $_variableName = '_' . strtolower($_elementName); |
|
181 | + $$_variableName = |
|
182 | + isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] : |
|
183 | + date($_elementKey); |
|
184 | + } |
|
185 | + } elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Year' ])) { |
|
186 | + // $_REQUEST given |
|
187 | + foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) { |
|
188 | + $_variableName = '_' . strtolower($_elementName); |
|
189 | + $$_variableName = isset($params[ 'time' ][ $field_array ][ $prefix . $_elementName ]) ? |
|
190 | + $params[ 'time' ][ $field_array ][ $prefix . $_elementName ] : date($_elementKey); |
|
191 | + } |
|
192 | + } else { |
|
193 | + // no date found, use NOW |
|
194 | + list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d')); |
|
195 | + } |
|
196 | + } elseif ($time === null) { |
|
197 | + if (array_key_exists('time', $params)) { |
|
198 | + $_year = $_month = $_day = $time = null; |
|
199 | + } else { |
|
200 | + list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d')); |
|
201 | + } |
|
202 | + } else { |
|
203 | + list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d', $time)); |
|
204 | + } |
|
205 | 205 | |
206 | - // make syntax "+N" or "-N" work with $start_year and $end_year |
|
207 | - // Note preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match) is slower than trim+substr |
|
208 | - foreach (array('start', 'end') as $key) { |
|
209 | - $key .= '_year'; |
|
210 | - $t = $$key; |
|
211 | - if ($t === null) { |
|
212 | - $$key = (int) $_current_year; |
|
213 | - } elseif ($t[ 0 ] == '+') { |
|
214 | - $$key = (int) ($_current_year + (int) trim(substr($t, 1))); |
|
215 | - } elseif ($t[ 0 ] == '-') { |
|
216 | - $$key = (int) ($_current_year - (int) trim(substr($t, 1))); |
|
217 | - } else { |
|
218 | - $$key = (int) $$key; |
|
219 | - } |
|
220 | - } |
|
206 | + // make syntax "+N" or "-N" work with $start_year and $end_year |
|
207 | + // Note preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match) is slower than trim+substr |
|
208 | + foreach (array('start', 'end') as $key) { |
|
209 | + $key .= '_year'; |
|
210 | + $t = $$key; |
|
211 | + if ($t === null) { |
|
212 | + $$key = (int) $_current_year; |
|
213 | + } elseif ($t[ 0 ] == '+') { |
|
214 | + $$key = (int) ($_current_year + (int) trim(substr($t, 1))); |
|
215 | + } elseif ($t[ 0 ] == '-') { |
|
216 | + $$key = (int) ($_current_year - (int) trim(substr($t, 1))); |
|
217 | + } else { |
|
218 | + $$key = (int) $$key; |
|
219 | + } |
|
220 | + } |
|
221 | 221 | |
222 | - // flip for ascending or descending |
|
223 | - if (($start_year > $end_year && !$reverse_years) || ($start_year < $end_year && $reverse_years)) { |
|
224 | - $t = $end_year; |
|
225 | - $end_year = $start_year; |
|
226 | - $start_year = $t; |
|
227 | - } |
|
222 | + // flip for ascending or descending |
|
223 | + if (($start_year > $end_year && !$reverse_years) || ($start_year < $end_year && $reverse_years)) { |
|
224 | + $t = $end_year; |
|
225 | + $end_year = $start_year; |
|
226 | + $start_year = $t; |
|
227 | + } |
|
228 | 228 | |
229 | - // generate year <select> or <input> |
|
230 | - if ($display_years) { |
|
231 | - $_extra = ''; |
|
232 | - $_name = $field_array ? ($field_array . '[' . $prefix . 'Year]') : ($prefix . 'Year'); |
|
233 | - if ($all_extra) { |
|
234 | - $_extra .= ' ' . $all_extra; |
|
235 | - } |
|
236 | - if ($year_extra) { |
|
237 | - $_extra .= ' ' . $year_extra; |
|
238 | - } |
|
229 | + // generate year <select> or <input> |
|
230 | + if ($display_years) { |
|
231 | + $_extra = ''; |
|
232 | + $_name = $field_array ? ($field_array . '[' . $prefix . 'Year]') : ($prefix . 'Year'); |
|
233 | + if ($all_extra) { |
|
234 | + $_extra .= ' ' . $all_extra; |
|
235 | + } |
|
236 | + if ($year_extra) { |
|
237 | + $_extra .= ' ' . $year_extra; |
|
238 | + } |
|
239 | 239 | |
240 | - if ($year_as_text) { |
|
241 | - $_html_years = |
|
242 | - '<input type="text" name="' . $_name . '" value="' . $_year . '" size="4" maxlength="4"' . $_extra . |
|
243 | - $extra_attrs . ' />'; |
|
244 | - } else { |
|
245 | - $_html_years = '<select name="' . $_name . '"'; |
|
246 | - if ($year_id !== null || $all_id !== null) { |
|
247 | - $_html_years .= ' id="' . smarty_function_escape_special_chars($year_id !== null ? |
|
248 | - ($year_id ? $year_id : $_name) : |
|
249 | - ($all_id ? ($all_id . $_name) : |
|
250 | - $_name)) . '"'; |
|
251 | - } |
|
252 | - if ($year_size) { |
|
253 | - $_html_years .= ' size="' . $year_size . '"'; |
|
254 | - } |
|
255 | - $_html_years .= $_extra . $extra_attrs . '>' . $option_separator; |
|
240 | + if ($year_as_text) { |
|
241 | + $_html_years = |
|
242 | + '<input type="text" name="' . $_name . '" value="' . $_year . '" size="4" maxlength="4"' . $_extra . |
|
243 | + $extra_attrs . ' />'; |
|
244 | + } else { |
|
245 | + $_html_years = '<select name="' . $_name . '"'; |
|
246 | + if ($year_id !== null || $all_id !== null) { |
|
247 | + $_html_years .= ' id="' . smarty_function_escape_special_chars($year_id !== null ? |
|
248 | + ($year_id ? $year_id : $_name) : |
|
249 | + ($all_id ? ($all_id . $_name) : |
|
250 | + $_name)) . '"'; |
|
251 | + } |
|
252 | + if ($year_size) { |
|
253 | + $_html_years .= ' size="' . $year_size . '"'; |
|
254 | + } |
|
255 | + $_html_years .= $_extra . $extra_attrs . '>' . $option_separator; |
|
256 | 256 | |
257 | - if (isset($year_empty) || isset($all_empty)) { |
|
258 | - $_html_years .= '<option value="">' . (isset($year_empty) ? $year_empty : $all_empty) . '</option>' . |
|
259 | - $option_separator; |
|
260 | - } |
|
257 | + if (isset($year_empty) || isset($all_empty)) { |
|
258 | + $_html_years .= '<option value="">' . (isset($year_empty) ? $year_empty : $all_empty) . '</option>' . |
|
259 | + $option_separator; |
|
260 | + } |
|
261 | 261 | |
262 | - $op = $start_year > $end_year ? - 1 : 1; |
|
263 | - for ($i = $start_year; $op > 0 ? $i <= $end_year : $i >= $end_year; $i += $op) { |
|
264 | - $_html_years .= '<option value="' . $i . '"' . ($_year == $i ? ' selected="selected"' : '') . '>' . $i . |
|
265 | - '</option>' . $option_separator; |
|
266 | - } |
|
262 | + $op = $start_year > $end_year ? - 1 : 1; |
|
263 | + for ($i = $start_year; $op > 0 ? $i <= $end_year : $i >= $end_year; $i += $op) { |
|
264 | + $_html_years .= '<option value="' . $i . '"' . ($_year == $i ? ' selected="selected"' : '') . '>' . $i . |
|
265 | + '</option>' . $option_separator; |
|
266 | + } |
|
267 | 267 | |
268 | - $_html_years .= '</select>'; |
|
269 | - } |
|
270 | - } |
|
268 | + $_html_years .= '</select>'; |
|
269 | + } |
|
270 | + } |
|
271 | 271 | |
272 | - // generate month <select> or <input> |
|
273 | - if ($display_months) { |
|
274 | - $_extra = ''; |
|
275 | - $_name = $field_array ? ($field_array . '[' . $prefix . 'Month]') : ($prefix . 'Month'); |
|
276 | - if ($all_extra) { |
|
277 | - $_extra .= ' ' . $all_extra; |
|
278 | - } |
|
279 | - if ($month_extra) { |
|
280 | - $_extra .= ' ' . $month_extra; |
|
281 | - } |
|
272 | + // generate month <select> or <input> |
|
273 | + if ($display_months) { |
|
274 | + $_extra = ''; |
|
275 | + $_name = $field_array ? ($field_array . '[' . $prefix . 'Month]') : ($prefix . 'Month'); |
|
276 | + if ($all_extra) { |
|
277 | + $_extra .= ' ' . $all_extra; |
|
278 | + } |
|
279 | + if ($month_extra) { |
|
280 | + $_extra .= ' ' . $month_extra; |
|
281 | + } |
|
282 | 282 | |
283 | - $_html_months = '<select name="' . $_name . '"'; |
|
284 | - if ($month_id !== null || $all_id !== null) { |
|
285 | - $_html_months .= ' id="' . smarty_function_escape_special_chars($month_id !== null ? |
|
286 | - ($month_id ? $month_id : $_name) : |
|
287 | - ($all_id ? ($all_id . $_name) : |
|
288 | - $_name)) . '"'; |
|
289 | - } |
|
290 | - if ($month_size) { |
|
291 | - $_html_months .= ' size="' . $month_size . '"'; |
|
292 | - } |
|
293 | - $_html_months .= $_extra . $extra_attrs . '>' . $option_separator; |
|
283 | + $_html_months = '<select name="' . $_name . '"'; |
|
284 | + if ($month_id !== null || $all_id !== null) { |
|
285 | + $_html_months .= ' id="' . smarty_function_escape_special_chars($month_id !== null ? |
|
286 | + ($month_id ? $month_id : $_name) : |
|
287 | + ($all_id ? ($all_id . $_name) : |
|
288 | + $_name)) . '"'; |
|
289 | + } |
|
290 | + if ($month_size) { |
|
291 | + $_html_months .= ' size="' . $month_size . '"'; |
|
292 | + } |
|
293 | + $_html_months .= $_extra . $extra_attrs . '>' . $option_separator; |
|
294 | 294 | |
295 | - if (isset($month_empty) || isset($all_empty)) { |
|
296 | - $_html_months .= '<option value="">' . (isset($month_empty) ? $month_empty : $all_empty) . '</option>' . |
|
297 | - $option_separator; |
|
298 | - } |
|
295 | + if (isset($month_empty) || isset($all_empty)) { |
|
296 | + $_html_months .= '<option value="">' . (isset($month_empty) ? $month_empty : $all_empty) . '</option>' . |
|
297 | + $option_separator; |
|
298 | + } |
|
299 | 299 | |
300 | - for ($i = 1; $i <= 12; $i ++) { |
|
301 | - $_val = sprintf('%02d', $i); |
|
302 | - $_text = isset($month_names) ? smarty_function_escape_special_chars($month_names[ $i ]) : |
|
303 | - ($month_format == "%m" ? $_val : strftime($month_format, $_month_timestamps[ $i ])); |
|
304 | - $_value = $month_value_format == "%m" ? $_val : strftime($month_value_format, $_month_timestamps[ $i ]); |
|
305 | - $_html_months .= '<option value="' . $_value . '"' . ($_val == $_month ? ' selected="selected"' : '') . |
|
306 | - '>' . $_text . '</option>' . $option_separator; |
|
307 | - } |
|
300 | + for ($i = 1; $i <= 12; $i ++) { |
|
301 | + $_val = sprintf('%02d', $i); |
|
302 | + $_text = isset($month_names) ? smarty_function_escape_special_chars($month_names[ $i ]) : |
|
303 | + ($month_format == "%m" ? $_val : strftime($month_format, $_month_timestamps[ $i ])); |
|
304 | + $_value = $month_value_format == "%m" ? $_val : strftime($month_value_format, $_month_timestamps[ $i ]); |
|
305 | + $_html_months .= '<option value="' . $_value . '"' . ($_val == $_month ? ' selected="selected"' : '') . |
|
306 | + '>' . $_text . '</option>' . $option_separator; |
|
307 | + } |
|
308 | 308 | |
309 | - $_html_months .= '</select>'; |
|
310 | - } |
|
309 | + $_html_months .= '</select>'; |
|
310 | + } |
|
311 | 311 | |
312 | - // generate day <select> or <input> |
|
313 | - if ($display_days) { |
|
314 | - $_extra = ''; |
|
315 | - $_name = $field_array ? ($field_array . '[' . $prefix . 'Day]') : ($prefix . 'Day'); |
|
316 | - if ($all_extra) { |
|
317 | - $_extra .= ' ' . $all_extra; |
|
318 | - } |
|
319 | - if ($day_extra) { |
|
320 | - $_extra .= ' ' . $day_extra; |
|
321 | - } |
|
312 | + // generate day <select> or <input> |
|
313 | + if ($display_days) { |
|
314 | + $_extra = ''; |
|
315 | + $_name = $field_array ? ($field_array . '[' . $prefix . 'Day]') : ($prefix . 'Day'); |
|
316 | + if ($all_extra) { |
|
317 | + $_extra .= ' ' . $all_extra; |
|
318 | + } |
|
319 | + if ($day_extra) { |
|
320 | + $_extra .= ' ' . $day_extra; |
|
321 | + } |
|
322 | 322 | |
323 | - $_html_days = '<select name="' . $_name . '"'; |
|
324 | - if ($day_id !== null || $all_id !== null) { |
|
325 | - $_html_days .= ' id="' . |
|
326 | - smarty_function_escape_special_chars($day_id !== null ? ($day_id ? $day_id : $_name) : |
|
327 | - ($all_id ? ($all_id . $_name) : $_name)) . '"'; |
|
328 | - } |
|
329 | - if ($day_size) { |
|
330 | - $_html_days .= ' size="' . $day_size . '"'; |
|
331 | - } |
|
332 | - $_html_days .= $_extra . $extra_attrs . '>' . $option_separator; |
|
323 | + $_html_days = '<select name="' . $_name . '"'; |
|
324 | + if ($day_id !== null || $all_id !== null) { |
|
325 | + $_html_days .= ' id="' . |
|
326 | + smarty_function_escape_special_chars($day_id !== null ? ($day_id ? $day_id : $_name) : |
|
327 | + ($all_id ? ($all_id . $_name) : $_name)) . '"'; |
|
328 | + } |
|
329 | + if ($day_size) { |
|
330 | + $_html_days .= ' size="' . $day_size . '"'; |
|
331 | + } |
|
332 | + $_html_days .= $_extra . $extra_attrs . '>' . $option_separator; |
|
333 | 333 | |
334 | - if (isset($day_empty) || isset($all_empty)) { |
|
335 | - $_html_days .= '<option value="">' . (isset($day_empty) ? $day_empty : $all_empty) . '</option>' . |
|
336 | - $option_separator; |
|
337 | - } |
|
334 | + if (isset($day_empty) || isset($all_empty)) { |
|
335 | + $_html_days .= '<option value="">' . (isset($day_empty) ? $day_empty : $all_empty) . '</option>' . |
|
336 | + $option_separator; |
|
337 | + } |
|
338 | 338 | |
339 | - for ($i = 1; $i <= 31; $i ++) { |
|
340 | - $_val = sprintf('%02d', $i); |
|
341 | - $_text = $day_format == '%02d' ? $_val : sprintf($day_format, $i); |
|
342 | - $_value = $day_value_format == '%02d' ? $_val : sprintf($day_value_format, $i); |
|
343 | - $_html_days .= '<option value="' . $_value . '"' . ($_val == $_day ? ' selected="selected"' : '') . '>' . |
|
344 | - $_text . '</option>' . $option_separator; |
|
345 | - } |
|
339 | + for ($i = 1; $i <= 31; $i ++) { |
|
340 | + $_val = sprintf('%02d', $i); |
|
341 | + $_text = $day_format == '%02d' ? $_val : sprintf($day_format, $i); |
|
342 | + $_value = $day_value_format == '%02d' ? $_val : sprintf($day_value_format, $i); |
|
343 | + $_html_days .= '<option value="' . $_value . '"' . ($_val == $_day ? ' selected="selected"' : '') . '>' . |
|
344 | + $_text . '</option>' . $option_separator; |
|
345 | + } |
|
346 | 346 | |
347 | - $_html_days .= '</select>'; |
|
348 | - } |
|
347 | + $_html_days .= '</select>'; |
|
348 | + } |
|
349 | 349 | |
350 | - // order the fields for output |
|
351 | - $_html = ''; |
|
352 | - for ($i = 0; $i <= 2; $i ++) { |
|
353 | - switch ($field_order[ $i ]) { |
|
354 | - case 'Y': |
|
355 | - case 'y': |
|
356 | - if (isset($_html_years)) { |
|
357 | - if ($_html) { |
|
358 | - $_html .= $field_separator; |
|
359 | - } |
|
360 | - $_html .= $_html_years; |
|
361 | - } |
|
362 | - break; |
|
350 | + // order the fields for output |
|
351 | + $_html = ''; |
|
352 | + for ($i = 0; $i <= 2; $i ++) { |
|
353 | + switch ($field_order[ $i ]) { |
|
354 | + case 'Y': |
|
355 | + case 'y': |
|
356 | + if (isset($_html_years)) { |
|
357 | + if ($_html) { |
|
358 | + $_html .= $field_separator; |
|
359 | + } |
|
360 | + $_html .= $_html_years; |
|
361 | + } |
|
362 | + break; |
|
363 | 363 | |
364 | - case 'm': |
|
365 | - case 'M': |
|
366 | - if (isset($_html_months)) { |
|
367 | - if ($_html) { |
|
368 | - $_html .= $field_separator; |
|
369 | - } |
|
370 | - $_html .= $_html_months; |
|
371 | - } |
|
372 | - break; |
|
364 | + case 'm': |
|
365 | + case 'M': |
|
366 | + if (isset($_html_months)) { |
|
367 | + if ($_html) { |
|
368 | + $_html .= $field_separator; |
|
369 | + } |
|
370 | + $_html .= $_html_months; |
|
371 | + } |
|
372 | + break; |
|
373 | 373 | |
374 | - case 'd': |
|
375 | - case 'D': |
|
376 | - if (isset($_html_days)) { |
|
377 | - if ($_html) { |
|
378 | - $_html .= $field_separator; |
|
379 | - } |
|
380 | - $_html .= $_html_days; |
|
381 | - } |
|
382 | - break; |
|
383 | - } |
|
384 | - } |
|
374 | + case 'd': |
|
375 | + case 'D': |
|
376 | + if (isset($_html_days)) { |
|
377 | + if ($_html) { |
|
378 | + $_html .= $field_separator; |
|
379 | + } |
|
380 | + $_html .= $_html_days; |
|
381 | + } |
|
382 | + break; |
|
383 | + } |
|
384 | + } |
|
385 | 385 | |
386 | - return $_html; |
|
386 | + return $_html; |
|
387 | 387 | } |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | if ($_month_timestamps === null) { |
59 | 59 | $_current_year = date('Y'); |
60 | 60 | $_month_timestamps = array(); |
61 | - for ($i = 1; $i <= 12; $i ++) { |
|
62 | - $_month_timestamps[ $i ] = mktime(0, 0, 0, $i, 1, 2000); |
|
61 | + for ($i = 1; $i <= 12; $i++) { |
|
62 | + $_month_timestamps[$i] = mktime(0, 0, 0, $i, 1, 2000); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -173,21 +173,20 @@ discard block |
||
173 | 173 | |
174 | 174 | // Note: date() is faster than strftime() |
175 | 175 | // Note: explode(date()) is faster than date() date() date() |
176 | - if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) { |
|
177 | - if (isset($params[ 'time' ][ $prefix . 'Year' ])) { |
|
176 | + if (isset($params['time']) && is_array($params['time'])) { |
|
177 | + if (isset($params['time'][$prefix . 'Year'])) { |
|
178 | 178 | // $_REQUEST[$field_array] given |
179 | 179 | foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) { |
180 | 180 | $_variableName = '_' . strtolower($_elementName); |
181 | 181 | $$_variableName = |
182 | - isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] : |
|
183 | - date($_elementKey); |
|
182 | + isset($params['time'][$prefix . $_elementName]) ? $params['time'][$prefix . $_elementName] : date($_elementKey); |
|
184 | 183 | } |
185 | - } elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Year' ])) { |
|
184 | + } elseif (isset($params['time'][$field_array][$prefix . 'Year'])) { |
|
186 | 185 | // $_REQUEST given |
187 | 186 | foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) { |
188 | 187 | $_variableName = '_' . strtolower($_elementName); |
189 | - $$_variableName = isset($params[ 'time' ][ $field_array ][ $prefix . $_elementName ]) ? |
|
190 | - $params[ 'time' ][ $field_array ][ $prefix . $_elementName ] : date($_elementKey); |
|
188 | + $$_variableName = isset($params['time'][$field_array][$prefix . $_elementName]) ? |
|
189 | + $params['time'][$field_array][$prefix . $_elementName] : date($_elementKey); |
|
191 | 190 | } |
192 | 191 | } else { |
193 | 192 | // no date found, use NOW |
@@ -210,9 +209,9 @@ discard block |
||
210 | 209 | $t = $$key; |
211 | 210 | if ($t === null) { |
212 | 211 | $$key = (int) $_current_year; |
213 | - } elseif ($t[ 0 ] == '+') { |
|
212 | + } elseif ($t[0] == '+') { |
|
214 | 213 | $$key = (int) ($_current_year + (int) trim(substr($t, 1))); |
215 | - } elseif ($t[ 0 ] == '-') { |
|
214 | + } elseif ($t[0] == '-') { |
|
216 | 215 | $$key = (int) ($_current_year - (int) trim(substr($t, 1))); |
217 | 216 | } else { |
218 | 217 | $$key = (int) $$key; |
@@ -245,9 +244,7 @@ discard block |
||
245 | 244 | $_html_years = '<select name="' . $_name . '"'; |
246 | 245 | if ($year_id !== null || $all_id !== null) { |
247 | 246 | $_html_years .= ' id="' . smarty_function_escape_special_chars($year_id !== null ? |
248 | - ($year_id ? $year_id : $_name) : |
|
249 | - ($all_id ? ($all_id . $_name) : |
|
250 | - $_name)) . '"'; |
|
247 | + ($year_id ? $year_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)) . '"'; |
|
251 | 248 | } |
252 | 249 | if ($year_size) { |
253 | 250 | $_html_years .= ' size="' . $year_size . '"'; |
@@ -259,7 +256,7 @@ discard block |
||
259 | 256 | $option_separator; |
260 | 257 | } |
261 | 258 | |
262 | - $op = $start_year > $end_year ? - 1 : 1; |
|
259 | + $op = $start_year > $end_year ? -1 : 1; |
|
263 | 260 | for ($i = $start_year; $op > 0 ? $i <= $end_year : $i >= $end_year; $i += $op) { |
264 | 261 | $_html_years .= '<option value="' . $i . '"' . ($_year == $i ? ' selected="selected"' : '') . '>' . $i . |
265 | 262 | '</option>' . $option_separator; |
@@ -283,9 +280,7 @@ discard block |
||
283 | 280 | $_html_months = '<select name="' . $_name . '"'; |
284 | 281 | if ($month_id !== null || $all_id !== null) { |
285 | 282 | $_html_months .= ' id="' . smarty_function_escape_special_chars($month_id !== null ? |
286 | - ($month_id ? $month_id : $_name) : |
|
287 | - ($all_id ? ($all_id . $_name) : |
|
288 | - $_name)) . '"'; |
|
283 | + ($month_id ? $month_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)) . '"'; |
|
289 | 284 | } |
290 | 285 | if ($month_size) { |
291 | 286 | $_html_months .= ' size="' . $month_size . '"'; |
@@ -297,11 +292,10 @@ discard block |
||
297 | 292 | $option_separator; |
298 | 293 | } |
299 | 294 | |
300 | - for ($i = 1; $i <= 12; $i ++) { |
|
295 | + for ($i = 1; $i <= 12; $i++) { |
|
301 | 296 | $_val = sprintf('%02d', $i); |
302 | - $_text = isset($month_names) ? smarty_function_escape_special_chars($month_names[ $i ]) : |
|
303 | - ($month_format == "%m" ? $_val : strftime($month_format, $_month_timestamps[ $i ])); |
|
304 | - $_value = $month_value_format == "%m" ? $_val : strftime($month_value_format, $_month_timestamps[ $i ]); |
|
297 | + $_text = isset($month_names) ? smarty_function_escape_special_chars($month_names[$i]) : ($month_format == "%m" ? $_val : strftime($month_format, $_month_timestamps[$i])); |
|
298 | + $_value = $month_value_format == "%m" ? $_val : strftime($month_value_format, $_month_timestamps[$i]); |
|
305 | 299 | $_html_months .= '<option value="' . $_value . '"' . ($_val == $_month ? ' selected="selected"' : '') . |
306 | 300 | '>' . $_text . '</option>' . $option_separator; |
307 | 301 | } |
@@ -323,8 +317,7 @@ discard block |
||
323 | 317 | $_html_days = '<select name="' . $_name . '"'; |
324 | 318 | if ($day_id !== null || $all_id !== null) { |
325 | 319 | $_html_days .= ' id="' . |
326 | - smarty_function_escape_special_chars($day_id !== null ? ($day_id ? $day_id : $_name) : |
|
327 | - ($all_id ? ($all_id . $_name) : $_name)) . '"'; |
|
320 | + smarty_function_escape_special_chars($day_id !== null ? ($day_id ? $day_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)) . '"'; |
|
328 | 321 | } |
329 | 322 | if ($day_size) { |
330 | 323 | $_html_days .= ' size="' . $day_size . '"'; |
@@ -336,7 +329,7 @@ discard block |
||
336 | 329 | $option_separator; |
337 | 330 | } |
338 | 331 | |
339 | - for ($i = 1; $i <= 31; $i ++) { |
|
332 | + for ($i = 1; $i <= 31; $i++) { |
|
340 | 333 | $_val = sprintf('%02d', $i); |
341 | 334 | $_text = $day_format == '%02d' ? $_val : sprintf($day_format, $i); |
342 | 335 | $_value = $day_value_format == '%02d' ? $_val : sprintf($day_value_format, $i); |
@@ -349,8 +342,8 @@ discard block |
||
349 | 342 | |
350 | 343 | // order the fields for output |
351 | 344 | $_html = ''; |
352 | - for ($i = 0; $i <= 2; $i ++) { |
|
353 | - switch ($field_order[ $i ]) { |
|
345 | + for ($i = 0; $i <= 2; $i++) { |
|
346 | + switch ($field_order[$i]) { |
|
354 | 347 | case 'Y': |
355 | 348 | case 'y': |
356 | 349 | if (isset($_html_years)) { |
@@ -19,13 +19,13 @@ discard block |
||
19 | 19 | */ |
20 | 20 | function smarty_mb_to_unicode($string, $encoding = null) |
21 | 21 | { |
22 | - if ($encoding) { |
|
23 | - $expanded = mb_convert_encoding($string, "UTF-32BE", $encoding); |
|
24 | - } else { |
|
25 | - $expanded = mb_convert_encoding($string, "UTF-32BE"); |
|
26 | - } |
|
22 | + if ($encoding) { |
|
23 | + $expanded = mb_convert_encoding($string, "UTF-32BE", $encoding); |
|
24 | + } else { |
|
25 | + $expanded = mb_convert_encoding($string, "UTF-32BE"); |
|
26 | + } |
|
27 | 27 | |
28 | - return unpack("N*", $expanded); |
|
28 | + return unpack("N*", $expanded); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | */ |
42 | 42 | function smarty_mb_from_unicode($unicode, $encoding = null) |
43 | 43 | { |
44 | - $t = ''; |
|
45 | - if (!$encoding) { |
|
46 | - $encoding = mb_internal_encoding(); |
|
47 | - } |
|
48 | - foreach ((array) $unicode as $utf32be) { |
|
49 | - $character = pack("N*", $utf32be); |
|
50 | - $t .= mb_convert_encoding($character, $encoding, "UTF-32BE"); |
|
51 | - } |
|
44 | + $t = ''; |
|
45 | + if (!$encoding) { |
|
46 | + $encoding = mb_internal_encoding(); |
|
47 | + } |
|
48 | + foreach ((array) $unicode as $utf32be) { |
|
49 | + $character = pack("N*", $utf32be); |
|
50 | + $t .= mb_convert_encoding($character, $encoding, "UTF-32BE"); |
|
51 | + } |
|
52 | 52 | |
53 | - return $t; |
|
53 | + return $t; |
|
54 | 54 | } |
@@ -20,13 +20,13 @@ |
||
20 | 20 | */ |
21 | 21 | function smarty_modifiercompiler_from_charset($params) |
22 | 22 | { |
23 | - if (!Smarty::$_MBSTRING) { |
|
24 | - return $params[ 0 ]; |
|
25 | - } |
|
23 | + if (!Smarty::$_MBSTRING) { |
|
24 | + return $params[ 0 ]; |
|
25 | + } |
|
26 | 26 | |
27 | - if (!isset($params[ 1 ])) { |
|
28 | - $params[ 1 ] = '"ISO-8859-1"'; |
|
29 | - } |
|
27 | + if (!isset($params[ 1 ])) { |
|
28 | + $params[ 1 ] = '"ISO-8859-1"'; |
|
29 | + } |
|
30 | 30 | |
31 | - return 'mb_convert_encoding(' . $params[ 0 ] . ', "' . addslashes(Smarty::$_CHARSET) . '", ' . $params[ 1 ] . ')'; |
|
31 | + return 'mb_convert_encoding(' . $params[ 0 ] . ', "' . addslashes(Smarty::$_CHARSET) . '", ' . $params[ 1 ] . ')'; |
|
32 | 32 | } |
@@ -21,12 +21,12 @@ |
||
21 | 21 | function smarty_modifiercompiler_from_charset($params) |
22 | 22 | { |
23 | 23 | if (!Smarty::$_MBSTRING) { |
24 | - return $params[ 0 ]; |
|
24 | + return $params[0]; |
|
25 | 25 | } |
26 | 26 | |
27 | - if (!isset($params[ 1 ])) { |
|
28 | - $params[ 1 ] = '"ISO-8859-1"'; |
|
27 | + if (!isset($params[1])) { |
|
28 | + $params[1] = '"ISO-8859-1"'; |
|
29 | 29 | } |
30 | 30 | |
31 | - return 'mb_convert_encoding(' . $params[ 0 ] . ', "' . addslashes(Smarty::$_CHARSET) . '", ' . $params[ 1 ] . ')'; |
|
31 | + return 'mb_convert_encoding(' . $params[0] . ', "' . addslashes(Smarty::$_CHARSET) . '", ' . $params[1] . ')'; |
|
32 | 32 | } |
@@ -29,37 +29,37 @@ |
||
29 | 29 | */ |
30 | 30 | function smarty_modifier_date_format($string, $format = null, $default_date = '', $formatter = 'auto') |
31 | 31 | { |
32 | - if ($format === null) { |
|
33 | - $format = Smarty::$_DATE_FORMAT; |
|
34 | - } |
|
35 | - /** |
|
36 | - * require_once the {@link shared.make_timestamp.php} plugin |
|
37 | - */ |
|
38 | - require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'); |
|
39 | - if ($string != '' && $string != '0000-00-00' && $string != '0000-00-00 00:00:00') { |
|
40 | - $timestamp = smarty_make_timestamp($string); |
|
41 | - } elseif ($default_date != '') { |
|
42 | - $timestamp = smarty_make_timestamp($default_date); |
|
43 | - } else { |
|
44 | - return; |
|
45 | - } |
|
46 | - if ($formatter == 'strftime' || ($formatter == 'auto' && strpos($format, '%') !== false)) { |
|
47 | - if (DS == '\\') { |
|
48 | - $_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T'); |
|
49 | - $_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S'); |
|
50 | - if (strpos($format, '%e') !== false) { |
|
51 | - $_win_from[] = '%e'; |
|
52 | - $_win_to[] = sprintf('%\' 2d', date('j', $timestamp)); |
|
53 | - } |
|
54 | - if (strpos($format, '%l') !== false) { |
|
55 | - $_win_from[] = '%l'; |
|
56 | - $_win_to[] = sprintf('%\' 2d', date('h', $timestamp)); |
|
57 | - } |
|
58 | - $format = str_replace($_win_from, $_win_to, $format); |
|
59 | - } |
|
32 | + if ($format === null) { |
|
33 | + $format = Smarty::$_DATE_FORMAT; |
|
34 | + } |
|
35 | + /** |
|
36 | + * require_once the {@link shared.make_timestamp.php} plugin |
|
37 | + */ |
|
38 | + require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'); |
|
39 | + if ($string != '' && $string != '0000-00-00' && $string != '0000-00-00 00:00:00') { |
|
40 | + $timestamp = smarty_make_timestamp($string); |
|
41 | + } elseif ($default_date != '') { |
|
42 | + $timestamp = smarty_make_timestamp($default_date); |
|
43 | + } else { |
|
44 | + return; |
|
45 | + } |
|
46 | + if ($formatter == 'strftime' || ($formatter == 'auto' && strpos($format, '%') !== false)) { |
|
47 | + if (DS == '\\') { |
|
48 | + $_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T'); |
|
49 | + $_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S'); |
|
50 | + if (strpos($format, '%e') !== false) { |
|
51 | + $_win_from[] = '%e'; |
|
52 | + $_win_to[] = sprintf('%\' 2d', date('j', $timestamp)); |
|
53 | + } |
|
54 | + if (strpos($format, '%l') !== false) { |
|
55 | + $_win_from[] = '%l'; |
|
56 | + $_win_to[] = sprintf('%\' 2d', date('h', $timestamp)); |
|
57 | + } |
|
58 | + $format = str_replace($_win_from, $_win_to, $format); |
|
59 | + } |
|
60 | 60 | |
61 | - return strftime($format, $timestamp); |
|
62 | - } else { |
|
63 | - return date($format, $timestamp); |
|
64 | - } |
|
61 | + return strftime($format, $timestamp); |
|
62 | + } else { |
|
63 | + return date($format, $timestamp); |
|
64 | + } |
|
65 | 65 | } |
@@ -25,15 +25,15 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function smarty_modifier_regex_replace($string, $search, $replace, $limit = - 1) |
27 | 27 | { |
28 | - if (is_array($search)) { |
|
29 | - foreach ($search as $idx => $s) { |
|
30 | - $search[ $idx ] = _smarty_regex_replace_check($s); |
|
31 | - } |
|
32 | - } else { |
|
33 | - $search = _smarty_regex_replace_check($search); |
|
34 | - } |
|
28 | + if (is_array($search)) { |
|
29 | + foreach ($search as $idx => $s) { |
|
30 | + $search[ $idx ] = _smarty_regex_replace_check($s); |
|
31 | + } |
|
32 | + } else { |
|
33 | + $search = _smarty_regex_replace_check($search); |
|
34 | + } |
|
35 | 35 | |
36 | - return preg_replace($search, $replace, $string, $limit); |
|
36 | + return preg_replace($search, $replace, $string, $limit); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -44,15 +44,15 @@ discard block |
||
44 | 44 | */ |
45 | 45 | function _smarty_regex_replace_check($search) |
46 | 46 | { |
47 | - // null-byte injection detection |
|
48 | - // anything behind the first null-byte is ignored |
|
49 | - if (($pos = strpos($search, "\0")) !== false) { |
|
50 | - $search = substr($search, 0, $pos); |
|
51 | - } |
|
52 | - // remove eval-modifier from $search |
|
53 | - if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[ 1 ], 'e') !== false)) { |
|
54 | - $search = substr($search, 0, - strlen($match[ 1 ])) . preg_replace('![e\s]+!', '', $match[ 1 ]); |
|
55 | - } |
|
47 | + // null-byte injection detection |
|
48 | + // anything behind the first null-byte is ignored |
|
49 | + if (($pos = strpos($search, "\0")) !== false) { |
|
50 | + $search = substr($search, 0, $pos); |
|
51 | + } |
|
52 | + // remove eval-modifier from $search |
|
53 | + if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[ 1 ], 'e') !== false)) { |
|
54 | + $search = substr($search, 0, - strlen($match[ 1 ])) . preg_replace('![e\s]+!', '', $match[ 1 ]); |
|
55 | + } |
|
56 | 56 | |
57 | - return $search; |
|
57 | + return $search; |
|
58 | 58 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | { |
28 | 28 | if (is_array($search)) { |
29 | 29 | foreach ($search as $idx => $s) { |
30 | - $search[ $idx ] = _smarty_regex_replace_check($s); |
|
30 | + $search[$idx] = _smarty_regex_replace_check($s); |
|
31 | 31 | } |
32 | 32 | } else { |
33 | 33 | $search = _smarty_regex_replace_check($search); |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | $search = substr($search, 0, $pos); |
51 | 51 | } |
52 | 52 | // remove eval-modifier from $search |
53 | - if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[ 1 ], 'e') !== false)) { |
|
54 | - $search = substr($search, 0, - strlen($match[ 1 ])) . preg_replace('![e\s]+!', '', $match[ 1 ]); |
|
53 | + if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) { |
|
54 | + $search = substr($search, 0, - strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | return $search; |
@@ -46,60 +46,60 @@ |
||
46 | 46 | |
47 | 47 | function smarty_function_cycle($params, $template) |
48 | 48 | { |
49 | - static $cycle_vars; |
|
49 | + static $cycle_vars; |
|
50 | 50 | |
51 | - $name = (empty($params[ 'name' ])) ? 'default' : $params[ 'name' ]; |
|
52 | - $print = (isset($params[ 'print' ])) ? (bool) $params[ 'print' ] : true; |
|
53 | - $advance = (isset($params[ 'advance' ])) ? (bool) $params[ 'advance' ] : true; |
|
54 | - $reset = (isset($params[ 'reset' ])) ? (bool) $params[ 'reset' ] : false; |
|
51 | + $name = (empty($params[ 'name' ])) ? 'default' : $params[ 'name' ]; |
|
52 | + $print = (isset($params[ 'print' ])) ? (bool) $params[ 'print' ] : true; |
|
53 | + $advance = (isset($params[ 'advance' ])) ? (bool) $params[ 'advance' ] : true; |
|
54 | + $reset = (isset($params[ 'reset' ])) ? (bool) $params[ 'reset' ] : false; |
|
55 | 55 | |
56 | - if (!isset($params[ 'values' ])) { |
|
57 | - if (!isset($cycle_vars[ $name ][ 'values' ])) { |
|
58 | - trigger_error("cycle: missing 'values' parameter"); |
|
56 | + if (!isset($params[ 'values' ])) { |
|
57 | + if (!isset($cycle_vars[ $name ][ 'values' ])) { |
|
58 | + trigger_error("cycle: missing 'values' parameter"); |
|
59 | 59 | |
60 | - return; |
|
61 | - } |
|
62 | - } else { |
|
63 | - if (isset($cycle_vars[ $name ][ 'values' ]) && $cycle_vars[ $name ][ 'values' ] != $params[ 'values' ]) { |
|
64 | - $cycle_vars[ $name ][ 'index' ] = 0; |
|
65 | - } |
|
66 | - $cycle_vars[ $name ][ 'values' ] = $params[ 'values' ]; |
|
67 | - } |
|
60 | + return; |
|
61 | + } |
|
62 | + } else { |
|
63 | + if (isset($cycle_vars[ $name ][ 'values' ]) && $cycle_vars[ $name ][ 'values' ] != $params[ 'values' ]) { |
|
64 | + $cycle_vars[ $name ][ 'index' ] = 0; |
|
65 | + } |
|
66 | + $cycle_vars[ $name ][ 'values' ] = $params[ 'values' ]; |
|
67 | + } |
|
68 | 68 | |
69 | - if (isset($params[ 'delimiter' ])) { |
|
70 | - $cycle_vars[ $name ][ 'delimiter' ] = $params[ 'delimiter' ]; |
|
71 | - } elseif (!isset($cycle_vars[ $name ][ 'delimiter' ])) { |
|
72 | - $cycle_vars[ $name ][ 'delimiter' ] = ','; |
|
73 | - } |
|
69 | + if (isset($params[ 'delimiter' ])) { |
|
70 | + $cycle_vars[ $name ][ 'delimiter' ] = $params[ 'delimiter' ]; |
|
71 | + } elseif (!isset($cycle_vars[ $name ][ 'delimiter' ])) { |
|
72 | + $cycle_vars[ $name ][ 'delimiter' ] = ','; |
|
73 | + } |
|
74 | 74 | |
75 | - if (is_array($cycle_vars[ $name ][ 'values' ])) { |
|
76 | - $cycle_array = $cycle_vars[ $name ][ 'values' ]; |
|
77 | - } else { |
|
78 | - $cycle_array = explode($cycle_vars[ $name ][ 'delimiter' ], $cycle_vars[ $name ][ 'values' ]); |
|
79 | - } |
|
75 | + if (is_array($cycle_vars[ $name ][ 'values' ])) { |
|
76 | + $cycle_array = $cycle_vars[ $name ][ 'values' ]; |
|
77 | + } else { |
|
78 | + $cycle_array = explode($cycle_vars[ $name ][ 'delimiter' ], $cycle_vars[ $name ][ 'values' ]); |
|
79 | + } |
|
80 | 80 | |
81 | - if (!isset($cycle_vars[ $name ][ 'index' ]) || $reset) { |
|
82 | - $cycle_vars[ $name ][ 'index' ] = 0; |
|
83 | - } |
|
81 | + if (!isset($cycle_vars[ $name ][ 'index' ]) || $reset) { |
|
82 | + $cycle_vars[ $name ][ 'index' ] = 0; |
|
83 | + } |
|
84 | 84 | |
85 | - if (isset($params[ 'assign' ])) { |
|
86 | - $print = false; |
|
87 | - $template->assign($params[ 'assign' ], $cycle_array[ $cycle_vars[ $name ][ 'index' ] ]); |
|
88 | - } |
|
85 | + if (isset($params[ 'assign' ])) { |
|
86 | + $print = false; |
|
87 | + $template->assign($params[ 'assign' ], $cycle_array[ $cycle_vars[ $name ][ 'index' ] ]); |
|
88 | + } |
|
89 | 89 | |
90 | - if ($print) { |
|
91 | - $retval = $cycle_array[ $cycle_vars[ $name ][ 'index' ] ]; |
|
92 | - } else { |
|
93 | - $retval = null; |
|
94 | - } |
|
90 | + if ($print) { |
|
91 | + $retval = $cycle_array[ $cycle_vars[ $name ][ 'index' ] ]; |
|
92 | + } else { |
|
93 | + $retval = null; |
|
94 | + } |
|
95 | 95 | |
96 | - if ($advance) { |
|
97 | - if ($cycle_vars[ $name ][ 'index' ] >= count($cycle_array) - 1) { |
|
98 | - $cycle_vars[ $name ][ 'index' ] = 0; |
|
99 | - } else { |
|
100 | - $cycle_vars[ $name ][ 'index' ] ++; |
|
101 | - } |
|
102 | - } |
|
96 | + if ($advance) { |
|
97 | + if ($cycle_vars[ $name ][ 'index' ] >= count($cycle_array) - 1) { |
|
98 | + $cycle_vars[ $name ][ 'index' ] = 0; |
|
99 | + } else { |
|
100 | + $cycle_vars[ $name ][ 'index' ] ++; |
|
101 | + } |
|
102 | + } |
|
103 | 103 | |
104 | - return $retval; |
|
104 | + return $retval; |
|
105 | 105 | } |
@@ -48,56 +48,56 @@ |
||
48 | 48 | { |
49 | 49 | static $cycle_vars; |
50 | 50 | |
51 | - $name = (empty($params[ 'name' ])) ? 'default' : $params[ 'name' ]; |
|
52 | - $print = (isset($params[ 'print' ])) ? (bool) $params[ 'print' ] : true; |
|
53 | - $advance = (isset($params[ 'advance' ])) ? (bool) $params[ 'advance' ] : true; |
|
54 | - $reset = (isset($params[ 'reset' ])) ? (bool) $params[ 'reset' ] : false; |
|
51 | + $name = (empty($params['name'])) ? 'default' : $params['name']; |
|
52 | + $print = (isset($params['print'])) ? (bool) $params['print'] : true; |
|
53 | + $advance = (isset($params['advance'])) ? (bool) $params['advance'] : true; |
|
54 | + $reset = (isset($params['reset'])) ? (bool) $params['reset'] : false; |
|
55 | 55 | |
56 | - if (!isset($params[ 'values' ])) { |
|
57 | - if (!isset($cycle_vars[ $name ][ 'values' ])) { |
|
56 | + if (!isset($params['values'])) { |
|
57 | + if (!isset($cycle_vars[$name]['values'])) { |
|
58 | 58 | trigger_error("cycle: missing 'values' parameter"); |
59 | 59 | |
60 | 60 | return; |
61 | 61 | } |
62 | 62 | } else { |
63 | - if (isset($cycle_vars[ $name ][ 'values' ]) && $cycle_vars[ $name ][ 'values' ] != $params[ 'values' ]) { |
|
64 | - $cycle_vars[ $name ][ 'index' ] = 0; |
|
63 | + if (isset($cycle_vars[$name]['values']) && $cycle_vars[$name]['values'] != $params['values']) { |
|
64 | + $cycle_vars[$name]['index'] = 0; |
|
65 | 65 | } |
66 | - $cycle_vars[ $name ][ 'values' ] = $params[ 'values' ]; |
|
66 | + $cycle_vars[$name]['values'] = $params['values']; |
|
67 | 67 | } |
68 | 68 | |
69 | - if (isset($params[ 'delimiter' ])) { |
|
70 | - $cycle_vars[ $name ][ 'delimiter' ] = $params[ 'delimiter' ]; |
|
71 | - } elseif (!isset($cycle_vars[ $name ][ 'delimiter' ])) { |
|
72 | - $cycle_vars[ $name ][ 'delimiter' ] = ','; |
|
69 | + if (isset($params['delimiter'])) { |
|
70 | + $cycle_vars[$name]['delimiter'] = $params['delimiter']; |
|
71 | + } elseif (!isset($cycle_vars[$name]['delimiter'])) { |
|
72 | + $cycle_vars[$name]['delimiter'] = ','; |
|
73 | 73 | } |
74 | 74 | |
75 | - if (is_array($cycle_vars[ $name ][ 'values' ])) { |
|
76 | - $cycle_array = $cycle_vars[ $name ][ 'values' ]; |
|
75 | + if (is_array($cycle_vars[$name]['values'])) { |
|
76 | + $cycle_array = $cycle_vars[$name]['values']; |
|
77 | 77 | } else { |
78 | - $cycle_array = explode($cycle_vars[ $name ][ 'delimiter' ], $cycle_vars[ $name ][ 'values' ]); |
|
78 | + $cycle_array = explode($cycle_vars[$name]['delimiter'], $cycle_vars[$name]['values']); |
|
79 | 79 | } |
80 | 80 | |
81 | - if (!isset($cycle_vars[ $name ][ 'index' ]) || $reset) { |
|
82 | - $cycle_vars[ $name ][ 'index' ] = 0; |
|
81 | + if (!isset($cycle_vars[$name]['index']) || $reset) { |
|
82 | + $cycle_vars[$name]['index'] = 0; |
|
83 | 83 | } |
84 | 84 | |
85 | - if (isset($params[ 'assign' ])) { |
|
85 | + if (isset($params['assign'])) { |
|
86 | 86 | $print = false; |
87 | - $template->assign($params[ 'assign' ], $cycle_array[ $cycle_vars[ $name ][ 'index' ] ]); |
|
87 | + $template->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | if ($print) { |
91 | - $retval = $cycle_array[ $cycle_vars[ $name ][ 'index' ] ]; |
|
91 | + $retval = $cycle_array[$cycle_vars[$name]['index']]; |
|
92 | 92 | } else { |
93 | 93 | $retval = null; |
94 | 94 | } |
95 | 95 | |
96 | 96 | if ($advance) { |
97 | - if ($cycle_vars[ $name ][ 'index' ] >= count($cycle_array) - 1) { |
|
98 | - $cycle_vars[ $name ][ 'index' ] = 0; |
|
97 | + if ($cycle_vars[$name]['index'] >= count($cycle_array) - 1) { |
|
98 | + $cycle_vars[$name]['index'] = 0; |
|
99 | 99 | } else { |
100 | - $cycle_vars[ $name ][ 'index' ] ++; |
|
100 | + $cycle_vars[$name]['index']++; |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 |