Changed the logic around so that any binary called "mimetex" is used
in preference to any other pre-installed binary. This makes me happier about the FAT binary, because a leaner binary can be installed without interfering with CVS etc.
This commit is contained in:
+38
-30
@@ -8,8 +8,8 @@
|
||||
require_once("../../config.php");
|
||||
|
||||
$CFG->algebrafilterdir = "filter/algebra";
|
||||
$CFG->texfilterdir = "filter/tex";
|
||||
$CFG->algebraimagedir = "filter/algebra";
|
||||
$CFG->texfilterdir = "filter/tex";
|
||||
$CFG->algebraimagedir = "filter/algebra";
|
||||
|
||||
error_reporting(E_ALL);
|
||||
|
||||
@@ -47,34 +47,42 @@
|
||||
$texexp = str_replace('>','>',$texexp);
|
||||
$texexp = preg_replace('!\r\n?!',' ',$texexp);
|
||||
$texexp = '\Large ' . $texexp;
|
||||
switch (PHP_OS) {
|
||||
case "Linux":
|
||||
$cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.linux\" -e \"$pathname\" ". escapeshellarg($texexp);
|
||||
break;
|
||||
case "WINNT":
|
||||
case "WIN32":
|
||||
case "Windows":
|
||||
$texexp = str_replace('"','\"',$texexp);
|
||||
$cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.exe";
|
||||
$cmd = str_replace(' ','^ ',$cmd);
|
||||
$cmd .= " ++ -e \"$pathname\" \"$texexp\"";
|
||||
break;
|
||||
case "Darwin":
|
||||
$cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin\" -e \"$pathname\" ". escapeshellarg($texexp);
|
||||
break;
|
||||
default: /// To allow drop-in binaries for other platforms
|
||||
if (!is_executable("$CFG->dirroot/$CFG->texfilterdir/mimetex")) {
|
||||
echo "Make sure you have an appropriate MimeTeX binary here:\n\n";
|
||||
echo " $CFG->dirroot/$CFG->texfilterdir/mimetex\n\n";
|
||||
echo "and that it has the right permissions set on it as executable program.\n\n";
|
||||
echo "You can get the latest binaries for your ".PHP_OS." platform from: \n\n";
|
||||
echo " http://moodle.org/download/mimetex/";
|
||||
exit;
|
||||
}
|
||||
$cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex -e $pathname ". escapeshellarg($texexp);
|
||||
break;
|
||||
|
||||
if (is_executable("$CFG->dirroot/$CFG->texfilterdir/mimetex")) { /// Use the custom binary
|
||||
|
||||
$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);
|
||||
break;
|
||||
|
||||
case "WINNT":
|
||||
case "WIN32":
|
||||
case "Windows":
|
||||
$texexp = str_replace('"','\"',$texexp);
|
||||
$cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.exe";
|
||||
$cmd = str_replace(' ','^ ',$cmd);
|
||||
$cmd .= " ++ -e \"$pathname\" \"$texexp\"";
|
||||
break;
|
||||
|
||||
case "Darwin":
|
||||
$cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin\" -e \"$pathname\" ". escapeshellarg($texexp);
|
||||
break;
|
||||
|
||||
default: /// Nothing was found, so tell them how to fix it.
|
||||
echo "Make sure you have an appropriate MimeTeX binary here:\n\n";
|
||||
echo " $CFG->dirroot/$CFG->texfilterdir/mimetex\n\n";
|
||||
echo "and that it has the right permissions set on it as executable program.\n\n";
|
||||
echo "You can get the latest binaries for your ".PHP_OS." platform from: \n\n";
|
||||
echo " http://moodle.org/download/mimetex/";
|
||||
exit;
|
||||
break;
|
||||
}
|
||||
}
|
||||
system($cmd, $status);
|
||||
system($cmd, $status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +99,7 @@
|
||||
} else {
|
||||
echo "The shell command<br>$cmd<br>returned status = $status<br>\n";
|
||||
echo "Image not found!<br>";
|
||||
echo "Please try the <a href=\"$CFG->wwwroot/filter/algebra/algebradebug.php\">debugging script</a>";
|
||||
echo "Please try the <a href=\"$CFG->wwwroot/filter/algebra/algebradebug.php\">debugging script</a>";
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
+29
-21
@@ -46,32 +46,40 @@
|
||||
$texexp = str_replace('>','>',$texexp);
|
||||
$texexp = preg_replace('!\r\n?!',' ',$texexp);
|
||||
$texexp = '\Large ' . $texexp;
|
||||
switch (PHP_OS) {
|
||||
case "Linux":
|
||||
$cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.linux\" -e \"$pathname\" ". escapeshellarg($texexp);
|
||||
break;
|
||||
case "WINNT":
|
||||
case "WIN32":
|
||||
case "Windows":
|
||||
$texexp = str_replace('"','\"',$texexp);
|
||||
$cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.exe";
|
||||
$cmd = str_replace(' ','^ ',$cmd);
|
||||
$cmd .= " ++ -e \"$pathname\" \"$texexp\"";
|
||||
break;
|
||||
case "Darwin":
|
||||
$cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin\" -e \"$pathname\" ". escapeshellarg($texexp);
|
||||
break;
|
||||
default: /// To allow drop-in binaries for other platforms
|
||||
if (!is_executable("$CFG->dirroot/$CFG->texfilterdir/mimetex")) {
|
||||
|
||||
if (is_executable("$CFG->dirroot/$CFG->texfilterdir/mimetex")) { /// Use the custom binary
|
||||
|
||||
$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);
|
||||
break;
|
||||
|
||||
case "WINNT":
|
||||
case "WIN32":
|
||||
case "Windows":
|
||||
$texexp = str_replace('"','\"',$texexp);
|
||||
$cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.exe";
|
||||
$cmd = str_replace(' ','^ ',$cmd);
|
||||
$cmd .= " ++ -e \"$pathname\" \"$texexp\"";
|
||||
break;
|
||||
|
||||
case "Darwin":
|
||||
$cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin\" -e \"$pathname\" ". escapeshellarg($texexp);
|
||||
break;
|
||||
|
||||
default: /// Nothing was found, so tell them how to fix it.
|
||||
echo "Make sure you have an appropriate MimeTeX binary here:\n\n";
|
||||
echo " $CFG->dirroot/$CFG->texfilterdir/mimetex\n\n";
|
||||
echo "and that it has the right permissions set on it as executable program.\n\n";
|
||||
echo "You can get the latest binaries for your ".PHP_OS." platform from: \n\n";
|
||||
echo " http://moodle.org/download/mimetex/";
|
||||
exit;
|
||||
}
|
||||
$cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex -e $pathname ". escapeshellarg($texexp);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
system($cmd, $status);
|
||||
}
|
||||
@@ -90,7 +98,7 @@
|
||||
} else {
|
||||
echo "The shell command<br>$cmd<br>returned status = $status<br>\n";
|
||||
echo "Image not found!<br>";
|
||||
echo "Please try the <a href=\"$CFG->wwwroot/filter/tex/texdebug.php\">debugging script</a>";
|
||||
echo "Please try the <a href=\"$CFG->wwwroot/$CFG->texfilterdir/texdebug.php\">debugging script</a>";
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
Reference in New Issue
Block a user