mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-06 03:14:27 +02:00
add javascript_charcode option to mailto
This commit is contained in:
2
NEWS
2
NEWS
@@ -1,3 +1,5 @@
|
|||||||
|
- add javascript_charcode encoding option to mailto function
|
||||||
|
(monte)
|
||||||
- add ids to html_radios labels (monte, menulis)
|
- add ids to html_radios labels (monte, menulis)
|
||||||
- fix handling of strip-tags with non-default delimiters (Mark West, messju)
|
- fix handling of strip-tags with non-default delimiters (Mark West, messju)
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
* - encode = (optional) can be one of:
|
* - encode = (optional) can be one of:
|
||||||
* * none : no encoding (default)
|
* * none : no encoding (default)
|
||||||
* * javascript : encode with javascript
|
* * javascript : encode with javascript
|
||||||
|
* * javascript_charcode : encode with javascript charcode
|
||||||
* * hex : encode with hexidecimal (no javascript)
|
* * hex : encode with hexidecimal (no javascript)
|
||||||
* - cc = (optional) address(es) to carbon copy
|
* - cc = (optional) address(es) to carbon copy
|
||||||
* - bcc = (optional) address(es) to blind carbon copy
|
* - bcc = (optional) address(es) to blind carbon copy
|
||||||
@@ -92,7 +93,7 @@ function smarty_function_mailto($params, &$smarty)
|
|||||||
$address .= $mail_parm_vals;
|
$address .= $mail_parm_vals;
|
||||||
|
|
||||||
$encode = (empty($params['encode'])) ? 'none' : $params['encode'];
|
$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");
|
$smarty->trigger_error("mailto: 'encode' parameter must be none, javascript or hex");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -107,6 +108,25 @@ function smarty_function_mailto($params, &$smarty)
|
|||||||
|
|
||||||
return '<script type="text/javascript">eval(unescape(\''.$js_encode.'\'))</script>';
|
return '<script type="text/javascript">eval(unescape(\''.$js_encode.'\'))</script>';
|
||||||
|
|
||||||
|
} elseif ($encode == 'javascript_charcode' ) {
|
||||||
|
$string = '<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>';
|
||||||
|
|
||||||
|
for($x = 0, $y = strlen($string); $x < $y; $x++ ) {
|
||||||
|
$ord[] = ord($string[$x]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$_ret = "<script type=\"text/javascript\" language=\"javascript\">\n";
|
||||||
|
$_ret .= "<!--\n";
|
||||||
|
$_ret .= "{document.write(String.fromCharCode(";
|
||||||
|
$_ret .= implode(',',$ord);
|
||||||
|
$_ret .= "))";
|
||||||
|
$_ret .= "}\n";
|
||||||
|
$_ret .= "//-->\n";
|
||||||
|
$_ret .= "</script>\n";
|
||||||
|
|
||||||
|
return $_ret;
|
||||||
|
|
||||||
|
|
||||||
} elseif ($encode == 'hex') {
|
} elseif ($encode == 'hex') {
|
||||||
|
|
||||||
preg_match('!^(.*)(\?.*)$!',$address,$match);
|
preg_match('!^(.*)(\?.*)$!',$address,$match);
|
||||||
|
Reference in New Issue
Block a user