The module file contains a code
[code]
drupal_add_js($module_path . _swfaddress_optimizer('/swfaddress-2.1/js/swfaddress-optimizer.js?'),
array('cache' => FALSE, 'preprocess' => FALSE));
[/code]
The function drupal_add_js in drupal 7 automatically encodes the characters like '?', '&', etc.
Hence, the swfaddress-optimizer.js is not loaded and the whole module doesn't work.
Replacing the code with general script src='path', it works.
But using this ugly fix, loads that javascript everywhere, even in the xml pages and thus swf file cannot parse the xml.

CommentFileSizeAuthor
#3 1259588-swf-optimizer_load.patch934 bytesgarphy

Comments

makschmiel’s picture

Try this:

drupal_add_js( $GLOBALS['base_url'] .'/'. $module_path . _swfaddress_optimizer('/swfaddress-2.4/js/swfaddress-optimizer.js?'),
      array('type' => 'external', 'cache' => FALSE, 'preprocess' => FALSE));
sumanraj’s picture

That did not worked, either.
I used following script instead:

$swfScript = array(
	  '#type' => 'markup',
	  '#markup' => '<script language="javascript" src="'.$base_url . '/'.$module_path. _swfaddress_optimizer('/swfaddress-2.1/js/swfaddress-optimizer.js?').'" type="text/javascript"></script>',
	);
	drupal_add_html_head($swfScript, 'themename');

which worked pretty well, but I don't think this is the good way to add javascript.

garphy’s picture

Status: Active » Needs review
StatusFileSize
new934 bytes

#2 does the trick for me.
Patch attached. Reviews welcomed.

marabak’s picture

Hello Garphy,

there's is an other solution : just put a slash before $module_path :

drupal_add_js('/'.$module_path . _swfaddress_optimizer('/swfaddress-2.1/js/swfaddress-optimizer.js?'), array('cache' => FALSE, 'preprocess' => FALSE));

instead of :

drupal_add_js($module_path . _swfaddress_optimizer('/swfaddress-2.1/js/swfaddress-optimizer.js?'), array('cache' => FALSE, 'preprocess' => FALSE));

file_create_url() is not encoding paths starting with a slash.

garphy’s picture

Much more elegant indeed, but is it handling cases where Drupal lives in a subfolder ?
Maybe if we combine #1 & #4 by appending the base path when required (not tested).

garphy’s picture

Issue summary: View changes

replaced script src='path' instead of <script>