From 6b3225138a33ecc6158fed794bbd6d4445fc4e36 Mon Sep 17 00:00:00 2001 From: mohrt Date: Fri, 25 Feb 2005 17:08:28 +0000 Subject: [PATCH] add javascript_charcode option to mailto --- NEWS | 2 ++ libs/plugins/function.mailto.php | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index d788a5c9..fd37976b 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ + - add javascript_charcode encoding option to mailto function + (monte) - add ids to html_radios labels (monte, menulis) - fix handling of strip-tags with non-default delimiters (Mark West, messju) diff --git a/libs/plugins/function.mailto.php b/libs/plugins/function.mailto.php index 7c3c20e1..64c122ce 100644 --- a/libs/plugins/function.mailto.php +++ b/libs/plugins/function.mailto.php @@ -20,6 +20,7 @@ * - encode = (optional) can be one of: * * none : no encoding (default) * * javascript : encode with javascript + * * javascript_charcode : encode with javascript charcode * * hex : encode with hexidecimal (no javascript) * - cc = (optional) address(es) to carbon copy * - bcc = (optional) address(es) to blind carbon copy @@ -92,7 +93,7 @@ function smarty_function_mailto($params, &$smarty) $address .= $mail_parm_vals; $encode = (empty($params['encode'])) ? 'none' : $params['encode']; - if (!in_array($encode,array('javascript','hex','none')) ) { + if (!in_array($encode,array('javascript','javascript_charcode','hex','none')) ) { $smarty->trigger_error("mailto: 'encode' parameter must be none, javascript or hex"); return; } @@ -107,6 +108,25 @@ function smarty_function_mailto($params, &$smarty) return ''; + } elseif ($encode == 'javascript_charcode' ) { + $string = ''.$text.''; + + for($x = 0, $y = strlen($string); $x < $y; $x++ ) { + $ord[] = ord($string[$x]); + } + + $_ret = "\n"; + + return $_ret; + + } elseif ($encode == 'hex') { preg_match('!^(.*)(\?.*)$!',$address,$match);