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