fixed indentiation

This commit is contained in:
messju
2003-12-11 09:25:23 +00:00
parent f2f91fd751
commit ec0a2dabd0

View File

@@ -40,11 +40,11 @@
* @link http://smarty.php.net/manual/en/language.function.mailto.php {mailto} * @link http://smarty.php.net/manual/en/language.function.mailto.php {mailto}
* (Smarty online manual) * (Smarty online manual)
* @version 1.2 * @version 1.2
* @author Monte Ohrt <monte@ispi.net> * @author Monte Ohrt <monte@ispi.net>
* @author credits to Jason Sweat (added cc, bcc and subject functionality) * @author credits to Jason Sweat (added cc, bcc and subject functionality)
* @param array * @param array
* @param Smarty * @param Smarty
* @return string * @return string
*/ */
function smarty_function_mailto($params, &$smarty) function smarty_function_mailto($params, &$smarty)
{ {
@@ -57,81 +57,81 @@ function smarty_function_mailto($params, &$smarty)
} }
if (empty($text)) { 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)) { if (!empty($cc)) {
$mail_parms[] = 'cc='.str_replace('%40','@',rawurlencode($cc)); $mail_parms[] = 'cc='.str_replace('%40','@',rawurlencode($cc));
} }
if (!empty($bcc)) { if (!empty($bcc)) {
$mail_parms[] = 'bcc='.str_replace('%40','@',rawurlencode($bcc)); $mail_parms[] = 'bcc='.str_replace('%40','@',rawurlencode($bcc));
} }
if (!empty($subject)) { if (!empty($subject)) {
$mail_parms[] = 'subject='.rawurlencode($subject); $mail_parms[] = 'subject='.rawurlencode($subject);
} }
if (!empty($newsgroups)) { if (!empty($newsgroups)) {
$mail_parms[] = 'newsgroups='.rawurlencode($newsgroups); $mail_parms[] = 'newsgroups='.rawurlencode($newsgroups);
} }
if (!empty($followupto)) { if (!empty($followupto)) {
$mail_parms[] = 'followupto='.str_replace('%40','@',rawurlencode($followupto)); $mail_parms[] = 'followupto='.str_replace('%40','@',rawurlencode($followupto));
} }
$mail_parm_vals = ''; $mail_parm_vals = '';
for ($i=0; $i<count($mail_parms); $i++) { for ($i=0; $i<count($mail_parms); $i++) {
$mail_parm_vals .= (0==$i) ? '?' : '&'; $mail_parm_vals .= (0==$i) ? '?' : '&';
$mail_parm_vals .= $mail_parms[$i]; $mail_parm_vals .= $mail_parms[$i];
} }
$address .= $mail_parm_vals; $address .= $mail_parm_vals;
if (empty($encode)) { if (empty($encode)) {
$encode = 'none'; $encode = 'none';
} elseif (!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;
} }
if ($encode == 'javascript' ) { if ($encode == 'javascript' ) {
$string = 'document.write(\'<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>\');'; $string = 'document.write(\'<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>\');';
for ($x=0; $x < strlen($string); $x++) { for ($x=0; $x < strlen($string); $x++) {
$js_encode .= '%' . bin2hex($string[$x]); $js_encode .= '%' . bin2hex($string[$x]);
} }
return '<script type="text/javascript" language="javascript">eval(unescape(\''.$js_encode.'\'))</script>'; return '<script type="text/javascript" language="javascript">eval(unescape(\''.$js_encode.'\'))</script>';
} elseif ($encode == 'hex') { } elseif ($encode == 'hex') {
preg_match('!^(.*)(\?.*)$!',$address,$match); preg_match('!^(.*)(\?.*)$!',$address,$match);
if(!empty($match[2])) { if(!empty($match[2])) {
$smarty->trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript."); $smarty->trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.");
return; return;
} }
for ($x=0; $x < strlen($address); $x++) { for ($x=0; $x < strlen($address); $x++) {
if(preg_match('!\w!',$address[$x])) { if(preg_match('!\w!',$address[$x])) {
$address_encode .= '%' . bin2hex($address[$x]); $address_encode .= '%' . bin2hex($address[$x]);
} else { } else {
$address_encode .= $address[$x]; $address_encode .= $address[$x];
} }
} }
for ($x=0; $x < strlen($text); $x++) { for ($x=0; $x < strlen($text); $x++) {
$text_encode .= '&#x' . bin2hex($text[$x]).';'; $text_encode .= '&#x' . bin2hex($text[$x]).';';
} }
return '<a href="mailto:'.$address_encode.'" '.$extra.'>'.$text_encode.'</a>'; return '<a href="mailto:'.$address_encode.'" '.$extra.'>'.$text_encode.'</a>';
} else { } else {
// no encoding // no encoding
return '<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>'; return '<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>';
} }
} }