removed extract-call -> cleaner parameter-handling

This commit is contained in:
messju
2003-12-11 09:38:18 +00:00
parent ec0a2dabd0
commit 0d6c033ee2

View File

@@ -49,39 +49,39 @@
function smarty_function_mailto($params, &$smarty) function smarty_function_mailto($params, &$smarty)
{ {
$extra = ''; $extra = '';
extract($params);
if (empty($address)) { if (empty($params['address'])) {
$smarty->trigger_error("mailto: missing 'address' parameter"); $smarty->trigger_error("mailto: missing 'address' parameter");
return; return;
} else {
$address = $params['address'];
} }
if (empty($text)) {
$text = $address; $text = $address;
}
// netscape and mozilla do not decode %40 (@) in BCC field (bug?) // netscape and mozilla do not decode %40 (@) in BCC field (bug?)
// so, don't encode it. // so, don't encode it.
$mail_parms = array(); $mail_parms = array();
if (!empty($cc)) { foreach ($params as $var=>$value) {
$mail_parms[] = 'cc='.str_replace('%40','@',rawurlencode($cc)); switch ($var) {
} case 'cc':
case 'bcc':
case 'followupto':
if (!empty($value))
$mail_parms[] = $var.'='.str_replace('%40','@',rawurlencode($value));
break;
if (!empty($bcc)) { case 'subject':
$mail_parms[] = 'bcc='.str_replace('%40','@',rawurlencode($bcc)); case 'newsgroups':
} $mail_parms[] = $var.'='.rawurlencode($value);
break;
if (!empty($subject)) { case 'extra':
$mail_parms[] = 'subject='.rawurlencode($subject); case 'text':
} $$var = $value;
if (!empty($newsgroups)) { default:
$mail_parms[] = 'newsgroups='.rawurlencode($newsgroups);
} }
if (!empty($followupto)) {
$mail_parms[] = 'followupto='.str_replace('%40','@',rawurlencode($followupto));
} }
$mail_parm_vals = ''; $mail_parm_vals = '';
@@ -91,9 +91,8 @@ function smarty_function_mailto($params, &$smarty)
} }
$address .= $mail_parm_vals; $address .= $mail_parm_vals;
if (empty($encode)) { $encode = (empty($params['encode'])) ? 'none' : $params['encode'];
$encode = 'none'; if (!in_array($encode,array('javascript','hex','none')) ) {
} elseif (!in_array($encode,array('javascript','hex','none')) ) {
$smarty->trigger_error("mailto: 'encode' parameter must be none, javascript or hex"); $smarty->trigger_error("mailto: 'encode' parameter must be none, javascript or hex");
return; return;
} }