From ab5d8d4e07bb3c8230d0285ef8902ef1979fce51 Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 18 Oct 2018 02:39:34 +0200 Subject: Updating Smarty --- lib/smarty/plugins/function.mailto.php | 103 ++++++++++++++------------------- 1 file changed, 44 insertions(+), 59 deletions(-) (limited to 'lib/smarty/plugins/function.mailto.php') diff --git a/lib/smarty/plugins/function.mailto.php b/lib/smarty/plugins/function.mailto.php index 55d5c06..27351df 100644 --- a/lib/smarty/plugins/function.mailto.php +++ b/lib/smarty/plugins/function.mailto.php @@ -2,64 +2,61 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsFunction */ - /** * Smarty {mailto} function plugin - * - * Type: function
- * Name: mailto
+ * Type: function + * Name: mailto * Date: May 21, 2002 - * Purpose: automate mailto address link creation, and optionally encode them.
+ * Purpose: automate mailto address link creation, and optionally encode them. * Params: - *
+ *
  * - 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
- * 
+ * * Examples: - *
+ *
  * {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"'}
- * 
* - * @link http://www.smarty.net/manual/en/language.function.mailto.php {mailto} - * (Smarty online manual) + * @link http://www.smarty.net/manual/en/language.function.mailto.php {mailto} + * (Smarty online manual) * @version 1.2 - * @author Monte Ohrt - * @author credits to Jason Sweat (added cc, bcc and subject functionality) - * @param array $params parameters - * @param Smarty_Internal_Template $template template object + * @author Monte Ohrt + * @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); + 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); + if (empty($params[ 'address' ])) { + trigger_error("mailto: missing 'address' parameter", E_USER_WARNING); return; } else { - $address = $params['address']; + $address = $params[ 'address' ]; } - $text = $address; // netscape and mozilla do not decode %40 (@) in BCC field (bug?) // so, don't encode it. @@ -71,76 +68,66 @@ function smarty_function_mailto($params, $template) case 'cc': case 'bcc': case 'followupto': - if (!empty($value)) + if (!empty($value)) { $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); + $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! - if ($encode == 'javascript') { + if ($encode === 'javascript') { $string = 'document.write(\'' . $text . '\');'; - $js_encode = ''; for ($x = 0, $_length = strlen($string); $x < $_length; $x++) { - $js_encode .= '%' . bin2hex($string[$x]); + $js_encode .= '%' . bin2hex($string[ $x ]); } - return ''; - } elseif ($encode == 'javascript_charcode') { + } elseif ($encode === 'javascript_charcode') { $string = '' . $text . ''; - - for($x = 0, $y = strlen($string); $x < $y; $x++) { - $ord[] = ord($string[$x]); + for ($x = 0, $y = strlen($string); $x < $y; $x++) { + $ord[] = ord($string[ $x ]); } - - $_ret = "\n"; - + $_ret = "\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); + 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++) { - if (preg_match('!\w!' . Smarty::$_UTF8_MODIFIER, $address[$x])) { - $address_encode .= '%' . bin2hex($address[$x]); + if (preg_match('!\w!' . Smarty::$_UTF8_MODIFIER, $address[ $x ])) { + $address_encode .= '%' . bin2hex($address[ $x ]); } else { - $address_encode .= $address[$x]; + $address_encode .= $address[ $x ]; } } $text_encode = ''; for ($x = 0, $_length = strlen($text); $x < $_length; $x++) { - $text_encode .= '&#x' . bin2hex($text[$x]) . ';'; + $text_encode .= '&#x' . bin2hex($text[ $x ]) . ';'; } - $mailto = "mailto:"; return '' . $text_encode . ''; } else { @@ -148,5 +135,3 @@ function smarty_function_mailto($params, $template) return '' . $text . ''; } } - -?> \ No newline at end of file -- cgit v1.2.3