@@ -19,70 +19,70 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | function smarty_outputfilter_trimwhitespace($source) |
| 21 | 21 | { |
| 22 | - $store = array(); |
|
| 23 | - $_store = 0; |
|
| 24 | - $_offset = 0; |
|
| 22 | + $store = array(); |
|
| 23 | + $_store = 0; |
|
| 24 | + $_offset = 0; |
|
| 25 | 25 | |
| 26 | - // Unify Line-Breaks to \n |
|
| 27 | - $source = preg_replace("/\015\012|\015|\012/", "\n", $source); |
|
| 26 | + // Unify Line-Breaks to \n |
|
| 27 | + $source = preg_replace("/\015\012|\015|\012/", "\n", $source); |
|
| 28 | 28 | |
| 29 | - // capture Internet Explorer and KnockoutJS Conditional Comments |
|
| 30 | - if (preg_match_all('#<!--((\[[^\]]+\]>.*?<!\[[^\]]+\])|(\s*/?ko\s+.+))-->#is', $source, $matches, |
|
| 31 | - PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
|
| 32 | - foreach ($matches as $match) { |
|
| 33 | - $store[] = $match[ 0 ][ 0 ]; |
|
| 34 | - $_length = strlen($match[ 0 ][ 0 ]); |
|
| 35 | - $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@'; |
|
| 36 | - $source = substr_replace($source, $replace, $match[ 0 ][ 1 ] - $_offset, $_length); |
|
| 29 | + // capture Internet Explorer and KnockoutJS Conditional Comments |
|
| 30 | + if (preg_match_all('#<!--((\[[^\]]+\]>.*?<!\[[^\]]+\])|(\s*/?ko\s+.+))-->#is', $source, $matches, |
|
| 31 | + PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
|
| 32 | + foreach ($matches as $match) { |
|
| 33 | + $store[] = $match[ 0 ][ 0 ]; |
|
| 34 | + $_length = strlen($match[ 0 ][ 0 ]); |
|
| 35 | + $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@'; |
|
| 36 | + $source = substr_replace($source, $replace, $match[ 0 ][ 1 ] - $_offset, $_length); |
|
| 37 | 37 | |
| 38 | - $_offset += $_length - strlen($replace); |
|
| 39 | - $_store ++; |
|
| 40 | - } |
|
| 41 | - } |
|
| 38 | + $_offset += $_length - strlen($replace); |
|
| 39 | + $_store ++; |
|
| 40 | + } |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - // Strip all HTML-Comments |
|
| 44 | - // yes, even the ones in <script> - see http://stackoverflow.com/a/808850/515124 |
|
| 45 | - $source = preg_replace('#<!--.*?-->#ms', '', $source); |
|
| 43 | + // Strip all HTML-Comments |
|
| 44 | + // yes, even the ones in <script> - see http://stackoverflow.com/a/808850/515124 |
|
| 45 | + $source = preg_replace('#<!--.*?-->#ms', '', $source); |
|
| 46 | 46 | |
| 47 | - // capture html elements not to be messed with |
|
| 48 | - $_offset = 0; |
|
| 49 | - if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is', |
|
| 50 | - $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
|
| 51 | - foreach ($matches as $match) { |
|
| 52 | - $store[] = $match[ 0 ][ 0 ]; |
|
| 53 | - $_length = strlen($match[ 0 ][ 0 ]); |
|
| 54 | - $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@'; |
|
| 55 | - $source = substr_replace($source, $replace, $match[ 0 ][ 1 ] - $_offset, $_length); |
|
| 47 | + // capture html elements not to be messed with |
|
| 48 | + $_offset = 0; |
|
| 49 | + if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is', |
|
| 50 | + $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
|
| 51 | + foreach ($matches as $match) { |
|
| 52 | + $store[] = $match[ 0 ][ 0 ]; |
|
| 53 | + $_length = strlen($match[ 0 ][ 0 ]); |
|
| 54 | + $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@'; |
|
| 55 | + $source = substr_replace($source, $replace, $match[ 0 ][ 1 ] - $_offset, $_length); |
|
| 56 | 56 | |
| 57 | - $_offset += $_length - strlen($replace); |
|
| 58 | - $_store ++; |
|
| 59 | - } |
|
| 60 | - } |
|
| 57 | + $_offset += $_length - strlen($replace); |
|
| 58 | + $_store ++; |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - $expressions = array(// replace multiple spaces between tags by a single space |
|
| 63 | - // can't remove them entirely, becaue that might break poorly implemented CSS display:inline-block elements |
|
| 64 | - '#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2', |
|
| 65 | - // remove spaces between attributes (but not in attribute values!) |
|
| 66 | - '#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5', |
|
| 67 | - // note: for some very weird reason trim() seems to remove spaces inside attributes. |
|
| 68 | - // maybe a \0 byte or something is interfering? |
|
| 69 | - '#^\s+<#Ss' => '<', '#>\s+$#Ss' => '>',); |
|
| 62 | + $expressions = array(// replace multiple spaces between tags by a single space |
|
| 63 | + // can't remove them entirely, becaue that might break poorly implemented CSS display:inline-block elements |
|
| 64 | + '#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2', |
|
| 65 | + // remove spaces between attributes (but not in attribute values!) |
|
| 66 | + '#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5', |
|
| 67 | + // note: for some very weird reason trim() seems to remove spaces inside attributes. |
|
| 68 | + // maybe a \0 byte or something is interfering? |
|
| 69 | + '#^\s+<#Ss' => '<', '#>\s+$#Ss' => '>',); |
|
| 70 | 70 | |
| 71 | - $source = preg_replace(array_keys($expressions), array_values($expressions), $source); |
|
| 72 | - // note: for some very weird reason trim() seems to remove spaces inside attributes. |
|
| 73 | - // maybe a \0 byte or something is interfering? |
|
| 71 | + $source = preg_replace(array_keys($expressions), array_values($expressions), $source); |
|
| 72 | + // note: for some very weird reason trim() seems to remove spaces inside attributes. |
|
| 73 | + // maybe a \0 byte or something is interfering? |
|
| 74 | 74 | |
| 75 | - $_offset = 0; |
|
| 76 | - if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
|
| 77 | - foreach ($matches as $match) { |
|
| 78 | - $_length = strlen($match[ 0 ][ 0 ]); |
|
| 79 | - $replace = $store[ $match[ 1 ][ 0 ] ]; |
|
| 80 | - $source = substr_replace($source, $replace, $match[ 0 ][ 1 ] + $_offset, $_length); |
|
| 75 | + $_offset = 0; |
|
| 76 | + if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
|
| 77 | + foreach ($matches as $match) { |
|
| 78 | + $_length = strlen($match[ 0 ][ 0 ]); |
|
| 79 | + $replace = $store[ $match[ 1 ][ 0 ] ]; |
|
| 80 | + $source = substr_replace($source, $replace, $match[ 0 ][ 1 ] + $_offset, $_length); |
|
| 81 | 81 | |
| 82 | - $_offset += strlen($replace) - $_length; |
|
| 83 | - $_store ++; |
|
| 84 | - } |
|
| 85 | - } |
|
| 82 | + $_offset += strlen($replace) - $_length; |
|
| 83 | + $_store ++; |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - return $source; |
|
| 87 | + return $source; |
|
| 88 | 88 | } |
@@ -30,13 +30,13 @@ discard block |
||
| 30 | 30 | if (preg_match_all('#<!--((\[[^\]]+\]>.*?<!\[[^\]]+\])|(\s*/?ko\s+.+))-->#is', $source, $matches, |
| 31 | 31 | PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
| 32 | 32 | foreach ($matches as $match) { |
| 33 | - $store[] = $match[ 0 ][ 0 ]; |
|
| 34 | - $_length = strlen($match[ 0 ][ 0 ]); |
|
| 33 | + $store[] = $match[0][0]; |
|
| 34 | + $_length = strlen($match[0][0]); |
|
| 35 | 35 | $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@'; |
| 36 | - $source = substr_replace($source, $replace, $match[ 0 ][ 1 ] - $_offset, $_length); |
|
| 36 | + $source = substr_replace($source, $replace, $match[0][1] - $_offset, $_length); |
|
| 37 | 37 | |
| 38 | 38 | $_offset += $_length - strlen($replace); |
| 39 | - $_store ++; |
|
| 39 | + $_store++; |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | |
@@ -49,13 +49,13 @@ discard block |
||
| 49 | 49 | if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is', |
| 50 | 50 | $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
| 51 | 51 | foreach ($matches as $match) { |
| 52 | - $store[] = $match[ 0 ][ 0 ]; |
|
| 53 | - $_length = strlen($match[ 0 ][ 0 ]); |
|
| 52 | + $store[] = $match[0][0]; |
|
| 53 | + $_length = strlen($match[0][0]); |
|
| 54 | 54 | $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@'; |
| 55 | - $source = substr_replace($source, $replace, $match[ 0 ][ 1 ] - $_offset, $_length); |
|
| 55 | + $source = substr_replace($source, $replace, $match[0][1] - $_offset, $_length); |
|
| 56 | 56 | |
| 57 | 57 | $_offset += $_length - strlen($replace); |
| 58 | - $_store ++; |
|
| 58 | + $_store++; |
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | |
@@ -75,12 +75,12 @@ discard block |
||
| 75 | 75 | $_offset = 0; |
| 76 | 76 | if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
| 77 | 77 | foreach ($matches as $match) { |
| 78 | - $_length = strlen($match[ 0 ][ 0 ]); |
|
| 79 | - $replace = $store[ $match[ 1 ][ 0 ] ]; |
|
| 80 | - $source = substr_replace($source, $replace, $match[ 0 ][ 1 ] + $_offset, $_length); |
|
| 78 | + $_length = strlen($match[0][0]); |
|
| 79 | + $replace = $store[$match[1][0]]; |
|
| 80 | + $source = substr_replace($source, $replace, $match[0][1] + $_offset, $_length); |
|
| 81 | 81 | |
| 82 | 82 | $_offset += strlen($replace) - $_length; |
| 83 | - $_store ++; |
|
| 83 | + $_store++; |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
@@ -22,6 +22,6 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | function smarty_modifiercompiler_count_sentences($params) |
| 24 | 24 | { |
| 25 | - // find periods, question marks, exclamation marks with a word before but not after. |
|
| 26 | - return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[ 0 ] . ', $tmp)'; |
|
| 25 | + // find periods, question marks, exclamation marks with a word before but not after. |
|
| 26 | + return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[ 0 ] . ', $tmp)'; |
|
| 27 | 27 | } |
@@ -23,5 +23,5 @@ |
||
| 23 | 23 | function smarty_modifiercompiler_count_sentences($params) |
| 24 | 24 | { |
| 25 | 25 | // find periods, question marks, exclamation marks with a word before but not after. |
| 26 | - return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[ 0 ] . ', $tmp)'; |
|
| 26 | + return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[0] . ', $tmp)'; |
|
| 27 | 27 | } |
@@ -21,15 +21,15 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | function smarty_modifiercompiler_default($params) |
| 23 | 23 | { |
| 24 | - $output = $params[ 0 ]; |
|
| 25 | - if (!isset($params[ 1 ])) { |
|
| 26 | - $params[ 1 ] = "''"; |
|
| 27 | - } |
|
| 24 | + $output = $params[ 0 ]; |
|
| 25 | + if (!isset($params[ 1 ])) { |
|
| 26 | + $params[ 1 ] = "''"; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - array_shift($params); |
|
| 30 | - foreach ($params as $param) { |
|
| 31 | - $output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)'; |
|
| 32 | - } |
|
| 29 | + array_shift($params); |
|
| 30 | + foreach ($params as $param) { |
|
| 31 | + $output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)'; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - return $output; |
|
| 34 | + return $output; |
|
| 35 | 35 | } |
@@ -21,9 +21,9 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | function smarty_modifiercompiler_default($params) |
| 23 | 23 | { |
| 24 | - $output = $params[ 0 ]; |
|
| 25 | - if (!isset($params[ 1 ])) { |
|
| 26 | - $params[ 1 ] = "''"; |
|
| 24 | + $output = $params[0]; |
|
| 25 | + if (!isset($params[1])) { |
|
| 26 | + $params[1] = "''"; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | array_shift($params); |
@@ -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 | } |