summaryrefslogtreecommitdiff
path: root/libs/plugins/function.mailto.php
diff options
context:
space:
mode:
Diffstat (limited to 'libs/plugins/function.mailto.php')
-rw-r--r--libs/plugins/function.mailto.php94
1 files changed, 47 insertions, 47 deletions
diff --git a/libs/plugins/function.mailto.php b/libs/plugins/function.mailto.php
index 976218f5..5875713a 100644
--- a/libs/plugins/function.mailto.php
+++ b/libs/plugins/function.mailto.php
@@ -1,20 +1,34 @@
<?php
/**
* Smarty plugin
- *
+ *
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {mailto} function plugin
- *
+ *
* Type: function<br>
* Name: mailto<br>
* 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.<br>
+ * 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)
+ * - 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"}
@@ -24,29 +38,15 @@
* {mailto address="me@domain.com" cc="you@domain.com,they@domain.com"}
* {mailto address="me@domain.com" extra='class="mailto"'}
* </pre>
- *
- * @link http://smarty.php.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)
- * @param array $params parameters
- * Input:<br>
- * - address = 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)
- * - 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
- * @param object $template template object
- * @return string
+ * @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
+ * @return string
*/
function smarty_function_mailto($params, $template)
{
@@ -57,9 +57,9 @@ function smarty_function_mailto($params, $template)
return;
} else {
$address = $params['address'];
- }
+ }
- $text = $address;
+ $text = $address;
// netscape and mozilla do not decode %40 (@) in BCC field (bug?)
// so, don't encode it.
$search = array('%40', '%2C');
@@ -84,29 +84,29 @@ function smarty_function_mailto($params, $template)
$$var = $value;
default:
- }
- }
+ }
+ }
$mail_parm_vals = '';
- for ($i = 0; $i < count($mail_parms); $i++) {
+ for ($i = 0, $_length = count($mail_parms); $i < $_length; $i++) {
$mail_parm_vals .= (0 == $i) ? '?' : '&';
$mail_parm_vals .= $mail_parms[$i];
- }
+ }
$address .= $mail_parm_vals;
$encode = (empty($params['encode'])) ? 'none' : $params['encode'];
if (!in_array($encode, array('javascript', 'javascript_charcode', 'hex', 'none'))) {
- trigger_error("mailto: 'encode' parameter must be none, javascript 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') {
$string = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');';
$js_encode = '';
- for ($x = 0; $x < strlen($string); $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') {
@@ -114,7 +114,7 @@ function smarty_function_mailto($params, $template)
for($x = 0, $y = strlen($string); $x < $y; $x++) {
$ord[] = ord($string[$x]);
- }
+ }
$_ret = "<script type=\"text/javascript\" language=\"javascript\">\n";
$_ret .= "<!--\n";
@@ -131,26 +131,26 @@ function smarty_function_mailto($params, $template)
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; $x < strlen($address); $x++) {
- if (preg_match('!\w!', $address[$x])) {
+ for ($x = 0, $_length = strlen($address); $x < $_length; $x++) {
+ if (preg_match('!\w!u', $address[$x])) {
$address_encode .= '%' . bin2hex($address[$x]);
} else {
$address_encode .= $address[$x];
- }
- }
+ }
+ }
$text_encode = '';
- for ($x = 0; $x < strlen($text); $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