X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/098a79f0819ebb89b7d48df4a6b154af4560f68e..9a23a8c0a51b7ec38a96f525484134f3cb85dc7e:/WEB-INF/lib/smarty/plugins/function.mailto.php
diff --git a/WEB-INF/lib/smarty/plugins/function.mailto.php b/WEB-INF/lib/smarty/plugins/function.mailto.php
new file mode 100644
index 00000000..976218f5
--- /dev/null
+++ b/WEB-INF/lib/smarty/plugins/function.mailto.php
@@ -0,0 +1,156 @@
+
+ * Name: mailto
+ * Date: May 21, 2002
+ * Purpose: automate mailto address link creation, and optionally
+ * encode them.
+ *
+ * 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://smarty.php.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
+ * Input:
+ * - 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
+ */
+function smarty_function_mailto($params, $template)
+{
+ $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.
+ $search = array('%40', '%2C');
+ $replace = array('@', ',');
+ $mail_parms = array();
+ foreach ($params as $var => $value) {
+ switch ($var) {
+ case 'cc':
+ case 'bcc':
+ case 'followupto':
+ 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;
+
+ default:
+ }
+ }
+
+ $mail_parm_vals = '';
+ for ($i = 0; $i < count($mail_parms); $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);
+ return;
+ }
+
+ if ($encode == 'javascript') {
+ $string = 'document.write(\'' . $text . '\');';
+
+ $js_encode = '';
+ for ($x = 0; $x < strlen($string); $x++) {
+ $js_encode .= '%' . bin2hex($string[$x]);
+ }
+
+ return '';
+ } elseif ($encode == 'javascript_charcode') {
+ $string = '' . $text . '';
+
+ for($x = 0, $y = strlen($string); $x < $y; $x++) {
+ $ord[] = ord($string[$x]);
+ }
+
+ $_ret = "\n";
+
+ return $_ret;
+ } 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; $x < strlen($address); $x++) {
+ if (preg_match('!\w!', $address[$x])) {
+ $address_encode .= '%' . bin2hex($address[$x]);
+ } else {
+ $address_encode .= $address[$x];
+ }
+ }
+ $text_encode = '';
+ for ($x = 0; $x < strlen($text); $x++) {
+ $text_encode .= '' . bin2hex($text[$x]) . ';';
+ }
+
+ $mailto = "mailto:";
+ return '' . $text_encode . '';
+ } else {
+ // no encoding
+ return '' . $text . '';
+ }
+}
+
+?>
\ No newline at end of file