Clickable emails

Author Message

David Eriksson

Tuesday 26 July 2005 6:20:06 am

We needed all email addresses to display as clickable mailto-links, and thus instead of hunting around in each and every template we modified the wash function. It doesn't really "wash" anymore, but it was the easiest solution we could find. Since we thus lost the spam filter, we developed a new one as well.

If anyone's interested, here's the patch:

*** lib/eztemplate/classes/eztemplatestringoperator.php Fri Jun 17 10:36:46 2005
--- lib/eztemplate/classes/eztemplatestringoperator.new Tue Jul 26 15:01:49 2005
***************
*** 354,359 ****
--- 354,374 ----
                                                array( $dotText,
                                                       $atText ),
                                                $operatorValue );
+
+               // Remove the spam filter
+               $addr = str_replace('SPAMFILTER', '', strip_tags($operatorValue));
+
+               // Encode to ASCII to prevent spam (since we removed the old spam filter)
+               $mailto = "mailto:";
+
+               $encodedEmail = '';
+               for ($i = 0; $i < strlen($addr); $i++)
+                       $encodedEmail .= '&#' . ord(substr($addr, $i)) . ';';
+
+               $operatorValue = "<a href='" . $mailto . $encodedEmail . "'>" . $encodedEmail . "</a>";
+
+               // done!
+
              } break;

              case 'pdf':

/David

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.