Module: spamspan.module
Module Description: The SpamSpan module obfuscates email addresses to help prevent spambots from collecting them.
spamspan.Info
version = "5.x-1.0"
project = "spamspan"
spamspan. Module
// $Id: spamspan.module,v 1.7 2007/01/17 21:33:58 lakka Exp $
Issue: hook_footer: Add the javascript to each page - too late for some themes
Test Environment:
Platform: Windows XP, XAMPP, APACHE, PHP 4.4
IDE: NuSphere PhpED Version 4.6.3 Professional
Debugger: Integrated with NuSphere
Observed Problem: email addresses obfuscated correctly, but showing on page as if JavaScript was NOT active. This would happen using the “chameleon” theme. In other themes the email addresses would show normally as if JavaScript was active.
Conditions to Test / Verify Problem exists:
Enable “chameleon” theme and make it the active theme for the site ( or for one user ).
Go to any page that the content has an email address and you should see the obfuscated version of the email address.
Problem Cause:
SpamSpan waits until function “spamspan_footer()” is called to add the JavaScript requirements to the static variable $javascript. That function is called from theme.closure() function.
Theme.closure is normally called after the HTML for the head tag has already been formed.
Details:
In function “chameleon_page()”
- calls function $output .= drupal_get_js(); while building HTML for the “head” tag
calling drupal_get_js() here does not get the SpamSpan JavaScript because it has not been added to it yet.
- calls function $output .= theme_closure(); just before closing the “body” tag
which now causes hook_footer to get executed, where “drupal_add_js()” is called to add SpamSpan’s JavaScript….TOO LATE…..
Remedy:
This is a workaround that I have created for those who are using the chameleon theme and want to use SpamSpan until a solution in SpamSpan is completed.
IN “chameleon.theme” function “chameleon_page()” BEFORE:
// Get blocks before so that they can alter the header (JavaScript, Stylesheets etc.)
$blocks_left = theme_blocks('left');
$blocks_right = theme_blocks('right');
IN “chameleon.theme” function “chameleon_page()” AFTER:
// Get blocks before so that they can alter the header (JavaScript, Stylesheets etc.)
$blocks_left = theme_blocks('left');
$blocks_right = theme_blocks('right');
// Cludge to allow spamspan.module to register its JavaScript in the header
$cludge = theme_closure();
// End Cludge
Note: I can provide additional information, including screen prints from debugger sessions and page output if required.
Comments
Comment #1
lakka commentedThis should be fixed in the Drupal 6 branch.