* * address : target email address * * text : display text to show for the link, defaults to the address if not provided * * subject : the email subject * * encode : one of the available encoding (none, js, jscharcode or hex) * * cc : address(es) to carbon copy, comma separated * * bcc : address(es) to blind carbon copy, comma separated * * newsgroups : newsgroup(s) to post to, comma separated * * followupto : address(es) to follow up, comma separated * * extra : additional attributes to add to the <a> tag * * This software is provided 'as-is', without any express or implied warranty. * In no event will the authors be held liable for any damages arising from the use of this software. * * @author Jordi Boggiano * @copyright Copyright (c) 2008, Jordi Boggiano * @license http://dwoo.org/LICENSE Modified BSD License * @link http://dwoo.org/ * @version 1.1.0 * @date 2009-07-18 * @package Dwoo */ function Dwoo_Plugin_mailto(Dwoo $dwoo, $address, $text=null, $subject=null, $encode=null, $cc=null, $bcc=null, $newsgroups=null, $followupto=null, $extra=null) { if (empty($address)) { return ''; } if (empty($text)) { $text = $address; } // build address string $address .= '?'; if (!empty($subject)) { $address .= 'subject='.rawurlencode($subject).'&'; } if (!empty($cc)) { $address .= 'cc='.rawurlencode($cc).'&'; } if (!empty($bcc)) { $address .= 'bcc='.rawurlencode($bcc).'&'; } if (!empty($newsgroups)) { $address .= 'newsgroups='.rawurlencode($newsgroups).'&'; } if (!empty($followupto)) { $address .= 'followupto='.rawurlencode($followupto).'&'; } $address = rtrim($address, '?&'); // output switch($encode) { case 'none': case null: return ''.$text.''; case 'js': case 'javascript': $str = 'document.write(\''.$text.'\');'; $len = strlen($str); $out = ''; for ($i=0; $i<$len; $i++) { $out .= '%'.bin2hex($str[$i]); } return ''; break; case 'javascript_charcode': case 'js_charcode': case 'jscharcode': case 'jschar': $str = ''.$text.''; $len = strlen($str); $out = '\n"; break; case 'hex': if (strpos($address, '?') !== false) { return $dwoo->triggerError('Mailto: Hex encoding is not possible with extra attributes, use one of : js, jscharcode or none.', E_USER_WARNING); } $out = ''; $len = strlen($text); for ($i=0; $i<$len; $i++) { $out .= '&#x'.bin2hex($text[$i]); } return $out.''; default: return $dwoo->triggerError('Mailto: encode argument is invalid, it must be one of : none (= no value), js, js_charcode or hex', E_USER_WARNING); } }