diff options
author | Thomas Willingham <beardyunixer@beardyunixer.com> | 2014-12-11 20:15:27 +0000 |
---|---|---|
committer | Thomas Willingham <beardyunixer@beardyunixer.com> | 2014-12-11 20:15:27 +0000 |
commit | 967ab871b836f618107fe144978bd1453c3c6634 (patch) | |
tree | 1bcb1b4bb1b25c904a2bc06f5c6d526d29909eaa /library/Smarty/libs/plugins/function.mailto.php | |
parent | 960c35bad3a0dbaa7a1f2191aef60ad014d926ca (diff) | |
download | volse-hubzilla-967ab871b836f618107fe144978bd1453c3c6634.tar.gz volse-hubzilla-967ab871b836f618107fe144978bd1453c3c6634.tar.bz2 volse-hubzilla-967ab871b836f618107fe144978bd1453c3c6634.zip |
Update Smarty
Diffstat (limited to 'library/Smarty/libs/plugins/function.mailto.php')
-rw-r--r-- | library/Smarty/libs/plugins/function.mailto.php | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/library/Smarty/libs/plugins/function.mailto.php b/library/Smarty/libs/plugins/function.mailto.php index 55d5c0602..520fb7aa6 100644 --- a/library/Smarty/libs/plugins/function.mailto.php +++ b/library/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 = "mailto:"; + 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 |