NobuNobu
nobun****@users*****
2006年 12月 26日 (火) 23:26:51 JST
Index: xoops2jp/html/class/smarty/plugins/function.html_select_date.php diff -u xoops2jp/html/class/smarty/plugins/function.html_select_date.php:1.2.8.2 xoops2jp/html/class/smarty/plugins/function.html_select_date.php:1.2.8.2.2.1 --- xoops2jp/html/class/smarty/plugins/function.html_select_date.php:1.2.8.2 Fri Jan 27 23:34:11 2006 +++ xoops2jp/html/class/smarty/plugins/function.html_select_date.php Tue Dec 26 23:26:51 2006 @@ -22,11 +22,13 @@ * month values (Gary Loescher) * - 1.3.1 added support for choosing format for * day values (Marcus Bointon) - * - 1.3.2 suppport negative timestamps, force year + * - 1.3.2 support negative timestamps, force year * dropdown to include given date unless explicitly set (Monte) + * - 1.3.4 fix behaviour of 0000-00-00 00:00:00 dates to match that + * of 0000-00-00 dates (cybot, boots) * @link http://smarty.php.net/manual/en/language.function.html.select.date.php {html_select_date} * (Smarty online manual) - * @version 1.3.2 + * @version 1.3.4 * @author Andrei Zmievski * @author Monte Ohrt <monte at ohrt dot com> * @param array @@ -131,19 +133,21 @@ } } - if(preg_match('!^-\d+$!',$time)) { + if (preg_match('!^-\d+$!', $time)) { // negative timestamp, use date() - $time = date('Y-m-d',$time); + $time = date('Y-m-d', $time); } // If $time is not in format yyyy-mm-dd - if (!preg_match('/^\d{0,4}-\d{0,2}-\d{0,2}$/', $time)) { + if (preg_match('/^(\d{0,4}-\d{0,2}-\d{0,2})/', $time, $found)) { + $time = $found[1]; + } else { // use smarty_make_timestamp to get an unix timestamp and // strftime to make yyyy-mm-dd $time = strftime('%Y-%m-%d', smarty_make_timestamp($time)); } // Now split this in pieces, which later can be used to set the select $time = explode("-", $time); - + // make syntax "+N" or "-N" work with start_year and end_year if (preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match)) { if ($match[1] == '+') { @@ -159,7 +163,7 @@ $start_year = strftime('%Y') - $match[2]; } } - if (strlen($time[0]) > 0) { + if (strlen($time[0]) > 0) { if ($start_year > $time[0] && !isset($params['start_year'])) { // force start year to include given date if not explicitly set $start_year = $time[0]; Index: xoops2jp/html/class/smarty/plugins/function.html_table.php diff -u xoops2jp/html/class/smarty/plugins/function.html_table.php:1.2.8.1 xoops2jp/html/class/smarty/plugins/function.html_table.php:1.2.8.1.2.1 --- xoops2jp/html/class/smarty/plugins/function.html_table.php:1.2.8.1 Sun Nov 20 17:05:54 2005 +++ xoops2jp/html/class/smarty/plugins/function.html_table.php Tue Dec 26 23:26:51 2006 @@ -15,12 +15,15 @@ * Purpose: make an html table from an array of data<br> * Input:<br> * - loop = array to loop through - * - cols = number of columns + * - cols = number of columns, comma separated list of column names + * or array of column names * - rows = number of rows * - table_attr = table attributes + * - th_attr = table heading attributes (arrays are cycled) * - tr_attr = table row attributes (arrays are cycled) * - td_attr = table cell attributes (arrays are cycled) * - trailpad = value to pad trailing cells with + * - caption = text for caption element * - vdir = vertical direction (default: "down", means top-to-bottom) * - hdir = horizontal direction (default: "right", means left-to-right) * - inner = inner loop (default "cols": print $loop line by line, @@ -31,10 +34,12 @@ * <pre> * {table loop=$data} * {table loop=$data cols=4 tr_attr='"bgcolor=red"'} - * {table loop=$data cols=4 tr_attr=$colors} + * {table loop=$data cols="first,second,third" tr_attr=$colors} * </pre> * @author Monte Ohrt <monte at ohrt dot com> - * @version 1.0 + * @author credit to Messju Mohr <messju at lammfellpuschen dot de> + * @author credit to boots <boots dot smarty at yahoo dot com> + * @version 1.1 * @link http://smarty.php.net/manual/en/language.function.html.table.php {html_table} * (Smarty online manual) * @param array @@ -45,13 +50,15 @@ { $table_attr = 'border="1"'; $tr_attr = ''; + $th_attr = ''; $td_attr = ''; - $cols = 3; + $cols = $cols_count = 3; $rows = 3; $trailpad = ' '; $vdir = 'down'; $hdir = 'right'; $inner = 'cols'; + $caption = ''; if (!isset($params['loop'])) { $smarty->trigger_error("html_table: missing 'loop' parameter"); @@ -65,6 +72,19 @@ break; case 'cols': + if (is_array($_value) && !empty($_value)) { + $cols = $_value; + $cols_count = count($_value); + } elseif (!is_numeric($_value) && is_string($_value) && !empty($_value)) { + $cols = explode(',', $_value); + $cols_count = count($cols); + } elseif (!empty($_value)) { + $cols_count = (int)$_value; + } else { + $cols_count = $cols; + } + break; + case 'rows': $$_key = (int)$_value; break; @@ -74,11 +94,13 @@ case 'hdir': case 'vdir': case 'inner': + case 'caption': $$_key = (string)$_value; break; case 'tr_attr': case 'td_attr': + case 'th_attr': $$_key = $_value; break; } @@ -87,25 +109,42 @@ $loop_count = count($loop); if (empty($params['rows'])) { /* no rows specified */ - $rows = ceil($loop_count/$cols); + $rows = ceil($loop_count/$cols_count); } elseif (empty($params['cols'])) { if (!empty($params['rows'])) { /* no cols specified, but rows */ - $cols = ceil($loop_count/$rows); + $cols_count = ceil($loop_count/$rows); } } $output = "<table $table_attr>\n"; + if (!empty($caption)) { + $output .= '<caption>' . $caption . "</caption>\n"; + } + + if (is_array($cols)) { + $cols = ($hdir == 'right') ? $cols : array_reverse($cols); + $output .= "<thead><tr>\n"; + + for ($r=0; $r<$cols_count; $r++) { + $output .= '<th' . smarty_function_html_table_cycle('th', $th_attr, $r) . '>'; + $output .= $cols[$r]; + $output .= "</th>\n"; + } + $output .= "</tr></thead>\n"; + } + + $output .= "<tbody>\n"; for ($r=0; $r<$rows; $r++) { $output .= "<tr" . smarty_function_html_table_cycle('tr', $tr_attr, $r) . ">\n"; - $rx = ($vdir == 'down') ? $r*$cols : ($rows-1-$r)*$cols; + $rx = ($vdir == 'down') ? $r*$cols_count : ($rows-1-$r)*$cols_count; - for ($c=0; $c<$cols; $c++) { - $x = ($hdir == 'right') ? $rx+$c : $rx+$cols-1-$c; + for ($c=0; $c<$cols_count; $c++) { + $x = ($hdir == 'right') ? $rx+$c : $rx+$cols_count-1-$c; if ($inner!='cols') { /* shuffle x to loop over rows*/ - $x = floor($x/$cols) + ($x%$cols)*$rows; + $x = floor($x/$cols_count) + ($x%$cols_count)*$rows; } if ($x<$loop_count) { @@ -116,6 +155,7 @@ } $output .= "</tr>\n"; } + $output .= "</tbody>\n"; $output .= "</table>\n"; return $output; Index: xoops2jp/html/class/smarty/plugins/function.mailto.php diff -u xoops2jp/html/class/smarty/plugins/function.mailto.php:1.2.8.1 xoops2jp/html/class/smarty/plugins/function.mailto.php:1.2.8.1.2.1 --- xoops2jp/html/class/smarty/plugins/function.mailto.php:1.2.8.1 Sun Nov 20 17:05:54 2005 +++ xoops2jp/html/class/smarty/plugins/function.mailto.php Tue Dec 26 23:26:51 2006 @@ -62,6 +62,8 @@ // netscape and mozilla do not decode %40 (@) in BCC field (bug?) // so, don't encode it. + $search = array('%40', '%2C'); + $replace = array('@', ','); $mail_parms = array(); foreach ($params as $var=>$value) { switch ($var) { @@ -69,7 +71,7 @@ case 'bcc': case 'followupto': if (!empty($value)) - $mail_parms[] = $var.'='.str_replace('%40','@',rawurlencode($value)); + $mail_parms[] = $var.'='.str_replace($search,$replace,rawurlencode($value)); break; case 'subject': Index: xoops2jp/html/class/smarty/plugins/modifier.capitalize.php diff -u xoops2jp/html/class/smarty/plugins/modifier.capitalize.php:1.2.8.1 xoops2jp/html/class/smarty/plugins/modifier.capitalize.php:1.2.8.1.2.1 --- xoops2jp/html/class/smarty/plugins/modifier.capitalize.php:1.2.8.1 Fri Jan 27 23:34:11 2006 +++ xoops2jp/html/class/smarty/plugins/modifier.capitalize.php Tue Dec 26 23:26:51 2006 @@ -21,7 +21,7 @@ function smarty_modifier_capitalize($string, $uc_digits = false) { smarty_modifier_capitalize_ucfirst(null, $uc_digits); - return preg_replace_callback('!\b\w+\b!', 'smarty_modifier_capitalize_ucfirst', $string); + return preg_replace_callback('!\'?\b\w(\w|\')*\b!', 'smarty_modifier_capitalize_ucfirst', $string); } function smarty_modifier_capitalize_ucfirst($string, $uc_digits = null) @@ -33,7 +33,7 @@ return; } - if(!preg_match('!\d!',$string[0]) || $_uc_digits) + if(substr($string[0],0,1) != "'" && !preg_match("!\d!",$string[0]) || $_uc_digits) return ucfirst($string[0]); else return $string[0]; Index: xoops2jp/html/class/smarty/plugins/modifier.date_format.php diff -u xoops2jp/html/class/smarty/plugins/modifier.date_format.php:1.2.8.1 xoops2jp/html/class/smarty/plugins/modifier.date_format.php:1.2.8.1.2.1 --- xoops2jp/html/class/smarty/plugins/modifier.date_format.php:1.2.8.1 Fri Jan 27 23:34:11 2006 +++ xoops2jp/html/class/smarty/plugins/modifier.date_format.php Tue Dec 26 23:26:51 2006 @@ -31,9 +31,11 @@ function smarty_modifier_date_format($string, $format="%b %e, %Y", $default_date=null) { if (substr(PHP_OS,0,3) == 'WIN') { - $_win_from = array ('%e', '%T', '%D'); - $_win_to = array ('%#d', '%H:%M:%S', '%m/%d/%y'); - $format = str_replace($_win_from, $_win_to, $format); + $hours = strftime('%I', $string); + $short_hours = ( $hours < 10 ) ? substr( $hours, -1) : $hours; + $_win_from = array ('%e', '%T', '%D', '%l'); + $_win_to = array ('%#d', '%H:%M:%S', '%m/%d/%y', $short_hours); + $format = str_replace($_win_from, $_win_to, $format); } if($string != '') { return strftime($format, smarty_make_timestamp($string)); Index: xoops2jp/html/class/smarty/plugins/modifier.debug_print_var.php diff -u xoops2jp/html/class/smarty/plugins/modifier.debug_print_var.php:1.2.8.1 xoops2jp/html/class/smarty/plugins/modifier.debug_print_var.php:1.2.8.1.2.1 --- xoops2jp/html/class/smarty/plugins/modifier.debug_print_var.php:1.2.8.1 Fri Jan 27 23:34:11 2006 +++ xoops2jp/html/class/smarty/plugins/modifier.debug_print_var.php Tue Dec 26 23:26:51 2006 @@ -22,33 +22,66 @@ */ function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40) { - $_replace = array("\n"=>'<i>\n</i>', "\r"=>'<i>\r</i>', "\t"=>'<i>\t</i>'); - if (is_array($var)) { - $results = "<b>Array (".count($var).")</b>"; - foreach ($var as $curr_key => $curr_val) { - $return = smarty_modifier_debug_print_var($curr_val, $depth+1, $length); - $results .= "<br>".str_repeat(' ', $depth*2)."<b>".strtr($curr_key, $_replace)."</b> => $return"; - } - } else if (is_object($var)) { - $object_vars = get_object_vars($var); - $results = "<b>".get_class($var)." Object (".count($object_vars).")</b>"; - foreach ($object_vars as $curr_key => $curr_val) { - $return = smarty_modifier_debug_print_var($curr_val, $depth+1, $length); - $results .= "<br>".str_repeat(' ', $depth*2)."<b>$curr_key</b> => $return"; - } - } else if (is_resource($var)) { - $results = '<i>'.(string)$var.'</i>'; - } else if (empty($var) && $var != "0") { - $results = '<i>empty</i>'; - } else { - if (strlen($var) > $length ) { - $results = substr($var, 0, $length-3).'...'; - } else { - $results = $var; - } - $results = htmlspecialchars($results); - $results = strtr($results, $_replace); + $_replace = array( + "\n" => '<i>\n</i>', + "\r" => '<i>\r</i>', + "\t" => '<i>\t</i>' + ); + + switch (gettype($var)) { + case 'array' : + $results = '<b>Array (' . count($var) . ')</b>'; + foreach ($var as $curr_key => $curr_val) { + $results .= '<br>' . str_repeat(' ', $depth * 2) + . '<b>' . strtr($curr_key, $_replace) . '</b> => ' + . smarty_modifier_debug_print_var($curr_val, ++$depth, $length); + $depth--; + } + break; + case 'object' : + $object_vars = get_object_vars($var); + $results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>'; + foreach ($object_vars as $curr_key => $curr_val) { + $results .= '<br>' . str_repeat(' ', $depth * 2) + . '<b> ->' . strtr($curr_key, $_replace) . '</b> = ' + . smarty_modifier_debug_print_var($curr_val, ++$depth, $length); + $depth--; + } + break; + case 'boolean' : + case 'NULL' : + case 'resource' : + if (true === $var) { + $results = 'true'; + } elseif (false === $var) { + $results = 'false'; + } elseif (null === $var) { + $results = 'null'; + } else { + $results = htmlspecialchars((string) $var); + } + $results = '<i>' . $results . '</i>'; + break; + case 'integer' : + case 'float' : + $results = htmlspecialchars((string) $var); + break; + case 'string' : + $results = strtr($var, $_replace); + if (strlen($var) > $length ) { + $results = substr($var, 0, $length - 3) . '...'; + } + $results = htmlspecialchars('"' . $results . '"'); + break; + case 'unknown type' : + default : + $results = strtr((string) $var, $_replace); + if (strlen($results) > $length ) { + $results = substr($results, 0, $length - 3) . '...'; + } + $results = htmlspecialchars($results); } + return $results; } Index: xoops2jp/html/class/smarty/plugins/modifier.regex_replace.php diff -u xoops2jp/html/class/smarty/plugins/modifier.regex_replace.php:1.2.8.2 xoops2jp/html/class/smarty/plugins/modifier.regex_replace.php:1.2.8.2.2.1 --- xoops2jp/html/class/smarty/plugins/modifier.regex_replace.php:1.2.8.2 Fri Jan 27 23:34:11 2006 +++ xoops2jp/html/class/smarty/plugins/modifier.regex_replace.php Tue Dec 26 23:26:51 2006 @@ -11,7 +11,7 @@ * * Type: modifier<br> * Name: regex_replace<br> - * Purpose: regular epxression search/replace + * Purpose: regular expression search/replace * @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php * regex_replace (Smarty online manual) * @author Monte Ohrt <monte at ohrt dot com> @@ -22,10 +22,11 @@ */ function smarty_modifier_regex_replace($string, $search, $replace) { - if (preg_match('!\W(\w+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) { + if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) { /* remove eval-modifier from $search */ - $search = substr($search, 0, -strlen($match[1])) . str_replace('e', '', $match[1]); + $search = substr($search, 0, -strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]); } + return preg_replace($search, $replace, $string); } Index: xoops2jp/html/class/smarty/plugins/outputfilter.trimwhitespace.php diff -u xoops2jp/html/class/smarty/plugins/outputfilter.trimwhitespace.php:1.2.8.1 xoops2jp/html/class/smarty/plugins/outputfilter.trimwhitespace.php:1.2.8.1.2.1 --- xoops2jp/html/class/smarty/plugins/outputfilter.trimwhitespace.php:1.2.8.1 Sun Nov 20 17:05:54 2005 +++ xoops2jp/html/class/smarty/plugins/outputfilter.trimwhitespace.php Tue Dec 26 23:26:51 2006 @@ -49,14 +49,14 @@ // preceeded by a php close tag. $source = trim(preg_replace('/((?<!\?>)\n)[\s]+/m', '\1', $source)); - // replace script blocks - smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@",$_script_blocks, $source); + // replace textarea blocks + smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@",$_textarea_blocks, $source); // replace pre blocks smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@",$_pre_blocks, $source); - // replace textarea blocks - smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@",$_textarea_blocks, $source); + // replace script blocks + smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@",$_script_blocks, $source); return $source; }