aboutsummaryrefslogtreecommitdiffstats
path: root/include/smarty/libs/plugins/function.mailto.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/smarty/libs/plugins/function.mailto.php45
1 files changed, 24 insertions, 21 deletions
diff --git a/include/smarty/libs/plugins/function.mailto.php b/include/smarty/libs/plugins/function.mailto.php
index 55d5c0602..520fb7aa6 100644
--- a/include/smarty/libs/plugins/function.mailto.php
+++ b/include/smarty/libs/plugins/function.mailto.php
@@ -2,13 +2,12 @@
/**
* Smarty plugin
*
- * @package Smarty
+ * @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {mailto} function plugin
- *
* Type: function<br>
* Name: mailto<br>
* Date: May 21, 2002
@@ -39,22 +38,24 @@
* {mailto address="me@domain.com" extra='class="mailto"'}
* </pre>
*
- * @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)
- * @param array $params parameters
- * @param Smarty_Internal_Template $template template object
+ * @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)
+ *
+ * @param array $params parameters
+ *
* @return string
*/
-function smarty_function_mailto($params, $template)
+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);
+ trigger_error("mailto: missing 'address' parameter", E_USER_WARNING);
+
return;
} else {
$address = $params['address'];
@@ -71,8 +72,9 @@ function smarty_function_mailto($params, $template)
case 'cc':
case 'bcc':
case 'followupto':
- if (!empty($value))
- $mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value));
+ if (!empty($value)) {
+ $mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value));
+ }
break;
case 'subject':
@@ -91,10 +93,11 @@ function smarty_function_mailto($params, $template)
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);
+
return;
}
// FIXME: (rodneyrehm) document.write() excues me what? 1998 has passed!
@@ -102,7 +105,7 @@ function smarty_function_mailto($params, $template)
$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]);
}
@@ -110,7 +113,7 @@ function smarty_function_mailto($params, $template)
} 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]);
}
@@ -125,11 +128,12 @@ function smarty_function_mailto($params, $template)
} 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);
+ 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 {
@@ -137,16 +141,15 @@ function smarty_function_mailto($params, $template)
}
}
$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
return '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
}
}
-
-?> \ No newline at end of file