This might be regarded as off topic, but I hope someone here reads PHP.
I'm trying to get image maps to execute Jmol commands inside a
MediaWiki using Nico's Jmol extension.
Jmol windows are loading just fine but I need to pass the commands
from the image maps. I contacted Tim Starling who wrote the Image Map
Extension for help and he suggested some code but it is not working
and I can't see how to correct it.
No, external links are limited to a set of previously defined
protocols, such as http: and https:. This is for security. If we
allowed javascript:, then someone could make a link which, when
clicked, steals your login session and posts it to another site for
exploitation.
What I would suggest is that you patch ImageMap_body.php at line 135
of the subversion trunk version <http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/ImageMap/ImageMap_body.php
> inserting something like this:
} elseif substr( $link, 0, strlen( 'loadjmol:' ) ) == 'loadjmol:' ) {
preg_match( '/^\[loadjmol:(.*?)\]/', $link, $m );
$path = $m[1];
$title = 'javascript:jmolScript(' .
Xml::encodeJsVar(
'load ' . strtr(
$path,
array( ';' => '', ' ' => '' ) .
'; snip;'
) . ');';
$alt = $url;
$externLink = true;
This would allow you to link to a virtual URL protocol "loadjmol:".
To continue your example:
circle 433 100 40 [loadjmol:model/miscellaneous/ene_reaction/1-
pentene_decomposition.xyz]
The encodeJsVar is to stop people from embedding arbitrary
JavaScript in a link, and the strtr is to stop people from embedding
arbitrary Jmol commands in a link. With a little bit of PHP
knowledge (the manual is at http://php.net/), you should be able to
extend this to link to whatever you want.
The code I wrote above is untested, it may have a bug or two.
I've tried inserting the code at line 135 but each time I try, it
breaks the wiki pages that have image maps in place.
Judging by the server logs, there is a missing "(" in the first line
so I tried
} elseif ( substr( $link, 0, strlen( 'loadjmol:' ) ) ==
'loadjmol:' ) {
but the logs still refer to unexpected T_VARIABLE in line 137 which is
$path = $m[1];
Are there any experts in PHP who can see the problem here?
All the best
Nick
--
3D Organic Animations http://www.chemtube3d.com
Tel: +44 (0)151-794-3506 (3500 secretary)
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users