Index: invisimail.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/invisimail/invisimail.module,v retrieving revision 1.3 diff -u -p -r1.3 invisimail.module --- invisimail.module 1 Oct 2007 23:07:12 -0000 1.3 +++ invisimail.module 25 Mar 2008 21:56:22 -0000 @@ -98,14 +98,32 @@ function invisimail($string, $format) { } function invisimail_callback($matches) { - return $matches[1] . invisimail_ascii_encode($matches[2]) . $matches[3]; -} - -function invisimail_ascii_encode($string) { $format = $GLOBALS['invisimail_format']; $js = variable_get('invisimail_js_'.$format, FALSE); $link = variable_get('invisimail_link_'.$format, FALSE); - + + return $matches[1] . invisimail_ascii_encode($matches[2], $js, $link) . $matches[3]; +} + +/** + * This function does the actual encoding. + * + * @param $string + * A string which contains only an email addres to be encoded. + * @param $js + * Optional: A boolean which sets whether Javascript is used for encoding. + * @param $link + * Optional: A boolean which set whether the result includes a mailto link. + * @param $text + * Optional: The text to be used for the link. + * @return + * An ascii encoded email address. + */ +function invisimail_ascii_encode($string, $js = FALSE, $link = FALSE, $text = NULL) { + if ($text == NULL) { + $text = $string; + } + if ($js) { $output = "