summaryrefslogtreecommitdiff
path: root/lib/smarty3/plugins/function.mailto.php
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2018-10-18 02:40:38 +0200
committeremkael <emkael@tlen.pl>2018-10-18 02:40:38 +0200
commiteab8a101e7a3fcbb41e01a574985e06c5a3775de (patch)
tree60f201da5984b0c3638d10da02bba42b61aa3177 /lib/smarty3/plugins/function.mailto.php
parent7f38be342c1495aeca418286c15c25c18ac9e142 (diff)
Updating Smarty
Diffstat (limited to 'lib/smarty3/plugins/function.mailto.php')
-rw-r--r--lib/smarty3/plugins/function.mailto.php62
1 files changed, 23 insertions, 39 deletions
diff --git a/lib/smarty3/plugins/function.mailto.php b/lib/smarty3/plugins/function.mailto.php
index 9d2a5d2..27351df 100644
--- a/lib/smarty3/plugins/function.mailto.php
+++ b/lib/smarty3/plugins/function.mailto.php
@@ -5,44 +5,42 @@
* @package Smarty
* @subpackage PluginsFunction
*/
-
/**
* Smarty {mailto} function plugin
- * Type: function<br>
- * Name: mailto<br>
+ * Type: function
+ * Name: mailto
* Date: May 21, 2002
- * Purpose: automate mailto address link creation, and optionally encode them.<br>
+ * Purpose: automate mailto address link creation, and optionally encode them.
* Params:
- * <pre>
+ *
* - address - (required) - e-mail address
* - text - (optional) - text to display, default is address
* - encode - (optional) - can be one of:
* * none : no encoding (default)
* * javascript : encode with javascript
* * javascript_charcode : encode with javascript charcode
- * * hex : encode with hexidecimal (no javascript)
+ * * hex : encode with hexadecimal (no javascript)
* - cc - (optional) - address(es) to carbon copy
* - bcc - (optional) - address(es) to blind carbon copy
* - subject - (optional) - e-mail subject
* - newsgroups - (optional) - newsgroup(s) to post to
* - followupto - (optional) - address(es) to follow up to
* - extra - (optional) - extra tags for the href link
- * </pre>
+ *
* Examples:
- * <pre>
+ *
* {mailto address="me@domain.com"}
* {mailto address="me@domain.com" encode="javascript"}
* {mailto address="me@domain.com" encode="hex"}
* {mailto address="me@domain.com" subject="Hello to you!"}
* {mailto address="me@domain.com" cc="you@domain.com,they@domain.com"}
* {mailto address="me@domain.com" extra='class="mailto"'}
- * </pre>
*
- * @link http://www.smarty.net/manual/en/language.function.mailto.php {mailto}
+ * @link http://www.smarty.net/manual/en/language.function.mailto.php {mailto}
* (Smarty online manual)
- * @version 1.2
- * @author Monte Ohrt <monte at ohrt dot com>
- * @author credits to Jason Sweat (added cc, bcc and subject functionality)
+ * @version 1.2
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @author credits to Jason Sweat (added cc, bcc and subject functionality)
*
* @param array $params parameters
*
@@ -53,15 +51,12 @@ function smarty_function_mailto($params)
static $_allowed_encoding =
array('javascript' => true, 'javascript_charcode' => true, 'hex' => true, 'none' => true);
$extra = '';
-
if (empty($params[ 'address' ])) {
trigger_error("mailto: missing 'address' parameter", E_USER_WARNING);
-
return;
} else {
$address = $params[ 'address' ];
}
-
$text = $address;
// netscape and mozilla do not decode %40 (@) in BCC field (bug?)
// so, don't encode it.
@@ -77,61 +72,52 @@ function smarty_function_mailto($params)
$mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value));
}
break;
-
case 'subject':
case 'newsgroups':
$mail_parms[] = $var . '=' . rawurlencode($value);
break;
-
case 'extra':
case 'text':
$$var = $value;
-
+ // no break
default:
}
}
-
if ($mail_parms) {
$address .= '?' . join('&', $mail_parms);
}
-
$encode = (empty($params[ 'encode' ])) ? 'none' : $params[ 'encode' ];
if (!isset($_allowed_encoding[ $encode ])) {
- trigger_error("mailto: 'encode' parameter must be none, javascript, javascript_charcode or hex",
- E_USER_WARNING);
-
+ trigger_error(
+ "mailto: 'encode' parameter must be none, javascript, javascript_charcode or hex",
+ E_USER_WARNING
+ );
return;
}
// FIXME: (rodneyrehm) document.write() excues me what? 1998 has passed!
- if ($encode == 'javascript') {
+ if ($encode === 'javascript') {
$string = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');';
-
$js_encode = '';
- for ($x = 0, $_length = strlen($string); $x < $_length; $x ++) {
+ for ($x = 0, $_length = strlen($string); $x < $_length; $x++) {
$js_encode .= '%' . bin2hex($string[ $x ]);
}
-
return '<script type="text/javascript">eval(unescape(\'' . $js_encode . '\'))</script>';
- } elseif ($encode == 'javascript_charcode') {
+ } elseif ($encode === 'javascript_charcode') {
$string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
-
- for ($x = 0, $y = strlen($string); $x < $y; $x ++) {
+ for ($x = 0, $y = strlen($string); $x < $y; $x++) {
$ord[] = ord($string[ $x ]);
}
-
$_ret = "<script type=\"text/javascript\" language=\"javascript\">\n" . "{document.write(String.fromCharCode(" .
implode(',', $ord) . "))" . "}\n" . "</script>\n";
-
return $_ret;
- } elseif ($encode == 'hex') {
+ } elseif ($encode === 'hex') {
preg_match('!^(.*)(\?.*)$!', $address, $match);
if (!empty($match[ 2 ])) {
trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.", E_USER_WARNING);
-
return;
}
$address_encode = '';
- for ($x = 0, $_length = strlen($address); $x < $_length; $x ++) {
+ for ($x = 0, $_length = strlen($address); $x < $_length; $x++) {
if (preg_match('!\w!' . Smarty::$_UTF8_MODIFIER, $address[ $x ])) {
$address_encode .= '%' . bin2hex($address[ $x ]);
} else {
@@ -139,12 +125,10 @@ function smarty_function_mailto($params)
}
}
$text_encode = '';
- for ($x = 0, $_length = strlen($text); $x < $_length; $x ++) {
+ for ($x = 0, $_length = strlen($text); $x < $_length; $x++) {
$text_encode .= '&#x' . bin2hex($text[ $x ]) . ';';
}
-
$mailto = "&#109;&#97;&#105;&#108;&#116;&#111;&#58;";
-
return '<a href="' . $mailto . $address_encode . '" ' . $extra . '>' . $text_encode . '</a>';
} else {
// no encoding