wwwroot;
// Get UI messages translated.
$atoms = get_string('atoms', 'jmol');
$spin = get_string('spin', 'jmol');
$helpwithjmol = get_string('helpprefix2', 'moodle', 'Jmol');
$help = get_string('help', 'moodle');
$download = get_string('download', 'jmol');
$off = get_string('off', 'jmol');
$percent20 = get_string('percent20', 'jmol');
$percent100 = get_string('percent100', 'jmol');
$jsdisabled = get_string('jsdisabled', 'jmol');
$dwnlstructfileregexp = get_string('dwnlstructfile', 'jmol', '\\3');
$controls ='jmolBr();
jmolHtml("'.$atoms.' ");
jmolRadioGroup([
["spacefill off", "'.$off.'"],
["spacefill 20%", "'.$percent20.'", "checked"],
["spacefill 100%", "'.$percent100.'"]
]);
jmolHtml(" ");
jmolCheckbox("spin on", "spin off", "'.$spin.'");
';
if(preg_match('|https?://.*?/|', $u)){
$relurl = preg_replace('|https?://.*?/|', '', $u);
}else{
$relurl = ''; // This will typically be the case if Moodle is the web root
}
$numdirs = substr_count($_SERVER['PHP_SELF'], '/') - 1;
if($numdirs==0){
$relurl = './' . $relurl;
}else{
$relurl = str_repeat('../', $numdirs) . $relurl;
}
$search = '/]*?)href=\"((?:\.|\\\|https?:\/\/'.$_SERVER["HTTP_HOST"].')[^\"]+\.(mol|pdb\.gz|pdb|csmol|xyz|cml))\??(.*?)\"([^>]*)>(.*?)<\/a>(\s*JMOLSCRIPT\{(.*?)\})?/is';
$callbackfunction = '
$dwnlstructfile = str_replace(\'\\\3\', $matches[3], \''.$dwnlstructfileregexp.'\');
if(preg_match(\'/s=(\d{1,3})/\', $matches[4], $optmatch))
$size = $optmatch[1];
else
$size = 350;
if(preg_match(\'/f=(\d)/\', $matches[4], $optmatch))
$form = $optmatch[1] != 0;
else
$form = true;
if(!preg_match(\'/c=(\d{1,2})/\', $matches[4], $optmatch))
{
$optmatch = array(1=>1);
}
switch($optmatch[1])
{
case 0:
$controls = \'\';
break;
case 2:
$controls =\'jmolBr();
jmolHtml("'.$atoms.' ");
jmolRadioGroup([
["spacefill off", "'.$off.'"],
["spacefill 20%", "'.$percent20.'", "checked"],
["spacefill 100%", "'.$percent100.'"]
]);
jmolHtml(" ");
jmolCheckbox("set unitcell 4;color unitcell goldenrod", "set unitcell off", "Unit Cell");
jmolHtml(" ");
jmolCheckbox("spin on", "spin off", "'.$spin.'");
\';
break;
case 3:
$controls =\'jmolBr();
jmolHtml("'.$atoms.' ");
jmolRadioGroup([
["backbone off;cartoons off;wireframe on;spacefill off", "off"],
["backbone off;cartoons off;wireframe on;spacefill 20%", "20%", "checked"],
["backbone off;cartoons off;wireframe on;spacefill 100%", "100%"],
["spacefill off;cartoons off;wireframe off;backbone 0.5;color backbone group", "backbone"],
["spacefill off;backbone off;wireframe off;cartoons on;color cartoons structure", "cartoon"]
]);
jmolHtml(" ");
jmolCheckbox("spin on", "spin off", "'.$spin.'");
\';
break;
default:
$controls =\'jmolBr();
jmolHtml("'.$atoms.' ");
jmolRadioGroup([
["spacefill off", "'.$off.'"],
["spacefill 20%", "'.$percent20.'", "checked"],
["spacefill 100%", "'.$percent100.'"]
]);
jmolHtml(" ");
jmolCheckbox("spin on", "spin off", "'.$spin.'");
\';
} // End of switch
if(sizeof($matches)>8){
//echo "Found Jmol script: $matches[8]";
$initscript = preg_replace("@(\s|
)+@si", " ", str_replace(array("\\n","\\"", "
"), array("; ", "", ""), $matches[8]));
}else{
$initscript = "";
}
return ($form ? "" : "") . "'
. '
'
. $newtext;
}
return $newtext;
}
?>