Permalink
Browse files

various improvements: updated mimetex, image positioning, XHTML valid…

…ation
  • Loading branch information...
1 parent 2debdf0 commit f352814af51f67ad7f5b733274bf882652010fee fiedorow committed Feb 10, 2005
View
@@ -39,7 +39,7 @@
$CFG->texfilterdir = "filter/tex";
-function string_file_picture_tex($imagefile, $tex= "", $height="", $width="") {
+function string_file_picture_tex($imagefile, $tex= "", $height="", $width="", $align="middle") {
// Given the path to a picture file in a course, or a URL,
// this function includes the picture in the page.
global $CFG;
@@ -65,7 +65,7 @@ function string_file_picture_tex($imagefile, $tex= "", $height="", $width="") {
} else {
$output .= "<a target=\"popup\" title=\"TeX\" href=";
$output .= "\"$CFG->wwwroot/$CFG->texfilterdir/displaytex.php?";
- $output .= urlencode($tex) . "\" onClick=\"return openpopup('/$CFG->texfilterdir/displaytex.php?";
+ $output .= urlencode($tex) . "\" onclick=\"return openpopup('/$CFG->texfilterdir/displaytex.php?";
$output .= urlencode($tex) . "', 'popup', 'menubar=0,location=0,scrollbars,";
$output .= "resizable,width=300,height=240', 0);\">";
}
@@ -75,7 +75,7 @@ function string_file_picture_tex($imagefile, $tex= "", $height="", $width="") {
} else {
$output .= "$CFG->wwwroot/$CFG->texfilterdir/pix.php?file=$imagefile";
}
- $output .= "\" />";
+ $output .= "\" style=\"vertical-align:$align\" />";
$output .= "</a>";
} else {
$output .= "Error: must pass URL or course";
@@ -125,6 +125,14 @@ function tex_filter ($courseid, $text) {
$texexp = $matches[1][$i] . $matches[2][$i];
$texexp = str_replace('<nolink>','',$texexp);
$texexp = str_replace('</nolink>','',$texexp);
+ $align = "middle";
+ if (preg_match('/^align=bottom /',$texexp)) {
+ $align = "text-bottom";
+ $texexp = preg_replace('/^align=bottom /','',$texexp);
+ } else if (preg_match('/^align=top /',$texexp)) {
+ $align = "text-top";
+ $texexp = preg_replace('/^align=top /','',$texexp);
+ }
$md5 = md5($texexp);
if (! $texcache = get_record("cache_filters","filter","tex", "md5key", $md5)) {
$texcache->filter = 'tex';
@@ -135,7 +143,7 @@ function tex_filter ($courseid, $text) {
insert_record("cache_filters",$texcache);
}
$filename = $md5 . ".gif";
- $text = str_replace( $matches[0][$i], string_file_picture_tex($filename, $texexp), $text);
+ $text = str_replace( $matches[0][$i], string_file_picture_tex($filename, $texexp, '', '', $align), $text);
}
return $text;
}
View
Binary file not shown.
View
Binary file not shown.
View
@@ -45,20 +45,20 @@
$texexp = str_replace('"','\"',$texexp);
$cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.exe";
$cmd = str_replace(' ','^ ',$cmd);
- $cmd .= " ++ -e \"$pathname\" \"$texexp\"";
+ $cmd .= " ++ -e \"$pathname\" -- \"$texexp\"";
} else if (is_executable("$CFG->dirroot/$CFG->texfilterdir/mimetex")) { /// Use the custom binary
- $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex -e $pathname ". escapeshellarg($texexp);
+ $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex -e $pathname -- ". escapeshellarg($texexp);
} else { /// Auto-detect the right TeX binary
switch (PHP_OS) {
case "Linux":
- $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.linux\" -e \"$pathname\" ". escapeshellarg($texexp);
+ $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.linux\" -e \"$pathname\" -- ". escapeshellarg($texexp);
break;
case "Darwin":
- $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin\" -e \"$pathname\" ". escapeshellarg($texexp);
+ $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin\" -e \"$pathname\" -- ". escapeshellarg($texexp);
break;
default: /// Nothing was found, so tell them how to fix it.
View
@@ -25,16 +25,16 @@
$pathname = "$CFG->dataroot/$CFG->teximagedir/$image";
switch (PHP_OS) {
case "Linux":
- system("$CFG->dirroot/$CFG->texfilterdir/mimetex.linux -e $pathname ". escapeshellarg($texexp) );
+ system("$CFG->dirroot/$CFG->texfilterdir/mimetex.linux -e $pathname -- ". escapeshellarg($texexp) );
break;
case "WINNT":
case "WIN32":
case "Windows":
$texexp = str_replace('"','\"',$texexp);
- system("$CFG->dirroot/$CFG->texfilterdir/mimetex.exe -e $pathname \"$texexp\"");
+ system("$CFG->dirroot/$CFG->texfilterdir/mimetex.exe -e $pathname -- \"$texexp\"");
break;
case "Darwin":
- system("$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin -e $pathname ". escapeshellarg($texexp) );
+ system("$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin -e $pathname -- ". escapeshellarg($texexp) );
break;
}
if (file_exists($pathname)) {

0 comments on commit f352814

Please sign in to comment.