diff --git a/filter/algebra/algebradebug.php b/filter/algebra/algebradebug.php
index 5de73001984..ddbe11f8e20 100644
--- a/filter/algebra/algebradebug.php
+++ b/filter/algebra/algebradebug.php
@@ -163,6 +163,19 @@ function outputText($texexp) {
function tex2image($texexp, $md5) {
global $CFG;
+ $error_message1 = "Your system is not configured to run mimeTeX. ";
+ $error_message1 .= "You need to download the appropriate
executable ";
+ $error_message1 .= "from ";
+ $error_message1 .= "http://moodle.org/download/mimetex/, or obtain the ";
+ $error_message1 .= "C source
from ";
+ $error_message1 .= "http://www.forkosh.com/mimetex.zip, compile it and ";
+ $error_message1 .= "put the executable into your
moodle/filter/tex/ directory. ";
+ $error_message1 .= "You also need to edit your moodle/filter/algebra/pix.php file
";
+ $error_message1 .= ' by adding the line
case "' . PHP_OS . "\":\n"; + $error_message1 .= " \$cmd = \"\\\\\"\$CFG->dirroot/\$CFG->texfilterdir/"; + $error_message1 .= 'mimetex.' . strtolower(PHP_OS) . "\\\\\" -e \\\\\"\$pathname\\\\\" \". escapeshellarg(\$texexp);"; + $error_message1 .= "You also need to add this to your algebradebug.php file."; + if ($texexp) { $texexp = '\Large ' . $texexp; $lifetime = 86400; @@ -175,22 +188,29 @@ function tex2image($texexp, $md5) { if (file_exists($pathname)) { unlink($pathname); } - $windows = 0; + $commandpath = ""; + $cmd = ""; switch (PHP_OS) { case "Linux": - $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.linux -e $pathname ". escapeshellarg($texexp); + $commandpath="$CFG->dirroot/$CFG->texfilterdir/mimetex.linux"; + $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.linux\" -e \"$pathname\" ". escapeshellarg($texexp); break; case "WINNT": case "WIN32": case "Windows": - $windows = 1; - $texexp = str_replace('"','\"',$texexp); - $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.exe -e $pathname \"$texexp\""; + $commandpath="$CFG->dirroot/$CFG->texfilterdir/mimetex.exe"; + $texexp = str_replace('"','\"',$texexp); + $cmd = str_replace(' ','^ ',$commandpath); + $cmd .= " ++ -e \"$pathname\" \"$texexp\""; break; case "Darwin": - $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin -e $pathname ". escapeshellarg($texexp); + $commandpath="$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin"; + $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin\" -e \"$pathname\" ". escapeshellarg($texexp); break; } + if (!$cmd) { + error($error_message1); + } system($cmd, $status); } if ($texexp && file_exists($pathname)) { @@ -204,10 +224,8 @@ function tex2image($texexp, $md5) { header("Content-type: $filetype"); readfile("$pathname"); } else { - if (!$windows) { - $ecmd = "$cmd 2>&1"; - echo `$ecmd` . "
Please enter an algebraic expression without any surrounding @@ into the text box below. (Click here for help.)