@@ -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 | |
@@ -21,9 +21,9 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | function smarty_modifiercompiler_strip_tags($params) |
| 23 | 23 | { |
| 24 | - if (!isset($params[ 1 ]) || $params[ 1 ] === true || trim($params[ 1 ], '"') == 'true') { |
|
| 25 | - return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})"; |
|
| 26 | - } else { |
|
| 27 | - return 'strip_tags(' . $params[ 0 ] . ')'; |
|
| 28 | - } |
|
| 24 | + if (!isset($params[ 1 ]) || $params[ 1 ] === true || trim($params[ 1 ], '"') == 'true') { |
|
| 25 | + return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})"; |
|
| 26 | + } else { |
|
| 27 | + return 'strip_tags(' . $params[ 0 ] . ')'; |
|
| 28 | + } |
|
| 29 | 29 | } |
@@ -21,9 +21,9 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | function smarty_modifiercompiler_strip_tags($params) |
| 23 | 23 | { |
| 24 | - if (!isset($params[ 1 ]) || $params[ 1 ] === true || trim($params[ 1 ], '"') == 'true') { |
|
| 24 | + if (!isset($params[1]) || $params[1] === true || trim($params[1], '"') == 'true') { |
|
| 25 | 25 | return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})"; |
| 26 | 26 | } else { |
| 27 | - return 'strip_tags(' . $params[ 0 ] . ')'; |
|
| 27 | + return 'strip_tags(' . $params[0] . ')'; |
|
| 28 | 28 | } |
| 29 | 29 | } |
@@ -27,40 +27,40 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false) |
| 29 | 29 | { |
| 30 | - if ($length == 0) { |
|
| 31 | - return ''; |
|
| 32 | - } |
|
| 30 | + if ($length == 0) { |
|
| 31 | + return ''; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - if (Smarty::$_MBSTRING) { |
|
| 35 | - if (mb_strlen($string, Smarty::$_CHARSET) > $length) { |
|
| 36 | - $length -= min($length, mb_strlen($etc, Smarty::$_CHARSET)); |
|
| 37 | - if (!$break_words && !$middle) { |
|
| 38 | - $string = preg_replace('/\s+?(\S+)?$/' . Smarty::$_UTF8_MODIFIER, '', |
|
| 39 | - mb_substr($string, 0, $length + 1, Smarty::$_CHARSET)); |
|
| 40 | - } |
|
| 41 | - if (!$middle) { |
|
| 42 | - return mb_substr($string, 0, $length, Smarty::$_CHARSET) . $etc; |
|
| 43 | - } |
|
| 34 | + if (Smarty::$_MBSTRING) { |
|
| 35 | + if (mb_strlen($string, Smarty::$_CHARSET) > $length) { |
|
| 36 | + $length -= min($length, mb_strlen($etc, Smarty::$_CHARSET)); |
|
| 37 | + if (!$break_words && !$middle) { |
|
| 38 | + $string = preg_replace('/\s+?(\S+)?$/' . Smarty::$_UTF8_MODIFIER, '', |
|
| 39 | + mb_substr($string, 0, $length + 1, Smarty::$_CHARSET)); |
|
| 40 | + } |
|
| 41 | + if (!$middle) { |
|
| 42 | + return mb_substr($string, 0, $length, Smarty::$_CHARSET) . $etc; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - return mb_substr($string, 0, $length / 2, Smarty::$_CHARSET) . $etc . |
|
| 46 | - mb_substr($string, - $length / 2, $length, Smarty::$_CHARSET); |
|
| 47 | - } |
|
| 45 | + return mb_substr($string, 0, $length / 2, Smarty::$_CHARSET) . $etc . |
|
| 46 | + mb_substr($string, - $length / 2, $length, Smarty::$_CHARSET); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - return $string; |
|
| 50 | - } |
|
| 49 | + return $string; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - // no MBString fallback |
|
| 53 | - if (isset($string[ $length ])) { |
|
| 54 | - $length -= min($length, strlen($etc)); |
|
| 55 | - if (!$break_words && !$middle) { |
|
| 56 | - $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1)); |
|
| 57 | - } |
|
| 58 | - if (!$middle) { |
|
| 59 | - return substr($string, 0, $length) . $etc; |
|
| 60 | - } |
|
| 52 | + // no MBString fallback |
|
| 53 | + if (isset($string[ $length ])) { |
|
| 54 | + $length -= min($length, strlen($etc)); |
|
| 55 | + if (!$break_words && !$middle) { |
|
| 56 | + $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1)); |
|
| 57 | + } |
|
| 58 | + if (!$middle) { |
|
| 59 | + return substr($string, 0, $length) . $etc; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - return substr($string, 0, $length / 2) . $etc . substr($string, - $length / 2); |
|
| 63 | - } |
|
| 62 | + return substr($string, 0, $length / 2) . $etc . substr($string, - $length / 2); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - return $string; |
|
| 65 | + return $string; |
|
| 66 | 66 | } |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // no MBString fallback |
| 53 | - if (isset($string[ $length ])) { |
|
| 53 | + if (isset($string[$length])) { |
|
| 54 | 54 | $length -= min($length, strlen($etc)); |
| 55 | 55 | if (!$break_words && !$middle) { |
| 56 | 56 | $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1)); |
@@ -20,13 +20,13 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | function smarty_modifiercompiler_to_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 ] . ', ' . $params[ 1 ] . ', "' . addslashes(Smarty::$_CHARSET) . '")'; |
|
| 31 | + return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 1 ] . ', "' . addslashes(Smarty::$_CHARSET) . '")'; |
|
| 32 | 32 | } |
@@ -21,12 +21,12 @@ |
||
| 21 | 21 | function smarty_modifiercompiler_to_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 ] . ', ' . $params[ 1 ] . ', "' . addslashes(Smarty::$_CHARSET) . '")'; |
|
| 31 | + return 'mb_convert_encoding(' . $params[0] . ', ' . $params[1] . ', "' . addslashes(Smarty::$_CHARSET) . '")'; |
|
| 32 | 32 | } |
@@ -20,31 +20,31 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | function smarty_modifiercompiler_unescape($params) |
| 22 | 22 | { |
| 23 | - if (!isset($params[ 1 ])) { |
|
| 24 | - $params[ 1 ] = 'html'; |
|
| 25 | - } |
|
| 26 | - if (!isset($params[ 2 ])) { |
|
| 27 | - $params[ 2 ] = '\'' . addslashes(Smarty::$_CHARSET) . '\''; |
|
| 28 | - } else { |
|
| 29 | - $params[ 2 ] = "'" . $params[ 2 ] . "'"; |
|
| 30 | - } |
|
| 23 | + if (!isset($params[ 1 ])) { |
|
| 24 | + $params[ 1 ] = 'html'; |
|
| 25 | + } |
|
| 26 | + if (!isset($params[ 2 ])) { |
|
| 27 | + $params[ 2 ] = '\'' . addslashes(Smarty::$_CHARSET) . '\''; |
|
| 28 | + } else { |
|
| 29 | + $params[ 2 ] = "'" . $params[ 2 ] . "'"; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - switch (trim($params[ 1 ], '"\'')) { |
|
| 33 | - case 'entity': |
|
| 34 | - case 'htmlall': |
|
| 35 | - if (Smarty::$_MBSTRING) { |
|
| 36 | - return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 2 ] . ', \'HTML-ENTITIES\')'; |
|
| 37 | - } |
|
| 32 | + switch (trim($params[ 1 ], '"\'')) { |
|
| 33 | + case 'entity': |
|
| 34 | + case 'htmlall': |
|
| 35 | + if (Smarty::$_MBSTRING) { |
|
| 36 | + return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 2 ] . ', \'HTML-ENTITIES\')'; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - return 'html_entity_decode(' . $params[ 0 ] . ', ENT_NOQUOTES, ' . $params[ 2 ] . ')'; |
|
| 39 | + return 'html_entity_decode(' . $params[ 0 ] . ', ENT_NOQUOTES, ' . $params[ 2 ] . ')'; |
|
| 40 | 40 | |
| 41 | - case 'html': |
|
| 42 | - return 'htmlspecialchars_decode(' . $params[ 0 ] . ', ENT_QUOTES)'; |
|
| 41 | + case 'html': |
|
| 42 | + return 'htmlspecialchars_decode(' . $params[ 0 ] . ', ENT_QUOTES)'; |
|
| 43 | 43 | |
| 44 | - case 'url': |
|
| 45 | - return 'rawurldecode(' . $params[ 0 ] . ')'; |
|
| 44 | + case 'url': |
|
| 45 | + return 'rawurldecode(' . $params[ 0 ] . ')'; |
|
| 46 | 46 | |
| 47 | - default: |
|
| 48 | - return $params[ 0 ]; |
|
| 49 | - } |
|
| 47 | + default: |
|
| 48 | + return $params[ 0 ]; |
|
| 49 | + } |
|
| 50 | 50 | } |
@@ -20,31 +20,31 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | function smarty_modifiercompiler_unescape($params) |
| 22 | 22 | { |
| 23 | - if (!isset($params[ 1 ])) { |
|
| 24 | - $params[ 1 ] = 'html'; |
|
| 23 | + if (!isset($params[1])) { |
|
| 24 | + $params[1] = 'html'; |
|
| 25 | 25 | } |
| 26 | - if (!isset($params[ 2 ])) { |
|
| 27 | - $params[ 2 ] = '\'' . addslashes(Smarty::$_CHARSET) . '\''; |
|
| 26 | + if (!isset($params[2])) { |
|
| 27 | + $params[2] = '\'' . addslashes(Smarty::$_CHARSET) . '\''; |
|
| 28 | 28 | } else { |
| 29 | - $params[ 2 ] = "'" . $params[ 2 ] . "'"; |
|
| 29 | + $params[2] = "'" . $params[2] . "'"; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - switch (trim($params[ 1 ], '"\'')) { |
|
| 32 | + switch (trim($params[1], '"\'')) { |
|
| 33 | 33 | case 'entity': |
| 34 | 34 | case 'htmlall': |
| 35 | 35 | if (Smarty::$_MBSTRING) { |
| 36 | - return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 2 ] . ', \'HTML-ENTITIES\')'; |
|
| 36 | + return 'mb_convert_encoding(' . $params[0] . ', ' . $params[2] . ', \'HTML-ENTITIES\')'; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - return 'html_entity_decode(' . $params[ 0 ] . ', ENT_NOQUOTES, ' . $params[ 2 ] . ')'; |
|
| 39 | + return 'html_entity_decode(' . $params[0] . ', ENT_NOQUOTES, ' . $params[2] . ')'; |
|
| 40 | 40 | |
| 41 | 41 | case 'html': |
| 42 | - return 'htmlspecialchars_decode(' . $params[ 0 ] . ', ENT_QUOTES)'; |
|
| 42 | + return 'htmlspecialchars_decode(' . $params[0] . ', ENT_QUOTES)'; |
|
| 43 | 43 | |
| 44 | 44 | case 'url': |
| 45 | - return 'rawurldecode(' . $params[ 0 ] . ')'; |
|
| 45 | + return 'rawurldecode(' . $params[0] . ')'; |
|
| 46 | 46 | |
| 47 | 47 | default: |
| 48 | - return $params[ 0 ]; |
|
| 48 | + return $params[0]; |
|
| 49 | 49 | } |
| 50 | 50 | } |
@@ -22,6 +22,6 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | function smarty_modifier_spacify($string, $spacify_char = ' ') |
| 24 | 24 | { |
| 25 | - // well… what about charsets besides latin and UTF-8? |
|
| 26 | - return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, - 1, PREG_SPLIT_NO_EMPTY)); |
|
| 25 | + // well… what about charsets besides latin and UTF-8? |
|
| 26 | + return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, - 1, PREG_SPLIT_NO_EMPTY)); |
|
| 27 | 27 | } |
@@ -24,89 +24,89 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth = 0, $objects = array()) |
| 26 | 26 | { |
| 27 | - $_replace = array("\n" => '\n', "\r" => '\r', "\t" => '\t'); |
|
| 28 | - switch (gettype($var)) { |
|
| 29 | - case 'array' : |
|
| 30 | - $results = '<b>Array (' . count($var) . ')</b>'; |
|
| 31 | - if ($depth == $max) { |
|
| 32 | - break; |
|
| 33 | - } |
|
| 34 | - foreach ($var as $curr_key => $curr_val) { |
|
| 35 | - $results .= '<br>' . str_repeat(' ', $depth * 2) . '<b>' . strtr($curr_key, $_replace) . |
|
| 36 | - '</b> => ' . |
|
| 37 | - smarty_modifier_debug_print_var($curr_val, $max, $length, ++ $depth, $objects); |
|
| 38 | - $depth --; |
|
| 39 | - } |
|
| 40 | - break; |
|
| 27 | + $_replace = array("\n" => '\n', "\r" => '\r', "\t" => '\t'); |
|
| 28 | + switch (gettype($var)) { |
|
| 29 | + case 'array' : |
|
| 30 | + $results = '<b>Array (' . count($var) . ')</b>'; |
|
| 31 | + if ($depth == $max) { |
|
| 32 | + break; |
|
| 33 | + } |
|
| 34 | + foreach ($var as $curr_key => $curr_val) { |
|
| 35 | + $results .= '<br>' . str_repeat(' ', $depth * 2) . '<b>' . strtr($curr_key, $_replace) . |
|
| 36 | + '</b> => ' . |
|
| 37 | + smarty_modifier_debug_print_var($curr_val, $max, $length, ++ $depth, $objects); |
|
| 38 | + $depth --; |
|
| 39 | + } |
|
| 40 | + break; |
|
| 41 | 41 | |
| 42 | - case 'object' : |
|
| 43 | - $object_vars = get_object_vars($var); |
|
| 44 | - $results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>'; |
|
| 45 | - if (in_array($var, $objects)) { |
|
| 46 | - $results .= ' called recursive'; |
|
| 47 | - break; |
|
| 48 | - } |
|
| 49 | - if ($depth == $max) { |
|
| 50 | - break; |
|
| 51 | - } |
|
| 52 | - $objects[] = $var; |
|
| 53 | - foreach ($object_vars as $curr_key => $curr_val) { |
|
| 54 | - $results .= '<br>' . str_repeat(' ', $depth * 2) . '<b> ->' . strtr($curr_key, $_replace) . |
|
| 55 | - '</b> = ' . smarty_modifier_debug_print_var($curr_val, $max, $length, ++ $depth, $objects); |
|
| 56 | - $depth --; |
|
| 57 | - } |
|
| 58 | - break; |
|
| 42 | + case 'object' : |
|
| 43 | + $object_vars = get_object_vars($var); |
|
| 44 | + $results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>'; |
|
| 45 | + if (in_array($var, $objects)) { |
|
| 46 | + $results .= ' called recursive'; |
|
| 47 | + break; |
|
| 48 | + } |
|
| 49 | + if ($depth == $max) { |
|
| 50 | + break; |
|
| 51 | + } |
|
| 52 | + $objects[] = $var; |
|
| 53 | + foreach ($object_vars as $curr_key => $curr_val) { |
|
| 54 | + $results .= '<br>' . str_repeat(' ', $depth * 2) . '<b> ->' . strtr($curr_key, $_replace) . |
|
| 55 | + '</b> = ' . smarty_modifier_debug_print_var($curr_val, $max, $length, ++ $depth, $objects); |
|
| 56 | + $depth --; |
|
| 57 | + } |
|
| 58 | + break; |
|
| 59 | 59 | |
| 60 | - case 'boolean' : |
|
| 61 | - case 'NULL' : |
|
| 62 | - case 'resource' : |
|
| 63 | - if (true === $var) { |
|
| 64 | - $results = 'true'; |
|
| 65 | - } elseif (false === $var) { |
|
| 66 | - $results = 'false'; |
|
| 67 | - } elseif (null === $var) { |
|
| 68 | - $results = 'null'; |
|
| 69 | - } else { |
|
| 70 | - $results = htmlspecialchars((string) $var); |
|
| 71 | - } |
|
| 72 | - $results = '<i>' . $results . '</i>'; |
|
| 73 | - break; |
|
| 60 | + case 'boolean' : |
|
| 61 | + case 'NULL' : |
|
| 62 | + case 'resource' : |
|
| 63 | + if (true === $var) { |
|
| 64 | + $results = 'true'; |
|
| 65 | + } elseif (false === $var) { |
|
| 66 | + $results = 'false'; |
|
| 67 | + } elseif (null === $var) { |
|
| 68 | + $results = 'null'; |
|
| 69 | + } else { |
|
| 70 | + $results = htmlspecialchars((string) $var); |
|
| 71 | + } |
|
| 72 | + $results = '<i>' . $results . '</i>'; |
|
| 73 | + break; |
|
| 74 | 74 | |
| 75 | - case 'integer' : |
|
| 76 | - case 'float' : |
|
| 77 | - $results = htmlspecialchars((string) $var); |
|
| 78 | - break; |
|
| 75 | + case 'integer' : |
|
| 76 | + case 'float' : |
|
| 77 | + $results = htmlspecialchars((string) $var); |
|
| 78 | + break; |
|
| 79 | 79 | |
| 80 | - case 'string' : |
|
| 81 | - $results = strtr($var, $_replace); |
|
| 82 | - if (Smarty::$_MBSTRING) { |
|
| 83 | - if (mb_strlen($var, Smarty::$_CHARSET) > $length) { |
|
| 84 | - $results = mb_substr($var, 0, $length - 3, Smarty::$_CHARSET) . '...'; |
|
| 85 | - } |
|
| 86 | - } else { |
|
| 87 | - if (isset($var[ $length ])) { |
|
| 88 | - $results = substr($var, 0, $length - 3) . '...'; |
|
| 89 | - } |
|
| 90 | - } |
|
| 80 | + case 'string' : |
|
| 81 | + $results = strtr($var, $_replace); |
|
| 82 | + if (Smarty::$_MBSTRING) { |
|
| 83 | + if (mb_strlen($var, Smarty::$_CHARSET) > $length) { |
|
| 84 | + $results = mb_substr($var, 0, $length - 3, Smarty::$_CHARSET) . '...'; |
|
| 85 | + } |
|
| 86 | + } else { |
|
| 87 | + if (isset($var[ $length ])) { |
|
| 88 | + $results = substr($var, 0, $length - 3) . '...'; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - $results = htmlspecialchars('"' . $results . '"', ENT_QUOTES, Smarty::$_CHARSET); |
|
| 93 | - break; |
|
| 92 | + $results = htmlspecialchars('"' . $results . '"', ENT_QUOTES, Smarty::$_CHARSET); |
|
| 93 | + break; |
|
| 94 | 94 | |
| 95 | - case 'unknown type' : |
|
| 96 | - default : |
|
| 97 | - $results = strtr((string) $var, $_replace); |
|
| 98 | - if (Smarty::$_MBSTRING) { |
|
| 99 | - if (mb_strlen($results, Smarty::$_CHARSET) > $length) { |
|
| 100 | - $results = mb_substr($results, 0, $length - 3, Smarty::$_CHARSET) . '...'; |
|
| 101 | - } |
|
| 102 | - } else { |
|
| 103 | - if (strlen($results) > $length) { |
|
| 104 | - $results = substr($results, 0, $length - 3) . '...'; |
|
| 105 | - } |
|
| 106 | - } |
|
| 95 | + case 'unknown type' : |
|
| 96 | + default : |
|
| 97 | + $results = strtr((string) $var, $_replace); |
|
| 98 | + if (Smarty::$_MBSTRING) { |
|
| 99 | + if (mb_strlen($results, Smarty::$_CHARSET) > $length) { |
|
| 100 | + $results = mb_substr($results, 0, $length - 3, Smarty::$_CHARSET) . '...'; |
|
| 101 | + } |
|
| 102 | + } else { |
|
| 103 | + if (strlen($results) > $length) { |
|
| 104 | + $results = substr($results, 0, $length - 3) . '...'; |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - $results = htmlspecialchars($results, ENT_QUOTES, Smarty::$_CHARSET); |
|
| 109 | - } |
|
| 108 | + $results = htmlspecialchars($results, ENT_QUOTES, Smarty::$_CHARSET); |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - return $results; |
|
| 111 | + return $results; |
|
| 112 | 112 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $results .= '<br>' . str_repeat(' ', $depth * 2) . '<b>' . strtr($curr_key, $_replace) . |
| 36 | 36 | '</b> => ' . |
| 37 | 37 | smarty_modifier_debug_print_var($curr_val, $max, $length, ++ $depth, $objects); |
| 38 | - $depth --; |
|
| 38 | + $depth--; |
|
| 39 | 39 | } |
| 40 | 40 | break; |
| 41 | 41 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | foreach ($object_vars as $curr_key => $curr_val) { |
| 54 | 54 | $results .= '<br>' . str_repeat(' ', $depth * 2) . '<b> ->' . strtr($curr_key, $_replace) . |
| 55 | 55 | '</b> = ' . smarty_modifier_debug_print_var($curr_val, $max, $length, ++ $depth, $objects); |
| 56 | - $depth --; |
|
| 56 | + $depth--; |
|
| 57 | 57 | } |
| 58 | 58 | break; |
| 59 | 59 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | $results = mb_substr($var, 0, $length - 3, Smarty::$_CHARSET) . '...'; |
| 85 | 85 | } |
| 86 | 86 | } else { |
| 87 | - if (isset($var[ $length ])) { |
|
| 87 | + if (isset($var[$length])) { |
|
| 88 | 88 | $results = substr($var, 0, $length - 3) . '...'; |
| 89 | 89 | } |
| 90 | 90 | } |
@@ -33,334 +33,334 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | function smarty_function_html_select_time($params) |
| 35 | 35 | { |
| 36 | - $prefix = "Time_"; |
|
| 37 | - $field_array = null; |
|
| 38 | - $field_separator = "\n"; |
|
| 39 | - $option_separator = "\n"; |
|
| 40 | - $time = null; |
|
| 41 | - |
|
| 42 | - $display_hours = true; |
|
| 43 | - $display_minutes = true; |
|
| 44 | - $display_seconds = true; |
|
| 45 | - $display_meridian = true; |
|
| 46 | - |
|
| 47 | - $hour_format = '%02d'; |
|
| 48 | - $hour_value_format = '%02d'; |
|
| 49 | - $minute_format = '%02d'; |
|
| 50 | - $minute_value_format = '%02d'; |
|
| 51 | - $second_format = '%02d'; |
|
| 52 | - $second_value_format = '%02d'; |
|
| 53 | - |
|
| 54 | - $hour_size = null; |
|
| 55 | - $minute_size = null; |
|
| 56 | - $second_size = null; |
|
| 57 | - $meridian_size = null; |
|
| 58 | - |
|
| 59 | - $all_empty = null; |
|
| 60 | - $hour_empty = null; |
|
| 61 | - $minute_empty = null; |
|
| 62 | - $second_empty = null; |
|
| 63 | - $meridian_empty = null; |
|
| 64 | - |
|
| 65 | - $all_id = null; |
|
| 66 | - $hour_id = null; |
|
| 67 | - $minute_id = null; |
|
| 68 | - $second_id = null; |
|
| 69 | - $meridian_id = null; |
|
| 70 | - |
|
| 71 | - $use_24_hours = true; |
|
| 72 | - $minute_interval = 1; |
|
| 73 | - $second_interval = 1; |
|
| 74 | - |
|
| 75 | - $extra_attrs = ''; |
|
| 76 | - $all_extra = null; |
|
| 77 | - $hour_extra = null; |
|
| 78 | - $minute_extra = null; |
|
| 79 | - $second_extra = null; |
|
| 80 | - $meridian_extra = null; |
|
| 81 | - |
|
| 82 | - foreach ($params as $_key => $_value) { |
|
| 83 | - switch ($_key) { |
|
| 84 | - case 'time': |
|
| 85 | - if (!is_array($_value) && $_value !== null) { |
|
| 86 | - $time = smarty_make_timestamp($_value); |
|
| 87 | - } |
|
| 88 | - break; |
|
| 89 | - |
|
| 90 | - case 'prefix': |
|
| 91 | - case 'field_array': |
|
| 92 | - |
|
| 93 | - case 'field_separator': |
|
| 94 | - case 'option_separator': |
|
| 95 | - |
|
| 96 | - case 'all_extra': |
|
| 97 | - case 'hour_extra': |
|
| 98 | - case 'minute_extra': |
|
| 99 | - case 'second_extra': |
|
| 100 | - case 'meridian_extra': |
|
| 101 | - |
|
| 102 | - case 'all_empty': |
|
| 103 | - case 'hour_empty': |
|
| 104 | - case 'minute_empty': |
|
| 105 | - case 'second_empty': |
|
| 106 | - case 'meridian_empty': |
|
| 107 | - |
|
| 108 | - case 'all_id': |
|
| 109 | - case 'hour_id': |
|
| 110 | - case 'minute_id': |
|
| 111 | - case 'second_id': |
|
| 112 | - case 'meridian_id': |
|
| 113 | - |
|
| 114 | - case 'hour_format': |
|
| 115 | - case 'hour_value_format': |
|
| 116 | - case 'minute_format': |
|
| 117 | - case 'minute_value_format': |
|
| 118 | - case 'second_format': |
|
| 119 | - case 'second_value_format': |
|
| 120 | - $$_key = (string) $_value; |
|
| 121 | - break; |
|
| 122 | - |
|
| 123 | - case 'display_hours': |
|
| 124 | - case 'display_minutes': |
|
| 125 | - case 'display_seconds': |
|
| 126 | - case 'display_meridian': |
|
| 127 | - case 'use_24_hours': |
|
| 128 | - $$_key = (bool) $_value; |
|
| 129 | - break; |
|
| 130 | - |
|
| 131 | - case 'minute_interval': |
|
| 132 | - case 'second_interval': |
|
| 133 | - |
|
| 134 | - case 'hour_size': |
|
| 135 | - case 'minute_size': |
|
| 136 | - case 'second_size': |
|
| 137 | - case 'meridian_size': |
|
| 138 | - $$_key = (int) $_value; |
|
| 139 | - break; |
|
| 140 | - |
|
| 141 | - default: |
|
| 142 | - if (!is_array($_value)) { |
|
| 143 | - $extra_attrs .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_value) . '"'; |
|
| 144 | - } else { |
|
| 145 | - trigger_error("html_select_date: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
|
| 146 | - } |
|
| 147 | - break; |
|
| 148 | - } |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) { |
|
| 152 | - if (isset($params[ 'time' ][ $prefix . 'Hour' ])) { |
|
| 153 | - // $_REQUEST[$field_array] given |
|
| 154 | - foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) { |
|
| 155 | - $_variableName = '_' . strtolower($_elementName); |
|
| 156 | - $$_variableName = |
|
| 157 | - isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] : |
|
| 158 | - date($_elementKey); |
|
| 159 | - } |
|
| 160 | - $_meridian = |
|
| 161 | - isset($params[ 'time' ][ $prefix . 'Meridian' ]) ? (' ' . $params[ 'time' ][ $prefix . 'Meridian' ]) : |
|
| 162 | - ''; |
|
| 163 | - $time = strtotime($_hour . ':' . $_minute . ':' . $_second . $_meridian); |
|
| 164 | - list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time)); |
|
| 165 | - } elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Hour' ])) { |
|
| 166 | - // $_REQUEST given |
|
| 167 | - foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) { |
|
| 168 | - $_variableName = '_' . strtolower($_elementName); |
|
| 169 | - $$_variableName = isset($params[ 'time' ][ $field_array ][ $prefix . $_elementName ]) ? |
|
| 170 | - $params[ 'time' ][ $field_array ][ $prefix . $_elementName ] : date($_elementKey); |
|
| 171 | - } |
|
| 172 | - $_meridian = isset($params[ 'time' ][ $field_array ][ $prefix . 'Meridian' ]) ? |
|
| 173 | - (' ' . $params[ 'time' ][ $field_array ][ $prefix . 'Meridian' ]) : ''; |
|
| 174 | - $time = strtotime($_hour . ':' . $_minute . ':' . $_second . $_meridian); |
|
| 175 | - list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time)); |
|
| 176 | - } else { |
|
| 177 | - // no date found, use NOW |
|
| 178 | - list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d')); |
|
| 179 | - } |
|
| 180 | - } elseif ($time === null) { |
|
| 181 | - if (array_key_exists('time', $params)) { |
|
| 182 | - $_hour = $_minute = $_second = $time = null; |
|
| 183 | - } else { |
|
| 184 | - list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s')); |
|
| 185 | - } |
|
| 186 | - } else { |
|
| 187 | - list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time)); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - // generate hour <select> |
|
| 191 | - if ($display_hours) { |
|
| 192 | - $_html_hours = ''; |
|
| 193 | - $_extra = ''; |
|
| 194 | - $_name = $field_array ? ($field_array . '[' . $prefix . 'Hour]') : ($prefix . 'Hour'); |
|
| 195 | - if ($all_extra) { |
|
| 196 | - $_extra .= ' ' . $all_extra; |
|
| 197 | - } |
|
| 198 | - if ($hour_extra) { |
|
| 199 | - $_extra .= ' ' . $hour_extra; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - $_html_hours = '<select name="' . $_name . '"'; |
|
| 203 | - if ($hour_id !== null || $all_id !== null) { |
|
| 204 | - $_html_hours .= ' id="' . |
|
| 205 | - smarty_function_escape_special_chars($hour_id !== null ? ($hour_id ? $hour_id : $_name) : |
|
| 206 | - ($all_id ? ($all_id . $_name) : $_name)) . '"'; |
|
| 207 | - } |
|
| 208 | - if ($hour_size) { |
|
| 209 | - $_html_hours .= ' size="' . $hour_size . '"'; |
|
| 210 | - } |
|
| 211 | - $_html_hours .= $_extra . $extra_attrs . '>' . $option_separator; |
|
| 212 | - |
|
| 213 | - if (isset($hour_empty) || isset($all_empty)) { |
|
| 214 | - $_html_hours .= '<option value="">' . (isset($hour_empty) ? $hour_empty : $all_empty) . '</option>' . |
|
| 215 | - $option_separator; |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - $start = $use_24_hours ? 0 : 1; |
|
| 219 | - $end = $use_24_hours ? 23 : 12; |
|
| 220 | - for ($i = $start; $i <= $end; $i ++) { |
|
| 221 | - $_val = sprintf('%02d', $i); |
|
| 222 | - $_text = $hour_format == '%02d' ? $_val : sprintf($hour_format, $i); |
|
| 223 | - $_value = $hour_value_format == '%02d' ? $_val : sprintf($hour_value_format, $i); |
|
| 224 | - |
|
| 225 | - if (!$use_24_hours) { |
|
| 226 | - $_hour12 = $_hour == 0 ? 12 : ($_hour <= 12 ? $_hour : $_hour - 12); |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - $selected = $_hour !== null ? ($use_24_hours ? $_hour == $_val : $_hour12 == $_val) : null; |
|
| 230 | - $_html_hours .= '<option value="' . $_value . '"' . ($selected ? ' selected="selected"' : '') . '>' . |
|
| 231 | - $_text . '</option>' . $option_separator; |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - $_html_hours .= '</select>'; |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - // generate minute <select> |
|
| 238 | - if ($display_minutes) { |
|
| 239 | - $_html_minutes = ''; |
|
| 240 | - $_extra = ''; |
|
| 241 | - $_name = $field_array ? ($field_array . '[' . $prefix . 'Minute]') : ($prefix . 'Minute'); |
|
| 242 | - if ($all_extra) { |
|
| 243 | - $_extra .= ' ' . $all_extra; |
|
| 244 | - } |
|
| 245 | - if ($minute_extra) { |
|
| 246 | - $_extra .= ' ' . $minute_extra; |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - $_html_minutes = '<select name="' . $_name . '"'; |
|
| 250 | - if ($minute_id !== null || $all_id !== null) { |
|
| 251 | - $_html_minutes .= ' id="' . smarty_function_escape_special_chars($minute_id !== null ? |
|
| 252 | - ($minute_id ? $minute_id : $_name) : |
|
| 253 | - ($all_id ? ($all_id . $_name) : |
|
| 254 | - $_name)) . '"'; |
|
| 255 | - } |
|
| 256 | - if ($minute_size) { |
|
| 257 | - $_html_minutes .= ' size="' . $minute_size . '"'; |
|
| 258 | - } |
|
| 259 | - $_html_minutes .= $_extra . $extra_attrs . '>' . $option_separator; |
|
| 260 | - |
|
| 261 | - if (isset($minute_empty) || isset($all_empty)) { |
|
| 262 | - $_html_minutes .= '<option value="">' . (isset($minute_empty) ? $minute_empty : $all_empty) . '</option>' . |
|
| 263 | - $option_separator; |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - $selected = $_minute !== null ? ($_minute - $_minute % $minute_interval) : null; |
|
| 267 | - for ($i = 0; $i <= 59; $i += $minute_interval) { |
|
| 268 | - $_val = sprintf('%02d', $i); |
|
| 269 | - $_text = $minute_format == '%02d' ? $_val : sprintf($minute_format, $i); |
|
| 270 | - $_value = $minute_value_format == '%02d' ? $_val : sprintf($minute_value_format, $i); |
|
| 271 | - $_html_minutes .= '<option value="' . $_value . '"' . ($selected === $i ? ' selected="selected"' : '') . |
|
| 272 | - '>' . $_text . '</option>' . $option_separator; |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - $_html_minutes .= '</select>'; |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - // generate second <select> |
|
| 279 | - if ($display_seconds) { |
|
| 280 | - $_html_seconds = ''; |
|
| 281 | - $_extra = ''; |
|
| 282 | - $_name = $field_array ? ($field_array . '[' . $prefix . 'Second]') : ($prefix . 'Second'); |
|
| 283 | - if ($all_extra) { |
|
| 284 | - $_extra .= ' ' . $all_extra; |
|
| 285 | - } |
|
| 286 | - if ($second_extra) { |
|
| 287 | - $_extra .= ' ' . $second_extra; |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - $_html_seconds = '<select name="' . $_name . '"'; |
|
| 291 | - if ($second_id !== null || $all_id !== null) { |
|
| 292 | - $_html_seconds .= ' id="' . smarty_function_escape_special_chars($second_id !== null ? |
|
| 293 | - ($second_id ? $second_id : $_name) : |
|
| 294 | - ($all_id ? ($all_id . $_name) : |
|
| 295 | - $_name)) . '"'; |
|
| 296 | - } |
|
| 297 | - if ($second_size) { |
|
| 298 | - $_html_seconds .= ' size="' . $second_size . '"'; |
|
| 299 | - } |
|
| 300 | - $_html_seconds .= $_extra . $extra_attrs . '>' . $option_separator; |
|
| 301 | - |
|
| 302 | - if (isset($second_empty) || isset($all_empty)) { |
|
| 303 | - $_html_seconds .= '<option value="">' . (isset($second_empty) ? $second_empty : $all_empty) . '</option>' . |
|
| 304 | - $option_separator; |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - $selected = $_second !== null ? ($_second - $_second % $second_interval) : null; |
|
| 308 | - for ($i = 0; $i <= 59; $i += $second_interval) { |
|
| 309 | - $_val = sprintf('%02d', $i); |
|
| 310 | - $_text = $second_format == '%02d' ? $_val : sprintf($second_format, $i); |
|
| 311 | - $_value = $second_value_format == '%02d' ? $_val : sprintf($second_value_format, $i); |
|
| 312 | - $_html_seconds .= '<option value="' . $_value . '"' . ($selected === $i ? ' selected="selected"' : '') . |
|
| 313 | - '>' . $_text . '</option>' . $option_separator; |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - $_html_seconds .= '</select>'; |
|
| 317 | - } |
|
| 318 | - |
|
| 319 | - // generate meridian <select> |
|
| 320 | - if ($display_meridian && !$use_24_hours) { |
|
| 321 | - $_html_meridian = ''; |
|
| 322 | - $_extra = ''; |
|
| 323 | - $_name = $field_array ? ($field_array . '[' . $prefix . 'Meridian]') : ($prefix . 'Meridian'); |
|
| 324 | - if ($all_extra) { |
|
| 325 | - $_extra .= ' ' . $all_extra; |
|
| 326 | - } |
|
| 327 | - if ($meridian_extra) { |
|
| 328 | - $_extra .= ' ' . $meridian_extra; |
|
| 329 | - } |
|
| 330 | - |
|
| 331 | - $_html_meridian = '<select name="' . $_name . '"'; |
|
| 332 | - if ($meridian_id !== null || $all_id !== null) { |
|
| 333 | - $_html_meridian .= ' id="' . smarty_function_escape_special_chars($meridian_id !== null ? |
|
| 334 | - ($meridian_id ? $meridian_id : |
|
| 335 | - $_name) : |
|
| 336 | - ($all_id ? ($all_id . $_name) : |
|
| 337 | - $_name)) . '"'; |
|
| 338 | - } |
|
| 339 | - if ($meridian_size) { |
|
| 340 | - $_html_meridian .= ' size="' . $meridian_size . '"'; |
|
| 341 | - } |
|
| 342 | - $_html_meridian .= $_extra . $extra_attrs . '>' . $option_separator; |
|
| 343 | - |
|
| 344 | - if (isset($meridian_empty) || isset($all_empty)) { |
|
| 345 | - $_html_meridian .= '<option value="">' . (isset($meridian_empty) ? $meridian_empty : $all_empty) . |
|
| 346 | - '</option>' . $option_separator; |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - $_html_meridian .= '<option value="am"' . ($_hour > 0 && $_hour < 12 ? ' selected="selected"' : '') . |
|
| 350 | - '>AM</option>' . $option_separator . '<option value="pm"' . |
|
| 351 | - ($_hour < 12 ? '' : ' selected="selected"') . '>PM</option>' . $option_separator . |
|
| 352 | - '</select>'; |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - $_html = ''; |
|
| 356 | - foreach (array('_html_hours', '_html_minutes', '_html_seconds', '_html_meridian') as $k) { |
|
| 357 | - if (isset($$k)) { |
|
| 358 | - if ($_html) { |
|
| 359 | - $_html .= $field_separator; |
|
| 360 | - } |
|
| 361 | - $_html .= $$k; |
|
| 362 | - } |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - return $_html; |
|
| 36 | + $prefix = "Time_"; |
|
| 37 | + $field_array = null; |
|
| 38 | + $field_separator = "\n"; |
|
| 39 | + $option_separator = "\n"; |
|
| 40 | + $time = null; |
|
| 41 | + |
|
| 42 | + $display_hours = true; |
|
| 43 | + $display_minutes = true; |
|
| 44 | + $display_seconds = true; |
|
| 45 | + $display_meridian = true; |
|
| 46 | + |
|
| 47 | + $hour_format = '%02d'; |
|
| 48 | + $hour_value_format = '%02d'; |
|
| 49 | + $minute_format = '%02d'; |
|
| 50 | + $minute_value_format = '%02d'; |
|
| 51 | + $second_format = '%02d'; |
|
| 52 | + $second_value_format = '%02d'; |
|
| 53 | + |
|
| 54 | + $hour_size = null; |
|
| 55 | + $minute_size = null; |
|
| 56 | + $second_size = null; |
|
| 57 | + $meridian_size = null; |
|
| 58 | + |
|
| 59 | + $all_empty = null; |
|
| 60 | + $hour_empty = null; |
|
| 61 | + $minute_empty = null; |
|
| 62 | + $second_empty = null; |
|
| 63 | + $meridian_empty = null; |
|
| 64 | + |
|
| 65 | + $all_id = null; |
|
| 66 | + $hour_id = null; |
|
| 67 | + $minute_id = null; |
|
| 68 | + $second_id = null; |
|
| 69 | + $meridian_id = null; |
|
| 70 | + |
|
| 71 | + $use_24_hours = true; |
|
| 72 | + $minute_interval = 1; |
|
| 73 | + $second_interval = 1; |
|
| 74 | + |
|
| 75 | + $extra_attrs = ''; |
|
| 76 | + $all_extra = null; |
|
| 77 | + $hour_extra = null; |
|
| 78 | + $minute_extra = null; |
|
| 79 | + $second_extra = null; |
|
| 80 | + $meridian_extra = null; |
|
| 81 | + |
|
| 82 | + foreach ($params as $_key => $_value) { |
|
| 83 | + switch ($_key) { |
|
| 84 | + case 'time': |
|
| 85 | + if (!is_array($_value) && $_value !== null) { |
|
| 86 | + $time = smarty_make_timestamp($_value); |
|
| 87 | + } |
|
| 88 | + break; |
|
| 89 | + |
|
| 90 | + case 'prefix': |
|
| 91 | + case 'field_array': |
|
| 92 | + |
|
| 93 | + case 'field_separator': |
|
| 94 | + case 'option_separator': |
|
| 95 | + |
|
| 96 | + case 'all_extra': |
|
| 97 | + case 'hour_extra': |
|
| 98 | + case 'minute_extra': |
|
| 99 | + case 'second_extra': |
|
| 100 | + case 'meridian_extra': |
|
| 101 | + |
|
| 102 | + case 'all_empty': |
|
| 103 | + case 'hour_empty': |
|
| 104 | + case 'minute_empty': |
|
| 105 | + case 'second_empty': |
|
| 106 | + case 'meridian_empty': |
|
| 107 | + |
|
| 108 | + case 'all_id': |
|
| 109 | + case 'hour_id': |
|
| 110 | + case 'minute_id': |
|
| 111 | + case 'second_id': |
|
| 112 | + case 'meridian_id': |
|
| 113 | + |
|
| 114 | + case 'hour_format': |
|
| 115 | + case 'hour_value_format': |
|
| 116 | + case 'minute_format': |
|
| 117 | + case 'minute_value_format': |
|
| 118 | + case 'second_format': |
|
| 119 | + case 'second_value_format': |
|
| 120 | + $$_key = (string) $_value; |
|
| 121 | + break; |
|
| 122 | + |
|
| 123 | + case 'display_hours': |
|
| 124 | + case 'display_minutes': |
|
| 125 | + case 'display_seconds': |
|
| 126 | + case 'display_meridian': |
|
| 127 | + case 'use_24_hours': |
|
| 128 | + $$_key = (bool) $_value; |
|
| 129 | + break; |
|
| 130 | + |
|
| 131 | + case 'minute_interval': |
|
| 132 | + case 'second_interval': |
|
| 133 | + |
|
| 134 | + case 'hour_size': |
|
| 135 | + case 'minute_size': |
|
| 136 | + case 'second_size': |
|
| 137 | + case 'meridian_size': |
|
| 138 | + $$_key = (int) $_value; |
|
| 139 | + break; |
|
| 140 | + |
|
| 141 | + default: |
|
| 142 | + if (!is_array($_value)) { |
|
| 143 | + $extra_attrs .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_value) . '"'; |
|
| 144 | + } else { |
|
| 145 | + trigger_error("html_select_date: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
|
| 146 | + } |
|
| 147 | + break; |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) { |
|
| 152 | + if (isset($params[ 'time' ][ $prefix . 'Hour' ])) { |
|
| 153 | + // $_REQUEST[$field_array] given |
|
| 154 | + foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) { |
|
| 155 | + $_variableName = '_' . strtolower($_elementName); |
|
| 156 | + $$_variableName = |
|
| 157 | + isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] : |
|
| 158 | + date($_elementKey); |
|
| 159 | + } |
|
| 160 | + $_meridian = |
|
| 161 | + isset($params[ 'time' ][ $prefix . 'Meridian' ]) ? (' ' . $params[ 'time' ][ $prefix . 'Meridian' ]) : |
|
| 162 | + ''; |
|
| 163 | + $time = strtotime($_hour . ':' . $_minute . ':' . $_second . $_meridian); |
|
| 164 | + list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time)); |
|
| 165 | + } elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Hour' ])) { |
|
| 166 | + // $_REQUEST given |
|
| 167 | + foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) { |
|
| 168 | + $_variableName = '_' . strtolower($_elementName); |
|
| 169 | + $$_variableName = isset($params[ 'time' ][ $field_array ][ $prefix . $_elementName ]) ? |
|
| 170 | + $params[ 'time' ][ $field_array ][ $prefix . $_elementName ] : date($_elementKey); |
|
| 171 | + } |
|
| 172 | + $_meridian = isset($params[ 'time' ][ $field_array ][ $prefix . 'Meridian' ]) ? |
|
| 173 | + (' ' . $params[ 'time' ][ $field_array ][ $prefix . 'Meridian' ]) : ''; |
|
| 174 | + $time = strtotime($_hour . ':' . $_minute . ':' . $_second . $_meridian); |
|
| 175 | + list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time)); |
|
| 176 | + } else { |
|
| 177 | + // no date found, use NOW |
|
| 178 | + list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d')); |
|
| 179 | + } |
|
| 180 | + } elseif ($time === null) { |
|
| 181 | + if (array_key_exists('time', $params)) { |
|
| 182 | + $_hour = $_minute = $_second = $time = null; |
|
| 183 | + } else { |
|
| 184 | + list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s')); |
|
| 185 | + } |
|
| 186 | + } else { |
|
| 187 | + list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time)); |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + // generate hour <select> |
|
| 191 | + if ($display_hours) { |
|
| 192 | + $_html_hours = ''; |
|
| 193 | + $_extra = ''; |
|
| 194 | + $_name = $field_array ? ($field_array . '[' . $prefix . 'Hour]') : ($prefix . 'Hour'); |
|
| 195 | + if ($all_extra) { |
|
| 196 | + $_extra .= ' ' . $all_extra; |
|
| 197 | + } |
|
| 198 | + if ($hour_extra) { |
|
| 199 | + $_extra .= ' ' . $hour_extra; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + $_html_hours = '<select name="' . $_name . '"'; |
|
| 203 | + if ($hour_id !== null || $all_id !== null) { |
|
| 204 | + $_html_hours .= ' id="' . |
|
| 205 | + smarty_function_escape_special_chars($hour_id !== null ? ($hour_id ? $hour_id : $_name) : |
|
| 206 | + ($all_id ? ($all_id . $_name) : $_name)) . '"'; |
|
| 207 | + } |
|
| 208 | + if ($hour_size) { |
|
| 209 | + $_html_hours .= ' size="' . $hour_size . '"'; |
|
| 210 | + } |
|
| 211 | + $_html_hours .= $_extra . $extra_attrs . '>' . $option_separator; |
|
| 212 | + |
|
| 213 | + if (isset($hour_empty) || isset($all_empty)) { |
|
| 214 | + $_html_hours .= '<option value="">' . (isset($hour_empty) ? $hour_empty : $all_empty) . '</option>' . |
|
| 215 | + $option_separator; |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + $start = $use_24_hours ? 0 : 1; |
|
| 219 | + $end = $use_24_hours ? 23 : 12; |
|
| 220 | + for ($i = $start; $i <= $end; $i ++) { |
|
| 221 | + $_val = sprintf('%02d', $i); |
|
| 222 | + $_text = $hour_format == '%02d' ? $_val : sprintf($hour_format, $i); |
|
| 223 | + $_value = $hour_value_format == '%02d' ? $_val : sprintf($hour_value_format, $i); |
|
| 224 | + |
|
| 225 | + if (!$use_24_hours) { |
|
| 226 | + $_hour12 = $_hour == 0 ? 12 : ($_hour <= 12 ? $_hour : $_hour - 12); |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + $selected = $_hour !== null ? ($use_24_hours ? $_hour == $_val : $_hour12 == $_val) : null; |
|
| 230 | + $_html_hours .= '<option value="' . $_value . '"' . ($selected ? ' selected="selected"' : '') . '>' . |
|
| 231 | + $_text . '</option>' . $option_separator; |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + $_html_hours .= '</select>'; |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + // generate minute <select> |
|
| 238 | + if ($display_minutes) { |
|
| 239 | + $_html_minutes = ''; |
|
| 240 | + $_extra = ''; |
|
| 241 | + $_name = $field_array ? ($field_array . '[' . $prefix . 'Minute]') : ($prefix . 'Minute'); |
|
| 242 | + if ($all_extra) { |
|
| 243 | + $_extra .= ' ' . $all_extra; |
|
| 244 | + } |
|
| 245 | + if ($minute_extra) { |
|
| 246 | + $_extra .= ' ' . $minute_extra; |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + $_html_minutes = '<select name="' . $_name . '"'; |
|
| 250 | + if ($minute_id !== null || $all_id !== null) { |
|
| 251 | + $_html_minutes .= ' id="' . smarty_function_escape_special_chars($minute_id !== null ? |
|
| 252 | + ($minute_id ? $minute_id : $_name) : |
|
| 253 | + ($all_id ? ($all_id . $_name) : |
|
| 254 | + $_name)) . '"'; |
|
| 255 | + } |
|
| 256 | + if ($minute_size) { |
|
| 257 | + $_html_minutes .= ' size="' . $minute_size . '"'; |
|
| 258 | + } |
|
| 259 | + $_html_minutes .= $_extra . $extra_attrs . '>' . $option_separator; |
|
| 260 | + |
|
| 261 | + if (isset($minute_empty) || isset($all_empty)) { |
|
| 262 | + $_html_minutes .= '<option value="">' . (isset($minute_empty) ? $minute_empty : $all_empty) . '</option>' . |
|
| 263 | + $option_separator; |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + $selected = $_minute !== null ? ($_minute - $_minute % $minute_interval) : null; |
|
| 267 | + for ($i = 0; $i <= 59; $i += $minute_interval) { |
|
| 268 | + $_val = sprintf('%02d', $i); |
|
| 269 | + $_text = $minute_format == '%02d' ? $_val : sprintf($minute_format, $i); |
|
| 270 | + $_value = $minute_value_format == '%02d' ? $_val : sprintf($minute_value_format, $i); |
|
| 271 | + $_html_minutes .= '<option value="' . $_value . '"' . ($selected === $i ? ' selected="selected"' : '') . |
|
| 272 | + '>' . $_text . '</option>' . $option_separator; |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + $_html_minutes .= '</select>'; |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + // generate second <select> |
|
| 279 | + if ($display_seconds) { |
|
| 280 | + $_html_seconds = ''; |
|
| 281 | + $_extra = ''; |
|
| 282 | + $_name = $field_array ? ($field_array . '[' . $prefix . 'Second]') : ($prefix . 'Second'); |
|
| 283 | + if ($all_extra) { |
|
| 284 | + $_extra .= ' ' . $all_extra; |
|
| 285 | + } |
|
| 286 | + if ($second_extra) { |
|
| 287 | + $_extra .= ' ' . $second_extra; |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + $_html_seconds = '<select name="' . $_name . '"'; |
|
| 291 | + if ($second_id !== null || $all_id !== null) { |
|
| 292 | + $_html_seconds .= ' id="' . smarty_function_escape_special_chars($second_id !== null ? |
|
| 293 | + ($second_id ? $second_id : $_name) : |
|
| 294 | + ($all_id ? ($all_id . $_name) : |
|
| 295 | + $_name)) . '"'; |
|
| 296 | + } |
|
| 297 | + if ($second_size) { |
|
| 298 | + $_html_seconds .= ' size="' . $second_size . '"'; |
|
| 299 | + } |
|
| 300 | + $_html_seconds .= $_extra . $extra_attrs . '>' . $option_separator; |
|
| 301 | + |
|
| 302 | + if (isset($second_empty) || isset($all_empty)) { |
|
| 303 | + $_html_seconds .= '<option value="">' . (isset($second_empty) ? $second_empty : $all_empty) . '</option>' . |
|
| 304 | + $option_separator; |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + $selected = $_second !== null ? ($_second - $_second % $second_interval) : null; |
|
| 308 | + for ($i = 0; $i <= 59; $i += $second_interval) { |
|
| 309 | + $_val = sprintf('%02d', $i); |
|
| 310 | + $_text = $second_format == '%02d' ? $_val : sprintf($second_format, $i); |
|
| 311 | + $_value = $second_value_format == '%02d' ? $_val : sprintf($second_value_format, $i); |
|
| 312 | + $_html_seconds .= '<option value="' . $_value . '"' . ($selected === $i ? ' selected="selected"' : '') . |
|
| 313 | + '>' . $_text . '</option>' . $option_separator; |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + $_html_seconds .= '</select>'; |
|
| 317 | + } |
|
| 318 | + |
|
| 319 | + // generate meridian <select> |
|
| 320 | + if ($display_meridian && !$use_24_hours) { |
|
| 321 | + $_html_meridian = ''; |
|
| 322 | + $_extra = ''; |
|
| 323 | + $_name = $field_array ? ($field_array . '[' . $prefix . 'Meridian]') : ($prefix . 'Meridian'); |
|
| 324 | + if ($all_extra) { |
|
| 325 | + $_extra .= ' ' . $all_extra; |
|
| 326 | + } |
|
| 327 | + if ($meridian_extra) { |
|
| 328 | + $_extra .= ' ' . $meridian_extra; |
|
| 329 | + } |
|
| 330 | + |
|
| 331 | + $_html_meridian = '<select name="' . $_name . '"'; |
|
| 332 | + if ($meridian_id !== null || $all_id !== null) { |
|
| 333 | + $_html_meridian .= ' id="' . smarty_function_escape_special_chars($meridian_id !== null ? |
|
| 334 | + ($meridian_id ? $meridian_id : |
|
| 335 | + $_name) : |
|
| 336 | + ($all_id ? ($all_id . $_name) : |
|
| 337 | + $_name)) . '"'; |
|
| 338 | + } |
|
| 339 | + if ($meridian_size) { |
|
| 340 | + $_html_meridian .= ' size="' . $meridian_size . '"'; |
|
| 341 | + } |
|
| 342 | + $_html_meridian .= $_extra . $extra_attrs . '>' . $option_separator; |
|
| 343 | + |
|
| 344 | + if (isset($meridian_empty) || isset($all_empty)) { |
|
| 345 | + $_html_meridian .= '<option value="">' . (isset($meridian_empty) ? $meridian_empty : $all_empty) . |
|
| 346 | + '</option>' . $option_separator; |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + $_html_meridian .= '<option value="am"' . ($_hour > 0 && $_hour < 12 ? ' selected="selected"' : '') . |
|
| 350 | + '>AM</option>' . $option_separator . '<option value="pm"' . |
|
| 351 | + ($_hour < 12 ? '' : ' selected="selected"') . '>PM</option>' . $option_separator . |
|
| 352 | + '</select>'; |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + $_html = ''; |
|
| 356 | + foreach (array('_html_hours', '_html_minutes', '_html_seconds', '_html_meridian') as $k) { |
|
| 357 | + if (isset($$k)) { |
|
| 358 | + if ($_html) { |
|
| 359 | + $_html .= $field_separator; |
|
| 360 | + } |
|
| 361 | + $_html .= $$k; |
|
| 362 | + } |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + return $_html; |
|
| 366 | 366 | } |
@@ -148,29 +148,27 @@ discard block |
||
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) { |
|
| 152 | - if (isset($params[ 'time' ][ $prefix . 'Hour' ])) { |
|
| 151 | + if (isset($params['time']) && is_array($params['time'])) { |
|
| 152 | + if (isset($params['time'][$prefix . 'Hour'])) { |
|
| 153 | 153 | // $_REQUEST[$field_array] given |
| 154 | 154 | foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) { |
| 155 | 155 | $_variableName = '_' . strtolower($_elementName); |
| 156 | 156 | $$_variableName = |
| 157 | - isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] : |
|
| 158 | - date($_elementKey); |
|
| 157 | + isset($params['time'][$prefix . $_elementName]) ? $params['time'][$prefix . $_elementName] : date($_elementKey); |
|
| 159 | 158 | } |
| 160 | 159 | $_meridian = |
| 161 | - isset($params[ 'time' ][ $prefix . 'Meridian' ]) ? (' ' . $params[ 'time' ][ $prefix . 'Meridian' ]) : |
|
| 162 | - ''; |
|
| 160 | + isset($params['time'][$prefix . 'Meridian']) ? (' ' . $params['time'][$prefix . 'Meridian']) : ''; |
|
| 163 | 161 | $time = strtotime($_hour . ':' . $_minute . ':' . $_second . $_meridian); |
| 164 | 162 | list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time)); |
| 165 | - } elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Hour' ])) { |
|
| 163 | + } elseif (isset($params['time'][$field_array][$prefix . 'Hour'])) { |
|
| 166 | 164 | // $_REQUEST given |
| 167 | 165 | foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) { |
| 168 | 166 | $_variableName = '_' . strtolower($_elementName); |
| 169 | - $$_variableName = isset($params[ 'time' ][ $field_array ][ $prefix . $_elementName ]) ? |
|
| 170 | - $params[ 'time' ][ $field_array ][ $prefix . $_elementName ] : date($_elementKey); |
|
| 167 | + $$_variableName = isset($params['time'][$field_array][$prefix . $_elementName]) ? |
|
| 168 | + $params['time'][$field_array][$prefix . $_elementName] : date($_elementKey); |
|
| 171 | 169 | } |
| 172 | - $_meridian = isset($params[ 'time' ][ $field_array ][ $prefix . 'Meridian' ]) ? |
|
| 173 | - (' ' . $params[ 'time' ][ $field_array ][ $prefix . 'Meridian' ]) : ''; |
|
| 170 | + $_meridian = isset($params['time'][$field_array][$prefix . 'Meridian']) ? |
|
| 171 | + (' ' . $params['time'][$field_array][$prefix . 'Meridian']) : ''; |
|
| 174 | 172 | $time = strtotime($_hour . ':' . $_minute . ':' . $_second . $_meridian); |
| 175 | 173 | list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time)); |
| 176 | 174 | } else { |
@@ -202,8 +200,7 @@ discard block |
||
| 202 | 200 | $_html_hours = '<select name="' . $_name . '"'; |
| 203 | 201 | if ($hour_id !== null || $all_id !== null) { |
| 204 | 202 | $_html_hours .= ' id="' . |
| 205 | - smarty_function_escape_special_chars($hour_id !== null ? ($hour_id ? $hour_id : $_name) : |
|
| 206 | - ($all_id ? ($all_id . $_name) : $_name)) . '"'; |
|
| 203 | + smarty_function_escape_special_chars($hour_id !== null ? ($hour_id ? $hour_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)) . '"'; |
|
| 207 | 204 | } |
| 208 | 205 | if ($hour_size) { |
| 209 | 206 | $_html_hours .= ' size="' . $hour_size . '"'; |
@@ -217,7 +214,7 @@ discard block |
||
| 217 | 214 | |
| 218 | 215 | $start = $use_24_hours ? 0 : 1; |
| 219 | 216 | $end = $use_24_hours ? 23 : 12; |
| 220 | - for ($i = $start; $i <= $end; $i ++) { |
|
| 217 | + for ($i = $start; $i <= $end; $i++) { |
|
| 221 | 218 | $_val = sprintf('%02d', $i); |
| 222 | 219 | $_text = $hour_format == '%02d' ? $_val : sprintf($hour_format, $i); |
| 223 | 220 | $_value = $hour_value_format == '%02d' ? $_val : sprintf($hour_value_format, $i); |
@@ -249,9 +246,7 @@ discard block |
||
| 249 | 246 | $_html_minutes = '<select name="' . $_name . '"'; |
| 250 | 247 | if ($minute_id !== null || $all_id !== null) { |
| 251 | 248 | $_html_minutes .= ' id="' . smarty_function_escape_special_chars($minute_id !== null ? |
| 252 | - ($minute_id ? $minute_id : $_name) : |
|
| 253 | - ($all_id ? ($all_id . $_name) : |
|
| 254 | - $_name)) . '"'; |
|
| 249 | + ($minute_id ? $minute_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)) . '"'; |
|
| 255 | 250 | } |
| 256 | 251 | if ($minute_size) { |
| 257 | 252 | $_html_minutes .= ' size="' . $minute_size . '"'; |
@@ -290,9 +285,7 @@ discard block |
||
| 290 | 285 | $_html_seconds = '<select name="' . $_name . '"'; |
| 291 | 286 | if ($second_id !== null || $all_id !== null) { |
| 292 | 287 | $_html_seconds .= ' id="' . smarty_function_escape_special_chars($second_id !== null ? |
| 293 | - ($second_id ? $second_id : $_name) : |
|
| 294 | - ($all_id ? ($all_id . $_name) : |
|
| 295 | - $_name)) . '"'; |
|
| 288 | + ($second_id ? $second_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)) . '"'; |
|
| 296 | 289 | } |
| 297 | 290 | if ($second_size) { |
| 298 | 291 | $_html_seconds .= ' size="' . $second_size . '"'; |
@@ -331,10 +324,7 @@ discard block |
||
| 331 | 324 | $_html_meridian = '<select name="' . $_name . '"'; |
| 332 | 325 | if ($meridian_id !== null || $all_id !== null) { |
| 333 | 326 | $_html_meridian .= ' id="' . smarty_function_escape_special_chars($meridian_id !== null ? |
| 334 | - ($meridian_id ? $meridian_id : |
|
| 335 | - $_name) : |
|
| 336 | - ($all_id ? ($all_id . $_name) : |
|
| 337 | - $_name)) . '"'; |
|
| 327 | + ($meridian_id ? $meridian_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)) . '"'; |
|
| 338 | 328 | } |
| 339 | 329 | if ($meridian_size) { |
| 340 | 330 | $_html_meridian .= ' size="' . $meridian_size . '"'; |