[phpMP-CVS] CVS: phpMP/includes/plugins block.textformat.php,NONE,1.1 function.debug.php,NONE,1.1 mo
Status: Pre-Alpha
Brought to you by:
heimidal
From: Brian R. <hei...@us...> - 2002-11-28 05:27:56
|
Update of /cvsroot/phpmp/phpMP/includes/plugins In directory sc8-pr-cvs1:/tmp/cvs-serv20362/includes/plugins Modified Files: function.html_options.php function.html_select_time.php function.popup_init.php modifier.debug_print_var.php modifier.default.php Added Files: block.textformat.php function.debug.php modifier.strip.php Log Message: Updated Smarty template engine --- NEW FILE: block.textformat.php --- <?php /* * Smarty plugin * ------------------------------------------------------------- * Type: block function * Name: textformat * Purpose: format text a certain way with preset styles * or custom wrap/indent settings * Params: style: string (email) * indent: integer (0) * wrap: integer (80) * wrap_char string ("\n") * indent_char: string (" ") * wrap_boundary: boolean (true) * ------------------------------------------------------------- */ function smarty_block_textformat($params, $content, &$this) { $style = null; $indent = 0; $indent_first = 0; $indent_char = ' '; $wrap = 80; $wrap_char = "\n"; $wrap_cut = false; $assign = null; if($content == null) { return true; } extract($params); if($style == 'email') { $wrap = 72; } // split into paragraphs $paragraphs = preg_split('![\r\n][\r\n]!',$content); foreach($paragraphs as $paragraph) { if($paragraph == '') { continue; } // convert mult. spaces & special chars to single space $paragraph = preg_replace(array('!\s+!','!(^\s+)|(\s+$)!'),array(' ',''),$paragraph); // indent first line if($indent_first > 0) { $paragraph = str_repeat($indent_char,$indent_first) . $paragraph; } // wordwrap sentences $paragraph = wordwrap($paragraph, $wrap - $indent, $wrap_char, $wrap_cut); // indent lines if($indent > 0) { $paragraph = preg_replace('!^!m',str_repeat($indent_char,$indent),$paragraph); } $output .= $paragraph . $wrap_char . $wrap_char; } if($assign != null) { $this->assign($assign,$output); } else { echo $output; } //echo $content; } /* vim: set expandtab: */ ?> --- NEW FILE: function.debug.php --- <?php /* * Smarty plugin * ------------------------------------------------------------- * Type: function * Name: debug * Version: 1.0 * Date: July 1, 2002 * Author: Monte Ohrt <mo...@is...> * Purpose: popup debug window * ------------------------------------------------------------- */ function smarty_function_debug($params, &$smarty) { if($params['output']) { $smarty->assign('_smarty_debug_output',$params['output']); } echo $smarty->_generate_debug_output(); } /* vim: set expandtab: */ ?> --- NEW FILE: modifier.strip.php --- <?php /* * Smarty plugin * ------------------------------------------------------------- * Type: modifier * Name: strip * Purpose: Replace all repeated spaces, newlines, tabs * with a single space or supplied replacement string. * Example: {$var|strip} {$var|strip:" "} * Author: Monte Ohrt <mo...@is...> * Version: 1.0 * Date: September 25th, 2002 * ------------------------------------------------------------- */ function smarty_modifier_strip($text, $replace = ' ') { return preg_replace('!\s+!', $replace, $text); } /* vim: set expandtab: */ ?> Index: function.html_options.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/plugins/function.html_options.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** function.html_options.php 25 Jul 2002 11:06:25 -0000 1.1 --- function.html_options.php 28 Nov 2002 05:27:53 -0000 1.2 *************** *** 22,29 **** settype($options, 'array'); foreach ($options as $key => $value) { ! $html_result .= "<option value=\"$key\""; ! if (in_array($key, $selected)) ! $html_result .= " selected=\"selected\""; ! $html_result .= ">$value</option>\n"; } } else { --- 22,26 ---- settype($options, 'array'); foreach ($options as $key => $value) { ! $html_result .= smarty_function_html_options_optoutput($key, $value, $selected); } } else { *************** *** 31,45 **** settype($values, 'array'); for ($i = 0, $for_max = count($output); $i < $for_max; $i++) { ! /* By default, check value against $selected */ ! $sel_check = $values[$i]; ! $html_result .= "<option"; ! if ($i < count($values)) ! $html_result .= " value=\"".$values[$i]."\""; ! else ! $sel_check = $output[$i]; /* if more outputs than values, then ! check output against $selected */ ! if (in_array($sel_check, $selected)) ! $html_result .= " selected=\"selected\""; ! $html_result .= ">".$output[$i]."</option>\n"; } } --- 28,36 ---- settype($values, 'array'); for ($i = 0, $for_max = count($output); $i < $for_max; $i++) { ! if ($i < count($values)) { ! $html_result .= smarty_function_html_options_optoutput($values[$i], $output[$i], $selected); ! } else { ! $html_result .= smarty_function_html_options_optoutput($output[$i], $output[$i], $selected); ! } } } *************** *** 49,52 **** --- 40,64 ---- else return $html_result; + } + + function smarty_function_html_options_optoutput($key, $value, $selected) { + if(!is_array($value)) { + $html_result = "<option label=\"$key\" value=\"$key\""; + if (in_array($key, $selected)) + $html_result .= " selected=\"selected\""; + $html_result .= ">$value</option>\n"; + } else { + $html_result = smarty_function_html_options_optgroup($key, $value, $selected); + } + return $html_result; + } + + function smarty_function_html_options_optgroup($key, $values, $selected) { + $optgroup_html = "<optgroup label=\"$key\">\n"; + foreach ($values as $key => $value) { + $optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected); + } + $optgroup_html .= "</optgroup>\n"; + return $optgroup_html; } Index: function.html_select_time.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/plugins/function.html_select_time.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** function.html_select_time.php 25 Jul 2002 11:06:25 -0000 1.1 --- function.html_select_time.php 28 Nov 2002 05:27:53 -0000 1.2 *************** *** 28,31 **** --- 28,36 ---- Can be combined with prefix. */ $field_array = null; + $all_extra = null; + $hour_extra = null; + $minute_extra = null; + $second_extra = null; + $meridian_extra = null; extract($params); *************** *** 42,49 **** $html_result .= '<select name='; if (null !== $field_array) { ! $html_result .= '"' . $field_array . '[' . $prefix . 'Hour]">'."\n"; } else { ! $html_result .= '"' . $prefix . 'Hour">'."\n"; } $html_result .= smarty_function_html_options(array('output' => $hours, 'values' => $hours, --- 47,61 ---- $html_result .= '<select name='; if (null !== $field_array) { ! $html_result .= '"' . $field_array . '[' . $prefix . 'Hour]"'; } else { ! $html_result .= '"' . $prefix . 'Hour"'; } + if (null !== $hour_extra){ + $html_result .= ' ' . $hour_extra; + } + if (null !== $all_extra){ + $html_result .= ' ' . $all_extra; + } + $html_result .= '>'."\n"; $html_result .= smarty_function_html_options(array('output' => $hours, 'values' => $hours, *************** *** 61,68 **** $html_result .= '<select name='; if (null !== $field_array) { ! $html_result .= '"' . $field_array . '[' . $prefix . 'Minute]">'."\n"; } else { ! $html_result .= '"' . $prefix . 'Minute">'."\n"; } $html_result .= smarty_function_html_options(array('output' => $minutes, 'values' => $minutes, --- 73,88 ---- $html_result .= '<select name='; if (null !== $field_array) { ! $html_result .= '"' . $field_array . '[' . $prefix . 'Minute]"'; } else { ! $html_result .= '"' . $prefix . 'Minute"'; ! } ! if (null !== $minute_extra){ ! $html_result .= ' ' . $minute_extra; ! } ! if (null !== $all_extra){ ! $html_result .= ' ' . $all_extra; } + $html_result .= '>'."\n"; + $html_result .= smarty_function_html_options(array('output' => $minutes, 'values' => $minutes, *************** *** 80,87 **** $html_result .= '<select name='; if (null !== $field_array) { ! $html_result .= '"' . $field_array . '[' . $prefix . 'Second]">'."\n"; } else { ! $html_result .= '"' . $prefix . 'Second">'."\n"; } $html_result .= smarty_function_html_options(array('output' => $seconds, 'values' => $seconds, --- 100,116 ---- $html_result .= '<select name='; if (null !== $field_array) { ! $html_result .= '"' . $field_array . '[' . $prefix . 'Second]"'; } else { ! $html_result .= '"' . $prefix . 'Second"'; } + + if (null !== $second_extra){ + $html_result .= ' ' . $second_extra; + } + if (null !== $all_extra){ + $html_result .= ' ' . $all_extra; + } + $html_result .= '>'."\n"; + $html_result .= smarty_function_html_options(array('output' => $seconds, 'values' => $seconds, *************** *** 95,102 **** $html_result .= '<select name='; if (null !== $field_array) { ! $html_result .= '"' . $field_array . '[' . $prefix . 'Meridian]">'."\n"; } else { ! $html_result .= '"' . $prefix . 'Meridian">'."\n"; } $html_result .= smarty_function_html_options(array('output' => array('AM', 'PM'), 'values' => array('am', 'pm'), --- 124,140 ---- $html_result .= '<select name='; if (null !== $field_array) { ! $html_result .= '"' . $field_array . '[' . $prefix . 'Meridian]"'; } else { ! $html_result .= '"' . $prefix . 'Meridian"'; ! } ! ! if (null !== $meridian_extra){ ! $html_result .= ' ' . $meridian_extra; ! } ! if (null !== $all_extra){ ! $html_result .= ' ' . $all_extra; } + $html_result .= '>'."\n"; + $html_result .= smarty_function_html_options(array('output' => array('AM', 'PM'), 'values' => array('am', 'pm'), Index: function.popup_init.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/plugins/function.popup_init.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** function.popup_init.php 25 Jul 2002 11:06:25 -0000 1.1 --- function.popup_init.php 28 Nov 2002 05:27:53 -0000 1.2 *************** *** 19,23 **** if (!empty($params['src'])) { echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:'.$zindex.';"></div>'."\n"; ! echo '<script language="JavaScript" src="'.$params['src'].'"></script>'."\n"; } else { $smarty->trigger_error("popup_init: missing src parameter"); --- 19,23 ---- if (!empty($params['src'])) { echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:'.$zindex.';"></div>'."\n"; ! echo '<script type="text/javascript" language="JavaScript" src="'.$params['src'].'"></script>'."\n"; } else { $smarty->trigger_error("popup_init: missing src parameter"); Index: modifier.debug_print_var.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/plugins/modifier.debug_print_var.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** modifier.debug_print_var.php 25 Jul 2002 11:06:25 -0000 1.1 --- modifier.debug_print_var.php 28 Nov 2002 05:27:53 -0000 1.2 *************** *** 18,21 **** --- 18,29 ---- } return $results; + } 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); + $results .= '<br>\r'.str_repeat(' ', $depth*2)."<b>$curr_key</b> => $return"; + } + return $results; } else { if (empty($var) && $var != "0") { Index: modifier.default.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/plugins/modifier.default.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** modifier.default.php 25 Jul 2002 11:06:25 -0000 1.1 --- modifier.default.php 28 Nov 2002 05:27:53 -0000 1.2 *************** *** 11,15 **** function smarty_modifier_default($string, $default = '') { ! if (empty($string)) return $default; else --- 11,15 ---- function smarty_modifier_default($string, $default = '') { ! if (!isset($string) || $string == '') return $default; else |