API: Gui
Filename:
fwpGui_emailMask.ctag
Released With:
5.0.0
Current Version:
1.1.0
Status: Active
Min Lasso Tested: 8.1.0
Max Lasso Tested: 8.5.3
Related:
Still don't get it?
Check out the talk list archives, or join and ask your questions.
Documentation Error or Request?
Email documentation corrections or comments
Creates a spambot repellent link and display of an email address. If the user's browser has JavaScript enabled, then a short JavaScript is written which assembles a dissected version of the email address and link. Because this is assembled client side on the fly as the page is rendered, the email address is not in a recognizable format in source code making it unlikely that a spambot will pick it up.
If JavaScript is not enabled, then a modified version of the email address in the format of user(at)domain.dom is written without an actual link.
[fwpGUI_emailMask: -addr=string, -link=string]
-addr - required : a properly formatted real email address
-link - optional : the text to display as the link. If unspecified, the email address will be displayed.
[fwpGUI_emailMask: -addr='me@private.com', -link='>contact']
<?lassoscript
//............................................................................
//
// pageblocks: (c) 2002-2007 http://www.pageblocks.org/
//
//............................................................................
/*
{fileName= fwpGui_emailMask }
{rsrcType= tag }
{rsrcName= fwpGui_emailMask.ctag }
{rsrcHTTP= http://www.pageblocks.org/refc/fwpGui_emailMask }
{lassoVrsnMin= 8.1.0 }
{lassoVrsnMax= 8.5.3 }
{author= Greg Willits, adapted from Johan Sölve tag at
http://www.listsearch.com/lassotalk.lasso?id=122260 }
{authorEmail= subscribe to pbTalk at www.pageblocks.org/talk/ }
{authorHTTP= www.pageblocks.org }
{desc= creates an email link using entities to mask
addresses from email harvesting robots }
{maintvsrn= 1.1 }
{maintrelease= 5.1.0 }
{maintdate= 2006-06-12 }
{maintauthor= Greg Willits }
{maintnotes= some little tweaks to make it a bit better }
{maintvsrn= 1.0 }
{maintrelease= 5.0.0 }
{maintdate= 2006-01-16 }
{maintauthor= Greg Willits }
{maintnotes= initial release }
*/
//.............................................................................
define_tag: 'fwpGUI_emailMask', -priority='replace',
-required='addr',
-optional='link';
local:
'fw_addr' = local:'addr',
'fw_link' = @local:'link',
'fw_addr2' = (string),
'fw_thisChar' = (string),
'fw_hex' = 0;
if: !(local:'fw_link');
#fw_link = #fw_addr;
#fw_link->(replace: '@', '-at-');
#fw_link->(replace: '.', '-dot-');
/if;
#fw_addr = 'mailto:' + #fw_addr;
// creates global variable hex map on first encounter
if: (global:'fw_gHexMap')->type != 'map';
global:'fw_gHexMap'=(map);
loop: -loopfrom=1, -loopto=255;
// convert decimal number to ascii character using decode_URL
#fw_hex = loop_count;
#fw_hex->(setformat: -hexadecimal=true);
#fw_hex = (string: #fw_hex);
#fw_hex->removeleading: '0x';
#fw_hex = '00' + #fw_hex;
#fw_hex = (#fw_hex)->(substring: (#fw_hex->length - 1));
$fw_gHexMap->(insert: (decode_url: ('%' + #fw_hex)) = #fw_hex);
/loop;
/if;
// converts the email addr to entities
iterate: #fw_addr, #fw_thisChar;
#fw_addr2 += '&#x';
#fw_addr2 += ($fw_gHexMap->find:#fw_thisChar);
#fw_addr2 += ';';
/iterate;
local:'fw_linkCode' = '<a href=" ' + #fw_addr2 + '">' + #fw_link + '</a>';
return: @#fw_linkCode;
/define_tag;
?>
© 2002-2012, pageblocks.org