cvs: smarty /libs/plugins function.mailto.php
"Messju Mohr" <[email protected]>
| Newsgroups | gmane.comp.php.cvs.smarty |
|---|---|
| Message-ID | <cvsmessju1071135498@cvsserver> |
messju Thu Dec 11 04:38:18 2003 EDT
Modified files:
/smarty/libs/plugins function.mailto.php
Log:
removed extract-call -> cleaner parameter-handling
Index: smarty/libs/plugins/function.mailto.php
diff -u smarty/libs/plugins/function.mailto.php:1.6 smarty/libs/plugins/function.mailto.php:1.7
--- smarty/libs/plugins/function.mailto.php:1.6 Thu Dec 11 04:25:23 2003
+++ smarty/libs/plugins/function.mailto.php Thu Dec 11 04:38:18 2003
@@ -48,40 +48,40 @@
*/
function smarty_function_mailto($params, &$smarty)
{
- $extra = '';
- extract($params);
+ $extra = '';
- if (empty($address)) {
+ if (empty($params['address'])) {
$smarty->trigger_error("mailto: missing 'address' parameter");
return;
+ } else {
+ $address = $params['address'];
}
- if (empty($text)) {
- $text = $address;
- }
+ $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));
- }
-
- if (!empty($bcc)) {
- $mail_parms[] = 'bcc='.str_replace('%40','@',rawurlencode($bcc));
- }
+ 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;
+
+ case 'subject':
+ case 'newsgroups':
+ $mail_parms[] = $var.'='.rawurlencode($value);
+ break;
+
+ case 'extra':
+ case 'text':
+ $$var = $value;
- if (!empty($subject)) {
- $mail_parms[] = 'subject='.rawurlencode($subject);
- }
-
- if (!empty($newsgroups)) {
- $mail_parms[] = 'newsgroups='.rawurlencode($newsgroups);
- }
-
- if (!empty($followupto)) {
- $mail_parms[] = 'followupto='.str_replace('%40','@',rawurlencode($followupto));
+ default:
+ }
}
$mail_parm_vals = '';
@@ -91,9 +91,8 @@
}
$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;
}
--
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php