I try to display some Geonext Applets in Moodle.
Geonext
So I've tried to adapt the Jochen Maeusle 's GeoGebra Filter.
With a simple link as ...
<a href="absolute path to../moodle/file.php/16/essaigeonext.gxtwidth=1101height=686">essai</a>
(where "absolut path to" is the actual url to my moodle folder)
...the resulting Geonext Filter manages to generate the following code :
<applet id="xxx" code="geonext.Geonext.class" codebase="./" archive="absolute path to..../moodle/filter/geonext/geonext.jar" height="686" width="1101" MAYSCRIPT> <param name="scriptable" value="true"> <param name="geonext" value="file:absolute path to..../moodle/file.php/16/essaigeonext.gxt"> </applet>
However, if the Geonext applet does start, the external file (here essaigeonext.gxt) is not displayed inside the applet.
The strange thing is that it does work (the Geonext applet displaying the right external file) with a simple html page with the following code :
<applet id="xxx" code="geonext.Geonext.class" codebase="./" archive="geonext.jar" width="1101" height="686" MAYSCRIPT> <param name="scriptable" value="true"> <param name="geonext" value="file:essaigeonext.gxt"> </applet>(here are relative paths since this html page is inside the same folder that the jar file and the gxt file)
It seems that Geonext canno't find external file with an absolut path (only with a relative one : the gxt file stored in the same folder than the HTML page containing the Geonext applet)
Indeed :
<param name="geonext" value="file:absolute path to..../moodle/file.php/16/essaigeonext.gxt">doesn't work even in a simple html page.
If someone may help me to fix this filter, thanks,
D.BODIN
Here is the code of the Jochen Maeusle 's GeoGebra Filter I've adapted :
<?php
function geonext_filter($courseid, $text) {
global $CFG;
//$pattern="(\?width\=[0-9]+)(xheight=[0-9]+)";
//$patternpregrepl="/\?width\=[0-9]+xheight=[0-9]+/";
$pattern="(width\=[0-9]+)(height=[0-9]+)";
$patternpregrepl="/width\=[0-9]+height=[0-9]+/";
$widthPattern= "/width\=\"[0-9]+\"/";
$heightPattern= "/height\=\"[0-9]+\"/";
//$pattern="/\?width\=[0-9]+)(&height=[0-9]+)";
$search = array(
'/<a(.*?)href=\"([^<]+)\.gxt\?d=([\d]{1,3}%?)x([\d]{1,3}%?)\"([^>]*)>(.*?)<\/a>/is',
'/<a(.*?)href=\"([^<]+)\.gxt\"([^>]*)>(.*?)<\/a>/is'
);
$replace = array();
$replace[0] = ' <applet id="xxx" code="geonext.Geonext.class" codebase="./"';
$replace[0] .= ' archive="';
$replace[0] .= $CFG->wwwroot.'/filter/geonext/geonext.jar"';
$replace[0] .= ' height="299" width="299" MAYSCRIPT>';
$replace[0] .= '<param name="scriptable" value="true"><param name="geonext" value="file:\\2.gxt"></applet>';
$replace[1] = ' <applet id="xxx" code="geonext.Geonext.class" codebase="./"';
$replace[1] .= ' archive="';
$replace[1] .= $CFG->wwwroot.'/filter/geonext/geonext.jar"';
$replace[1] .= ' height="299" width="299" MAYSCRIPT>';
$replace[1] .= '<param name="scriptable" value="true"><param name="geonext" value="file:\\2.gxt"></applet>';
$match = ereg($pattern,$text,$regs);
if ($match ==true) {
$w=$regs[1]; $h=$regs[2];
$neu = preg_replace($patternpregrepl,"",$text);
}
else {
$w=400;$h=400;$neu=$text;
}
// $neu = preg_replace($patternpregrepl,"",$text);
$text = preg_replace($search, $replace, $neu);
if ($match ==true){
$wr= '"'.$w.'"';
$hr= '"'.$h.'"';
//zerlegen:
$wr1=substr($w,0,6);$wr2=substr($w,6);
$hr1=substr($h,0,7);$hr2=substr($h,7);
$wre= $wr1.'"'.$wr2.'"';
$hre= $hr1.'"'.$hr2.'"';
$text = preg_replace($widthPattern,$wre, $text);
$text = preg_replace($heightPattern,$hre , $text);
}
return $text;
}
?>